ACR122u p2p limitations

Asked by corzand

I have just bought a brand new ACR122u, but i have some doubts about nfcpy limitations with this reader.
I already use nfcpy on raspberry pi with an adafruit nxp pn532 nfc board, and i'm really enjoying it.. At the moment, i've wrote a single python program that uses nfcpy for p2p (with android) and tag reading. It's working like a charm!

Unfortunately, I need to substitute the adafruit pn532 nfc reader with an acr 122u.
I read about some limitations in p2p mode, but it's not clear to me: what i can't do with this reader?

I need to read passive tags (nxp ntag 216) and be able to receive a message from android (or windows phone) phones and hopefully reply to this message. (using Snep)

These are the files of the python program that i wrote:
https://github.com/spotsoftware/io-at-spot/blob/master/raspberry/python/nfc_controller.py
https://github.com/spotsoftware/io-at-spot/blob/master/raspberry/python/custom_snep_server.py

Thank you Stephen for your work, this project is an amazing nfc library!

PS: This morning i am doing some tests, and i'm starting from very simple examples.

Running:
$ sudo python tagtool.py -d nfc is working, green led turns on and when i put a tag on the reader, the read operation is successful

[main] enable debug output for module 'nfc'
[nfc.clf] searching for reader with path 'usb'
[nfc.dev.transport] using pyusb version 0.x
[nfc.dev.transport] path matches '^(usb|)$'
[nfc.dev] trying usb:072f:2200
[nfc.dev] import nfc.dev.acr122
[nfc.dev.transport] >>> 6f050000000000000000ff00480000
[nfc.dev.transport] <<< 800a000000000000810041435231323255323133
[nfc.dev.acr122] initialize ACR122U213
[nfc.dev.acr122] CCID ICC-POWER-ON
[nfc.dev.transport] >>> 62000000000000000000
[nfc.dev.transport] <<< 800200000000000081003b00
[nfc.dev.acr122] Set PICC Operating Parameters
[nfc.dev.transport] >>> 6f050000000000000000ff00517f00
[nfc.dev.transport] <<< 80020000000000008100907f
[nfc.dev.acr122] Configure Buzzer and LED
[nfc.dev.transport] >>> 6f090000000000000000ff00400e0400000000
[nfc.dev.transport] <<< 800200000000000081009002
[nfc.dev.acr122] PN53x GetFirmwareVersion called with timeout 100 ms
[nfc.dev.transport] >>> 6f070000000000000000ff00000002d402
[nfc.dev.transport] <<< 80080000000000008100d503320106079000
[nfc.dev.pn53x] chipset is a PN532 version 1.6
[nfc.dev.acr122] PN53x SAMConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f0a0000000000000000ff00000005d414010000
[nfc.dev.transport] <<< 80040000000000008100d5159000
[nfc.dev.acr122] PN53x Diagnose called with timeout 100 ms
[nfc.dev.transport] >>> 6f0d0000000000000000ff00000008d400006e66637079
[nfc.dev.transport] <<< 800a0000000000008100d501006e666370799000
[nfc.dev.pn53x] ATR_RES timeout: 102.4 ms
[nfc.dev.pn53x] non-DEP timeout: 51.2 ms
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f0b0000000000000000ff00000006d432020b0b0a
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.dev.pn53x] set retries: ATR_REQ=2 PSL_REQ=1 PassiveTarget=3
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f0b0000000000000000ff00000006d43205020103
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.clf] using ACS ACR122U PICC Interface at usb:001:005
[nfc.clf] connect({'llcp': None, 'card': {'on-release': <bound method TagTool.on_card_release of <__main__.TagTool object at 0x1775570>>, 'on-connect': <bound method TagTool.on_card_connect of <__main__.TagTool object at 0x1775570>>, 'on-startup': <bound method TagTool.on_card_startup of <__main__.TagTool object at 0x1775570>>, 'targets': []}, 'rdwr': {'on-connect': <bound method TagTool.on_rdwr_connect of <__main__.TagTool object at 0x1775570>>, 'on-startup': <bound method TagTool.on_rdwr_startup of <__main__.TagTool object at 0x1775570>>}})
[main] touch a tag
[nfc.dev.pn53x] polling for NFC-A technology
[nfc.dev.acr122] PN53x InListPassiveTarget called with timeout 1000 ms
[nfc.dev.transport] >>> 6f090000000000000000ff00000004d44a0100
[nfc.dev.transport] <<< 80050000000000008100d54b009000
[nfc.dev.acr122] PN53x InListPassiveTarget called with timeout 1000 ms
[nfc.dev.transport] >>> 6f090000000000000000ff00000004d44a0104
[nfc.dev.transport] <<< 80050000000000008100d54b009000
[nfc.dev.pn53x] poll NFC-F 00ffff0103
[nfc.dev.acr122] PN53x InListPassiveTarget called with timeout 1000 ms
[nfc.dev.transport] >>> 6f0e0000000000000000ff00000009d44a010100ffff0103
[nfc.dev.transport] <<< 80050000000000008100d54b009000
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f090000000000000000ff00000004d4320100
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.dev.pn53x] polling for NFC-A technology
[nfc.dev.acr122] PN53x InListPassiveTarget called with timeout 1000 ms
[nfc.dev.transport] >>> 6f090000000000000000ff00000004d44a0100
[nfc.dev.transport] <<< 80110000000000008100d54b010100440007047b2072d538809000
[nfc.dev.pn53x] found NFC-A target @ 106 kbps
[nfc.clf] found target TTA br=106 cfg=440000 uid=047b2072d53880 ats=
[nfc.dev] Driver.set_communication_mode() should be implemented.
[nfc.tag.tt2] read block #0
[nfc.clf] >>> 3000 0.100s
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f0b0000000000000000ff00000006d432020b0b0b
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f090000000000000000ff00000004d4320403
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.dev.acr122] PN53x InDataExchange called with timeout 406 ms
[nfc.dev.transport] >>> 6f0a0000000000000000ff00000005d440013000
[nfc.dev.transport] <<< 80150000000000008100d54100047b20d772d538801f480000e1106d009000
[nfc.clf] <<< 047b20d772d538801f480000e1106d00
[nfc.tag.tt2] capability container e1106d00
[nfc.tag.tt2] read block #4
[nfc.clf] >>> 3004 0.100s
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f0b0000000000000000ff00000006d432020b0b0b
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f090000000000000000ff00000004d4320403
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.dev.acr122] PN53x InDataExchange called with timeout 406 ms
[nfc.dev.transport] >>> 6f0a0000000000000000ff00000005d440013004
[nfc.dev.transport] <<< 80150000000000008100d541000300fe000000000000000000000000009000
[nfc.clf] <<< 0300fe00000000000000000000000000
[nfc.clf] connected to Type2Tag ATQ=4400 SAK=00 UID=047b2072d53880
Type2Tag ATQ=4400 SAK=00 UID=047b2072d53880
NDEF capabilities:
  version = 1.0
  readable = yes
  writeable = yes
  capacity = 868 byte
  message = 0 byte
