fix(14a): raw() returns whole firmware buffer instead of received bytes

hf.iso14a.raw() returned the entire receive buffer the firmware replies
with (sizeof(buf)), so a tag that didn't answer came back as a run of
zeros (~40 bytes) rather than empty. The firmware puts the real received
length in oldarg[0]; trim resp.data to it. No response -> empty (raw=b"",
data=None); adds a `received` count. 2 regression tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
michael
2026-07-14 13:22:39 -07:00
parent 2f9e825bd4
commit 7b5af3f9d2
2 changed files with 33 additions and 2 deletions

View File

@@ -63,10 +63,16 @@ class HF14ACommands:
payload=data,
timeout=5.0,
)
# The firmware replies with its whole receive buffer; oldarg[0] is the number of bytes
# actually received (0 = the tag didn't answer). Trim to it so a no-response is empty,
# not a buffer of zeros.
received = resp.oldarg[0] if resp.oldarg else 0
payload = resp.data[:received] if resp.data else b""
return {
"status": resp.status,
"data": resp.data.hex() if resp.data else None,
"raw": resp.data,
"received": received,
"data": payload.hex() if payload else None,
"raw": payload,
}
async def sniff(self, param: int = 0) -> dict: