Error number 16 (Device or resource busy) ACR122U-A9

Asked by Luca Pirovano

Hi, I've a problem with my device ACS ACR122U. I'm trying simply to read a NFC card throught a Python script. I'm looking at the documentation of NFCpy and i have used this code (only for a test):

import nfc

clf = nfc.ContactlessFrontend()
assert clf.open('usb:072f:2200') is True
clf.close()

When I start my program, I get this error message: IOError: [Errno 16] Device or resource busy

Here's the full log:
/usr/src/Python-2.7.14/python /home/luca/PyCharm/reader.py
No handlers could be found for logger "nfc.llcp.sec"
Traceback (most recent call last):
  File "/home/luca/PyCharm/reader.py", line 4, in <module>
    assert clf.open('usb:072f:2200') is True
  File "/usr/local/lib/python2.7/site-packages/nfc/clf/__init__.py", line 148, in open
    self.device = device.connect(path)
  File "/usr/local/lib/python2.7/site-packages/nfc/clf/device.py", line 95, in connect
    raise error
IOError: [Errno 16] Device or resource busy

Process finished with exit code 1

I am using PyCharm full edition for scripting. How can i solve it?

Thanks in advance

Question information

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

Have you run the "python -m nfc" command as described under "Verify installation" of the Getting started documentation page?

Revision history for this message
Luca Pirovano (pirox4256) said :
#4

Yes, and I get this message:

luca@luca-Lenovo-YOGA-510-14ISK:/opt/pycharm/bin$ python2.7 -m nfc --search-tty
No handlers could be found for logger "nfc.llcp.sec"
This is the 0.13.5 version of nfcpy run in Python 2.7.14
on Linux-4.15.0-32-generic-x86_64-with-debian-buster-sid
I'm now searching your system for contactless devices
** found usb:072f:2200 at usb:001:016 but access is denied
-- the device is owned by 'root' but you are 'luca'
-- also members of the 'root' group would be permitted
-- you could use 'sudo' but this is not recommended
-- better assign the device to the 'plugdev' group
   sudo sh -c 'echo SUBSYSTEM==\"usb\", ACTION==\"add\", ATTRS{idVendor}==\"072f\", ATTRS{idProduct}==\"2200\", GROUP=\"plugdev\" >> /etc/udev/rules.d/nfcdev.rules'
   sudo udevadm control -R # then re-attach device
Sorry, but I couldn't find any contactless device

How can I solve? if I try to install nfcpy I get this:

luca@luca-Lenovo-YOGA-510-14ISK:/opt/pycharm/bin$ sudo pip install -U nfcpy
The directory '/home/luca/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/luca/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: nfcpy in /usr/local/lib/python2.7/site-packages (0.13.5)
Requirement already satisfied, skipping upgrade: libusb1 in /usr/local/lib/python2.7/site-packages (from nfcpy) (1.6.6)
Requirement already satisfied, skipping upgrade: ndeflib in /usr/local/lib/python2.7/site-packages (from nfcpy) (0.3.2)
Requirement already satisfied, skipping upgrade: pyserial in /usr/local/lib/python2.7/site-packages (from nfcpy) (3.4)
Requirement already satisfied, skipping upgrade: pydes in /usr/local/lib/python2.7/site-packages (from nfcpy) (2.0.1)
luca@luca-Lenovo-YOGA-510-14ISK:/opt/pycharm/bin$

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) said :
#5

The output of "python -m nfc" contains precisely the command you should execute to resolve the problem. I think I can't make that one easier.

Revision history for this message
Luca Pirovano (pirox4256) said :
#6

OK, thanks.
Now I've another error. I execute the command but it does not work..

python2.7 -m nfc --search-tty
No handlers could be found for logger "nfc.llcp.sec"
This is the 0.13.5 version of nfcpy run in Python 2.7.14
on Linux-4.15.0-32-generic-x86_64-with-debian-buster-sid
I'm now searching your system for contactless devices
** found usb:072f:2200 at usb:001:018 but it's already used
-- scan sysfs entry at '/sys/bus/usb/devices/1-3:1.0/'
-- the device is used by the 'usbfs' kernel driver
-- this indicates a user mode driver with libusb
-- find the process that uses /dev/bus/usb/001/018
   ps --no-headers -o cmd -p `sudo lsof -t /dev/bus/usb/001/018`
Sorry, but I couldn't find any contactless device
luca@luca-Lenovo-YOGA-510-14ISK:/opt/pycharm/bin$ python2.7 -m nfc
No handlers could be found for logger "nfc.llcp.sec"
This is the 0.13.5 version of nfcpy run in Python 2.7.14
on Linux-4.15.0-32-generic-x86_64-with-debian-buster-sid
I'm now searching your system for contactless devices
** found usb:072f:2200 at usb:001:018 but it's already used
-- scan sysfs entry at '/sys/bus/usb/devices/1-3:1.0/'
-- the device is used by the 'usbfs' kernel driver
-- this indicates a user mode driver with libusb
-- find the process that uses /dev/bus/usb/001/018
   ps --no-headers -o cmd -p `sudo lsof -t /dev/bus/usb/001/018`
I'm not trying serial devices because you haven't told me
-- add the option '--search-tty' to have me looking
-- but beware that this may break other serial devs
Sorry, but I couldn't find any contactless device

How can I solve?

Revision history for this message
Stephen Tiedemann (stephen-tiedemann) said :
#7

Some other process is using the reader. You need to find and disable it. The output message contains some help to find out the other process.

Revision history for this message
Adam Michalowsky (adamolly) said :
#8

Hi Luca,

I'm facing this exact same problem as well.

Stephen, if you have any tips for figuring out what process is using the reader, that'd be greatly appreciated. I'm new to this and have yet to be able to find the process and turn it off.

Can you help with this problem?

Provide an answer of your own, or ask Luca Pirovano for more information if necessary.

To post a message you must log in.