Big transponder support update
This commit is contained in:
53
tests/test_sim_rf430frl.py
Normal file
53
tests/test_sim_rf430frl.py
Normal file
@@ -0,0 +1,53 @@
|
||||
"""Tests for the TI RF430FRL15xH ISO 15693 sensor transponder (identity + base)."""
|
||||
import asyncio
|
||||
import pytest
|
||||
|
||||
from pm3py.sim.frame import RFFrame
|
||||
from pm3py.transponders.hf.iso15693.ti.rf430frl import (
|
||||
RF430FRL152H, RF430FRL153H, RF430FRL154H,
|
||||
)
|
||||
|
||||
|
||||
def run(coro):
|
||||
return asyncio.new_event_loop().run_until_complete(coro)
|
||||
|
||||
|
||||
def cmd(tag, payload: bytes):
|
||||
return run(tag.handle_frame(RFFrame.from_bytes(payload)))
|
||||
|
||||
|
||||
class TestIdentity:
|
||||
@pytest.mark.parametrize("cls,dev_id", [
|
||||
(RF430FRL152H, b"\xE7\x81"),
|
||||
(RF430FRL153H, b"\xFB\x81"),
|
||||
(RF430FRL154H, b"\xFC\x81"),
|
||||
])
|
||||
def test_device_id_and_uid_prefix(self, cls, dev_id):
|
||||
tag = cls()
|
||||
assert tag.device_id == dev_id
|
||||
assert tag._uid[0:3] == b"\xE0\x07\xA2" # E0 + TI mfg 07 + UID5
|
||||
|
||||
def test_ti_manufacturer_code(self):
|
||||
assert RF430FRL152H()._uid[1] == 0x07
|
||||
|
||||
|
||||
class TestIso15693:
|
||||
def test_inventory(self):
|
||||
tag = RF430FRL152H()
|
||||
run(tag.power_on())
|
||||
r = cmd(tag, bytes([0x26, 0x01, 0x00]))
|
||||
assert r.data[0] == 0x00
|
||||
assert bytes(reversed(r.data[2:10])) == tag._uid
|
||||
|
||||
def test_read_write_block(self):
|
||||
tag = RF430FRL152H()
|
||||
run(tag.power_on())
|
||||
cmd(tag, bytes([0x02, 0x21, 0x04, 0xAA, 0xBB, 0xCC, 0xDD]))
|
||||
assert cmd(tag, bytes([0x02, 0x20, 0x04])).data[1:5] == b"\xAA\xBB\xCC\xDD"
|
||||
|
||||
def test_get_system_info(self):
|
||||
tag = RF430FRL152H()
|
||||
run(tag.power_on())
|
||||
r = cmd(tag, bytes([0x02, 0x2B]))
|
||||
assert r.data[1] == 0x0F
|
||||
assert bytes(reversed(r.data[2:10])) == tag._uid
|
||||
Reference in New Issue
Block a user