Skip to main content

Crate tag_attach_cycle

Crate tag_attach_cycle 

Source
Expand description

tag-attach-cycle: repeatedly attach to and detach from a tag.

Port of host/commandline/tag-attach-cycle.cc. Each cycle attaches (which resets the tag), optionally reads and prints its status, stays attached for --on-ms, detaches, and stays away for --off-ms. With --cycles 0 it runs until Ctrl-C, which ends the run between steps rather than killing the process.

Exits 0 when the cycles complete or Ctrl-C stops them; 1 if an attach fails.

Usage: tag-attach-cycle [-d] [-b BUS:DEVICE] [--on-ms MS] [--off-ms MS] [--cycles N] [--no-status]; both intervals default to 5000 ms.

This is a test of the attach path itself, one of the two legitimate reasons to attach to a running tag: every cycle resets the tag and ends whatever it was doing, so it says nothing about how a run behaves unattended. A status read that fails is reported on stderr and the cycle continues.

Β§Hardware side effects

One target reset per cycle. A tag past its start time is restarted by each reset.

StructsΒ§

Cli πŸ”’
repeatedly attach and detach from a running tag

StaticsΒ§

STOP_REQUESTED πŸ”’
Set by Ctrl-C to end the cycling.

FunctionsΒ§

interruptible_sleep πŸ”’
Sleeps for ms, in steps of at most 100 ms, returning early on Ctrl-C.
main πŸ”’
Installs the Ctrl-C handler, then runs the attach/detach cycles.
print_status πŸ”’
Prints the tag’s state, clock (ms since the Unix epoch) and internal and external flash page counts for cycle, and any firmware debug message on stderr.