Attach Pdo names from dictionary.
authorFlorian Pose <fp@igh-essen.com>
Fri, 01 Aug 2008 12:28:18 +0000
changeset 1186 ff481f097c97
parent 1185 337ce4fc2383
child 1187 aa616c3286ce
Attach Pdo names from dictionary.
TODO
master/fsm_master.c
master/pdo.c
master/pdo_entry.c
master/slave.c
master/slave.h
--- a/TODO	Fri Aug 01 11:09:39 2008 +0000
+++ b/TODO	Fri Aug 01 12:28:18 2008 +0000
@@ -8,9 +8,9 @@
 
 Version 1.4.0:
 
-* Attach Pdo names from SII or Coe dictionary to Pdos read via CoE.
 * Update documentation.
 * Check for possible race condition in jiffy-based frame timeout calculation.
+* Use down_interruptible() for cdev calls.
 
 Future issues:
 
--- a/master/fsm_master.c	Fri Aug 01 11:09:39 2008 +0000
+++ b/master/fsm_master.c	Fri Aug 01 12:28:18 2008 +0000
@@ -818,6 +818,9 @@
                sdo_count, entry_count, slave->ring_position);
     }
 
+    // attach pdo names from dictionary
+    ec_slave_attach_pdo_names(slave);
+
     ec_fsm_master_restart(fsm);
 }
 
--- a/master/pdo.c	Fri Aug 01 11:09:39 2008 +0000
+++ b/master/pdo.c	Fri Aug 01 12:28:18 2008 +0000
@@ -119,6 +119,9 @@
 {
     unsigned int len;
 
+    if (pdo->name && name && !strcmp(pdo->name, name))
+        return 0;
+    
     if (pdo->name)
         kfree(pdo->name);
 
--- a/master/pdo_entry.c	Fri Aug 01 11:09:39 2008 +0000
+++ b/master/pdo_entry.c	Fri Aug 01 12:28:18 2008 +0000
@@ -94,6 +94,9 @@
 {
     unsigned int len;
 
+    if (entry->name && name && !strcmp(entry->name, name))
+        return 0;
+    
     if (entry->name)
         kfree(entry->name);
 
--- a/master/slave.c	Fri Aug 01 11:09:39 2008 +0000
+++ b/master/slave.c	Fri Aug 01 12:28:18 2008 +0000
@@ -667,3 +667,54 @@
 }
 
 /*****************************************************************************/
+
+/** Find name for a Pdo and its entries.
+ */
+void ec_slave_find_names_for_pdo(
+        ec_slave_t *slave,
+        ec_pdo_t *pdo
+        )
+{
+    const ec_sdo_t *sdo;
+    ec_pdo_entry_t *pdo_entry;
+    const ec_sdo_entry_t *sdo_entry;
+
+    list_for_each_entry(sdo, &slave->sdo_dictionary, list) {
+        if (sdo->index == pdo->index) {
+            ec_pdo_set_name(pdo, sdo->name);
+        } else {
+            list_for_each_entry(pdo_entry, &pdo->entries, list) {
+                if (sdo->index == pdo_entry->index) {
+                    sdo_entry = ec_sdo_get_entry_const(
+                            sdo, pdo_entry->subindex);
+                    if (sdo_entry) {
+                        ec_pdo_entry_set_name(pdo_entry,
+                                sdo_entry->description);
+                    }
+                }
+            }
+        }
+    }
+}
+
+/*****************************************************************************/
+
+/** Attach Pdo names.
+ */
+void ec_slave_attach_pdo_names(
+        ec_slave_t *slave
+        )
+{
+    unsigned int i;
+    ec_sync_t *sync;
+    ec_pdo_t *pdo;
+    
+    for (i = 0; i < slave->sii.sync_count; i++) {
+        sync = slave->sii.syncs + i;
+        list_for_each_entry(pdo, &sync->pdos.list, list) {
+            ec_slave_find_names_for_pdo(slave, pdo);
+        }
+    }
+}
+
+/*****************************************************************************/
--- a/master/slave.h	Fri Aug 01 11:09:39 2008 +0000
+++ b/master/slave.h	Fri Aug 01 12:28:18 2008 +0000
@@ -170,6 +170,7 @@
 const ec_sdo_t *ec_slave_get_sdo_by_pos_const(const ec_slave_t *, uint16_t);
 uint16_t ec_slave_sdo_count(const ec_slave_t *);
 const ec_pdo_t *ec_slave_find_pdo(const ec_slave_t *, uint16_t);
+void ec_slave_attach_pdo_names(ec_slave_t *);
 
 /*****************************************************************************/