RFID reader control library
Project description
sllurp is a Python library to interface with RFID readers. It is a pure-Python implementation of the Low Level Reader Protocol (LLRP).
These readers are known to work well with sllurp, but it should be adaptable with not much effort to other LLRP-compatible readers:
Impinj Speedway (R1000)
Impinj Speedway Revolution (R220, R420)
Impinj Speedway xPortal
Motorola MC9190-Z (handheld)
File an issue on GitHub if you would like help getting another kind of reader to work.
sllurp is distributed under version 3 of the GNU General Public License. See LICENSE.txt for details.
Quick Start
Install from PyPI:
$ virtualenv .venv $ source .venv/bin/activate $ pip install sllurp $ sllurp inventory ip.add.re.ss
Run sllurp --help and sllurp inventory --help to see options.
Or install from GitHub:
$ git clone https://github.com/ransford/sllurp.git $ cd sllurp $ virtualenv .venv $ source .venv/bin/activate $ pip install . $ sllurp inventory ip.add.re.ss
If the reader gets into a funny state because you’re debugging against it (e.g., if your program or sllurp has crashed), you can set it back to an idle state by running sllurp reset ip.add.re.ss.
Reader API
sllurp spawn his own “thread” to manage network interaction with the reader. To make a connection, create a LLRPReaderClient and connect() it:
# Minimal example; see sllurp/verb/inventory.py for more.
from sllurp import llrp
from sllurp.llrp import LLRPReaderConfig, LLRPReaderClient, LLRP_DEFAULT_PORT
import logging
logging.getLogger().setLevel(logging.INFO)
def tag_report_cb (reader, tag_reports):
for tag in tag_reports:
print('tag: %r' % tag)
config = LLRPReaderConfig()
reader = LLRPReaderClient(host, LLRP_DEFAULT_PORT, config)
reader.add_tag_report_callback(tag_report_cb)
reader.connect()
# We are now connected to the reader and inventory is running.
try:
# Block forever or until a disconnection of the reader
reader.join(None)
except (KeyboardInterrupt, SystemExit):
# catch ctrl-C and stop inventory before disconnecting
reader.disconnect()
Getting More Information From Tag Reports
When initializing LLRPReaderConfig, set flags in the tag_content_selector dictionary argument:
llrp.LLRPReaderConfig({
'tag_content_selector': {
'EnableROSpecID': False,
'EnableSpecIndex': False,
'EnableInventoryParameterSpecID': False,
'EnableAntennaID': True,
'EnableChannelIndex': False,
'EnablePeakRSSI': True,
'EnableFirstSeenTimestamp': False,
'EnableLastSeenTimestamp': True,
'EnableTagSeenCount': True,
'EnableAccessSpecID': False,
}
})
Logging
sllurp logs under the name sllurp, so if you wish to log its output, you can do this the application that imports sllurp:
sllurp_logger = logging.getLogger('sllurp')
sllurp_logger.setLevel(logging.DEBUG)
sllurp_logger.setHandler(logging.FileHandler('sllurp.log'))
# or .setHandler(logging.StreamHandler()) to log to stderr...
Vendor Extensions
sllurp has limited support for vendor extensions through LLRP’s custom message facilities. For example, sllurp inventory –impinj-search-mode N allows you to set the Impinj search mode to single target (1) or dual target (2).
Handy Reader Commands
To see what inventory settings an Impinj reader is currently using (i.e., to fetch the current ROSpec), ssh to the reader and
> show rfid llrp rospec 0
The “nuclear option” for resetting a reader is:
> reboot
If You Find a Bug
Start an issue on GitHub! Please follow Simon Tatham’s guide on writing good bug reports.
Bug reports are most useful when they’re accompanied by verbose error messages. Turn sllurp’s log level up to DEBUG, which you can do by specifying the -d command-line option to sllurp. You can log to a logfile with the -l [filename] option. Or simply put this at the beginning of your own code:
import logging
logging.getLogger('sllurp').setLevel(logging.DEBUG)
Known Issues
Reader mode selection is confusing, not least because most readers seem to conflate ModeIndex and ModeIdentifier. If you’re using sllurp inventory, use --mode-identifier N. Check your reader’s manual to see what mode identifiers it supports via the C1G2RFControl parameter, or run sllurp --debug inventory against a reader to see a dump of the supported modes in the capabilities description.
Contributing
Want to contribute? Here are some areas that need improvement:
Encode more protocol messages in the construct branch.
Write tests for common encoding and decoding tasks.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sllurp-2.0.1.tar.gz
.
File metadata
- Download URL: sllurp-2.0.1.tar.gz
- Upload date:
- Size: 66.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e12ac7963914eccd5af16307b05ec3249a2f2c7adb1d0981d9f1271f64eb4bb4 |
|
MD5 | b2f81654be77491820db336b86ef287f |
|
BLAKE2b-256 | 281e4ff1dc6edde35703828a6442bd11a68009f6c310df22a9a02e8ee3264941 |
File details
Details for the file sllurp-2.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: sllurp-2.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 75.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.18 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f493f1a4a21dd72419b50fdc027bd39261ae286de1edcc73e385833d566584ff |
|
MD5 | cfe31c0738e7ca1652c7ed7d56dd21be |
|
BLAKE2b-256 | dd32597ff7341ce847bf2c91ff1cb038c274baa55f0aca593ba01e56d469d5d5 |