From 0a4bded8ed921ad363833c6cf9c4f381d03cfd25 Mon Sep 17 00:00:00 2001 From: Florian Pose <fp@igh-essen.com> Date: Fri, 20 Oct 2006 10:48:30 +0000 Subject: [PATCH] Reconfiguration of slaves, though they are in the correct state at startup. --- master/fsm.c | 27 +++++++++++++++++++-------- master/slave.c | 1 + master/slave.h | 1 + 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/master/fsm.c b/master/fsm.c index 35cad062..bc06b574 100644 --- a/master/fsm.c +++ b/master/fsm.c @@ -571,15 +571,24 @@ void ec_fsm_master_action_process_states(ec_fsm_t *fsm // check if any slaves are not in the state, they're supposed to be list_for_each_entry(slave, &master->slaves, list) { - if (slave->error_flag || - !slave->online || - slave->requested_state == EC_SLAVE_STATE_UNKNOWN || - slave->current_state == slave->requested_state) continue; + if (slave->error_flag + || !slave->online + || slave->requested_state == EC_SLAVE_STATE_UNKNOWN + || (slave->current_state == slave->requested_state + && (slave->configured + || slave->current_state == EC_SLAVE_STATE_INIT))) continue; + + if (!slave->configured + && slave->current_state != EC_SLAVE_STATE_INIT) { + EC_INFO("Reconfiguring slave %i.\n", slave->ring_position); + } - ec_state_string(slave->current_state, old_state); - ec_state_string(slave->requested_state, new_state); - EC_INFO("Changing state of slave %i from %s to %s.\n", - slave->ring_position, old_state, new_state); + if (slave->current_state != slave->requested_state) { + ec_state_string(slave->current_state, old_state); + ec_state_string(slave->requested_state, new_state); + EC_INFO("Changing state of slave %i from %s to %s.\n", + slave->ring_position, old_state, new_state); + } fsm->slave = slave; fsm->slave_state = ec_fsm_slaveconf_init; @@ -1399,6 +1408,8 @@ void ec_fsm_slaveconf_init(ec_fsm_t *fsm /**< finite state machine */) if (fsm->change_state != ec_fsm_end) return; + slave->configured = 1; + if (master->debug_level) { EC_DBG("Slave %i is now in INIT.\n", slave->ring_position); } diff --git a/master/slave.c b/master/slave.c index 76e147ae..48f07184 100644 --- a/master/slave.c +++ b/master/slave.c @@ -132,6 +132,7 @@ int ec_slave_init(ec_slave_t *slave, /**< EtherCAT slave */ slave->requested_state = EC_SLAVE_STATE_UNKNOWN; slave->current_state = EC_SLAVE_STATE_UNKNOWN; + slave->configured = 0; slave->error_flag = 0; slave->online = 1; slave->fmmu_count = 0; diff --git a/master/slave.h b/master/slave.h index 943895e2..1a311874 100644 --- a/master/slave.h +++ b/master/slave.h @@ -197,6 +197,7 @@ struct ec_slave ec_slave_state_t requested_state; /**< requested slave state */ ec_slave_state_t current_state; /**< current slave state */ + unsigned int configured; /**< the slave is configured by this master */ unsigned int error_flag; /**< stop processing after an error */ unsigned int online; /**< non-zero, if the slave responds. */ uint8_t registered; /**< true, if slave has been registered */ -- GitLab