From f9cc8222b41618ffcf41ab30ea1efb17101ccca3 Mon Sep 17 00:00:00 2001 From: Josh Pieper Date: Wed, 31 Jan 2024 15:48:17 -0500 Subject: [PATCH] Manually poll ACAN2517FD to work around broken interrupts --- src/Moteus.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Moteus.h b/src/Moteus.h index 63b6b51..ca60c2d 100644 --- a/src/Moteus.h +++ b/src/Moteus.h @@ -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; @@ -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; }