Changed the datatypes of the shift times in ecrt_slave_config_dc() stable-1.5
authorFlorian Pose <fp@igh-essen.com>
Thu, 29 Nov 2012 10:15:40 +0100
branchstable-1.5
changeset 2449 5db725cc40f9
parent 2448 41dc9a4a0f76
child 2450 c0cf0e6cff43
child 2452 abc1d1caead7
Changed the datatypes of the shift times in ecrt_slave_config_dc()
to int32_t to correctly display negative shift times.
include/ecrt.h
lib/slave_config.c
master/fsm_slave_config.c
master/globals.h
master/slave_config.c
--- a/include/ecrt.h	Tue Nov 20 14:53:36 2012 +0100
+++ b/include/ecrt.h	Thu Nov 29 10:15:40 2012 +0100
@@ -64,6 +64,8 @@
  *   ecrt_master_reference_clock_time() and the feature flag
  *   EC_HAVE_REF_CLOCK_TIME to have the possibility to synchronize the master
  *   clock to the reference clock.
+ * - Changed the datatypes of the shift times in ecrt_slave_config_dc() to
+ *   int32_t to correctly display negative shift times.
  *
  * Changes in version 1.5:
  *
@@ -1266,14 +1268,16 @@
  * The AssignActivate word is vendor-specific and can be taken from the XML
  * device description file (Device -> Dc -> AssignActivate). Set this to zero,
  * if the slave shall be operated without distributed clocks (default).
+ *
+ * \attention The \a sync1_shift time is ignored.
  */
 void ecrt_slave_config_dc(
         ec_slave_config_t *sc, /**< Slave configuration. */
         uint16_t assign_activate, /**< AssignActivate word. */
         uint32_t sync0_cycle, /**< SYNC0 cycle time [ns]. */
-        uint32_t sync0_shift, /**< SYNC0 shift time [ns]. */
+        int32_t sync0_shift, /**< SYNC0 shift time [ns]. */
         uint32_t sync1_cycle, /**< SYNC1 cycle time [ns]. */
-        uint32_t sync1_shift /**< SYNC1 shift time [ns]. */
+        int32_t sync1_shift /**< SYNC1 shift time [ns]. */
         );
 
 /** Add an SDO configuration.
--- a/lib/slave_config.c	Tue Nov 20 14:53:36 2012 +0100
+++ b/lib/slave_config.c	Thu Nov 29 10:15:40 2012 +0100
@@ -306,8 +306,8 @@
 /*****************************************************************************/
 
 void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate,
-        uint32_t sync0_cycle_time, uint32_t sync0_shift_time,
-        uint32_t sync1_cycle_time, uint32_t sync1_shift_time)
+        uint32_t sync0_cycle_time, int32_t sync0_shift_time,
+        uint32_t sync1_cycle_time, int32_t sync1_shift_time)
 {
     ec_ioctl_config_t data;
     int ret;
@@ -321,7 +321,7 @@
 
     ret = ioctl(sc->master->fd, EC_IOCTL_SC_DC, &data);
     if (EC_IOCTL_IS_ERROR(ret)) {
-        fprintf(stderr, "Failed to set assign_activate word: %s\n",
+        fprintf(stderr, "Failed to set DC parameters: %s\n",
                 strerror(EC_IOCTL_ERRNO(ret)));
     }
 }
--- a/master/fsm_slave_config.c	Tue Nov 20 14:53:36 2012 +0100
+++ b/master/fsm_slave_config.c	Thu Nov 29 10:15:40 2012 +0100
@@ -1305,7 +1305,7 @@
             EC_SLAVE_DBG(slave, 1, "      app_time=%llu\n", master->app_time);
             EC_SLAVE_DBG(slave, 1, "    start_time=%llu\n", start_time);
             EC_SLAVE_DBG(slave, 1, "    cycle_time=%u\n", sync0->cycle_time);
-            EC_SLAVE_DBG(slave, 1, "    shift_time=%u\n", sync0->shift_time);
+            EC_SLAVE_DBG(slave, 1, "    shift_time=%i\n", sync0->shift_time);
             EC_SLAVE_DBG(slave, 1, "     remainder=%u\n", remainder);
             EC_SLAVE_DBG(slave, 1, "         start=%llu\n", start);
             start_time = start;
--- a/master/globals.h	Tue Nov 20 14:53:36 2012 +0100
+++ b/master/globals.h	Thu Nov 29 10:15:40 2012 +0100
@@ -182,7 +182,7 @@
  */
 typedef struct {
     uint32_t cycle_time; /**< Cycle time [ns]. */
-    uint32_t shift_time; /**< Shift time [ns]. */
+    int32_t shift_time; /**< Shift time [ns]. */
 } ec_sync_signal_t;
 
 /** Access states for SDO entries.
--- a/master/slave_config.c	Tue Nov 20 14:53:36 2012 +0100
+++ b/master/slave_config.c	Thu Nov 29 10:15:40 2012 +0100
@@ -79,10 +79,10 @@
 
     sc->used_fmmus = 0;
     sc->dc_assign_activate = 0x0000;
-    sc->dc_sync[0].cycle_time = 0x00000000;
-    sc->dc_sync[1].cycle_time = 0x00000000;
-    sc->dc_sync[0].shift_time = 0x00000000;
-    sc->dc_sync[1].shift_time = 0x00000000;
+    sc->dc_sync[0].cycle_time = 0U;
+    sc->dc_sync[1].cycle_time = 0;
+    sc->dc_sync[0].shift_time = 0U;
+    sc->dc_sync[1].shift_time = 0;
 
     INIT_LIST_HEAD(&sc->sdo_configs);
     INIT_LIST_HEAD(&sc->sdo_requests);
@@ -771,12 +771,12 @@
 /*****************************************************************************/
 
 void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate,
-        uint32_t sync0_cycle_time, uint32_t sync0_shift_time,
-        uint32_t sync1_cycle_time, uint32_t sync1_shift_time)
+        uint32_t sync0_cycle_time, int32_t sync0_shift_time,
+        uint32_t sync1_cycle_time, int32_t sync1_shift_time)
 {
     EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, assign_activate = 0x%04X,"
-            " sync0_cycle = %u, sync0_shift = %u,"
-            " sync1_cycle = %u, sync1_shift = %u\n",
+            " sync0_cycle = %u, sync0_shift = %i,"
+            " sync1_cycle = %u, sync1_shift = %i\n",
             __func__, sc, assign_activate, sync0_cycle_time, sync0_shift_time,
             sync1_cycle_time, sync1_shift_time);