Do not use slaves's SoE state machine for configuration. stable-1.5
authorFlorian Pose <fp@igh-essen.com>
Thu, 06 Dec 2012 14:06:10 +0100
branchstable-1.5
changeset 2482 06b53ebfa0c3
parent 2481 c99ff159b60d
child 2483 ec53d873dc5e
Do not use slaves's SoE state machine for configuration.
master/fsm_master.c
master/fsm_master.h
master/fsm_slave_config.c
master/fsm_slave_config.h
--- a/master/fsm_master.c	Thu Dec 06 14:04:40 2012 +0100
+++ b/master/fsm_master.c	Thu Dec 06 14:06:10 2012 +0100
@@ -86,10 +86,11 @@
 
     // init sub-state-machines
     ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram);
+    ec_fsm_soe_init(&fsm->fsm_soe, fsm->datagram);
     ec_fsm_pdo_init(&fsm->fsm_pdo, &fsm->fsm_coe);
     ec_fsm_change_init(&fsm->fsm_change, fsm->datagram);
     ec_fsm_slave_config_init(&fsm->fsm_slave_config, fsm->datagram,
-            &fsm->fsm_change, &fsm->fsm_coe, &fsm->fsm_pdo);
+            &fsm->fsm_change, &fsm->fsm_coe, &fsm->fsm_soe, &fsm->fsm_pdo);
     ec_fsm_slave_scan_init(&fsm->fsm_slave_scan, fsm->datagram,
             &fsm->fsm_slave_config, &fsm->fsm_pdo);
     ec_fsm_sii_init(&fsm->fsm_sii, fsm->datagram);
@@ -105,6 +106,7 @@
 {
     // clear sub-state machines
     ec_fsm_coe_clear(&fsm->fsm_coe);
+    ec_fsm_soe_clear(&fsm->fsm_soe);
     ec_fsm_pdo_clear(&fsm->fsm_pdo);
     ec_fsm_change_clear(&fsm->fsm_change);
     ec_fsm_slave_config_clear(&fsm->fsm_slave_config);
@@ -611,7 +613,7 @@
         return;
     }
 
-    // slave has error flag set; process next one
+    // process next slave
     ec_fsm_master_action_next_slave_state(fsm);
 }
 
--- a/master/fsm_master.h	Thu Dec 06 14:04:40 2012 +0100
+++ b/master/fsm_master.h	Thu Dec 06 14:06:10 2012 +0100
@@ -90,6 +90,7 @@
     ec_sdo_request_t *sdo_request; /**< SDO request to process. */
 
     ec_fsm_coe_t fsm_coe; /**< CoE state machine */
+    ec_fsm_soe_t fsm_soe; /**< SoE state machine */
     ec_fsm_pdo_t fsm_pdo; /**< PDO configuration state machine. */
     ec_fsm_change_t fsm_change; /**< State change state machine */
     ec_fsm_slave_config_t fsm_slave_config; /**< slave state machine */
--- a/master/fsm_slave_config.c	Thu Dec 06 14:04:40 2012 +0100
+++ b/master/fsm_slave_config.c	Thu Dec 06 14:06:10 2012 +0100
@@ -114,6 +114,7 @@
         ec_datagram_t *datagram, /**< datagram structure to use */
         ec_fsm_change_t *fsm_change, /**< State change state machine to use. */
         ec_fsm_coe_t *fsm_coe, /**< CoE state machine to use. */
+        ec_fsm_soe_t *fsm_soe, /**< SoE state machine to use. */
         ec_fsm_pdo_t *fsm_pdo /**< PDO configuration state machine to use. */
         )
 {
@@ -123,6 +124,7 @@
     fsm->datagram = datagram;
     fsm->fsm_change = fsm_change;
     fsm->fsm_coe = fsm_coe;
+    fsm->fsm_soe = fsm_soe;
     fsm->fsm_pdo = fsm_pdo;
 }
 
