Closed joshwapohlmann closed 1 year ago
So, I commited this issue because I just found the solution. The manual states there are 2 ways to abort an operation (and to get back to a clean state).
This solved my issue AND another issue I had reading out an NTAG213.
How?
I simply added a sendAck()
function and execute it manually:
nfc.init()
nfc.ntag2xx_ReadPage(...);
For completeness, here the code snippet I added to the library
/**************************************************************************/
/*!
@brief Sends an ACK to the PN532 causing it to abort the current operation and wait for a new command
*/
/**************************************************************************/
bool Adafruit_PN532::sendAck() {
uint8_t cmd = PN532_SPI_DATAWRITE;
spi_dev->write(pn532ack, 6, &cmd, 1);
return true;
}
A pull request will follow
@joshwapohlmann thanks for providing this solution :) I would like to add it to my fork but if you would submit the mentioned PR I could use that and give you credit that way :)
I added it to play around with it but if I use it before nfc.ntag2xx_ReadPage(...); my PN532 hangs. Maybe you need to provide more details?
Next time I play with it I will make some tests and also check in my exact changes I'm using right now.
Closing. Looks resolved.
Using ESP32 dev kit, Platformio, library version 1.2.2
During initialization I receive the following sequence instead of an ACK
0x0 0x3F 0xDF 0xFF 0xE9 0xAF
The code executed so far is
With
build_flags = -DPN532DEBUG
the serial monitor showsI checked the PN532 user manual. Normally, whatever state it is in, it should abort ANY prior command when receiving a new command (page 38). This is clearly the case (i also checked with a logic analyzer) when retrieving the firmware version.
After this, the code correctly waits for the IC to be ready
where it reads the status register until it is
RDY
.After this,
bool Adafruit_PN532::readack()
is called. In the manual on page 45 the procedure is explained.The code follow this exactly
According to the manual, even in case of a syntax error, it will respond with an ACK. This means, the received data is the response to a prior command. Therefore an ACK was missed. It is unclear how and where it happens.