# HG changeset patch # User Florian Pose # Date 1210694826 0 # Node ID 6630f4dbcfd2237ce16ebb5942caa2fbe556563c # Parent 17c3b3aafbb912530c2d99a3fd89438f58e640f5 Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs. diff -r 17c3b3aafbb9 -r 6630f4dbcfd2 master/domain.c --- a/master/domain.c Fri Apr 25 15:01:15 2008 +0000 +++ b/master/domain.c Tue May 13 16:07:06 2008 +0000 @@ -196,10 +196,18 @@ ec_fmmu_config_t *fmmu /**< FMMU configuration. */ ) { + unsigned int wc_increment; fmmu->domain = domain; domain->data_size += fmmu->data_size; - domain->expected_working_counter += working_counter_increment[fmmu->dir]; + wc_increment = working_counter_increment[fmmu->dir]; + domain->expected_working_counter += wc_increment; + + if (domain->master->debug_level) + EC_DBG("Domain %u: Added %u bytes (now %u) with dir %u -> WC %u" + " (now %u).\n", domain->index, fmmu->data_size, + domain->data_size, fmmu->dir, wc_increment, + domain->expected_working_counter); } /*****************************************************************************/ @@ -439,13 +447,14 @@ jiffies - domain->notify_jiffies > HZ) { domain->notify_jiffies = jiffies; if (domain->working_counter_changes == 1) { - EC_INFO("Domain %u working counter change: %u\n", domain->index, - domain->working_counter); + EC_INFO("Domain %u: Working counter changed to %u/%u.\n", + domain->index, domain->working_counter, + domain->expected_working_counter); } else { - EC_INFO("Domain %u: %u working counter changes. Currently %u\n", + EC_INFO("Domain %u: %u working counter changes. Currently %u/%u.\n", domain->index, domain->working_counter_changes, - domain->working_counter); + domain->working_counter, domain->expected_working_counter); } domain->working_counter_changes = 0; } diff -r 17c3b3aafbb9 -r 6630f4dbcfd2 master/slave.c --- a/master/slave.c Fri Apr 25 15:01:15 2008 +0000 +++ b/master/slave.c Tue May 13 16:07:06 2008 +0000 @@ -1164,14 +1164,14 @@ /*****************************************************************************/ -/** - * Get the sync manager for either Rx- or Tx-Pdos. +/** Get the sync manager for either Rx- or Tx-Pdos. + * + * \todo This seems not to be correct in every case... * \return pointer to sync manager, or NULL. */ - ec_sync_t *ec_slave_get_pdo_sync( - ec_slave_t *slave, /**< EtherCAT slave */ - ec_direction_t dir /**< input or output */ + ec_slave_t *slave, /**< EtherCAT slave. */ + ec_direction_t dir /**< Input or output. */ ) { unsigned int sync_index; @@ -1181,11 +1181,18 @@ return NULL; } - sync_index = (unsigned int) dir; - if (slave->sii.mailbox_protocols) sync_index += 2; - - if (sync_index >= slave->sii.sync_count) - return NULL; + if (slave->sii.sync_count != 1) { + sync_index = (unsigned int) dir; + if (slave->sii.mailbox_protocols) sync_index += 2; + + if (sync_index >= slave->sii.sync_count) + return NULL; + } else { // sync_count == 1 + // A single sync manager may be used for inputs OR outputs! + if (ec_sync_direction(&slave->sii.syncs[0]) != dir) + return NULL; + sync_index = 0; + } return &slave->sii.syncs[sync_index]; } diff -r 17c3b3aafbb9 -r 6630f4dbcfd2 master/sync.c --- a/master/sync.c Fri Apr 25 15:01:15 2008 +0000 +++ b/master/sync.c Tue May 13 16:07:06 2008 +0000 @@ -144,13 +144,22 @@ { int index = sync->index; - if (sync->slave && sync->slave->sii.mailbox_protocols) { - index -= 2; - } + if (sync->slave->sii.sync_count != 1) { + if (sync->slave && sync->slave->sii.mailbox_protocols) { + index -= 2; + } - if (index < 0 || index > 1) { - EC_WARN("ec_sync_get_direction(): invalid sync manager index.\n"); - return EC_DIR_OUTPUT; + if (index < 0 || index > 1) { + EC_WARN("ec_sync_get_direction(): invalid sync manager index.\n"); + return EC_DIR_OUTPUT; + } + } else { // sync_count == 1 + if (!list_empty(&sync->pdos.list)) { + const ec_pdo_t *pdo = + list_entry(sync->pdos.list.next, ec_pdo_t, list); + return pdo->dir; + } + } return (ec_direction_t) index;