From e17ebc9764d7b38569a8ead9b7e8a3ae8c8df4ae Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Fri, 16 Mar 2007 13:39:19 +0000 Subject: [PATCH] Configure alternative PDO mapping only on slaves that have PDO sync managers. --- master/fsm_mapping.c | 13 ++++++++----- master/slave.c | 13 +++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/master/fsm_mapping.c b/master/fsm_mapping.c index b6dd2fa8..96d400d7 100644 --- a/master/fsm_mapping.c +++ b/master/fsm_mapping.c @@ -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", diff --git a/master/slave.c b/master/slave.c index 505a4ebf..a5160be9 100644 --- a/master/slave.c +++ b/master/slave.c @@ -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); }