# HG changeset patch # User Florian Pose # Date 1217593698 0 # Node ID ff481f097c9782849045601f66f315a7b1b2a095 # Parent 337ce4fc2383e1803182e482ab7e075f6fd0be54 Attach Pdo names from dictionary. diff -r 337ce4fc2383 -r ff481f097c97 TODO --- 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: diff -r 337ce4fc2383 -r ff481f097c97 master/fsm_master.c --- 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); } diff -r 337ce4fc2383 -r ff481f097c97 master/pdo.c --- 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); diff -r 337ce4fc2383 -r ff481f097c97 master/pdo_entry.c --- 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); diff -r 337ce4fc2383 -r ff481f097c97 master/slave.c --- 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); + } + } +} + +/*****************************************************************************/ diff -r 337ce4fc2383 -r ff481f097c97 master/slave.h --- 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 *); /*****************************************************************************/