fix: COBS decoder stripped trailing 0x00 data bytes (broke Ping command)

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.
This commit is contained in:
swaits committed 2026-03-29 21:33:07 -06:00
1 parent d22d2b92ac
commit b2e8b1d366
1 file changed
-4
-4
View File
@@ -236,9 +236,5 @@ fn cobs_decode(src: &[u8], dest: &mut [u8]) -> Option<usize> {
di += 1;
}
}
// Strip trailing zero if present (COBS artifact)
if di > 0 && dest[di - 1] == 0 {
di -= 1;
}
Some(di)
}