Configure alternative PDO mapping only on slaves that have PDO sync
managers.
This commit is contained in:
parent
2a1920caaa
commit
e17ebc9764
|
|
@ -161,20 +161,23 @@ void ec_fsm_mapping_next_sync(
|
|||
ec_fsm_mapping_t *fsm /**< mapping state machine */
|
||||
)
|
||||
{
|
||||
do {
|
||||
while (1) {
|
||||
if (fsm->dir > EC_DIR_INPUT) {
|
||||
// no more sync managers to configure mappings for
|
||||
// no more directions to configure mappings for
|
||||
fsm->state = ec_fsm_mapping_state_end;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(fsm->sync = ec_slave_get_pdo_sync(fsm->slave, fsm->dir))) {
|
||||
fsm->state = ec_fsm_mapping_state_error;
|
||||
return;
|
||||
// no sync manager found for this direction
|
||||
fsm->dir++;
|
||||
continue;
|
||||
}
|
||||
|
||||
fsm->dir++;
|
||||
if (fsm->sync->alt_mapping)
|
||||
break;
|
||||
}
|
||||
while (!fsm->sync->alt_mapping);
|
||||
|
||||
if (fsm->slave->master->debug_level) {
|
||||
EC_DBG("Configuring PDO mapping for SM%u of slave %i.\n",
|
||||
|
|
|
|||
|
|
@ -1111,10 +1111,8 @@ ec_sync_t *ec_slave_get_pdo_sync(
|
|||
sync_index = (unsigned int) dir;
|
||||
if (slave->sii_mailbox_protocols) sync_index += 2;
|
||||
|
||||
if (sync_index >= slave->sii_sync_count) {
|
||||
EC_ERR("No appropriate sync manager found.\n");
|
||||
if (sync_index >= slave->sii_sync_count)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &slave->sii_syncs[sync_index];
|
||||
}
|
||||
|
|
@ -1297,7 +1295,7 @@ int ecrt_slave_pdo_mapping_add(
|
|||
unsigned int not_found = 1;
|
||||
|
||||
if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)) {
|
||||
EC_ERR("Slave %i does not support CoE!\n", slave->ring_position);
|
||||
EC_ERR("Slave %u does not support CoE!\n", slave->ring_position);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1310,7 +1308,7 @@ int ecrt_slave_pdo_mapping_add(
|
|||
}
|
||||
|
||||
if (not_found) {
|
||||
EC_ERR("Slave %i does not provide PDO %04X!\n",
|
||||
EC_ERR("Slave %u does not provide PDO 0x%04X!\n",
|
||||
slave->ring_position, pdo_index);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -1323,8 +1321,11 @@ int ecrt_slave_pdo_mapping_add(
|
|||
}
|
||||
|
||||
|
||||
if (!(sync = ec_slave_get_pdo_sync(slave, dir)))
|
||||
if (!(sync = ec_slave_get_pdo_sync(slave, dir))) {
|
||||
EC_ERR("Failed to obtain sync manager for PDO mapping of slave %u!\n",
|
||||
slave->ring_position);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ec_sync_add_pdo(sync, pdo);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue