Skip to content

Commit 2725da4

Browse files
committed
Clarify MCP2515 pumpEvents
1 parent ca5cfff commit 2725da4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

examples/SineWaveCAN/SineWaveCAN.ino

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ void setup() {
244244

245245
void loop() {
246246
pumpEvents(can_intf); // This is required on some platforms to handle incoming feedback CAN messages
247+
// Note that on MCP2515-based platforms, this will delay for a fixed 10ms.
248+
// This has been found to reduce the number of dropped messages, however it can be removed
249+
// for applications requiring loop times over 100Hz.
247250

248251
float SINE_PERIOD = 2.0f; // Period of the position command sine wave in seconds
249252

src/ODriveMCPCAN.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ static void onReceive(const CanMsg& msg, ODriveCAN& odrive) {
3333
}
3434

3535
static void pumpEvents(MCP2515Class& intf) {
36-
// nothing to do
37-
// TODO: maybe remove
38-
delay(10); // not sure why this resulted in less dropped messages, could have been a twisted coincidence
36+
// On other platforms, this polls and processes incoming CAN messages.
37+
// However, this is not possible on MCP2515-based platforms.
38+
39+
// A 10ms delay was found to reduce the number of dropped messages, however a
40+
// specific root cause has not been identified, and may be a quirk in the MCP2515.
41+
delay(10);
3942
}
4043

4144
CREATE_CAN_INTF_WRAPPER(MCP2515Class)

0 commit comments

Comments
 (0)