Improved working counter output; fixed problem with slaves that have a single sync manager used for outputs.

This commit is contained in:
Florian Pose 2008-05-13 16:07:06 +00:00
parent 78a1317663
commit c8b67e13ee
3 changed files with 45 additions and 20 deletions

View File

@ -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;
}

View File

@ -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 (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;
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];
}

View File

@ -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 (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;