Skip to content

Warn when the co-processor rejects corrupt SPI packets - #220

Open
twells46 wants to merge 1 commit into
masterfrom
spi-reject-warning
Open

twells46 wants to merge 1 commit into
masterfrom
spi-reject-warning

Conversation

@twells46

Copy link
Copy Markdown
Contributor

Since kipr/Wombat-Firmware#12, the co-processor counts the SPI packets it drops writes from (corrupt count byte or out-of-range address). It keeps the count mod 16 in the high nibble of REG_RW_MOT_DONE. Nothing on the host read that count, so those lost writes went unnoticed.

WombatDevice::transfer() now watches the nibble and logs a warning when it changes:

co-processor rejected N corrupt SPI packet(s); some writes may have been lost
  • It warns at most once every 5 seconds. On close, it warns once more if any rejections haven't been reported yet.
  • The first value it reads is the baseline. A step of −1 is ignored, because the firmware's main loop can briefly write back the previous count.
  • Older firmware leaves the nibble at 0, so nothing changes there. get_motor_done already masks the low four bits and is unchanged.

Testing

  • Cross-compiles for aarch64 in the repo's Docker builder with no warnings in the changed file.

🤖 Generated with Claude Code

Wombat-Firmware now counts packets with a corrupt count byte or an
out-of-range address, mod 16, in the high nibble of REG_RW_MOT_DONE
(kipr/Wombat-Firmware#12). Without a reader on the host, those lost
writes are silent.

WombatDevice::transfer() watches the nibble and logs a warning when it
moves, at most once every 5 seconds, and once more on close if any are
still unreported. The first value seen is the baseline. A step of -1 is
ignored: the firmware's main loop can briefly write back the previous
count.

Older firmware leaves the nibble at 0, so it never warns. get_motor_done
already masks the low four bits and is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant