Output DC config in 'ethercat config'.
authorFlorian Pose <fp@igh-essen.com>
Thu, 07 May 2009 10:33:26 +0000
changeset 1455 aa18fcfe0fd1
parent 1454 b9986feec1a5
child 1456 bd1f69a429f3
Output DC config in 'ethercat config'.
TODO
lib/slave_config.c
master/cdev.c
master/ioctl.h
tool/CommandConfig.cpp
--- a/TODO	Thu May 07 10:11:21 2009 +0000
+++ b/TODO	Thu May 07 10:33:26 2009 +0000
@@ -14,7 +14,6 @@
     - Check 32/64 bit operations.
     - Use vendor correction factors when calculating transmission delays.
     - Skip setting system time offset when application detached.
-    - Output DC configuration in 'ethercat config'.
     - How to set the SYNC1 shift time?
     - Do not output graph, if topology calculation failed.
 * Fix unloading problem of ec_e100 driver.
--- a/lib/slave_config.c	Thu May 07 10:11:21 2009 +0000
+++ b/lib/slave_config.c	Thu May 07 10:33:26 2009 +0000
@@ -248,14 +248,14 @@
         uint32_t sync0_cycle_time, uint32_t sync0_shift_time,
         uint32_t sync1_cycle_time, uint32_t sync1_shift_time)
 {
-    ec_ioctl_sc_dc_t data;
-
-    data.config_index = sc->index;
-    data.assign_activate = assign_activate;
-	data.sync[0].cycle_time = sync0_cycle_time;
-	data.sync[0].shift_time = sync0_shift_time;
-	data.sync[1].cycle_time = sync1_cycle_time;
-	data.sync[1].shift_time = sync1_shift_time;
+    ec_ioctl_config_t data;
+
+    data.config_index = sc->index;
+    data.dc_assign_activate = assign_activate;
+	data.dc_sync[0].cycle_time = sync0_cycle_time;
+	data.dc_sync[0].shift_time = sync0_shift_time;
+	data.dc_sync[1].cycle_time = sync1_cycle_time;
+	data.dc_sync[1].shift_time = sync1_shift_time;
 
     if (ioctl(sc->master->fd, EC_IOCTL_SC_DC, &data) == -1) {
         fprintf(stderr, "Failed to set assign_activate word.\n");
--- a/master/cdev.c	Thu May 07 10:11:21 2009 +0000
+++ b/master/cdev.c	Thu May 07 10:33:26 2009 +0000
@@ -1257,6 +1257,10 @@
     }
     data.sdo_count = ec_slave_config_sdo_count(sc);
     data.slave_position = sc->slave ? sc->slave->ring_position : -1;
+    data.dc_assign_activate = sc->dc_assign_activate;
+    for (i = 0; i < EC_SYNC_SIGNAL_COUNT; i++) {
+        data.dc_sync[i] = sc->dc_sync[i];
+    }
 
     up(&master->master_sem);
 
@@ -1936,7 +1940,7 @@
         ec_cdev_priv_t *priv /**< Private data structure of file handle. */
         )
 {
-    ec_ioctl_sc_dc_t data;
+    ec_ioctl_config_t data;
     ec_slave_config_t *sc;
 
 	if (unlikely(!priv->requested))
@@ -1953,11 +1957,11 @@
         return -ENOENT;
     }
 
-    ecrt_slave_config_dc(sc, data.assign_activate,
-            data.sync[0].cycle_time,
-            data.sync[0].shift_time,
-            data.sync[1].cycle_time,
-            data.sync[1].shift_time);
+    ecrt_slave_config_dc(sc, data.dc_assign_activate,
+            data.dc_sync[0].cycle_time,
+            data.dc_sync[0].shift_time,
+            data.dc_sync[1].cycle_time,
+            data.dc_sync[1].shift_time);
 
     up(&master->master_sem);
 
--- a/master/ioctl.h	Thu May 07 10:11:21 2009 +0000
+++ b/master/ioctl.h	Thu May 07 10:33:26 2009 +0000
@@ -95,7 +95,7 @@
 #define EC_IOCTL_SC_ADD_ENTRY          EC_IOW(0x25, ec_ioctl_add_pdo_entry_t)
 #define EC_IOCTL_SC_CLEAR_ENTRIES      EC_IOW(0x26, ec_ioctl_config_pdo_t)
 #define EC_IOCTL_SC_REG_PDO_ENTRY     EC_IOWR(0x27, ec_ioctl_reg_pdo_entry_t)
-#define EC_IOCTL_SC_DC                 EC_IOW(0x28, ec_ioctl_sc_dc_t)
+#define EC_IOCTL_SC_DC                 EC_IOW(0x28, ec_ioctl_config_t)
 #define EC_IOCTL_SC_SDO                EC_IOW(0x29, ec_ioctl_sc_sdo_t)
 #define EC_IOCTL_SC_SDO_REQUEST       EC_IOWR(0x2a, ec_ioctl_sdo_request_t)
 #define EC_IOCTL_SC_VOE               EC_IOWR(0x2b, ec_ioctl_voe_t)
@@ -391,19 +391,14 @@
     } syncs[EC_MAX_SYNC_MANAGERS];
     uint32_t sdo_count;
     int32_t slave_position;
+    uint16_t dc_assign_activate;
+    ec_sync_signal_t dc_sync[EC_SYNC_SIGNAL_COUNT];
 } ec_ioctl_config_t;
 
 /*****************************************************************************/
 
 typedef struct {
     // inputs
-    uint64_t app_time;
-} ec_ioctl_app_time_t;
-
-/*****************************************************************************/
-
-typedef struct {
-    // inputs
     uint32_t config_index;
     uint8_t sync_index;
     uint16_t pdo_pos;
@@ -473,15 +468,6 @@
 typedef struct {
     // inputs
     uint32_t config_index;
-    uint16_t assign_activate;
-    ec_sync_signal_t sync[EC_SYNC_SIGNAL_COUNT];
-} ec_ioctl_sc_dc_t;
-
-/*****************************************************************************/
-
-typedef struct {
-    // inputs
-    uint32_t config_index;
     uint16_t index;
     uint8_t subindex;
     const uint8_t *data;
@@ -541,6 +527,13 @@
 
 /*****************************************************************************/
 
+typedef struct {
+    // inputs
+    uint64_t app_time;
+} ec_ioctl_app_time_t;
+
+/*****************************************************************************/
+
 /** \endcond */
 
 #endif
--- a/tool/CommandConfig.cpp	Thu May 07 10:11:21 2009 +0000
+++ b/tool/CommandConfig.cpp	Thu May 07 10:33:26 2009 +0000
@@ -218,6 +218,22 @@
             cout << "  None." << endl;
         }
 
+        if (configIter->dc_assign_activate) {
+            int i;
+
+            cout << "DC configuration:" << endl
+                << "  AssignActivate: 0x" << hex << setfill('0')
+                << setw(4) << configIter->dc_assign_activate << endl;
+
+            cout << "        Cycle time [ns]  Shift time [ns]" << endl;
+            for (i = 0; i < EC_SYNC_SIGNAL_COUNT; i++) {
+                cout << "  SYNC" << dec << i << setfill(' ') << right
+                    << setw(11) << configIter->dc_sync[i].cycle_time
+                    << "      "
+                    << setw(11) << configIter->dc_sync[i].shift_time
+                    << endl;
+            }
+        }
         cout << endl;
     }
 }