From e647297b12e653c3548d9d35352f0751603fe05c Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Fri, 1 Aug 2008 12:28:18 +0000 Subject: [PATCH] Attach Pdo names from dictionary. --- TODO | 2 +- master/fsm_master.c | 3 +++ master/pdo.c | 3 +++ master/pdo_entry.c | 3 +++ master/slave.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ master/slave.h | 1 + 6 files changed, 62 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 139b5aa1..6ecac124 100644 --- a/TODO +++ b/TODO @@ -8,9 +8,9 @@ $Id$ 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: diff --git a/master/fsm_master.c b/master/fsm_master.c index 4507ca7e..e071d8b3 100644 --- a/master/fsm_master.c +++ b/master/fsm_master.c @@ -818,6 +818,9 @@ void ec_fsm_master_state_sdo_dictionary( sdo_count, entry_count, slave->ring_position); } + // attach pdo names from dictionary + ec_slave_attach_pdo_names(slave); + ec_fsm_master_restart(fsm); } diff --git a/master/pdo.c b/master/pdo.c index 1e58732f..a2db5d8d 100644 --- a/master/pdo.c +++ b/master/pdo.c @@ -119,6 +119,9 @@ int ec_pdo_set_name( { unsigned int len; + if (pdo->name && name && !strcmp(pdo->name, name)) + return 0; + if (pdo->name) kfree(pdo->name); diff --git a/master/pdo_entry.c b/master/pdo_entry.c index 06246850..f99f7a6e 100644 --- a/master/pdo_entry.c +++ b/master/pdo_entry.c @@ -94,6 +94,9 @@ int ec_pdo_entry_set_name( { unsigned int len; + if (entry->name && name && !strcmp(entry->name, name)) + return 0; + if (entry->name) kfree(entry->name); diff --git a/master/slave.c b/master/slave.c index e0de5f3d..b687882f 100644 --- a/master/slave.c +++ b/master/slave.c @@ -667,3 +667,54 @@ const ec_pdo_t *ec_slave_find_pdo( } /*****************************************************************************/ + +/** 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); + } + } +} + +/*****************************************************************************/ diff --git a/master/slave.h b/master/slave.h index c52fc874..adf9c3ed 100644 --- a/master/slave.h +++ b/master/slave.h @@ -170,6 +170,7 @@ const ec_sdo_t *ec_slave_get_sdo_const(const ec_slave_t *, uint16_t); 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 *); /*****************************************************************************/