Improve hello message exchange #2
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The first part might not be needed if we assume CAN transmission to be reliable.
The second part might not be desired, but not for the reason you think: if we just
delay()
before sending the hello message, the hello messages of other modules will overflow our RX buffer. If we however transmit all at once, the collision avoidance will make sure only one packet at a time is sent, the code on the microcontroller will then sequentially handle every CAN packet. A better solution however would be to busyloop in the random "delay" and keep handling packets.The first part is still useful for newly connected modules. I noticed this in practice when we were still physically working on OBUS: the controller is turned on first and modules only after that. It would be sweet if they show up without restarting the controller, and it's not hard to implement.
For the second part: I had imagined setting a timer variable and letting the main loop loop, with a check to see if it should send the reply already. If you think the CAN module will already handle this, it's not necessary though.
Didn't think of that, this does seem useful now. How will this interact with the info phase? If the info phase doesn't get repeated, module that need this will instantly crash.
Looks like a good solution! The CAN module will handle collisions and make sure all messages get delivered, but the receive buffer can still overflow.
The receive buffer overflowing would imply that the main loop was stopped. Do you mean that the CAN module might block the CPU when it has messages in the "retry sending" queue?
I looked into it in the datasheet: the CAN chip will, independently of the microcontroller, keep retrying to transmit when it loses arbitration (when it loses the priority race). That means that the random delay is not needed I think. It will also retransmit if an recoverable error happens.