Improved CoE error messages.
authorFlorian Pose <fp@igh-essen.com>
Tue, 26 Jan 2010 11:20:07 +0100
changeset 1792 3eb466e9bad5
parent 1791 27030c6b2de3
child 1793 651f6ba216c5
Improved CoE error messages.
master/fsm_coe.c
--- a/master/fsm_coe.c	Tue Jan 26 10:17:44 2010 +0100
+++ b/master/fsm_coe.c	Tue Jan 26 11:20:07 2010 +0100
@@ -50,6 +50,7 @@
 #define EC_COE_DOWN_SEG_MIN_DATA_SIZE    7
 
 #define DEBUG_RETRIES 0
+#define DEBUG_LONG 0
 
 /*****************************************************************************/
 
@@ -1198,6 +1199,7 @@
 {
     ec_datagram_t *datagram = fsm->datagram;
     ec_slave_t *slave = fsm->slave;
+    unsigned long diff_ms;
 
     if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
         return; // FIXME: check for response first?
@@ -1210,10 +1212,10 @@
         return;
     }
 
+    diff_ms = (jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
+
     if (datagram->working_counter != 1) {
         if (!datagram->working_counter) {
-            unsigned long diff_ms =
-                (jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
             if (diff_ms < fsm->request->response_timeout) {
 #if DEBUG_RETRIES
                 if (fsm->slave->master->debug_level) {
@@ -1227,12 +1229,22 @@
             }
         }
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Reception of CoE download request failed on slave %u: ",
-                slave->ring_position);
+        EC_ERR("Reception of CoE download request for SDO 0x%04x:%x failed"
+                " with timeout after %u ms on slave %u: ",
+                fsm->request->index, fsm->request->subindex, (u32) diff_ms,
+                fsm->slave->ring_position);
         ec_datagram_print_wc_error(datagram);
         return;
     }
 
+#if DEBUG_LONG
+    if (diff_ms > 200) {
+        EC_WARN("SDO 0x%04x:%x download took %u ms on slave %u.\n",
+                fsm->request->index, fsm->request->subindex, (u32) diff_ms,
+                fsm->slave->ring_position);
+    }
+#endif
+
     fsm->jiffies_start = datagram->jiffies_sent;
 
     ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
@@ -1275,8 +1287,10 @@
             (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
         if (diff_ms >= fsm->request->response_timeout) {
             fsm->state = ec_fsm_coe_error;
-            EC_ERR("Timeout while waiting for SDO download response on "
-                    "slave %u.\n", slave->ring_position);
+            EC_ERR("Timeout after %u ms while waiting for SDO 0x%04x:%x"
+                    " download response on slave %u.\n", (u32) diff_ms,
+                    fsm->request->index, fsm->request->subindex, 
+                    slave->ring_position);
             return;
         }
 
@@ -1693,6 +1707,7 @@
 {
     ec_datagram_t *datagram = fsm->datagram;
     ec_slave_t *slave = fsm->slave;
+    unsigned long diff_ms;
 
     if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--)
         return; // FIXME: check for response first?
@@ -1705,10 +1720,10 @@
         return;
     }
 
+    diff_ms = (jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
+
     if (datagram->working_counter != 1) {
         if (!datagram->working_counter) {
-            unsigned long diff_ms =
-                (jiffies - fsm->request->jiffies_sent) * 1000 / HZ;
             if (diff_ms < fsm->request->response_timeout) {
 #if DEBUG_RETRIES
                 if (fsm->slave->master->debug_level) {
@@ -1722,12 +1737,22 @@
             }
         }
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Reception of CoE upload request failed on slave %u: ",
-                slave->ring_position);
+        EC_ERR("Reception of CoE upload request for SDO 0x%04x:%x failed"
+                " with timeout after %u ms on slave %u: ",
+                fsm->request->index, fsm->request->subindex, (u32) diff_ms,
+                fsm->slave->ring_position);
         ec_datagram_print_wc_error(datagram);
         return;
     }
 
+#if DEBUG_LONG
+    if (diff_ms > 200) {
+        EC_WARN("SDO 0x%04x:%x upload took %u ms on slave %u.\n",
+                fsm->request->index, fsm->request->subindex, (u32) diff_ms,
+                fsm->slave->ring_position);
+    }
+#endif
+
     fsm->jiffies_start = datagram->jiffies_sent;
 
     ec_slave_mbox_prepare_check(slave, datagram); // can not fail.
@@ -1770,8 +1795,10 @@
             (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ;
         if (diff_ms >= fsm->request->response_timeout) {
             fsm->state = ec_fsm_coe_error;
-            EC_ERR("Timeout while waiting for SDO upload response on "
-                    "slave %u.\n", slave->ring_position);
+            EC_ERR("Timeout after %u ms while waiting for SDO 0x%04x:%x"
+                    " upload response on slave %u.\n", (u32) diff_ms,
+                    fsm->request->index, fsm->request->subindex,
+                    slave->ring_position);
             return;
         }