From 2916b4f822ce0eb4c07d36adcdd131cc996febda Mon Sep 17 00:00:00 2001 From: Jacob Dahl <37091262+dakejahl@users.noreply.github.com> Date: Wed, 26 Aug 2026 16:37:23 -0600 Subject: [PATCH] fix(uavcan): classify TX frames dropped while peeking the queue (#28397) peek() discards entries whose deadline has passed before returning the head of the queue, and counted them with a bare registerRejectedFrame(). That is the fourth drop path; the reported split covers three. The frames landed in the total and in neither bucket, so `uavcan status` printed lines like TX rejected: 64 frames (0 expired, 0 no memory) which reads as "no drops worth caring about" when 64 frames of in-flight transfers had just been discarded. Serving a DroneCAN node firmware update hits this path on every interface. The total stays a separate counter rather than the sum of the two buckets: it is what makes an unclassified path visible at all, which is how this one was found. (cherry picked from commit c2cf9be6aa7e7587af253fadf2b30853415fe61c) Assisted-by: GitHub Copilot:gpt-6-astra Backport-note: Companion to #28395: account for expired frames in the new TX-drop diagnostics. --- .../libdronecan/libuavcan/include/uavcan/transport/can_io.hpp | 2 ++ .../uavcan/libdronecan/libuavcan/src/transport/uc_can_io.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/drivers/uavcan/libdronecan/libuavcan/include/uavcan/transport/can_io.hpp b/src/drivers/uavcan/libdronecan/libuavcan/include/uavcan/transport/can_io.hpp index 144c246bc4e..e33f703c299 100644 --- a/src/drivers/uavcan/libdronecan/libuavcan/include/uavcan/transport/can_io.hpp +++ b/src/drivers/uavcan/libdronecan/libuavcan/include/uavcan/transport/can_io.hpp @@ -117,6 +117,8 @@ public: /// The 'or equal' condition is necessary to avoid frame reordering. bool topPriorityHigherOrEqual(const CanFrame& rhs_frame) const; + /// Total. Every drop is also counted in exactly one of the two below, so a total that exceeds + /// their sum means a drop path was added without classifying it. uint32_t getRejectedFrameCount() const { return rejected_frames_cnt_; } /// Frames dropped because their transmit deadline had already passed. Not a memory shortage. diff --git a/src/drivers/uavcan/libdronecan/libuavcan/src/transport/uc_can_io.cpp b/src/drivers/uavcan/libdronecan/libuavcan/src/transport/uc_can_io.cpp index cb310bb6c84..1ca5b8700e8 100644 --- a/src/drivers/uavcan/libdronecan/libuavcan/src/transport/uc_can_io.cpp +++ b/src/drivers/uavcan/libdronecan/libuavcan/src/transport/uc_can_io.cpp @@ -207,7 +207,7 @@ CanTxQueue::Entry* CanTxQueue::peek() { UAVCAN_TRACE("CanTxQueue", "Peek: Expired %s", p->toString().c_str()); Entry* const next = p->getNextListNode(); - registerRejectedFrame(); + registerExpiredFrame(); remove(p); p = next; }