Fixed bug if scanning is not allowed when link goes up.
authorFlorian Pose <fp@igh-essen.com>
Mon, 03 Mar 2008 16:17:23 +0000
changeset 853 726326d0aef4
parent 852 ab439cbc7a81
child 854 f4f53be425ac
Fixed bug if scanning is not allowed when link goes up.
master/fsm_master.c
--- a/master/fsm_master.c	Mon Mar 03 13:26:32 2008 +0000
+++ b/master/fsm_master.c	Mon Mar 03 16:17:23 2008 +0000
@@ -298,11 +298,15 @@
         }
     }
 
-    // fetch state from each slave
-    fsm->slave = list_entry(master->slaves.next, ec_slave_t, list);
-    ec_datagram_fprd(fsm->datagram, fsm->slave->station_address, 0x0130, 2);
-    fsm->retries = EC_FSM_RETRIES;
-    fsm->state = ec_fsm_master_state_read_states;
+    if (list_empty(&master->slaves)) {
+        fsm->state = ec_fsm_master_state_end;
+    } else {
+        // fetch state from each slave
+        fsm->slave = list_entry(master->slaves.next, ec_slave_t, list);
+        ec_datagram_fprd(fsm->datagram, fsm->slave->station_address, 0x0130, 2);
+        fsm->retries = EC_FSM_RETRIES;
+        fsm->state = ec_fsm_master_state_read_states;
+    }
 }
 
 /*****************************************************************************/