diff --git a/master/domain.c b/master/domain.c index 361e6239f17a82385eba2d5436a9bd1658c0689c..60a93503d12dbefb3be52a67be4a87c698e856bc 100644 --- a/master/domain.c +++ b/master/domain.c @@ -196,10 +196,18 @@ void ec_domain_add_fmmu_config( 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 @@ void ecrt_domain_process(ec_domain_t *domain) 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 --git a/master/slave.c b/master/slave.c index 26a0826f29300902c4ef22936e11bd64f7b71162..b542f595fb016f2d7b55c701451d454ea7845dea 100644 --- a/master/slave.c +++ b/master/slave.c @@ -1164,14 +1164,14 @@ ssize_t ec_store_slave_attribute(struct kobject *kobj, /**< slave's kobject */ /*****************************************************************************/ -/** - * 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 @@ ec_sync_t *ec_slave_get_pdo_sync( 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 --git a/master/sync.c b/master/sync.c index ad5d1d6c2444c514ec0fdffc62d890616a40aab3..de6cd37ea854f0a3d67265c989684f42719bbb2d 100644 --- a/master/sync.c +++ b/master/sync.c @@ -144,13 +144,22 @@ ec_direction_t ec_sync_direction( { int index = sync->index; - 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 (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; + } + } 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;