Topic: PN532 and UART desync

Hello everyone,
I'm having an issue with my brand new breakout board (adafruit v.1.3) using UART bus.

After compiling the libnfc with the pn532_uart driver, I sometimes get a timeout error (exactly once on 2 tries) : http://pastebin.com/JD1jV5e9

As adafruit suggested, it really looks like a desync. But I really don't know how to fix it. UART bus is only 2 wires, so how can I re-sync it ?

Thanks
Alex

Re: PN532 and UART desync

Hi,

Your timeouts seems to be normal, what's the problem ? what do you expect that happend ?

Romuald Conty

Re: PN532 and UART desync

Hi Rconty,
I don't understand what is normal. If you look at my pastebin, you'll see :
- a first launch of nfc-list : timeout, it detects no reader
- a second launch of nfc-list that works fine

If it's normal, could you explain why?

Thanks for your help

Alex

Re: PN532 and UART desync

Sorry, I did not see the first non-detection.

I don't know why it timeouts. Theorically, at reset (plug-time) PN532 is in special low power mode, so we have to send a special awake frame (55 55 00 00 00) then a special command to set power-on (SAMConfiguration: 00  00  ff  03  fd  d4  14  01  17  00).

If you run it 3 or 4 times, there only problem on the first launch, right ?

You could try to raise up the SAMConfiguration timeout in libnfc/drivers/pn532_uart.c (line 304), timeout is currently 1000 (in ms).

That's strange since I don't have the problem with my PN532 UART board... BTW, feel free to give us some feedback smile

Romuald Conty

Re: PN532 and UART desync

Well, no. It's exactly working once on two tries, no matter how many times I launched the nfc-list command.

I'll have a look on SAMConfiguration in pn532_uart.c, but if you have the same board, it should work fine too...
Is there an eeprom where the pn532 store "settings"? In this case, is it possible to erase it?

Thanks for your help
Alex

Re: PN532 and UART desync

Hi Romuald,
Raised up the timeout to 3000 and got the same result.

Could you tell me what version of the lib you are using ? My next try will be on an ubuntu live cd, to be sure my OS is not the cause of this issue...

Thanks for your help
Alex

Re: PN532 and UART desync

Hi Romuald,
I made another test on a different computer, with a fresh installed Ubuntu and I got the same result :

ubuntu@ubuntu:~/Documents/libnfc-1.5.1$ utils/nfc-list
/home/ubuntu/Documents/libnfc-1.5.1/utils/.libs/lt-nfc-list uses libnfc 1.5.1 (r1175)
pn53x_check_communication: Operation timed-out
pn53x_check_communication: Operation timed-out
No NFC device found.

ubuntu@ubuntu:~/Documents/libnfc-1.5.1$ utils/nfc-list
/home/ubuntu/Documents/libnfc-1.5.1/utils/.libs/lt-nfc-list uses libnfc 1.5.1 (r1175)
pn53x_check_communication: Operation timed-out
Connected to NFC device: PN532 (/dev/ttyUSB0) - PN532 v1.6 (0x07)
1 ISO14443A passive target(s) found:
   ATQA (SENS_RES): 00  04
      UID (NFCID1): 4a  3a  39  f1
     SAK (SEL_RES): 08

I'm getting 2 "timeouts" because a USB key is connected to the computer at the same time.
I really don't understand. My last guest is that the chip is malfunctioning. What do you think?

Thanks for your help

Alex

Re: PN532 and UART desync

Hi,

Unfortunately, I have no idea what happend.

Please give some details if you found something.

Thanks.

Romuald Conty

Re: PN532 and UART desync

Hi K4ngoo,

I am having the exact same issue as you describe. The first time I run nfc-poll I get a uart timeout, but the second time is successful. Then the third time I get another timeout, but the fourth time is successful. Etc. Etc.

Did you manage to find a solution to the problem?


Thanks,

Lachlan.

K4ngoo wrote:

Hi Romuald,
I made another test on a different computer, with a fresh installed Ubuntu and I got the same result :

ubuntu@ubuntu:~/Documents/libnfc-1.5.1$ utils/nfc-list
/home/ubuntu/Documents/libnfc-1.5.1/utils/.libs/lt-nfc-list uses libnfc 1.5.1 (r1175)
pn53x_check_communication: Operation timed-out
pn53x_check_communication: Operation timed-out
No NFC device found.

ubuntu@ubuntu:~/Documents/libnfc-1.5.1$ utils/nfc-list
/home/ubuntu/Documents/libnfc-1.5.1/utils/.libs/lt-nfc-list uses libnfc 1.5.1 (r1175)
pn53x_check_communication: Operation timed-out
Connected to NFC device: PN532 (/dev/ttyUSB0) - PN532 v1.6 (0x07)
1 ISO14443A passive target(s) found:
   ATQA (SENS_RES): 00  04
      UID (NFCID1): 4a  3a  39  f1
     SAK (SEL_RES): 08

I'm getting 2 "timeouts" because a USB key is connected to the computer at the same time.
I really don't understand. My last guest is that the chip is malfunctioning. What do you think?

Thanks for your help

Alex

Re: PN532 and UART desync

I have found a solution to my problem, or is it a cause?

As I mentioned earlier I am using an Adafruit PN532 breakout board. I was connecting this to a FTDI USB-to-TTL converter.

I dumped the FTDI converter and tried a Prolific PL2303 USB-to-RS232 converter with a separate RS232-to-TTL level converter, and all the problems disappeared, despite the messy setup.

The new setup works perfectly every single time. No failures, no errors. Finally!

Unfortunately the solution is a very long way from satisfactory in general. The FTDI chips allow direct conversion from USB to TTL serial levels, whereas the PL2303 requires a second, separate level converter to talk to the Adafruit breakout board.

But at least someone who knows more than me might know where to look to attempt to solve this problem. I might try changing the FTDI driver (if I can figure out how) and see if that makes any difference.


Thanks,
Lachlan.