master/master.c
branchstable-1.5
changeset 2266 ec8e1151b8a7
parent 2244 fc891656a9fe
child 2291 1f44094e2004
equal deleted inserted replaced
2265:b13e4dee72b8 2266:ec8e1151b8a7
   603         ret = wait_event_interruptible(master->config_queue,
   603         ret = wait_event_interruptible(master->config_queue,
   604                     !master->config_busy);
   604                     !master->config_busy);
   605         if (ret) {
   605         if (ret) {
   606             EC_MASTER_INFO(master, "Finishing slave configuration"
   606             EC_MASTER_INFO(master, "Finishing slave configuration"
   607                     " interrupted by signal.\n");
   607                     " interrupted by signal.\n");
   608             goto out_allow;
   608             goto out_return;
   609         }
   609         }
   610 
   610 
   611         EC_MASTER_DBG(master, 1, "Waiting for pending slave"
   611         EC_MASTER_DBG(master, 1, "Waiting for pending slave"
   612                 " configuration returned.\n");
   612                 " configuration returned.\n");
   613     } else {
   613     } else {
   654     master->app_cb_data = NULL;
   654     master->app_cb_data = NULL;
   655     return ret;
   655     return ret;
   656     
   656     
   657 out_allow:
   657 out_allow:
   658     master->allow_scan = 1;
   658     master->allow_scan = 1;
       
   659 out_return:
   659     return ret;
   660     return ret;
   660 }
   661 }
   661 
   662 
   662 /*****************************************************************************/
   663 /*****************************************************************************/
   663 
   664 
   670     if (master->active) {
   671     if (master->active) {
   671         ecrt_master_deactivate(master); // also clears config
   672         ecrt_master_deactivate(master); // also clears config
   672     } else {
   673     } else {
   673         ec_master_clear_config(master);
   674         ec_master_clear_config(master);
   674     }
   675     }
       
   676 
       
   677     /* Re-allow scanning for IDLE phase. */
       
   678     master->allow_scan = 1;
   675 
   679 
   676     EC_MASTER_DBG(master, 1, "OPERATION -> IDLE.\n");
   680     EC_MASTER_DBG(master, 1, "OPERATION -> IDLE.\n");
   677 
   681 
   678     master->phase = EC_IDLE;
   682     master->phase = EC_IDLE;
   679 }
   683 }
  2014     if (ret < 0) {
  2018     if (ret < 0) {
  2015         EC_MASTER_ERR(master, "Failed to start master thread!\n");
  2019         EC_MASTER_ERR(master, "Failed to start master thread!\n");
  2016         return ret;
  2020         return ret;
  2017     }
  2021     }
  2018 
  2022 
  2019     master->allow_scan = 1; // allow re-scanning on topology change
  2023     /* Allow scanning after a topology change. */
       
  2024     master->allow_scan = 1;
       
  2025 
  2020     master->active = 1;
  2026     master->active = 1;
  2021 
  2027 
  2022     // notify state machine, that the configuration shall now be applied
  2028     // notify state machine, that the configuration shall now be applied
  2023     master->config_changed = 1;
  2029     master->config_changed = 1;
  2024 
  2030 
  2086 #endif
  2092 #endif
  2087     if (ec_master_thread_start(master, ec_master_idle_thread,
  2093     if (ec_master_thread_start(master, ec_master_idle_thread,
  2088                 "EtherCAT-IDLE"))
  2094                 "EtherCAT-IDLE"))
  2089         EC_MASTER_WARN(master, "Failed to restart master thread!\n");
  2095         EC_MASTER_WARN(master, "Failed to restart master thread!\n");
  2090 
  2096 
  2091     master->allow_scan = 1;
  2097     /* Disallow scanning to get into the same state like after a master
       
  2098      * request (after ec_master_enter_operation_phase() is called). */
       
  2099     master->allow_scan = 0;
       
  2100 
  2092     master->active = 0;
  2101     master->active = 0;
  2093 }
  2102 }
  2094 
  2103 
  2095 /*****************************************************************************/
  2104 /*****************************************************************************/
  2096 
  2105