Introduced ec_datagram_print_state() method and used it at all places where
authorFlorian Pose <fp@igh-essen.com>
Tue, 23 Feb 2010 15:13:56 +0100
changeset 1822 74e6ac2369f4
parent 1821 40321a37d085
child 1823 2bf892fe8080
Introduced ec_datagram_print_state() method and used it at all places where
the datagram state is output.
master/datagram.c
master/datagram.h
master/fsm_change.c
master/fsm_coe.c
master/fsm_foe.c
master/fsm_master.c
master/fsm_sii.c
master/fsm_slave_config.c
master/fsm_slave_scan.c
master/voe_handler.c
--- a/master/datagram.c	Tue Feb 23 13:18:31 2010 +0100
+++ b/master/datagram.c	Tue Feb 23 15:13:56 2010 +0100
@@ -500,6 +500,43 @@
 
 /*****************************************************************************/
 
+/** Prints the state of a datagram.
+ *
+ * Outputs a text message.
+ */
+void ec_datagram_print_state(
+        const ec_datagram_t *datagram /**< EtherCAT datagram */
+        )
+{
+    printk("Datagram ");
+    switch (datagram->state) {
+        case EC_DATAGRAM_INIT:
+            printk("initialized");
+            break;
+        case EC_DATAGRAM_QUEUED:
+            printk("queued");
+            break;
+        case EC_DATAGRAM_SENT:
+            printk("sent");
+            break;
+        case EC_DATAGRAM_RECEIVED:
+            printk("received");
+            break;
+        case EC_DATAGRAM_TIMED_OUT:
+            printk("timed out");
+            break;
+        case EC_DATAGRAM_ERROR:
+            printk("error");
+            break;
+        default:
+            printk("???");
+    }
+
+    printk(".\n");
+}
+
+/*****************************************************************************/
+
 /** Evaluates the working counter of a single-cast datagram.
  *
  * Outputs an error message.
--- a/master/datagram.h	Tue Feb 23 13:18:31 2010 +0100
+++ b/master/datagram.h	Tue Feb 23 15:13:56 2010 +0100
@@ -134,6 +134,7 @@
 int ec_datagram_lwr(ec_datagram_t *, uint32_t, size_t, uint8_t *);
 int ec_datagram_lrw(ec_datagram_t *, uint32_t, size_t, uint8_t *);
 
+void ec_datagram_print_state(const ec_datagram_t *);
 void ec_datagram_print_wc_error(const ec_datagram_t *);
 void ec_datagram_output_stats(ec_datagram_t *);
 const char *ec_datagram_type_string(const ec_datagram_t *);
--- a/master/fsm_change.c	Tue Feb 23 13:18:31 2010 +0100
+++ b/master/fsm_change.c	Tue Feb 23 15:13:56 2010 +0100
@@ -182,9 +182,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_change_state_error;
-        EC_ERR("Failed to receive state datagram from slave %u"
-                " (datagram state %u)!\n",
-               fsm->slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive state datagram from slave %u: ",
+               fsm->slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -248,9 +248,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_change_state_error;
-        EC_ERR("Failed to receive state checking datagram from slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive state checking datagram from slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -386,9 +386,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_change_state_error;
-        EC_ERR("Failed to receive AL status code datagram from slave %u"
-                " (datagram state %u).\n",
-               fsm->slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive AL status code datagram from slave %u: ",
+               fsm->slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -445,9 +445,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_change_state_error;
-        EC_ERR("Failed to receive state ack datagram for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive state ack datagram for slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -485,9 +485,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_change_state_error;
-        EC_ERR("Failed to receive state ack check datagram from slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive state ack check datagram from slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
--- a/master/fsm_coe.c	Tue Feb 23 13:18:31 2010 +0100
+++ b/master/fsm_coe.c	Tue Feb 23 15:13:56 2010 +0100
@@ -327,8 +327,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE dictionary request datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -363,9 +363,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Failed to receive CoE mailbox check datagram for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive CoE mailbox check datagram for slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -421,8 +421,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE dictionary response datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -572,8 +572,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE SDO description request datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -608,9 +608,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Failed to receive CoE mailbox check datagram from slave %u"
-                " (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive CoE mailbox check datagram from slave %u: ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -666,8 +666,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE SDO description response datagram from"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -808,8 +808,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE SDO entry request datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -846,8 +846,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE mailbox check datagram from slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+                ": ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -905,8 +905,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE SDO description response datagram from"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1209,8 +1209,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE download request datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1270,9 +1270,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Failed to receive CoE mailbox check datagram for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive CoE mailbox check datagram for slave %u: ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1391,8 +1391,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE download response datagram from"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1498,9 +1498,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Failed to receive CoE mailbox check datagram for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive CoE mailbox check datagram for slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1556,8 +1556,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE download response datagram from"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1716,9 +1716,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Failed to receive CoE upload request for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive CoE upload request for slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1778,9 +1778,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Failed to receive CoE mailbox check datagram from slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive CoE mailbox check datagram from slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1865,8 +1865,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE upload response datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -2043,8 +2043,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE upload segment request datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -2079,9 +2079,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
-        EC_ERR("Failed to receive CoE mailbox check datagram for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive CoE mailbox check datagram for slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -2137,8 +2137,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_coe_error;
         EC_ERR("Failed to receive CoE upload segment response datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
--- a/master/fsm_foe.c	Tue Feb 23 13:18:31 2010 +0100
+++ b/master/fsm_foe.c	Tue Feb 23 15:13:56 2010 +0100
@@ -333,9 +333,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
-        EC_ERR("Failed to receive FoE mailbox check datagram for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive FoE mailbox check datagram for slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -391,8 +391,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
         EC_ERR("Failed to receive FoE ack response datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -468,9 +468,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
-        EC_ERR("Failed to send FoE WRQ for slave %u"
-                " (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+        EC_ERR("Failed to send FoE WRQ for slave %u: ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -512,8 +512,8 @@
     if (fsm->datagram->state != EC_DATAGRAM_RECEIVED) {
         ec_foe_set_tx_error(fsm, FOE_RECEIVE_ERROR);
         EC_ERR("Failed to receive FoE ack response datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -602,9 +602,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
-        EC_ERR("Failed to send FoE RRQ for slave %u"
-                " (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+        EC_ERR("Failed to send FoE RRQ for slave %u" ": ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -695,9 +695,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
-        EC_ERR("Failed to send FoE DATA READ for slave %u"
-                " (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+        EC_ERR("Failed to send FoE DATA READ for slave %u: ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -753,8 +753,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
         EC_ERR("Failed to receive FoE DATA READ datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -874,9 +874,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         ec_foe_set_rx_error(fsm, FOE_RECEIVE_ERROR);
-        EC_ERR("Failed to send FoE ACK for slave %u"
-                " (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+        EC_ERR("Failed to send FoE ACK for slave %u: ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
--- a/master/fsm_master.c	Tue Feb 23 13:18:31 2010 +0100
+++ b/master/fsm_master.c	Tue Feb 23 15:13:56 2010 +0100
@@ -607,9 +607,9 @@
         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);
+        EC_ERR("Failed to receive AL state datagram for slave %u: ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         ec_fsm_master_restart(fsm);
         return;
     }
--- a/master/fsm_sii.c	Tue Feb 23 13:18:31 2010 +0100
+++ b/master/fsm_sii.c	Tue Feb 23 15:13:56 2010 +0100
@@ -210,9 +210,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_sii_state_error;
-        EC_ERR("Failed to receive SII read datagram from slave %u"
-                " (datagram state %u).\n",
-               fsm->slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive SII read datagram from slave %u: ",
+               fsm->slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -259,9 +259,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_sii_state_error;
-        EC_ERR("Failed to receive SII check/fetch datagram from slave %u"
-                " (datagram state %u).\n",
-               fsm->slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive SII check/fetch datagram from slave %u: ",
+               fsm->slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -358,9 +358,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_sii_state_error;
-        EC_ERR("Failed to receive SII write datagram for slave %u"
-                " (datagram state %u).\n",
-               fsm->slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive SII write datagram for slave %u: ",
+               fsm->slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -400,9 +400,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_sii_state_error;
-        EC_ERR("Failed to receive SII write check datagram from slave %u"
-                " (datagram state %u).\n",
-               fsm->slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive SII write check datagram from slave %u: ",
+               fsm->slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
--- a/master/fsm_slave_config.c	Tue Feb 23 13:18:31 2010 +0100
+++ b/master/fsm_slave_config.c	Tue Feb 23 15:13:56 2010 +0100
@@ -419,9 +419,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_config_state_error;
-        EC_ERR("Failed to receive DC times datagram for slave %u"
-                " (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive DC times datagram for slave %u: ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -468,9 +468,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_config_state_error;
-        EC_ERR("Failed to receive DC system time offset datagram for slave %u"
-                " (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive DC system time offset datagram for"
+                " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -636,8 +636,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_config_state_error;
         EC_ERR("Failed to receive sync manager configuration datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -895,8 +895,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_config_state_error;
         EC_ERR("Failed to receive watchdog divider configuration datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -956,8 +956,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_config_state_error;
         EC_ERR("Failed to receive sync manager watchdog configuration "
-                "datagram for slave %u (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+                "datagram for slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1043,8 +1043,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_config_state_error;
         EC_ERR("Failed to receive process data sync manager configuration"
-               " datagram for slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " datagram for slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1130,9 +1130,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_config_state_error;
-        EC_ERR("Failed to receive FMMUs datagram for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive FMMUs datagram for slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1214,9 +1214,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_config_state_error;
-        EC_ERR("Failed to receive DC cycle times datagram for slave %u"
-                " (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive DC cycle times datagram for slave %u: ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1292,9 +1292,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_config_state_error;
-        EC_ERR("Failed to receive DC start time datagram for slave %u"
-                " (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive DC start time datagram for slave %u: ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -1334,9 +1334,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_config_state_error;
-        EC_ERR("Failed to receive DC activation datagram for slave %u"
-                " (datagram state %u).\n",
-                slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive DC activation datagram for slave %u: ",
+                slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
--- a/master/fsm_slave_scan.c	Tue Feb 23 13:18:31 2010 +0100
+++ b/master/fsm_slave_scan.c	Tue Feb 23 15:13:56 2010 +0100
@@ -179,7 +179,9 @@
    Slave scan state: ADDRESS.
 */
 