@@ -688,7 +690,9 @@
         ec_fsm_slave_config_t *fsm /**< slave state machine */
         )
 {
-    if (ec_fsm_coe_exec(fsm->fsm_coe)) return;
+    if (ec_fsm_coe_exec(fsm->fsm_coe)) {
+        return;
+    }
 
     if (!ec_fsm_coe_success(fsm->fsm_coe)) {
         EC_SLAVE_ERR(fsm->slave, "SDO configuration failed.\n");
@@ -726,7 +730,6 @@
         )
 {
     ec_slave_t *slave = fsm->slave;
-    ec_fsm_soe_t *fsm_soe = &slave->fsm.fsm_soe;
     ec_soe_request_t *req;
 
     if (!slave->config) {
@@ -741,10 +744,9 @@
             fsm->soe_request = req;
             ec_soe_request_copy(&fsm->soe_request_copy, fsm->soe_request);
             ec_soe_request_write(&fsm->soe_request_copy);
-            ec_fsm_soe_transfer(fsm_soe, fsm->slave, &fsm->soe_request_copy);
-            ec_fsm_soe_exec(fsm_soe); // execute immediately
-            ec_master_queue_external_datagram(slave->master,
-                    fsm_soe->datagram);
+            ec_fsm_soe_transfer(fsm->fsm_soe, fsm->slave,
+                    &fsm->soe_request_copy);
+            ec_fsm_soe_exec(fsm->fsm_soe); // execute immediately
             return;
         }
     }
@@ -762,14 +764,12 @@
         )
 {
     ec_slave_t *slave = fsm->slave;
-    ec_fsm_soe_t *fsm_soe = &slave->fsm.fsm_soe;
-
-    if (ec_fsm_soe_exec(fsm_soe)) {
-        ec_master_queue_external_datagram(slave->master, fsm_soe->datagram);
-        return;
-    }
-
-    if (!ec_fsm_soe_success(fsm_soe)) {
+
+    if (ec_fsm_soe_exec(fsm->fsm_soe)) {
+        return;
+    }
+
+    if (!ec_fsm_soe_success(fsm->fsm_soe)) {
         EC_SLAVE_ERR(slave, "SoE configuration failed.\n");
         fsm->slave->error_flag = 1;
         fsm->state = ec_fsm_slave_config_state_error;
@@ -788,10 +788,9 @@
         if (fsm->soe_request->al_state == EC_AL_STATE_PREOP) {
             ec_soe_request_copy(&fsm->soe_request_copy, fsm->soe_request);
             ec_soe_request_write(&fsm->soe_request_copy);
-            ec_fsm_soe_transfer(fsm_soe, fsm->slave, &fsm->soe_request_copy);
-            ec_fsm_soe_exec(fsm_soe); // execute immediately
-            ec_master_queue_external_datagram(slave->master,
-                    fsm_soe->datagram);
+            ec_fsm_soe_transfer(fsm->fsm_soe, fsm->slave,
+                    &fsm->soe_request_copy);
+            ec_fsm_soe_exec(fsm->fsm_soe); // execute immediately
             return;
         }
     }
@@ -1455,7 +1454,6 @@
         )
 {
     ec_slave_t *slave = fsm->slave;
-    ec_fsm_soe_t *fsm_soe = &slave->fsm.fsm_soe;
     ec_soe_request_t *req;
 
     if (!slave->config) {
@@ -1470,10 +1468,9 @@
             fsm->soe_request = req;
             ec_soe_request_copy(&fsm->soe_request_copy, fsm->soe_request);
             ec_soe_request_write(&fsm->soe_request_copy);
-            ec_fsm_soe_transfer(fsm_soe, fsm->slave, &fsm->soe_request_copy);
-            ec_fsm_soe_exec(fsm_soe); // execute immediately
-            ec_master_queue_external_datagram(slave->master,
-                    fsm_soe->datagram);
+            ec_fsm_soe_transfer(fsm->fsm_soe, fsm->slave,
+                    &fsm->soe_request_copy);
+            ec_fsm_soe_exec(fsm->fsm_soe); // execute immediately
             return;
         }
     }
@@ -1491,14 +1488,12 @@
         )
 {
     ec_slave_t *slave = fsm->slave;
-    ec_fsm_soe_t *fsm_soe = &slave->fsm.fsm_soe;
-
-    if (ec_fsm_soe_exec(fsm_soe)) {
-        ec_master_queue_external_datagram(slave->master, fsm_soe->datagram);
-        return;
-    }
-
-    if (!ec_fsm_soe_success(fsm_soe)) {
+
+    if (ec_fsm_soe_exec(fsm->fsm_soe)) {
+        return;
+    }
+
+    if (!ec_fsm_soe_success(fsm->fsm_soe)) {
         EC_SLAVE_ERR(slave, "SoE configuration failed.\n");
         fsm->slave->error_flag = 1;
         fsm->state = ec_fsm_slave_config_state_error;
@@ -1517,10 +1512,9 @@
         if (fsm->soe_request->al_state == EC_AL_STATE_SAFEOP) {
             ec_soe_request_copy(&fsm->soe_request_copy, fsm->soe_request);
             ec_soe_request_write(&fsm->soe_request_copy);
-            ec_fsm_soe_transfer(fsm_soe, fsm->slave, &fsm->soe_request_copy);
-            ec_fsm_soe_exec(fsm_soe); // execute immediately
-            ec_master_queue_external_datagram(slave->master,
-                    fsm_soe->datagram);
+            ec_fsm_soe_transfer(fsm->fsm_soe, fsm->slave,
+                    &fsm->soe_request_copy);
+            ec_fsm_soe_exec(fsm->fsm_soe); // execute immediately
             return;
         }
     }
--- a/master/fsm_slave_config.h	Thu Dec 06 14:04:40 2012 +0100
+++ b/master/fsm_slave_config.h	Thu Dec 06 14:06:10 2012 +0100
@@ -56,6 +56,7 @@
     ec_datagram_t *datagram; /**< Datagram used in the state machine. */
     ec_fsm_change_t *fsm_change; /**< State change state machine. */
     ec_fsm_coe_t *fsm_coe; /**< CoE state machine. */
+    ec_fsm_soe_t *fsm_soe; /**< SoE state machine. */
     ec_fsm_pdo_t *fsm_pdo; /**< PDO configuration state machine. */
 
     ec_slave_t *slave; /**< Slave the FSM runs on. */
@@ -72,7 +73,7 @@
 /*****************************************************************************/
 
 void ec_fsm_slave_config_init(ec_fsm_slave_config_t *, ec_datagram_t *,
-        ec_fsm_change_t *, ec_fsm_coe_t *, ec_fsm_pdo_t *);
+        ec_fsm_change_t *, ec_fsm_coe_t *, ec_fsm_soe_t *, ec_fsm_pdo_t *);
 void ec_fsm_slave_config_clear(ec_fsm_slave_config_t *);
 
 void ec_fsm_slave_config_start(ec_fsm_slave_config_t *, ec_slave_t *);