ACR122U ubuntu 10.04. usb.USBError: could not claim interface 0: Device or resource busy

Bug #908917 reported by Kaur Mätas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nfcpy
Won't Fix
Undecided
Unassigned

Bug Description

I have ACR122u working under ubuntu 10.04

for example I do:
[04:09:15] /home/elulamp/Development/nfcpy $ pcsc_scan
PC/SC device scanner
V 1.4.16 (c) 2001-2009, Ludovic Rousseau <email address hidden>
Compiled with PC/SC lite version: 1.5.3
Scanning present readers...
0: ACS ACR122U 00 00

Tue Dec 27 04:09:27 2011
 Reader 0: ACS ACR122U 00 00
  Card state: Card inserted,
  ATR: 3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 FF 40 00 00 00 00 D4

ATR: 3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 FF 40 00 00 00 00 D4
+ TS = 3B --> Direct Convention
+ T0 = 8F, Y(1): 1000, K: 15 (historical bytes)
  TD(1) = 80 --> Y(i+1) = 1000, Protocol T = 0
-----
  TD(2) = 01 --> Y(i+1) = 0000, Protocol T = 1
-----
+ Historical bytes: 80 4F 0C A0 00 00 03 06 03 FF 40 00 00 00 00
  Category indicator byte: 80 (compact TLV data object)
    Tag: 4, len: F (initial access data)
      Initial access data: 0C A0 00 00 03 06 03 FF 40 00 00 00 00
+ TCK = D4 (correct checksum)

Possibly identified card (using /home/elulamp/.smartcard_list.txt):
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 FF 40 00 00 00 00 D4
3B 8F 80 01 80 4F 0C A0 00 00 03 06 03 .. .. 00 00 00 00 ..
 RFID - ISO 14443 Type A Part 3 (as per PCSC std part3)

Now I will try to use nfcpy:

[04:03:46] /home/elulamp/Development/nfcpy $ sudo python
Python 2.6.7 (r267:88850, Dec 27 2011, 02:24:28)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import nfc
>>> c = nfc.ContactlessFrontend()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "nfc/clf.py", line 42, in __init__
    self.dev = dev.connect(path)
  File "nfc/dev/__init__.py", line 102, in connect
    return driver.init(dev)
  File "nfc/dev/acr122_usb.py", line 107, in init
    bus = acr122_usb(usb_dev)
  File "nfc/dev/acr122_usb.py", line 71, in __init__
    self.dh.claimInterface(interface[0])
usb.USBError: could not claim interface 0: Device or resource busy

and if I do now pcsc_scan again I get this

PC/SC device scanner
V 1.4.16 (c) 2001-2009, Ludovic Rousseau <email address hidden>
Compiled with PC/SC lite version: 1.5.3
Scanning present readers...
0: ACS ACR122U 00 00

Tue Dec 27 04:07:54 2011
 Reader 0: ACS ACR122U 00 00
  Card state: Status unavailable,

It seems nfcpy "blocks" somehow my acr122

Revision history for this message
Kaur Mätas (elulamp) wrote :

Oh and acr122 firmware is ACR122U207

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) wrote :

I have no experience of running nfcpy together with pcsc-lite, so there may be any sorts of interference. Also I was using an ACR122U203 for development and testing.

I'd appreciate if you could do some more experiments.
- run examples/tagtool.py with debug output enabled (-d flag)
- try remove "self.dh.reset()" in nfc/dev/acr122_usb.py (line 69)
- try using nfcpy without pcsc-lite daemon running

Revision history for this message
Kaur Mätas (elulamp) wrote :

1) run examples/tagtool.py with debug output enabled (-d flag):

[20:28:02] /home/../Development/nfcpy/examples $ sudo python tagtool.py -d
searching for a usable reader
searching for a usb bus reader
path match for 'usb' (or no path given)
trying usb:001:003
import nfc.dev.acr122_usb
Traceback (most recent call last):
  File "tagtool.py", line 295, in <module>
    main()
  File "tagtool.py", line 211, in main
    try: clf = nfc.ContactlessFrontend(device); break
  File "/home/elulamp/Development/nfcpy/nfc/clf.py", line 42, in __init__
    self.dev = dev.connect(path)
  File "/home/elulamp/Development/nfcpy/nfc/dev/__init__.py", line 102, in connect
    return driver.init(dev)
  File "/home/elulamp/Development/nfcpy/nfc/dev/acr122_usb.py", line 107, in init
    bus = acr122_usb(usb_dev)
  File "/home/elulamp/Development/nfcpy/nfc/dev/acr122_usb.py", line 71, in __init__
    self.dh.claimInterface(interface[0])
usb.USBError: could not claim interface 0: Device or resource busy
-16
Exception usb.USBError: 'error submitting URB: Device or resource busy' in <bound method acr122_usb.__del__ of <nfc.dev.acr122_usb.acr122_usb object at 0xb765fa4c>> ignored

