Skip to content
Snippets Groups Projects
Commit 0a4bded8 authored by Florian Pose's avatar Florian Pose
Browse files

Reconfiguration of slaves, though they are in the correct state at startup.

parent 3174a1b0
No related branches found
No related tags found
No related merge requests found
...@@ -571,15 +571,24 @@ void ec_fsm_master_action_process_states(ec_fsm_t *fsm ...@@ -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 // check if any slaves are not in the state, they're supposed to be
list_for_each_entry(slave, &master->slaves, list) { list_for_each_entry(slave, &master->slaves, list) {
if (slave->error_flag || if (slave->error_flag
!slave->online || || !slave->online
slave->requested_state == EC_SLAVE_STATE_UNKNOWN || || slave->requested_state == EC_SLAVE_STATE_UNKNOWN
slave->current_state == slave->requested_state) continue; || (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); if (slave->current_state != slave->requested_state) {
ec_state_string(slave->requested_state, new_state); ec_state_string(slave->current_state, old_state);
EC_INFO("Changing state of slave %i from %s to %s.\n", ec_state_string(slave->requested_state, new_state);
slave->ring_position, old_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 = slave;
fsm->slave_state = ec_fsm_slaveconf_init; fsm->slave_state = ec_fsm_slaveconf_init;
...@@ -1399,6 +1408,8 @@ void ec_fsm_slaveconf_init(ec_fsm_t *fsm /**< finite state machine */) ...@@ -1399,6 +1408,8 @@ void ec_fsm_slaveconf_init(ec_fsm_t *fsm /**< finite state machine */)
if (fsm->change_state != ec_fsm_end) return; if (fsm->change_state != ec_fsm_end) return;
slave->configured = 1;
if (master->debug_level) { if (master->debug_level) {
EC_DBG("Slave %i is now in INIT.\n", slave->ring_position); EC_DBG("Slave %i is now in INIT.\n", slave->ring_position);
} }
......
...@@ -132,6 +132,7 @@ int ec_slave_init(ec_slave_t *slave, /**< EtherCAT slave */ ...@@ -132,6 +132,7 @@ int ec_slave_init(ec_slave_t *slave, /**< EtherCAT slave */
slave->requested_state = EC_SLAVE_STATE_UNKNOWN; slave->requested_state = EC_SLAVE_STATE_UNKNOWN;
slave->current_state = EC_SLAVE_STATE_UNKNOWN; slave->current_state = EC_SLAVE_STATE_UNKNOWN;
slave->configured = 0;
slave->error_flag = 0; slave->error_flag = 0;
slave->online = 1; slave->online = 1;
slave->fmmu_count = 0; slave->fmmu_count = 0;
......
...@@ -197,6 +197,7 @@ struct ec_slave ...@@ -197,6 +197,7 @@ struct ec_slave
ec_slave_state_t requested_state; /**< requested slave state */ ec_slave_state_t requested_state; /**< requested slave state */
ec_slave_state_t current_state; /**< current 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 error_flag; /**< stop processing after an error */
unsigned int online; /**< non-zero, if the slave responds. */ unsigned int online; /**< non-zero, if the slave responds. */
uint8_t registered; /**< true, if slave has been registered */ uint8_t registered; /**< true, if slave has been registered */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment