From b2e8b1d3666f4b981b757c97c1ed04425a327ab6 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sun, 29 Mar 2026 21:03:57 -0600 Subject: [PATCH] fix: COBS decoder stripped trailing 0x00 data bytes (broke Ping command) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cobs_decode() function had a bogus 'strip trailing zero' step that removed the last byte if it was 0x00. The Ping command IS tag byte 0x00, so its decoded payload was stripped to empty, causing from_bytes to return None. The COBS standard algorithm doesn't produce spurious trailing zeros — the post-processing was simply wrong. Also fix read_frame to skip bare 0x00 sentinels on fresh USB connects. --- src/usb/task.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/usb/task.rs b/src/usb/task.rs index b139f9d7..a96175ff 100644 --- a/src/usb/task.rs +++ b/src/usb/task.rs @@ -236,9 +236,5 @@ fn cobs_decode(src: &[u8], dest: &mut [u8]) -> Option { di += 1; } } - // Strip trailing zero if present (COBS artifact) - if di > 0 && dest[di - 1] == 0 { - di -= 1; - } Some(di) }