2) try remove "self.dh.reset()" in nfc/dev/acr122_usb.py (line 69)

Same output as before

3) after stopping pcsc-lite I get following error

[20:46:30] /home/../Development/nfcpy/examples $ sudo python tagtool.py -d
searching for a usable reader
searching for a usb bus reader
path match for 'usb' (or no path given)
trying usb:001:007
import nfc.dev.acr122_usb
GetFirmwareVersion
>>> 6b070000000000000000ff00000002d402
Connection timed out
Traceback (most recent call last):
  File "tagtool.py", line 295, in <module>
    main()
  File "tagtool.py", line 211, in main
    try: clf = nfc.ContactlessFrontend(device); break
  File "/home/elulamp/Development/nfcpy/nfc/clf.py", line 42, in __init__
    self.dev = dev.connect(path)
  File "/home/elulamp/Development/nfcpy/nfc/dev/__init__.py", line 102, in connect
    return driver.init(dev)
  File "/home/elulamp/Development/nfcpy/nfc/dev/acr122_usb.py", line 108, in init
    dev = acr122(bus)
  File "/home/elulamp/Development/nfcpy/nfc/dev/pn53x.py", line 113, in __init__
    ic, ver, rev, support = self.get_firmware_version()
  File "/home/elulamp/Development/nfcpy/nfc/dev/pn53x.py", line 186, in get_firmware_version
    rsp = self.command(0x02)
  File "/home/elulamp/Development/nfcpy/nfc/dev/acr122_usb.py", line 49, in command
    raise pn53x.NoResponse("no response from pn53x")
nfc.dev.pn53x.NoResponse: no response from pn53x
Exception usb.USBError: 'Connection timed out' in <bound method acr122_usb.__del__ of <nfc.dev.acr122_usb.acr122_usb object at 0xb7722a4c>> ignored

And nfc reader led does not light up

Revision history for this message
Kaur Mätas (elulamp) wrote :

Got it working under windows, put now if I do any operations with my reader I have to reinstall libusb drivers for my device.

I do no know if is it a reader specific issue or what.

Revision history for this message
Kaur Mätas (elulamp) wrote :

Windows being so unstable, I gave another go in ubuntu. On a fresh copy, no pcscd daemon installed I get following error:

[01:38:41] /home/../Development/nfcpy/examples $ sudo python helloworld.py
Traceback (most recent call last):
  File "helloworld.py", line 68, in <module>
    main()
  File "helloworld.py", line 35, in main
    clf = nfc.ContactlessFrontend()
  File "/home/elulamp/Development/nfcpy/nfc/clf.py", line 42, in __init__
    self.dev = dev.connect(path)
  File "/home/elulamp/Development/nfcpy/nfc/dev/__init__.py", line 102, in connect
    return driver.init(dev)
  File "/home/elulamp/Development/nfcpy/nfc/dev/acr122_usb.py", line 108, in init
    dev = acr122(bus)
  File "/home/elulamp/Development/nfcpy/nfc/dev/pn53x.py", line 113, in __init__
    ic, ver, rev, support = self.get_firmware_version()
  File "/home/elulamp/Development/nfcpy/nfc/dev/pn53x.py", line 186, in get_firmware_version
    rsp = self.command(0x02)
  File "/home/elulamp/Development/nfcpy/nfc/dev/acr122_usb.py", line 45, in command
    self.bus.write(frame)
  File "/home/elulamp/Development/nfcpy/nfc/dev/pn53x_usb.py", line 60, in write
    self.dh.bulkWrite(self.usb_out, frame)
usb.USBError: No error
Exception usb.USBError: 'No error' in <bound method acr122_usb.__del__ of <nfc.dev.acr122_usb.acr122_usb object at 0x95f406c>> ignored

Revision history for this message
Kaur Mätas (elulamp) wrote :

And what are the bare minimum libraries I need to get it working with ACR122U?

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) wrote :

(Sorry, I've enjoyed winter vacation)

On Ubuntu the only required additional library is python-usb, but you seem to have that installed. I can only guess then that ACR122U207 is different enough from a ACR122U203 to produce the error.

I've posted the script ccid-nfc.py to http://pastebin.com/gAXFcdzV which I used initially to learn the behaviour of ACR122U. Maybe you could play around with that, I guess you have sufficient programming skills to enable test sections in the script. You will need to copy it into your /home/../Development/ directory.

Revision history for this message
Samuel Ortiz (kapteen) wrote :

FWIW, I have the same issue (timeout for each and every command nfcpy tries to send) with my ACR122U207.
I ran ccid-nfc.py and got the following output:

trying reader at usb port 001:015
Device: 015
  Device class: 0
  Device sub class: 0
  Device protocol: 0
  Max packet size: 8
  idVendor: 1839 (0x072f)
  idProduct: 8704 (0x2200)
  Device Version: 02.07
  Configuration: 1
    Total length: 93
    selfPowered: 0
    remoteWakeup: 0
    maxPower: 144
    Interface: 0
    Alternate Setting: 0
      Interface class: 11
      Interface sub class: 0
      Interface protocol: 0
      Endpoint: 0x81L
        Type: 3
        Max packet size: 8
        Interval: 2
      Endpoint: 0x2L
        Type: 2
        Max packet size: 64
        Interval: 0
      Endpoint: 0x82L
        Type: 2
        Max packet size: 64
        Interval: 0

I'll try to find some time to investigate that further, but Stephen what's the output you get with a ACR122U203 ?

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) wrote :
Download full text (3.3 KiB)

