master/master.c
branchredundancy
changeset 2349 2f5993d86ea5
parent 2340 3f2a4f9ff786
child 2360 622a7faa07df
equal deleted inserted replaced
2348:abb390ec7c4a 2349:2f5993d86ea5
   618         ret = wait_event_interruptible(master->config_queue,
   618         ret = wait_event_interruptible(master->config_queue,
   619                     !master->config_busy);
   619                     !master->config_busy);
   620         if (ret) {
   620         if (ret) {
   621             EC_MASTER_INFO(master, "Finishing slave configuration"
   621             EC_MASTER_INFO(master, "Finishing slave configuration"
   622                     " interrupted by signal.\n");
   622                     " interrupted by signal.\n");
   623             goto out_allow;
   623             goto out_return;
   624         }
   624         }
   625 
   625 
   626         EC_MASTER_DBG(master, 1, "Waiting for pending slave"
   626         EC_MASTER_DBG(master, 1, "Waiting for pending slave"
   627                 " configuration returned.\n");
   627                 " configuration returned.\n");
   628     } else {
   628     } else {
   670     master->app_cb_data = NULL;
   670     master->app_cb_data = NULL;
   671     return ret;
   671     return ret;
   672     
   672     
   673 out_allow:
   673 out_allow:
   674     master->allow_scan = 1;
   674     master->allow_scan = 1;
       
   675 out_return:
   675     return ret;
   676     return ret;
   676 }
   677 }
   677 
   678 
   678 /*****************************************************************************/
   679 /*****************************************************************************/
   679 
   680 
   686     if (master->active) {
   687     if (master->active) {
   687         ecrt_master_deactivate(master); // also clears config
   688         ecrt_master_deactivate(master); // also clears config
   688     } else {
   689     } else {
   689         ec_master_clear_config(master);
   690         ec_master_clear_config(master);
   690     }
   691     }
       
   692 
       
   693     /* Re-allow scanning for IDLE phase. */
       
   694     master->allow_scan = 1;
   691 
   695 
   692     EC_MASTER_DBG(master, 1, "OPERATION -> IDLE.\n");
   696     EC_MASTER_DBG(master, 1, "OPERATION -> IDLE.\n");
   693 
   697 
   694     master->phase = EC_IDLE;
   698     master->phase = EC_IDLE;
   695 }
   699 }
  2131     if (ret < 0) {
  2135     if (ret < 0) {
  2132         EC_MASTER_ERR(master, "Failed to start master thread!\n");
  2136         EC_MASTER_ERR(master, "Failed to start master thread!\n");
  2133         return ret;
  2137         return ret;
  2134     }
  2138     }
  2135 
  2139 
  2136     master->allow_scan = 1; // allow re-scanning on topology change
  2140     /* Allow scanning after a topology change. */
       
  2141     master->allow_scan = 1;
       
  2142 
  2137     master->active = 1;
  2143     master->active = 1;
  2138 
  2144 
  2139     // notify state machine, that the configuration shall now be applied
  2145     // notify state machine, that the configuration shall now be applied
  2140     master->config_changed = 1;
  2146     master->config_changed = 1;
  2141 
  2147 
  2203 #endif
  2209 #endif
  2204     if (ec_master_thread_start(master, ec_master_idle_thread,
  2210     if (ec_master_thread_start(master, ec_master_idle_thread,
  2205                 "EtherCAT-IDLE"))
  2211                 "EtherCAT-IDLE"))
  2206         EC_MASTER_WARN(master, "Failed to restart master thread!\n");
  2212         EC_MASTER_WARN(master, "Failed to restart master thread!\n");
  2207 
  2213 
  2208     master->allow_scan = 1;
  2214     /* Disallow scanning to get into the same state like after a master
       
  2215      * request (after ec_master_enter_operation_phase() is called). */
       
  2216     master->allow_scan = 0;
       
  2217 
  2209     master->active = 0;
  2218     master->active = 0;
  2210 }
  2219 }
  2211 
  2220 
  2212 /*****************************************************************************/
  2221 /*****************************************************************************/
  2213 
  2222