Adafruit-PN532 icon indicating copy to clipboard operation
Adafruit-PN532 copied to clipboard

Increasing the answer/command buffer size

Open salmg opened this issue 5 years ago • 5 comments

Noticed that the buffer used for PN532 communication is limited by 64 bytes:

#define PN532_PACKBUFFSIZ 64

  • The C-APDU command length can be up to 261 bytes (CLA-INS-P1-P2-P3-255 data bytes-Le)
  • The R-APDU returned to the host controller can have a length of 258 bytes (256 data bytes-SW1-SW2)

By design, the library uses just one buffer for commands and answers with fixed size(PN532_PACKBUFFSIZ) but a very low one.

Using only 64 bytes from the PN532 buffer is almost four times less its limit. This limitation affects directly the ISO/14443A or raw communication projects.

Making some tests, I noticed that the actual library design could be implemented with a buffer size of 255 without changing anything else:

#define PN532_PACKBUFFSIZ 255

salmg avatar Apr 07 '20 04:04 salmg

can you confirm/deny that sending a large apdu (say 80 bytes) is possible? In my setup ( https://github.com/adafruit/Adafruit-PN532/issues/73 ) increasing the command buffer for receiving apdus works fine (large apdu replies are received ok), but sending large apdus fails.

asdfjkl avatar Oct 20 '20 11:10 asdfjkl

I have to mentioned that I tested that buffer size using only the SPI configuration.

salmg avatar Oct 26 '20 02:10 salmg

Looks similar to #38

caternuson avatar Feb 20 '23 20:02 caternuson

can you confirm/deny that sending a large apdu (say 80 bytes) is possible? In my setup ( #73 ) increasing the command buffer for receiving apdus works fine (large apdu replies are received ok), but sending large apdus fails.

see the manual reference in https://github.com/adafruit/Adafruit-PN532/issues/124 which is unambiguous

mhaberler avatar Dec 09 '23 20:12 mhaberler