Examples¶
Nine runnable scripts live in the
examples/
folder. Each one takes the serial port as an optional argument (default
/dev/ttyUSB0) and uses the factory-default key FFFFFFFFFFFF:
Use a spare card
Examples 04–07 and 09 write to the card. They never touch sector trailers, but they will overwrite data blocks.
-
01 — Basic card UID
Reads the UID three ways and prints the reader's firmware version.
ping()·get_version()·get_uid()·get_uid_int()·scan_tag() -
02 — Event mode
Turns on auto mode and waits for the reader to announce a card.
wait_for_card() -
03 — Async wait
Waits for a card without blocking an asyncio event loop. This is the pattern for FastAPI and other async services.
wait_for_card_async() -
04 — Read & write a block
Runs the full authenticate → read → write → verify cycle on one 16-byte block.
authenticate_sector()·read_block()·write_block() -
05 — Sector operations
Reads and writes all three data blocks of a sector in one call.
read_sector()·write_sector() -
06 — Multi-sector bulk I/O
Reads and writes blocks across several sectors, each with its own key.
read_blocks()·write_blocks()·SectorAuth -
07 — Value blocks
Creates a stored-value counter, then increments, decrements, transfers and restores it.
create_value_block()·increment_value()·decrement_value()·transfer()·restore() -
08 — Multi-card enumeration
Lists every card on the reader using HALT and REQUEST ALL.
get_uid()·halt()·request_all() -
09 — RF power cycling
Recovers a stuck card by switching the RF field off and on, inside a retry loop.
rf_power()·authenticate_sector()·read_block()