Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to PN532 via USB=>UART converter #479

Open
cpeppler01 opened this issue Mar 18, 2018 · 7 comments
Open

Unable to connect to PN532 via USB=>UART converter #479

cpeppler01 opened this issue Mar 18, 2018 · 7 comments

Comments

@cpeppler01
Copy link

cpeppler01 commented Mar 18, 2018

I have purchased an Adafruit PN532 board (https://www.adafruit.com/product/364).
I have no problem connecting via libnfc using the internal UART /dev/ttys0. Works great.

I would like to use this board without using GPIO pins (conflict with another application
that needs the pins).

I then purchased a USB=> UART converter (https://www.adafruit.com/product/954).
I tested the converter using Rpi/minicom connected to a PC, and it works fine. I can see characters going back and forth, no problem.

I can see the converter from the Rpi:
lsusb
[...]
Bus 001 Device 005: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
[...]
I can see it in dmesg
[...]
[78053.972607] usb 1-1.2: cp210x converter now attached to ttyUSB0
[...]
pi@raspi:/etc/nfc/devices.d $ ls -l /dev/tty[ASU]* /dev/serial?
lrwxrwxrwx 1 root root 5 Mar 17 17:59 /dev/serial0 -> ttyS0
lrwxrwxrwx 1 root root 7 Mar 17 17:59 /dev/serial1 -> ttyAMA0
crw-rw---- 1 root dialout 204, 64 Mar 17 17:59 /dev/ttyAMA0
crw-rw---- 1 root dialout 4, 64 Mar 18 16:35 /dev/ttyS0
crw-rw---- 1 root dialout 188, 0 Mar 18 15:44 /dev/ttyUSB0

pi@raspi:/etc/nfc/devices.d $ ls
device1.conf device2.conf
pi@raspi:/etc/nfc/devices.d $ cat device1.conf
name = "Capnetix Adafruit - ttyS0"
connstring = "pn532_uart:/dev/ttyS0"
allow_intrusive_scan = true
optional = true
pi@raspi:/etc/nfc/devices.d $ cat device2.conf
name = "Capnetix Adafruit - ttyUSB0"
connstring = "pn532_uart:/dev/ttyUSB0"
#connstring = "pn53x_usb:/dev/ttyUSB0"
allow_intrusive_scan = true
optional = true

The internal UART works great.
I've tried everything to get libnfc to talk to the board through this USB=>UART bridge. It just will not recognize it.

Any help or guidance would be appreciated.

Environment: Raspberry Pi 3, Model B, Hardware BCM2835, Revision a02082

@cpeppler01
Copy link
Author

After much digging, I discovered the libnfc/contrib/libnfc/pn532_uart_on_rpi_3.conf.sample, and saw the lack of double quotes around the connstring value. I removed the double quotes on my system, and got this trace:
pi@raspi:/dev/libnfc/utils $ nfc-scan-device
nfc-scan-device uses libnfc libnfc-1.7.1-191-g216145f
1 NFC device(s) found:
Capnetix Adafruit - ttyUSB0:
pn532_uart:/dev/ttyUSB0
pi@raspi:/dev/libnfc/utils $ nfc-list
nfc-list uses libnfc libnfc-1.7.1-191-g216145f
nfc_initiator_init: Timeout
pi@raspi:~/dev/libnfc/utils $ nfc-scan-device
nfc-scan-device uses libnfc libnfc-1.7.1-191-g216145f
No NFC device found.

Now I have a new problem. libnfc finds the board on the initial probe, but on second and subsequent probes...nothing.. Timeouts, and eventually, no response.

is there some type of specific configuration required on the USB => UART /dev/ttyUSB0 required? Baud rates, or something?

stty -F /dev/ttyUSB0 -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^; erase = ^?; kill = ^U; eof = ^D; eol = ;
eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 0; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt
-echoctl -echoke

Here is /dev/TTYS0:
stty -F /dev/ttyS0 -a
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^; erase = ^?; kill = ^U; eof = ^D; eol = ;
eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

@alfem
Copy link

alfem commented Jul 23, 2018

I also have got those timeout errors and my Ubuntu 16.04 does not detect the board.

I am testing a nfc cheap pn532 board thru "Cygnal Integrated Products, Inc. CP210x UART Bridge".

@alfem
Copy link

alfem commented Jul 24, 2018

After deleting the libnfc ubuntu package and compiled the master branch, I get the same results:

debug libnfc.config key: [device.name], value: [Adafruit PN532 board via UART]
debug libnfc.config key: [device.connstring], value: [pn532_uart:/dev/ttyUSB0]
debug libnfc.config Unable to open directory: /etc/nfc/devices.d
debug libnfc.general log_level is set to 3
debug libnfc.general allow_autoscan is set to true
debug libnfc.general allow_intrusive_scan is set to true
debug libnfc.general 1 device(s) defined by user
debug libnfc.general #0 name: "Adafruit PN532 board via UART", connstring: "pn532_uart:/dev/ttyUSB0"
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyUSB0 at 115200 baud.
debug libnfc.bus.uart Serial port speed requested to be set to 115200 baud.
debug libnfc.chip.pn53x Diagnose
debug libnfc.chip.pn53x Timeout value: 500
debug libnfc.bus.uart TX: 55 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00
debug libnfc.chip.pn53x SAMConfiguration
debug libnfc.chip.pn53x Timeout value: 1000
debug libnfc.bus.uart TX: 00 00 ff 03 fd d4 14 01 17 00
debug libnfc.bus.uart Timeout!
debug libnfc.driver.pn532_uart Unable to read ACK
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS31 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS30 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS29 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS28 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS27 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS26 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS25 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS24 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS23 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS22 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS21 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS20 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS19 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS18 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS17 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS16 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS15 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS14 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS13 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS12 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS11 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS10 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS9 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS8 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS7 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS6 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS5 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS4 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS3 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS2 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS1 at 115200 baud.
debug libnfc.driver.pn532_uart Trying to find PN532 device on serial port: /dev/ttyS0 at 115200 baud.
debug libnfc.general 0 device(s) found using pn532_uart driver
debug libnfc.general 0 device(s) found using pn53x_usb driver
debug libnfc.driver.pn532_uart Attempt to open: /dev/ttyUSB0 at 115200 baud.
debug libnfc.bus.uart Serial port speed requested to be set to 115200 baud.
debug libnfc.chip.pn53x Diagnose
debug libnfc.chip.pn53x Timeout value: 500
debug libnfc.bus.uart TX: 55 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00
debug libnfc.chip.pn53x SAMConfiguration
debug libnfc.chip.pn53x Timeout value: 1000
debug libnfc.bus.uart TX: 00 00 ff 03 fd d4 14 01 17 00
debug libnfc.bus.uart Timeout!
debug libnfc.driver.pn532_uart Unable to read ACK
error libnfc.driver.pn532_uart pn53x_check_communication error
debug libnfc.chip.pn53x InRelease
debug libnfc.bus.uart TX: 00 00 ff 03 fd d4 52 00 da 00
debug libnfc.bus.uart Timeout!
debug libnfc.driver.pn532_uart Unable to read ACK
debug libnfc.general Unable to open "pn532_uart:/dev/ttyUSB0".`

@sanbrother
Copy link

I googled a lot, and finally found that it was due to the power supply. Try another one.

@nelsonic
Copy link

@cpeppler01 | @alfem | @sanbrother did you manage to get the PN532 working using the USB => UART converter?
(we are researching if this is a viable option for a similar usecase... any insight will be very much appreciated)

@AlonsoVi
Copy link

After many headaches, what worked for me was allowing the intrusive scan. In Debian, it is as simple as changing the file in /etc/nfc/ libnfc.conf, removing the # to un-comment the (ninth) line and replace false with true. I hope that it works for you too so that you don't have to endure the pain that it was to figure it out!! :)

(running libnfc's latest version, 1.8.0)

@AnasMalas
Copy link

After many headaches, what worked for me was allowing the intrusive scan. In Debian, it is as simple as changing the file in /etc/nfc/ libnfc.conf, removing the # to un-comment the (ninth) line and replace false with true. I hope that it works for you too so that you don't have to endure the pain that it was to figure it out!! :)

(running libnfc's latest version, 1.8.0)

I cannot find that file in that directory. What should I do? I would heavily appreciate not having to pull my own hair

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

No branches or pull requests

6 participants