Python driver for NordicID UHF RFID readers wrapping NurApi
Project description
nurapi
Table of Contents
Installation
pip install nurapi
Usage
Connect to the reader
# Create driver
reader = NUR()
# Connect
reader.ConnectSerialPortEx(port_name='COM8')
# or reader.ConnectSerialPort(port_numer=8)
# or reader.SetUsbAutoConnect(True)
# Check connection status just by checking physical layer status
reader.IsConnected()
# Check connection status checking full transport layer
reader.Ping()
... use the reader ...
# Disconnect reader
reader.Disconnect()
Get basic information about the reader
## GET INFO
reader_info = reader.GetReaderInfo()
device_caps = reader.GetDeviceCaps()
Sample response values:
reader_info = NurReaderInfo(serial='K134500382', alt_serial='K134700326', name='STIX', fcc_id='', hw_version='PWM0022', sw_ver_major=5, sw_ver_minor=10, dev_build=65, num_gpio=0, num_sensors=0, num_regions=21, num_antennas=1, max_antennas=1)
device_caps = NurDeviceCaps(dwSize=40, flagSet1=15696847, flagSet2=0, maxTxdBm=27, txAttnStep=1, maxTxmW=500, txSteps=20, szTagBuffer=630, curCfgMaxAnt=1, curCfgMaxGPIO=0, chipVersion=2, moduleType=3, moduleConfigFlags=4, v2Level=1, secChipMajorVersion=0, secChipMinorVersion=0, secChipMaintenanceVersion=0, secChipReleaseVersion=0)
Configure the reader
## MODULE SETUP
module_setup = NurModuleSetup()
module_setup.link_freq = SETUP_LINK_FREQ.BLF_160
module_setup.rx_decoding = SETUP_RX_DEC.FM0
desired_tx_level_dbm = 25
module_setup.tx_level = ((device_caps.maxTxdBm - desired_tx_level_dbm) *
device_caps.txAttnStep)
module_setup.antenna_mask_ex = 0b00000001 # Antenna 1 (BIT0)
module_setup.selected_antenna = -1 # Automatic selection
reader.SetModuleSetup(
setup_flags=[
NUR_MODULESETUP_FLAGS.NUR_SETUP_LINKFREQ,
NUR_MODULESETUP_FLAGS.NUR_SETUP_RXDEC,
NUR_MODULESETUP_FLAGS.NUR_SETUP_TXLEVEL,
NUR_MODULESETUP_FLAGS.NUR_SETUP_ANTMASKEX,
NUR_MODULESETUP_FLAGS.NUR_SETUP_SELECTEDANT
],
module_setup=module_setup)
module_setup = reader.GetModuleSetup(
setup_flags=[
NUR_MODULESETUP_FLAGS.NUR_SETUP_LINKFREQ,
NUR_MODULESETUP_FLAGS.NUR_SETUP_RXDEC,
NUR_MODULESETUP_FLAGS.NUR_SETUP_TXLEVEL,
NUR_MODULESETUP_FLAGS.NUR_SETUP_ANTMASKEX,
NUR_MODULESETUP_FLAGS.NUR_SETUP_SELECTEDANT
])
Perform single synchronous inventory
# Trigger a simple inventory
inventory_response = reader.SimpleInventory()
if inventory_response.num_tags_mem > 0:
# Fetch read tags to tag buffer including metadata
tag_count = reader.FetchTags(include_meta=True)
# Get data of read tags
for idx in range(tag_count):
tag_data = reader.GetTagData(idx=idx)
# Clear tag buffer
reader.ClearTags()
Perform continuous asynchronous inventory
def my_callback(inventory_stream_data: NurInventoryStreamData):
global some_epc
# If stream stopped, restart
if inventory_stream_data.stopped:
reader.StartInventoryStream(rounds=10, q=0, session=0)
# Check number of tags read
tag_count = reader.GetTagCount()
# Get data of read tags
for idx in range(tag_count):
tag_data = reader.GetTagData(idx=idx)
some_epc = tag_data.epc
reader.ClearTags()
# Configure the callback
reader.set_notification_callback(notification_callback=my_callback)
# Start inventory stream
reader.StartInventoryStream(rounds=10, q=0, session=0)
# Do other stuff
time.sleep(1)
# Stop inventory stream
reader.StopInventoryStream()
Execute Read/Write operations
reader.WriteTagByEPC(
epc=bytes.fromhex('010203040506070809101112'),
secured=False,
passwd=0,
bank=NurBank.NUR_BANK_USER,
address=0,
byte_count=2,
data=bytearray([0x12, 0x34]))
data: bytearray = reader.ReadTagByEPC(
epc=bytes.fromhex('010203040506070809101112'),
secured=False,
passwd=0,
bank=NurBank.NUR_BANK_USER,
address=0,
byte_count=2)
License
nurapi
is distributed under the terms of the MIT license.
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 nurapi-1.5.2.tar.gz
.
File metadata
- Download URL: nurapi-1.5.2.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cef3f1edd5115f4ac4a24c108d509315b5a899df64b33c23a13e811bee9f30d1 |
|
MD5 | 8e3b15c09dff8b3029d8a9ccbd6d27ae |
|
BLAKE2b-256 | 3a0b0b63bf16c530dba3c5c1a76e0c0b75783828902a36a3a464f284ed6d45cd |
File details
Details for the file nurapi-1.5.2-py3-none-any.whl
.
File metadata
- Download URL: nurapi-1.5.2-py3-none-any.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4eba9ecad9c00370ddf918ee9eb96b7797089d72203bebaec7a75b9cb6c3c443 |
|
MD5 | 44660fc6a48fdce98e371430772d29cf |
|
BLAKE2b-256 | a16655fc04ab95c73da192800565aa7183afb6612de95fdce4d4da4902457a1a |