Send sync datagrams only if reference clock is found. stable-1.5
authorFlorian Pose <fp@igh-essen.com>
Wed, 05 Dec 2012 15:54:49 +0100
branchstable-1.5
changeset 2476 9a0d30056e70
parent 2475 9c18c29b8942
child 2477 1d5ebfb7fec1
Send sync datagrams only if reference clock is found.
master/master.c
--- a/master/master.c	Wed Dec 05 14:55:32 2012 +0100
+++ b/master/master.c	Wed Dec 05 15:54:49 2012 +0100
@@ -2072,8 +2072,7 @@
 
     // always set DC reference clock to OP
     if (master->dc_ref_clock) {
-        ec_slave_request_state(master->dc_ref_clock,
-                EC_SLAVE_STATE_OP);
+        ec_slave_request_state(master->dc_ref_clock, EC_SLAVE_STATE_OP);
     }
 }
 
@@ -2629,16 +2628,20 @@
 
 void ecrt_master_sync_reference_clock(ec_master_t *master)
 {
-    EC_WRITE_U32(master->ref_sync_datagram.data, master->app_time);
-    ec_master_queue_datagram(master, &master->ref_sync_datagram);
+    if (master->dc_ref_clock) {
+        EC_WRITE_U32(master->ref_sync_datagram.data, master->app_time);
+        ec_master_queue_datagram(master, &master->ref_sync_datagram);
+    }
 }
 
 /*****************************************************************************/
 
 void ecrt_master_sync_slave_clocks(ec_master_t *master)
 {
-    ec_datagram_zero(&master->sync_datagram);
-    ec_master_queue_datagram(master, &master->sync_datagram);
+    if (master->dc_ref_clock) {
+        ec_datagram_zero(&master->sync_datagram);
+        ec_master_queue_datagram(master, &master->sync_datagram);
+    }
 }
 
 /*****************************************************************************/