[nfc.dev.transport] >>> 6f090000000000000000ff00400c0400000000
[nfc.dev.transport] <<< 800200000000000081009000

Running:
$ sudo python beam.py -d nfc send link http://nfcpy.org "nfcpy project home"

fails. This is the output:

[main] enable debug output for module 'nfc'
[nfc.clf] searching for reader with path 'usb'
[nfc.dev.transport] using pyusb version 0.x
[nfc.dev.transport] path matches '^(usb|)$'
[nfc.dev] trying usb:072f:2200
[nfc.dev] import nfc.dev.acr122
[nfc.dev.transport] >>> 6f050000000000000000ff00480000
[nfc.dev.transport] <<< 800a000000000000810041435231323255323133
[nfc.dev.acr122] initialize ACR122U213
[nfc.dev.acr122] CCID ICC-POWER-ON
[nfc.dev.transport] >>> 62000000000000000000
[nfc.dev.transport] <<< 800200000000000081003b00
[nfc.dev.acr122] Set PICC Operating Parameters
[nfc.dev.transport] >>> 6f050000000000000000ff00517f00
[nfc.dev.transport] <<< 80020000000000008100907f
[nfc.dev.acr122] Configure Buzzer and LED
[nfc.dev.transport] >>> 6f090000000000000000ff00400e0400000000
[nfc.dev.transport] <<< 800200000000000081009002
[nfc.dev.acr122] PN53x GetFirmwareVersion called with timeout 100 ms
[nfc.dev.transport] >>> 6f070000000000000000ff00000002d402
[nfc.dev.transport] <<< 80080000000000008100d503320106079000
[nfc.dev.pn53x] chipset is a PN532 version 1.6
[nfc.dev.acr122] PN53x SAMConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f0a0000000000000000ff00000005d414010000
[nfc.dev.transport] <<< 80040000000000008100d5159000
[nfc.dev.acr122] PN53x Diagnose called with timeout 100 ms
[nfc.dev.transport] >>> 6f0d0000000000000000ff00000008d400006e66637079
[nfc.dev.transport] <<< 800a0000000000008100d501006e666370799000
[nfc.dev.pn53x] ATR_RES timeout: 102.4 ms
[nfc.dev.pn53x] non-DEP timeout: 51.2 ms
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f0b0000000000000000ff00000006d432020b0b0a
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.dev.pn53x] set retries: ATR_REQ=2 PSL_REQ=1 PassiveTarget=3
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f0b0000000000000000ff00000006d43205020103
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.clf] using ACS ACR122U PICC Interface at usb:001:005
[nfc.clf] connect({'llcp': {'on-connect': <bound method Main.on_llcp_connect of <__main__.Main object at 0x17f5e90>>, 'on-startup': <bound method Main.on_llcp_startup of <__main__.Main object at 0x17f5e90>>, 'miu': 2175, 'role': None, 'agf': True, 'lto': 500, 'symm-log': True}, 'card': None, 'rdwr': None})
[nfc.snep.server] snep server bound to port 4 (MIU=1984, RW=15), will accept up to 1048576 byte NDEF messages
[nfc.clf] listen for 0.375 sec as target DEP br=None gb=46666d010111020207ff03020013040132070103
[nfc.dev.acr122] listen mode is disabled for this device
[nfc.dep] using hardware DEP implementation
[nfc.dev.pn53x] polling for a p2p target
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f090000000000000000ff00000004d4320100
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.dev.pn53x] nfcid3 not used in passive mode
[nfc.dev.acr122] PN53x InJumpForDEP called with timeout 1000 ms
[nfc.dev.transport] >>> 6f230000000000000000ff0000001ed45600020500ffff000346666d010111020207ff03020013040132070103
[nfc.dev.transport] <<< 80050000000000008100d557019000
[nfc.dev.acr122] PN53x InJumpForDEP called with timeout 1000 ms
[nfc.dev.transport] >>> 6f2d0000000000000000ff00000028d45601020700ffff000301fed5afa1112123557546666d010111020207ff03020013040132070103
[nfc.dev.transport] <<< 80050000000000008100d557019000
[nfc.clf] listen for 0.476 sec as target DEP br=None gb=46666d010111020207ff03020013040132070103
[nfc.dev.acr122] listen mode is disabled for this device
[nfc.dep] using hardware DEP implementation
[nfc.dev.pn53x] polling for a p2p target
[nfc.dev.acr122] PN53x RFConfiguration called with timeout 100 ms
[nfc.dev.transport] >>> 6f090000000000000000ff00000004d4320100
[nfc.dev.transport] <<< 80040000000000008100d5339000
[nfc.dev.pn53x] nfcid3 not used in passive mode
[nfc.dev.acr122] PN53x InJumpForDEP called with timeout 1000 ms
[nfc.dev.transport] >>> 6f230000000000000000ff0000001ed45600020500ffff000346666d010111020207ff03020013040132070103
[nfc.dev.transport] <<< 80050000000000008100d557019000
[nfc.dev.acr122] PN53x InJumpForDEP called with timeout 1000 ms
[nfc.dev.transport] >>> 6f2d0000000000000000ff00000028d45601020700ffff000301fe0e0e7e53df8224ac46666d010111020207ff03020013040132070103
[nfc.dev.pn53x] [Errno 110] Connection timed out
[nfc.clf] [Errno 110] Connection timed out
[nfc.dev.transport] >>> 6f090000000000000000ff00400c0400000000
-110

