Skip to content

fix: strip I2C status byte from PN532 read transactions#45

Open
ashitaka1 wants to merge 2 commits intoZaparooProject:mainfrom
ashitaka1:pr/fix-i2c-ready-byte
Open

fix: strip I2C status byte from PN532 read transactions#45
ashitaka1 wants to merge 2 commits intoZaparooProject:mainfrom
ashitaka1:pr/fix-i2c-ready-byte

Conversation

@ashitaka1
Copy link

Summary

  • The PN532 prepends a status/ready byte (0x01) to every I2C read transaction (datasheet section 6.2.4). The transport did not account for this, so ACK frame comparison always failed and frame data was shifted by one byte.
  • Add readI2C() helper that reads n+1 bytes, verifies the status byte, and strips it before returning data to the caller.
  • Update MockI2CBus and JitteryMockI2CBus to prepend the status byte on multi-byte reads, matching real hardware behavior.

Note: This branch includes the I2C address fix from #44. Both fixes are needed for a functional I2C transport.

Testing

  • All 25 I2C unit tests pass (with race detector)
  • Confirmed on Raspberry Pi 5 with PN532 on /dev/i2c-1:
    • Init() succeeds (GetFirmwareVersion + SAMConfiguration)
    • Tag detection works: detected MIFARE tag via DetectTag()

Avery Rosen added 2 commits February 14, 2026 16:52
The PN532 datasheet documents 0x48/0x49 as 8-bit addresses (including
the R/W bit). periph.io and the Linux kernel expect 7-bit addresses,
so the correct value is 0x24 (0x48 >> 1).

Also add parseI2CPath() to handle composite detection paths
(/dev/i2c-1:0x24) that the detection layer produces, and a hardware
validation script for testing on Raspberry Pi.
The PN532 prepends a status/ready byte (0x01) to every I2C read
transaction (datasheet section 6.2.4). The transport did not account
for this, causing ACK frame comparison to always fail and frame data
to be shifted by one byte.

Add readI2C() helper that reads n+1 bytes, verifies the status byte,
and copies the data bytes into the caller's buffer. Update MockI2CBus
and JitteryMockI2CBus to prepend the status byte, matching real
hardware behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant