Fixed reset of allow_scanning flag if ecrt_master_activate() was not called. stable-1.5
authorFlorian Pose <fp@igh-essen.com>
Fri, 13 Jan 2012 11:27:20 +0100
branchstable-1.5
changeset 2266 ec8e1151b8a7
parent 2265 b13e4dee72b8
child 2272 d274f5b4d4e1
Fixed reset of allow_scanning flag if ecrt_master_activate() was not called.
master/master.c
--- a/master/master.c	Tue Jan 10 13:04:06 2012 +0100
+++ b/master/master.c	Fri Jan 13 11:27:20 2012 +0100
@@ -605,7 +605,7 @@
         if (ret) {
             EC_MASTER_INFO(master, "Finishing slave configuration"
                     " interrupted by signal.\n");
-            goto out_allow;
+            goto out_return;
         }
 
         EC_MASTER_DBG(master, 1, "Waiting for pending slave"
@@ -656,6 +656,7 @@
     
 out_allow:
     master->allow_scan = 1;
+out_return:
     return ret;
 }
 
@@ -673,6 +674,9 @@
         ec_master_clear_config(master);
     }
 
+    /* Re-allow scanning for IDLE phase. */
+    master->allow_scan = 1;
+
     EC_MASTER_DBG(master, 1, "OPERATION -> IDLE.\n");
 
     master->phase = EC_IDLE;
@@ -2016,7 +2020,9 @@
         return ret;
     }
 
-    master->allow_scan = 1; // allow re-scanning on topology change
+    /* Allow scanning after a topology change. */
+    master->allow_scan = 1;
+
     master->active = 1;
 
     // notify state machine, that the configuration shall now be applied
@@ -2088,7 +2094,10 @@
                 "EtherCAT-IDLE"))
         EC_MASTER_WARN(master, "Failed to restart master thread!\n");
 
-    master->allow_scan = 1;
+    /* Disallow scanning to get into the same state like after a master
+     * request (after ec_master_enter_operation_phase() is called). */
+    master->allow_scan = 0;
+
     master->active = 0;
 }