Skip to main content

Crate tag_reset

Crate tag_reset 

Source
Expand description

tag-reset: stop, erase, and return a tag to the idle state.

Port of host/commandline/tag-reset.cc. Waits for the tag to report a definite state after the attach reset, stops it if it is RUNNING, HIBERNATING or CONFIGURED and polls until it is FINISHED or ABORTED, erases it and polls until the erase reaches IDLE, and optionally syncs its clock (--set-rtc).

Exits 0 with the tag IDLE; 1 if the attach, a status read, the stop, the erase or the clock sync fails, the tag never settles, does not stop within --stop-timeout or reach IDLE within --reset-timeout, or is in a state it cannot be reset from (TEST, CALIBRATE, EXCEPTION).

Usage: tag-reset [-d] [-b BUS:DEVICE] [--set-rtc] [--reset-timeout S] [--stop-timeout S] [--settle-timeout S] (defaults 180, 30 and 10 s). Option errors exit 2 (clap).

§Hardware side effects

Destructive: the attach resets the tag, the stop ends any run, and the erase discards every stored sample and the state-transition log. The erase is done by the firmware already on the tag, which knows its own log layout, so run this before flashing a new image (step 2 of the flashing protocol in AGENTS.md). An IDLE tag is left as it is, apart from --set-rtc, which overwrites its clock with the host’s. Status reads that fail while the erase is in progress are skipped, not fatal, since the firmware may be busy sweeping storage.

Structs§

Cli 🔒
stop, erase, and return a tag to the idle state

Functions§

fail 🔒
Prints message to stderr and returns exit status 1.
main 🔒
Attaches, settles, stops an acquiring tag, erases a stopped one, checks it ended IDLE and optionally sets its clock.
report_debug 🔒
Prints the firmware’s debug message, if any, to stderr as is.
settle 🔒
Polls status a second apart until the tag reports a state other than STATE_UNSPECIFIED, which it can legitimately report while booting after the attach reset. A failed read is fatal: a tag that never answered must not be mistaken for one that is already idle.