Store PDO mapping source in sync manager.
authorFlorian Pose <fp@igh-essen.com>
Thu, 04 Oct 2007 08:09:41 +0000
changeset 762 15214036c72a
parent 761 f1a23fd26052
child 763 5e238783b71a
Store PDO mapping source in sync manager.
master/fsm_coe_map.c
master/slave.c
master/sync.c
master/sync.h
--- a/master/fsm_coe_map.c	Wed Oct 03 09:19:01 2007 +0000
+++ b/master/fsm_coe_map.c	Thu Oct 04 08:09:41 2007 +0000
@@ -276,6 +276,7 @@
         list_for_each_entry(pdo, &fsm->pdos, list) {
             ec_sync_add_pdo(sync, pdo);
         }
+        sync->mapping_source = EC_SYNC_MAPPING_COE;
         ec_fsm_coe_map_clear_pdos(fsm);
 
         // next sync manager
--- a/master/slave.c	Wed Oct 03 09:19:01 2007 +0000
+++ b/master/slave.c	Thu Oct 04 08:09:41 2007 +0000
@@ -576,6 +576,7 @@
 
         // if sync manager index is positive, the PDO is mapped by default
         if (pdo->sync_index >= 0) {
+            ec_sync_t *sync;
             ec_pdo_t *mapped_pdo;
 
             if (pdo->sync_index >= slave->sii_sync_count) {
@@ -583,6 +584,7 @@
                         pdo->sync_index, pdo->index, slave->ring_position);
                 return -1;
             }
+            sync = &slave->sii_syncs[pdo->sync_index];
 
             if (!(mapped_pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
                 EC_ERR("Failed to allocate PDO memory.\n");
@@ -595,8 +597,8 @@
                 return -1;
             }
 
-            list_add_tail(&mapped_pdo->list,
-                    &slave->sii_syncs[pdo->sync_index].pdos);
+            list_add_tail(&mapped_pdo->list, &sync->pdos);
+            sync->mapping_source = EC_SYNC_MAPPING_SII;
         }
     }
 
@@ -810,8 +812,12 @@
                 ec_sync_size(sync), sync->control_register,
                 sync->enable ? "enable" : "disable");
 
-        if (list_empty(&sync->pdos))
+        if (list_empty(&sync->pdos)) {
             off += sprintf(buffer + off, "    No PDOs mapped.\n");
+        } else if (sync->mapping_source != EC_SYNC_MAPPING_NONE) {
+            off += sprintf(buffer + off, "    PDO mapping information from %s.\n",
+                    sync->mapping_source == EC_SYNC_MAPPING_SII ? "SII" : "CoE");
+        }
 
         list_for_each_entry(pdo, &sync->pdos, list) {
             off += sprintf(buffer + off, "    %s 0x%04X \"%s\"\n",
@@ -830,7 +836,7 @@
 
     // type-cast to avoid warnings on some compilers
     if (!list_empty((struct list_head *) &slave->sii_pdos))
-        off += sprintf(buffer + off, "\nAvailable PDOs:\n");
+        off += sprintf(buffer + off, "\nAvailable PDOs from SII:\n");
 
     list_for_each_entry(pdo, &slave->sii_pdos, list) {
         off += sprintf(buffer + off, "  %s 0x%04X \"%s\"",
--- a/master/sync.c	Wed Oct 03 09:19:01 2007 +0000
+++ b/master/sync.c	Thu Oct 04 08:09:41 2007 +0000
@@ -62,6 +62,7 @@
     sync->est_length = 0;
     INIT_LIST_HEAD(&sync->pdos);
     sync->alt_mapping = 0;
+    sync->mapping_source = EC_SYNC_MAPPING_NONE;
 }
 
 /*****************************************************************************/
--- a/master/sync.h	Wed Oct 03 09:19:01 2007 +0000
+++ b/master/sync.h	Thu Oct 04 08:09:41 2007 +0000
@@ -54,6 +54,19 @@
 /*****************************************************************************/
 
 /**
+ * EtherCAT sync manager PDO mapping information source.
+ */
+
+typedef enum {
+    EC_SYNC_MAPPING_NONE, /**< No PDO mapping information */
+    EC_SYNC_MAPPING_SII, /**< PDO mapping information from SII */
+    EC_SYNC_MAPPING_COE /**< PDO mapping information from CoE dictionary */
+}
+ec_sync_mapping_source_t;
+
+/*****************************************************************************/
+
+/**
  * Sync manager.
  */
 
@@ -69,6 +82,7 @@
     uint16_t est_length; /**< used to calculate the length via PDO ranges */
     struct list_head pdos; /**< list of mapped PDOs */
     unsigned int alt_mapping; /**< alternative mapping configured */
+    ec_sync_mapping_source_t mapping_source; /**< pdo mapping source */
 }
 ec_sync_t;