Skip to content

Commit

Permalink
Manually poll ACAN2517FD to work around broken interrupts
Browse files Browse the repository at this point in the history
  • Loading branch information
jpieper committed Jan 31, 2024
1 parent d1a678a commit f9cc822
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Moteus.h
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ class Moteus {
bool Poll() {
const auto now = micros();

// Ensure any interrupts have been handled.
can_bus_.poll();

if (!can_bus_.available()) { return false; }

CANFDMessage rx_msg;
Expand Down Expand Up @@ -520,7 +523,13 @@ class Moteus {

PadCan(&can_message);

// To work even when the ACAN2517FD doesn't have functioning
// interrupts, we will just poll it before and after attempting to
// send our message. This slows things down, but we're on an
// Arduino, so who cares?
can_bus_.poll();
can_bus_.tryToSend(can_message);
can_bus_.poll();

return frame.reply_required;
}
Expand Down

0 comments on commit f9cc822

Please # to comment.