After this error, python program exits, but the green led is turned on.
Now i'm not able to use the reader anymore.. looks like it's busy.

Running tagtool again, i'm not able to read tag anymore, i get this error:

$sudo python tagtool.py -d nfc
[main] enable debug output for module 'nfc'
[nfc.clf] searching for reader with path 'usb'
[nfc.dev.transport] using pyusb version 0.x
[nfc.dev.transport] path matches '^(usb|)$'
[nfc.dev] trying usb:072f:2200
[nfc.dev] import nfc.dev.acr122
[nfc.dev.transport] >>> 6f050000000000000000ff00480000
[nfc.dev.transport] <<< 800a000000000000810041435231323255323133
[nfc.dev.acr122] initialize ACR122U213
[nfc.dev.acr122] CCID ICC-POWER-ON
[nfc.dev.transport] >>> 62000000000000000000
[nfc.dev.transport] <<< 800a000000000000810041435231323255323133
[nfc.dev.acr122] Set PICC Operating Parameters
[nfc.dev.transport] >>> 6f050000000000000000ff00517f00
[nfc.dev.transport] <<< 800200000000000081003b00
[nfc.dev.acr122] Configure Buzzer and LED
[nfc.dev.transport] >>> 6f090000000000000000ff00400e0400000000
[nfc.dev.transport] <<< 80020000000000008100907f
[nfc.dev.acr122] PN53x GetFirmwareVersion called with timeout 100 ms
[nfc.dev.transport] >>> 6f070000000000000000ff00000002d402
[nfc.dev.transport] <<< 800200000000000081009002
[nfc.dev.acr122] insufficient data for decoding chip response
[nfc.clf] no reader found at 'usb'
[main] no contactless reader found

