Subdevice recovery #253
Unanswered
jbbjarnason
asked this question in
Q&A
Replies: 3 comments 1 reply
-
I think this would be possible if the function |
Beta Was this translation helpful? Give feedback.
1 reply
-
For reference, here is how we implemented the recovery mechanism with soem, /**
* Check the state of attached slaves.
* If the slaves are no longer in operational mode. Attempt to
* switch them to operational mode. And if the slaves have
* been lost attempt to add them again.
* @param group_index 0 for all groups
*/
auto check_state(uint8_t group_index = 0) -> void {
auto& grp = group_list_as_span()[group_index];
while (running_) {
if (grp.docheckstate == 1 || wkc_ < expected_wkc_) {
grp.docheckstate = FALSE;
ecx_readstate(&context_);
auto slaves = slave_list_as_span();
uint16_t slave_index = 1;
for (ec_slave& slave : slaves) {
if (slave.state != EC_STATE_OPERATIONAL) {
grp.docheckstate = TRUE;
if (slave.state == EC_STATE_SAFE_OP + EC_STATE_ERROR) {
logger_.warn("Slave {}, {} is in SAFE_OP+ERROR, attempting ACK", slave_index, slave.name);
slave.state = EC_STATE_SAFE_OP + EC_STATE_ACK;
ecx_writestate(&context_, slave_index);
} else if (slave.state == EC_STATE_SAFE_OP) {
logger_.warn("Slave {}, {} is in SAFE_OP, change to OPERATIONAL", slave_index, slave.name);
slave.state = EC_STATE_OPERATIONAL;
ecx_writestate(&context_, slave_index);
} else if (slave.state > EC_STATE_NONE) {
if (ecx_reconfig_slave(&context_, slave_index, EC_TIMEOUTRET) != 0) {
slave.islost = FALSE;
logger_.warn("Slave {}, {} reconfigured", slave_index, slave.name);
}
} else if (slave.islost == 0) {
ecx_statecheck(&context_, slave_index, EC_STATE_OPERATIONAL, EC_TIMEOUTRET);
if (slave.state == EC_STATE_NONE) {
slave.islost = TRUE;
logger_.warn("Slave {}, {} lost", slave_index, slave.name);
}
}
}
if (slave.islost == 1) {
if (slave.state != EC_STATE_NONE) {
slave.islost = FALSE;
logger_.info("Slave {}, {} found", slave_index, slave.name);
} else if (ecx_recover_slave(&context_, slave_index, EC_TIMEOUTRET) != 0) {
slave.islost = FALSE;
logger_.info("Slave {}, {} recovered", slave_index, slave.name);
}
}
slave_index++;
}
if (context_.grouplist->docheckstate == 0) {
logger_.info("All slaves resumed OPERATIONAL");
}
}
std::this_thread::sleep_for(milliseconds(10));
}
} this ran in separate thread I am trying to implement the same behavior with ethercrab. |
Beta Was this translation helpful? Give feedback.
0 replies
-
My workaround currently is to bring down the whole group when working counter is not as expected, and try to initialize again until expected count of subdevices are discovered. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So I would like to implement recovery mechanism running the ethercat daemon.
The recovery mechanism would check the state of device or just the working counter of the group.
Example (non compilable)
My intention is to disturb the network as little as possible and try to recover from any power outage or other problems in a smart way.
Is this possible with current api without reinitializing the whole group?
I have gone through the subdevice code and I can't seem to find if this is possible,
Beta Was this translation helpful? Give feedback.
All reactions