# HG changeset patch # User Florian Pose # Date 1174052359 0 # Node ID 582a90a34303032a9edd3aa9a905149f340661b8 # Parent d7c5a958bad03e36c0dee42c87145ffd56165013 Configure alternative PDO mapping only on slaves that have PDO sync managers. diff -r d7c5a958bad0 -r 582a90a34303 master/fsm_mapping.c --- a/master/fsm_mapping.c Fri Mar 16 11:23:08 2007 +0000 +++ b/master/fsm_mapping.c Fri Mar 16 13:39:19 2007 +0000 @@ -161,20 +161,23 @@ 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++; - } - while (!fsm->sync->alt_mapping); + if (fsm->sync->alt_mapping) + break; + } if (fsm->slave->master->debug_level) { EC_DBG("Configuring PDO mapping for SM%u of slave %i.\n", diff -r d7c5a958bad0 -r 582a90a34303 master/slave.c --- a/master/slave.c Fri Mar 16 11:23:08 2007 +0000 +++ b/master/slave.c Fri Mar 16 13:39:19 2007 +0000 @@ -1111,10 +1111,8 @@ 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 @@ 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 @@ } 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 @@ } - 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); }