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:
michael
2026-07-05 00:08:40 -07:00
parent 625104ea03
commit 3d4634a406
4 changed files with 79 additions and 11 deletions

View File

@@ -99,3 +99,17 @@ def test_led_pwm_non_capable_raises():
with pytest.raises(PM3Error, match="do not support"):
asyncio.get_event_loop().run_until_complete(
hw.led("blue", brightness=50)) # blue=D, not PWM on Easy
def test_standalone():
transport = make_mock_transport()
hw = HWCommands(transport)
result = asyncio.get_event_loop().run_until_complete(hw.standalone(arg=3, mode="14a"))
assert result["status"] == 0
# Firmware RunMod() never replies -> fire-and-forget
transport.send_ng_no_response.assert_awaited_once()
cmd, payload = transport.send_ng_no_response.call_args.args
assert cmd == Cmd.STANDALONE
# PACKED {uint8 arg; uint8 mlen; uint8 mode[10]} = 12 bytes
assert payload == struct.pack("<BB", 3, 3) + b"14a" + bytes(7)
transport.send_ng.assert_not_called()