Samuel,

below is the output of lsusb for my ACR122. The only relevant differences I could spot are version 2.03 vs. 2.07 and the max powere re

Bus 001 Device 005: ID 072f:2200 Advanced Card Systems, Ltd
Device Descriptor:
  bLength 18
  bDescriptorType 1
  bcdUSB 1.10
  bDeviceClass 0 (Defined at Interface level)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize0 8
  idVendor 0x072f Advanced Card Systems, Ltd
  idProduct 0x2200
  bcdDevice 2.03
  iManufacturer 1 ACS
  iProduct 2 ACR122U PICC Interface
  iSerial 0
  bNumConfigurations 1
  Configuration Descriptor:
    bLength 9
    bDescriptorType 2
    wTotalLength 93
    bNumInterfaces 1
    bConfigurationValue 1
    iConfiguration 0
    bmAttributes 0x80
      (Bus Powered)
    MaxPower 200mA
    Interface Descriptor:
      bLength 9
      bDescriptorType 4
      bInterfaceNumber 0
      bAlternateSetting 0
      bNumEndpoints 3
      bInterfaceClass 11 Chip/SmartCard
      bInterfaceSubClass 0
      bInterfaceProtocol 0
      iInterface 0
      ChipCard Interface Descriptor:
        bLength 54
        bDescriptorType 33
        bcdCCID 1.00
        nMaxSlotIndex 0
        bVoltageSupport 7 5.0V 3.0V 1.8V
        dwProtocols 2 T=1
        dwDefaultClock 4000
        dwMaxiumumClock 4000
        bNumClockSupported 0
        dwDataRate 10752 bps
        dwMaxDataRate 250000 bps
        bNumDataRatesSupp. 0
        dwMaxIFSD 256
        dwSyncProtocols 00000000
        dwMechanical 00000000
        dwFeatures 00020040
          Auto parameter negotation made by CCID
          Short APDU level exchange
        dwMaxCCIDMsgLen 271
        bClassGetResponse 00
        bClassEnvelope 00
        wlcdLayout none
        bPINSupport 0
        bMaxCCIDBusySlots 1
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x81 EP 1 IN
        bmAttributes 3
          Transfer Type Interrupt
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0008 1x 8 bytes
        bInterval 2
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x02 EP 2 OUT
        bmAttributes 2
          Transfer Type Bulk
          Synch Type None
          Usage Type Data
        wMaxPacketSize 0x0040 1x 64 bytes
        bInterval 0
      Endpoint Descriptor:
        bLength 7
        bDescriptorType 5
        bEndpointAddress 0x82 EP 2 IN
        bmAttributes 2
          Transfer Type Bulk
       ...

Read more...

Revision history for this message
Daniel (d-gutierrez-reina) wrote :

Hi Stephen and Samuel,

I am Daniel Gutiérrez. I am also working on ACR122U and I algo got the same problem as Samuel, the reader is blocked after trying to connect to it. I have ran your script (Stephen) and I got the following message

dany@ubuntu:~/nfcpy$ python ccid-nfc.py
trying reader at usb port 002:009
Traceback (most recent call last):
  File "ccid-nfc.py", line 50, in <module>
    dh.reset()
usb.USBError: could not reset: Operation not permitted
dany@ubuntu:~/nfcpy$ sudo python ccid-nfc.py
trying reader at usb port 002:009
Traceback (most recent call last):
  File "ccid-nfc.py", line 52, in <module>
    dh.claimInterface(interface[0])
usb.USBError: could not claim interface 0: Device or resource busy
dany@ubuntu:~/nfcpy$ pcsc_scan
PC/SC device scanner
V 1.4.16 (c) 2001-2009, Ludovic Rousseau <email address hidden>
Compiled with PC/SC lite version: 1.5.3
Scanning present readers...
0: ACS ACR122U 00 00

Wed Jul 25 10:33:52 2012
 Reader 0: ACS ACR122U 00 00
  Card state: Status unavailable,

Could help me with that. I am working on Ubuntu 10.04. The objective of my work is to establish peer to peer communications between two ACS ACR122U readers.

Thank you in advance!

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) wrote :

For what it's supposed to do the ACR122 is working fine. Device busy errors can always be if there is another processe using the device. The tagtool.py example can be used to inspect with a fully qualified device path like "--device usb:<VID>:<PID>".

Changed in nfcpy:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.