Skip to content

Wait for the erase to finish before reporting success - #4

Open
lgnap wants to merge 1 commit into
LinuxRenaissance:masterfrom
lgnap:wait-for-erase-to-finish
Open

lgnap wants to merge 1 commit into
LinuxRenaissance:masterfrom
lgnap:wait-for-erase-to-finish

Conversation

@lgnap

@lgnap lgnap commented Sep 6, 2026

Copy link
Copy Markdown

Replaces my #3, which duplicated @zinic's #1. This keeps only the part that
does not overlap: reading the reply properly.

It is independent of device support and applies to the Interview PRO too —
it touches delete_recordings() and nothing else, so it should merge cleanly
before or after #1.

The bug

The device does not answer once. It streams progress reports as it erases:

02 4A 41 00     0 %
02 4A 41 05     5 %
   ...
02 4A 41 64   100 %

Byte [3] is a percentage, not a status constant — the README's "status
code of 100" is the device reporting 100 % complete.

Reading a single reply therefore returns at the first report, which is 0:

$ ./krode delete
Sending delete command to PID 0x0056...
Done. Recordings deleted (status: 0).      <- 2.3 s before the device finished

The (status: %d) in the current message is what makes this visible: it prints
0, not 100.

The fix

Read until byte [3] reaches 100. Progress is shown on a terminal and
suppressed when redirected, so logs do not fill with percents.

Losing the device after progress has been reported is treated as a normal
ending rather than an error — the transmitter drops off the bus as soon as it
is done. Losing it before any reply is still an error. I added that branch
after hitting exactly that case during testing; it is the one part I have not
been able to re-trigger deliberately since, so it is worth a second pair of
eyes.

Testing

Verified on a Wireless PRO TX (PID 0x0056), which needs #1 or a locally added
PID to be reachable — I built a throwaway copy with the PID added rather than
touching the committed source, so this diff is only the read loop.

Sending delete command to PID 0x0056...
Done. Recordings deleted.
  1.21 s

I do not have an Interview PRO, so that hardware is untested by me. The change
is device-agnostic, but the timing characteristics may differ.

Builds clean with -Wall -Wextra. The committed krode binary is untouched.

The device does not answer once. It streams progress reports,
02 4A 41 <percent>, stepping to 100 — byte [3] is a percentage, not a
status constant. The README's 'status code of 100' is the device saying
100 % complete.

Reading a single reply therefore prints 'Done. Recordings deleted.
(status: 0)' while the erase has not started. Observed on hardware:
the message appeared 2.3 s before the device had finished.

krode now reads until 100 %, showing progress on a terminal and staying
quiet when redirected so logs do not fill with percents.

Losing the device after progress has been reported is treated as a normal
ending rather than a failure: the transmitter drops off the bus as soon as
it is done. Losing it before any reply is still an error.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@zinic

zinic commented Sep 9, 2026

Copy link
Copy Markdown

Nice catch on this!

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.

2 participants