Display error flag in 'ethercat ls'; cleaned up usage of error flag;
authorFlorian Pose <fp@igh-essen.com>
Tue, 10 Jun 2008 12:05:25 +0000
changeset 987 3c9090138140
parent 986 a486591ba86b
child 988 a47c5a3c143d
Display error flag in 'ethercat ls'; cleaned up usage of error flag;
removed action_acknowledge.
TODO
documentation/graphs/fsm_master.dot
master/cdev.c
master/fsm_master.c
master/ioctl.h
tools/Master.cpp
--- a/TODO	Tue Jun 10 11:54:39 2008 +0000
+++ b/TODO	Tue Jun 10 12:05:25 2008 +0000
@@ -9,7 +9,7 @@
 Version 1.4.0:
 
 * Replace all Sysfs files via the new ethercat tool.
-    - Slave info (flags, mailbox, general) 
+    - Slave info (mailbox, general) 
     - Config info (alias, position, type, Pdos, Sdos)
 * Slaves as array.
 * Remove the end state of the master state machine.
--- a/documentation/graphs/fsm_master.dot	Tue Jun 10 11:54:39 2008 +0000
+++ b/documentation/graphs/fsm_master.dot	Tue Jun 10 12:05:25 2008 +0000
@@ -34,13 +34,10 @@
     action_configure -> configure_slave [weight=10]
     action_configure -> action_next_slave_state
 
-    action_acknowledge [shape=point,label=""]
-    action_acknowledge -> acknowledge [weight=10]
-    action_acknowledge -> action_configure
-    action_acknowledge -> action_next_slave_state
-
     read_state [fontname="Helvetica"]
-    read_state -> action_acknowledge [weight=10]
+    read_state -> acknowledge
+    read_state -> action_configure [weight=10]
+    read_state -> action_next_slave_state
 
     acknowledge [fontname="Helvetica"]
     acknowledge -> action_configure [weight=10]
--- a/master/cdev.c	Tue Jun 10 11:54:39 2008 +0000
+++ b/master/cdev.c	Tue Jun 10 12:05:25 2008 +0000
@@ -193,6 +193,7 @@
                 data.serial_number = slave->sii.serial_number;
                 data.alias = slave->sii.alias;
                 data.state = slave->current_state;
+                data.error_flag = slave->error_flag;
 
                 data.sync_count = slave->sii.sync_count;
                 data.sdo_count = ec_slave_sdo_count(slave);
--- a/master/fsm_master.c	Tue Jun 10 11:54:39 2008 +0000
+++ b/master/fsm_master.c	Tue Jun 10 12:05:25 2008 +0000
@@ -364,8 +364,7 @@
                     continue;
                 }
 
-                if (slave->current_state == EC_SLAVE_STATE_INIT ||
-                        slave->error_flag) {
+                if (slave->current_state == EC_SLAVE_STATE_INIT) {
                     req->state = EC_REQUEST_FAILURE;
                     continue;
                 }
@@ -450,7 +449,7 @@
                 || slave->sdo_dictionary_fetched
                 || slave->current_state == EC_SLAVE_STATE_INIT
                 || jiffies - slave->jiffies_preop < EC_WAIT_SDO_DICT * HZ
-                || slave->error_flag) continue;
+                ) continue;
 
         if (master->debug_level) {
             EC_DBG("Fetching Sdo dictionary from slave %u.\n",
@@ -514,9 +513,8 @@
     ec_slave_t *slave = fsm->slave;
 
     // Does the slave have to be configured?
-    if (!slave->error_flag
-            && (slave->current_state != slave->requested_state
-                || slave->force_config)) {
+    if ((slave->current_state != slave->requested_state
+                || slave->force_config) && !slave->error_flag) {
         // Start slave configuration, if it is allowed.
         down(&master->config_sem);
         if (!master->allow_config) {
@@ -553,13 +551,43 @@
 
 /*****************************************************************************/
 
-/** Master action: Acknowledge.
- */
-void ec_fsm_master_action_acknowledge(
+/** Master state: READ STATE.
+ *
+ * Fetches the AL state of a slave.
+ */
+void ec_fsm_master_state_read_state(
         ec_fsm_master_t *fsm /**< Master state machine. */
         )
 {
     ec_slave_t *slave = fsm->slave;
+    ec_datagram_t *datagram = fsm->datagram;
+
+    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
+        return;
+
+    if (datagram->state != EC_DATAGRAM_RECEIVED) {
+        EC_ERR("Failed to receive AL state datagram for slave %u"
+                " (datagram state %u)\n",
+                slave->ring_position, datagram->state);
+        fsm->state = ec_fsm_master_state_error;
+        return;
+    }
+
+    // did the slave not respond to its station address?
+    if (datagram->working_counter != 1) {
+        if (!slave->error_flag) {
+            slave->error_flag = 1;
+            if (fsm->master->debug_level)
+                EC_DBG("Slave %u did not respond to state query.\n",
+                        fsm->slave->ring_position);
+        }
+        fsm->topology_change_pending = 1;
+        fsm->state = ec_fsm_master_state_error;
+        return;
+    }
+
+    // A single slave responded
+    ec_slave_set_state(slave, EC_READ_U8(datagram->data));
 
     if (!slave->error_flag) {
         // Check, if new slave state has to be acknowledged
@@ -582,48 +610,6 @@
 
 /*****************************************************************************/
 
-/** Master state: READ STATE.
- *
- * Fetches the AL state of a slave.
- */
-void ec_fsm_master_state_read_state(
-        ec_fsm_master_t *fsm /**< Master state machine. */
-        )
-{
-    ec_slave_t *slave = fsm->slave;
-    ec_datagram_t *datagram = fsm->datagram;
-
-    if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
-        return;
-
-    if (datagram->state != EC_DATAGRAM_RECEIVED) {
-        EC_ERR("Failed to receive AL state datagram for slave %u"
-                " (datagram state %u)\n",
-                slave->ring_position, datagram->state);
-        fsm->state = ec_fsm_master_state_error;
-        return;
-    }
-
-    // did the slave not respond to its station address?
-    if (datagram->working_counter != 1) {
-        if (!slave->error_flag) {
-            slave->error_flag = 1;
-            if (fsm->master->debug_level)
-                EC_DBG("Slave %u did not respond to state query.\n",
-                        fsm->slave->ring_position);
-        }
-        fsm->topology_change_pending = 1;
-        fsm->state = ec_fsm_master_state_error;
-        return;
-    }
-
-    // A single slave responded
-    ec_slave_set_state(slave, EC_READ_U8(datagram->data));
-    ec_fsm_master_action_acknowledge(fsm);
-}
-
-/*****************************************************************************/
-
 /** Master state: ACKNOWLEDGE.
  */
 void ec_fsm_master_state_acknowledge(
@@ -781,7 +767,6 @@
     if (ec_fsm_sii_exec(&fsm->fsm_sii)) return;
 
     if (!ec_fsm_sii_success(&fsm->fsm_sii)) {
-        slave->error_flag = 1;
         EC_ERR("Failed to write SII data to slave %u.\n",
                 slave->ring_position);
         request->state = EC_REQUEST_FAILURE;
--- a/master/ioctl.h	Tue Jun 10 11:54:39 2008 +0000
+++ b/master/ioctl.h	Tue Jun 10 12:05:25 2008 +0000
@@ -85,7 +85,7 @@
 
 /*****************************************************************************/
 
-#define EC_IOCTL_SLAVE_NAME_SIZE 100
+#define EC_IOCTL_SLAVE_NAME_SIZE 99
 
 typedef struct {
     // input
@@ -98,6 +98,7 @@
     uint32_t serial_number;
     uint16_t alias;
     uint8_t state;
+    uint8_t error_flag;
     uint8_t sync_count;
     uint16_t sdo_count;
     uint32_t sii_nwords;
--- a/tools/Master.cpp	Tue Jun 10 11:54:39 2008 +0000
+++ b/tools/Master.cpp	Tue Jun 10 12:05:25 2008 +0000
@@ -264,7 +264,8 @@
             aliasIndex++;
         }
 
-        cout << "  " << slaveState(slave.state) << "  ";
+        cout << "  " << slaveState(slave.state)
+            << "  " << (slave.error_flag ? 'E' : '+') << "  ";
 
         if (strlen(slave.name)) {
             cout << slave.name;