fix(hf,hw): fire-and-forget dropfield, full HF_SNIFF struct, standalone payload
dropfield waited on a reply the firmware never sends (bare hf_field_off();break;) -> 2s stall + raise; use send_ng_no_response. hf.sniff under-sent the 10-byte {u32,u32,u8,u8} struct and mis-parsed the uint16 reply. hw.standalone sent an empty payload for a {arg,mlen,mode[10]} struct and blocked; pack it + fire-and-forget. Pre-existing, independent of rebase.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,3 +16,29 @@ def test_hf_tune():
|
||||
# Firmware requires the START(1)/MEASURE(2)/STOP(3) mode-byte sequence
|
||||
modes = [call.args[1] for call in t.send_ng.call_args_list]
|
||||
assert modes == [bytes([1]), bytes([2]), bytes([3])]
|
||||
|
||||
|
||||
def test_hf_dropfield():
|
||||
t = AsyncMock()
|
||||
hf = HFCommands(t)
|
||||
result = asyncio.get_event_loop().run_until_complete(hf.dropfield())
|
||||
assert result["status"] == 0
|
||||
# Firmware CMD_HF_DROPFIELD sends no reply -> must be fire-and-forget
|
||||
t.send_ng_no_response.assert_awaited_once()
|
||||
assert t.send_ng_no_response.call_args.args[0] == Cmd.HF_DROPFIELD
|
||||
t.send_ng.assert_not_called()
|
||||
|
||||
|
||||
def test_hf_sniff():
|
||||
t = AsyncMock()
|
||||
hf = HFCommands(t)
|
||||
# Firmware replies with a uint16 sample count (1234 = 0x04D2)
|
||||
t.send_ng.return_value = PM3Response(cmd=Cmd.HF_SNIFF, status=0,
|
||||
reason=0, ng=True, data=b"\xd2\x04")
|
||||
result = asyncio.get_event_loop().run_until_complete(
|
||||
hf.sniff(samples_to_skip=5, triggers_to_skip=6, skip_mode=1, skip_ratio=2))
|
||||
assert result["samples"] == 1234
|
||||
assert result["status"] == 0
|
||||
# Always sends the full 10-byte PACKED {u32 u32 u8 u8} struct
|
||||
payload = t.send_ng.call_args.args[1]
|
||||
assert payload == b"\x05\x00\x00\x00\x06\x00\x00\x00\x01\x02"
|
||||
|
||||
Reference in New Issue
Block a user