Bugfix: ecrt_domain_state() always returned -1.
authorFlorian Pose <fp@igh-essen.com>
Sat, 23 Sep 2006 10:56:02 +0000
changeset 363 58588a3a1562
parent 362 ae38aeb6fde9
child 364 9028b20e3c12
Bugfix: ecrt_domain_state() always returned -1.
master/domain.c
master/domain.h
--- a/master/domain.c	Tue Sep 19 14:08:31 2006 +0000
+++ b/master/domain.c	Sat Sep 23 10:56:02 2006 +0000
@@ -515,10 +515,14 @@
     ec_datagram_t *datagram;
 
     working_counter_sum = 0;
+    domain->state = 0;
     list_for_each_entry(datagram, &domain->datagrams, list) {
         if (datagram->state == EC_DATAGRAM_RECEIVED) {
             working_counter_sum += datagram->working_counter;
         }
+        else {
+            domain->state = -1;
+        }
     }
 
     if (working_counter_sum != domain->response_count) {
@@ -554,13 +558,7 @@
 
 int ecrt_domain_state(const ec_domain_t *domain /**< EtherCAT domain */)
 {
-    ec_datagram_t *datagram;
-
-    list_for_each_entry(datagram, &domain->datagrams, list) {
-        if (datagram->state != EC_DATAGRAM_RECEIVED) return -1;
-    }
-
-    return 0;
+    return domain->state;
 }
 
 /*****************************************************************************/
--- a/master/domain.h	Tue Sep 19 14:08:31 2006 +0000
+++ b/master/domain.h	Sat Sep 23 10:56:02 2006 +0000
@@ -66,6 +66,7 @@
     struct list_head datagrams; /**< process data datagrams */
     uint32_t base_address; /**< logical offset address of the process data */
     unsigned int response_count; /**< number of responding slaves */
+    unsigned int state; /**< domain error state */
     struct list_head data_regs; /**< PDO data registrations */
     unsigned int working_counter_changes; /**< working counter changes
                                              since last notification */