master/domain.c
branchstable-1.1
changeset 1716 9440f4ff25c7
parent 1715 e675450f2174
child 1717 cc1ee18207d3
--- a/master/domain.c	Thu Aug 03 12:59:01 2006 +0000
+++ b/master/domain.c	Wed Aug 09 14:38:44 2006 +0000
@@ -106,6 +106,8 @@
     domain->data_size = 0;
     domain->base_address = 0;
     domain->response_count = 0xFFFFFFFF;
+    domain->t_last = 0;
+    domain->working_counter_changes = 0;
 
     INIT_LIST_HEAD(&domain->data_regs);
     INIT_LIST_HEAD(&domain->datagrams);
@@ -151,7 +153,7 @@
 /*****************************************************************************/
 
 /**
-   Registeres a data field in a domain.
+   Registeres a PDO entry.
    \return 0 in case of success, else < 0
 */
 
@@ -225,7 +227,7 @@
 /*****************************************************************************/
 
 /**
-   Clears the list of the registered data fields.
+   Clears the list of the data registrations.
 */
 
 void ec_domain_clear_data_regs(ec_domain_t *domain /**< EtherCAT domain */)
@@ -511,6 +513,7 @@
 {
     unsigned int working_counter_sum;
     ec_datagram_t *datagram;
+    cycles_t t_now = get_cycles();
 
     working_counter_sum = 0;
     list_for_each_entry(datagram, &domain->datagrams, list) {
@@ -520,9 +523,23 @@
     }
 
     if (working_counter_sum != domain->response_count) {
+        domain->working_counter_changes++;
         domain->response_count = working_counter_sum;
-        EC_INFO("Domain %i working counter change: %i\n", domain->index,
-                domain->response_count);
+    }
+
+    if (domain->working_counter_changes &&
+        (u32) (t_now - domain->t_last) / cpu_khz > 1000) {
+        domain->t_last = t_now;
+        if (domain->working_counter_changes == 1) {
+            EC_INFO("Domain %i working counter change: %i\n", domain->index,
+                    domain->response_count);
+        }
+        else {
+            EC_INFO("Domain %i: %u WC changes. Current response count: %i\n",
+                    domain->index, domain->working_counter_changes,
+                    domain->response_count);
+        }
+        domain->working_counter_changes = 0;
     }
 
     ec_domain_queue(domain);