Further details:

- $lsmod | grep usb is not returning output
- I have no pcsc

Question information

Language:
English Edit question
Status:
Solved
For:
nfcpy Edit question
Assignee:
No assignee Edit question
Solved by:
corzand
Solved:
Last query:
Last reply:
Revision history for this message
Stephen Tiedemann (stephen-tiedemann) said :
#1

First of all, ACR122 is a bad choice for any serious project. The firmware that implements the USB CCID interface is, I wouldn't say buggy, but it's designed for a different purpose than just to pass PC/SC Escape command payload to the PN532, as nfcpy does.

I could reproduce the problem without difficulty, the poll for P2P target stops after less that 10 iterations. Each polling loop is actually two parts, first for 424kbps passive and then for 424kbps active communication mode. It always fails in the poll for active communication mode. A larger timeout (5000ms) only gets a few more iterations. Disabling the poll for active mode communication helped, I've run the polling loop now for many minutes. Drawback is that not passive communication mode does not work with all phones, my Xperia Z is one of those.

To disable the active mode poll you'll have to modify nfcpy. Only with the next major update (then be 0.10) it will be possible to do this through the API.

=== modified file 'nfc/dev/pn53x.py'
--- nfc/dev/pn53x.py 2014-01-09 17:57:25 +0000
+++ nfc/dev/pn53x.py 2015-05-22 11:44:41 +0000
@@ -476,7 +476,7 @@
         pollrq = "\x00\xFF\xFF\x00\x03"
         nfcid3 = "\x01\xfe" + os.urandom(8)

- for mode, speed in (("passive", "424"), ("active", "424")):
+ for mode, speed in [("passive", "424")]:
             try:
                 rsp = self.chipset.in_jump_for_dep(
                     mode, speed, pollrq, nfcid3, general_bytes)

Revision history for this message
corzand (acorzani) said :
#2

Dear Stephen,
after your modification and some updates to my code, i finally wrote some working code with the ACR122.