-void ec_fsm_slave_scan_state_address(ec_fsm_slave_scan_t *fsm /**< slave state machine */)
+void ec_fsm_slave_scan_state_address(
+        ec_fsm_slave_scan_t *fsm /**< slave state machine */
+        )
 {
     ec_datagram_t *datagram = fsm->datagram;
 
@@ -188,9 +190,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_scan_state_error;
-        EC_ERR("Failed to receive station address datagram for slave %u"
-                " (datagram state %u)\n",
-                fsm->slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive station address datagram for slave %u: ",
+                fsm->slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -228,9 +230,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_scan_state_error;
-        EC_ERR("Failed to receive AL state datagram from slave %u"
-                " (datagram state %u).\n",
-               fsm->slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive AL state datagram from slave %u: ",
+               fsm->slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -276,9 +278,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_scan_state_error;
-        EC_ERR("Failed to receive base data datagram for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive base data datagram for slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -351,9 +353,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_scan_state_error;
-        EC_ERR("Failed to receive system time datagram for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive system time datagram for slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -403,9 +405,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_scan_state_error;
-        EC_ERR("Failed to receive system time datagram for slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive system time datagram for slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -463,9 +465,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_scan_state_error;
-        EC_ERR("Failed to receive DL status datagram from slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive DL status datagram from slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -763,9 +765,9 @@
 
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_scan_state_error;
-        EC_ERR("Failed to receive get reg alias datagram from slave %u"
-                " (datagram state %u).\n",
-               fsm->slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive get reg alias datagram from slave %u: ",
+               fsm->slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -860,8 +862,8 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         fsm->state = ec_fsm_slave_scan_state_error;
         EC_ERR("Failed to receive sync manager configuration datagram"
-                " from slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+                " from slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
--- a/master/voe_handler.c	Tue Feb 23 13:18:31 2010 +0100
+++ b/master/voe_handler.c	Tue Feb 23 15:13:56 2010 +0100
@@ -257,8 +257,8 @@
         voe->state = ec_voe_handler_state_error;
         voe->request_state = EC_INT_REQUEST_FAILURE;
         EC_ERR("Failed to receive VoE write request datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -332,9 +332,9 @@
     if (datagram->state != EC_DATAGRAM_RECEIVED) {
         voe->state = ec_voe_handler_state_error;
         voe->request_state = EC_INT_REQUEST_FAILURE;
-        EC_ERR("Failed to receive VoE mailbox check datagram from slave %u"
-                " (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+        EC_ERR("Failed to receive VoE mailbox check datagram from slave %u: ",
+               slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -388,8 +388,8 @@
         voe->state = ec_voe_handler_state_error;
         voe->request_state = EC_INT_REQUEST_FAILURE;
         EC_ERR("Failed to receive VoE read datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }
 
@@ -480,8 +480,8 @@
         voe->state = ec_voe_handler_state_error;
         voe->request_state = EC_INT_REQUEST_FAILURE;
         EC_ERR("Failed to receive VoE read datagram for"
-               " slave %u (datagram state %u).\n",
-               slave->ring_position, datagram->state);
+               " slave %u: ", slave->ring_position);
+        ec_datagram_print_state(datagram);
         return;
     }