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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user