rfid
Classes
|
Handles RFID reader communication via serial port. |
- class Rfid(port='/dev/ttyAMA0', baudrate=9600)[source]
Bases:
objectHandles RFID reader communication via serial port.
- port
Serial port path.
- Type:
str
- baudrate
Serial baudrate.
- Type:
int
- multiple
Whether multiple tags where detected recently-ish.
- Type:
bool
- time_detections
Time window in seconds to check for duplicate IDs.
- Type:
float
- id
The most recently read RFID tag ID.
- Type:
str
- id_history
History of read IDs and timestamps.
- Type:
Deque[tuple[str, datetime]]
- reading
Flag to control reading loop (not used in loop, running is used).
- Type:
bool
- s
The serial connection.
- Type:
serial.Serial
- thread
Background thread for reading serial data.
- Type:
threading.Thread
- running
Flag to control the background thread.
- Type:
bool
- read_serial() None[source]
Reads data from the serial port in a background loop.
- clean_old_ids() None[source]
Removes IDs from history that are older than time_detections.
- update_multiple() None[source]
Updates the multiple flag if more than one unique ID is in history.
- stop() None[source]
Stops the serial reading thread.
- get_id() tuple[str, bool][source]
Retrieves the current RFID tag ID and multiple status.
- Returns:
- A tuple containing the ID (str) and whether multiple tags were detected (bool).
Returns (“”, False) if reading is disabled.
- Return type:
tuple[str, bool]