Files
meshcore-tth/src
tthandClaude Opus 5 7060cc30ab fix(cli): i2c -- stop truncating the reply mid-word, and over-reading to do it
`i2c` on a SenseCap answered `no I2C device answered; expected-empt`. The cut
is not in transport: the node emits those 37 bytes.

The expected-empty list's first entry is `"; expected-empty %02X"` -- 19 chars
plus a NUL -- assembled in a 16-byte scratch buffer. snprintf() stored 15 chars
and returned 19, the length it WANTED. Using that return as a byte count did
two things: memcpy read 20 bytes out of a 16-byte stack buffer, and the write
cursor advanced past the NUL that had actually been stored, so every following
address landed after the string terminator where nothing would ever read it.

So the list has been invisible on every board since it was added, not just this
one -- which matters, because the whole point of printing the addresses the
build expects is to tell "sensor absent" from "sensor at the wrong address".

Fixed by appending through a helper that measures the source with strlen() and
writes only whole entries, plus buffers sized for the real worst case. A host
reproduction under ASan flags the old path as a 20-byte read of a 16-byte
frame and the new one comes back clean, printing the full
`expected-empty 40 44 76`; in a buffer too small it now stops on an entry
boundary instead of mid-word.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 10:21:39 +02:00
..