Introduced frames_timed_out flag to notice bus failure when link down is
authorFlorian Pose <fp@igh-essen.com>
Thu, 03 May 2007 14:29:21 +0000
changeset 664 18c48cb7de06
parent 663 38d9c37664d9
child 665 a9794f927d78
Introduced frames_timed_out flag to notice bus failure when link down is
not detected.
master/master.c
master/master.h
--- a/master/master.c	Fri Mar 16 14:42:04 2007 +0000
+++ b/master/master.c	Thu May 03 14:29:21 2007 +0000
@@ -453,6 +453,7 @@
 
     master->mode = EC_MASTER_MODE_OPERATION;
     master->pdo_slaves_offline = 0; // assume all PDO slaves online
+    master->frames_timed_out = 0;
     master->ext_request_cb = NULL;
     master->ext_release_cb = NULL;
     master->ext_cb_data = NULL;
@@ -1485,6 +1486,7 @@
 {
     ec_datagram_t *datagram, *next;
     cycles_t cycles_timeout;
+    unsigned int frames_timed_out = 0;
 
     // receive datagrams
     ec_device_poll(&master->main_device);
@@ -1497,12 +1499,15 @@
 
         if (master->main_device.cycles_poll - datagram->cycles_sent
             > cycles_timeout) {
+            frames_timed_out = 1;
             list_del_init(&datagram->queue);
             datagram->state = EC_DATAGRAM_TIMED_OUT;
             master->stats.timeouts++;
             ec_master_output_stats(master);
         }
     }
+
+    master->frames_timed_out = frames_timed_out;
 }
 
 /*****************************************************************************/
@@ -1563,7 +1568,8 @@
         )
 {
     status->bus_status =
-        master->pdo_slaves_offline ? EC_BUS_FAILURE : EC_BUS_OK;
+        (master->pdo_slaves_offline || master->frames_timed_out)
+        ? EC_BUS_FAILURE : EC_BUS_OK;
     status->bus_tainted = master->fsm.tainted; 
     status->slaves_responding = master->fsm.slaves_responding;
 }
--- a/master/master.h	Fri Mar 16 14:42:04 2007 +0000
+++ b/master/master.h	Thu May 03 14:29:21 2007 +0000
@@ -137,6 +137,8 @@
     unsigned int pdo_slaves_offline; /** number of slaves, for which PDOs
                                        were registered and that are offline
                                        (used for bus status) */
+    unsigned int frames_timed_out; /**< there were frame timeouts in the last
+                                     call to ecrt_master_receive() */
 
     int thread_id; /**< master thread PID */
     struct completion thread_exit; /**< thread completion object */