feat(pm3py): LF commands (tune, read, sniff, sim, config, search, t55xx)

This commit is contained in:
michael
2026-03-15 22:15:51 -07:00
parent 10761b1d5f
commit 95133843a4
3 changed files with 209 additions and 0 deletions

27
tests/test_lf.py Normal file
View File

@@ -0,0 +1,27 @@
import struct
import asyncio
from unittest.mock import AsyncMock
from pm3py.protocol import Cmd
from pm3py.transport import PM3Response
from pm3py.lf import LFCommands
def make_response(cmd, status, data):
return PM3Response(cmd=cmd, status=status, reason=0, ng=True, data=data)
def test_lf_tune():
t = AsyncMock()
lf = LFCommands(t)
# First call: init, second call: poll returns data
t.send_ng.return_value = make_response(Cmd.MEASURE_ANTENNA_TUNING_LF, 0,
struct.pack("<I", 42000))
result = asyncio.get_event_loop().run_until_complete(lf.tune(divisor=95))
assert "voltage_mV" in result
def test_lf_config_get():
t = AsyncMock()
lf = LFCommands(t)
payload = struct.pack("<bbbhhib", 1, 8, 1, 95, 128, 0, 0)
t.send_ng.return_value = make_response(Cmd.LF_SAMPLING_GET_CONFIG, 0, payload)
result = asyncio.get_event_loop().run_until_complete(lf.config())
assert "decimation" in result
assert "bits_per_sample" in result