Earliest time point when OnRpdoWrite is reliable triggered?
In our MotorDriver, we begin to initialize the stepper motors with OnBoot. Some vendors require to cycle enable power and enable operation for the drives to work reliable. When we switch the drives through SDO 0x6040 (mapped or directly) the drives answer with changing SDO 0x6041. This is mapped to a PDO and reverse PDO mapping is used. But we encountered that this init does not work reliable when starting from OnBoot() in the Driver. So we added a sleep to find out if it works in priciple:
void MotorDriver::OnBoot(lely::canopen::NmtState st, char es, const std::string &what) noexcept
{
DCFDriver::OnBoot(st, es, what);
if (es == 0)
{
SubmitWait(std::chrono::milliseconds(1000), [this](std::error_code error)
{
if (!error)
SubmitWrite(0x6040, 0, ...)
});
}
}
void MotorDriver::OnRpdoWrite(uint16_t idx, uint8_t subidx) noexcept
{
// handle the result here
}This made it more reliable but we still have cases where OnRpdoWrite is not called. But on the CAN bus, the communication happened:
2163.601797 0/0x000 NMT 8 - FD1.6 01 08 start
2163.601961 392/0x188 PDO 8 - FD1.6 33 02 0x233
2164.604098 1544/0x608 SDO 8 - FD1.6 2b 40 60 00 06 00 00 00 w Req exp 6040:0 Val 0x6
2164.604406 1416/0x588 SDO 8 - FD1.6 60 40 60 00 00 00 00 00 w Res - 6040:0
2164.604537 392/0x188 PDO 8 - FD1.6 31 02 0x231 It is not deterministic which node(s) is/are not behaving correctly.