RFID PN532 I2C error

Hello,
i am using PN532 RFID reader and I2C communication. On arduinos like Uno, ProMini, Mega it is working just fine, but on Nano Every there is some error during compilation in PN532_I2C.cpp. I tried MegaCoreX and also megaavr but with no luck.

C:\Users\JHRA\Documents\Arduino\libraries\NDEF\PN532_I2C.cpp: In member function 'int8_t PN532_I2C::readAckFrame()':
C:\Users\JHRA\Documents\Arduino\libraries\NDEF\PN532_I2C.cpp:196:73: error: call of overloaded 'requestFrom(int, unsigned int)' is ambiguous
if (_wire->requestFrom(PN532_I2C_ADDRESS, sizeof(PN532_ACK) + 1)) {
^
In file included from C:\Users\JHRA\Documents\Arduino\libraries\NDEF\PN532_I2C.h:8:0,
from C:\Users\JHRA\Documents\Arduino\libraries\NDEF\PN532_I2C.cpp:5:
C:\Users\JHRA\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\libraries\Wire\src/Wire.h:61:12: note: candidate: virtual size_t TwoWire::requestFrom(uint8_t, size_t)
size_t requestFrom(uint8_t, size_t);
^~~~~~~~~~~
C:\Users\JHRA\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.7\libraries\Wire\src/Wire.h:63:12: note: candidate: size_t TwoWire::requestFrom(int, int)
size_t requestFrom(int, int);
^~~~~~~~~~~
exit status 1

Compilation error: exit status 1

Is there any way how to fix this.
Thank you.

It is a known problem. Someone had the same troubles a day ago: https://forum.arduino.cc/t/wire-h-signature-uint8-t-requestfrom-uint8-t-uint8-t-and-others-missing/1033081/.
Here is the Issue at Github: https://github.com/arduino/Arduino/issues/11820.

Meanwhile, you have to change the library and use normal integers for the parameters.
Do you use this library ? https://github.com/nurun/arduino_NFC
You could change the calls to Wire.requestFrom():

// Wire.requestFrom((uint8_t)PN532_I2C_ADDRESS, (uint8_t)(length+2));  // old
Wire.requestFrom((int)PN532_I2C_ADDRESS, (int)(length+2));  // new

A good standard starts with good agreements and good documentation of the standard. However, I get the feeling that the Arduino team does not know yet in which direction they want to go with the parameters.

I would not patch the PN Library, but the broken Wire.h code.

I am using this library https://github.com/elechouse/PN532/tree/PN532_HSU/PN532_I2C

Can you change the parameters to 'int' ?

Sorry, i exactly don't know what to change in this library of mine. I tried to change some things, but with no luck. It says that the problem is on row 196 in

if (_wire->requestFrom(PN532_I2C_ADDRESS, sizeof(PN532_ACK) + 1)) {

but if i tried to change

const uint8_t PN532_ACK[] = {0, 0, 0xFF, 0, 0xFF, 0};

to

const int PN532_ACK[] = {0, 0, 0xFF, 0, 0xFF, 0};

There is still

error: call of overloaded 'requestFrom(int, unsigned int)' is ambiguous

PN532_I2C.cpp (5.3 kB)

Ok so i changed

if (_wire->requestFrom(PN532_I2C_ADDRESS, (int)sizeof(PN532_ACK) + 1)) {

and now error is gone. We will see if this code will work with PN532 module :slight_smile:

Did you return PN532_ACK back to uint8_t ? It is only the call to Wire.requestFrom() that has a parameter type problem.

Sure, everything in the library is same as in original library except of

if (_wire->requestFrom(PN532_I2C_ADDRESS, (int)sizeof(PN532_ACK) + 1)) {

Thank you :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.