Git Product home page Git Product logo

nfcpy's Introduction

Python module for near field communication

Python Package

Documentation

CI Status

Code Coverage

The nfcpy module implements NFC Forum specifications for wireless short-range data exchange with NFC devices and tags. It is written in Python and aims to provide an easy-to-use yet powerful framework for applications integrating NFC. The source code is licensed under the EUPL and hosted on GitHub. Release versions are published on PyPI for pip install -U nfcpy. Documentation for latest development and active release versions can be found on Read the Docs. The GitHub issues tracker is the place for bug reports or related questions. Other questions may have been or get answered on the project's Launchpad answers page or stackoverflow.

nfcpy's People

Contributors

aknaub avatar dkotrada avatar edevil avatar fdawidow avatar ghxbob avatar henrycjc avatar hideo54 avatar m-gregoire avatar mizutoki79 avatar mofe23 avatar nehpetsde avatar svvitale avatar te-stephentiedemann avatar turbolocust avatar wie-niet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nfcpy's Issues

NFC data transfer too slow using nfcpy

Hi guys,
I have written a python application, based on nfcpy, that transfers a binary file onto a type 2 tag.
So far everything worked fine besides the transfer speed. On windows the transfer rate is around 200Bytes/second and on Linux slightly better, 280Bytes/second whereas I would expect a closer values to the theoretical value of 800Bytes/second.
I have stripped completely my python script and my Tag code, so basically I can't blame any of the two applications.
When debugging I do see that the messages take quite a while to write, around 0.8 seconds per record, which is quite a lot. My records have 150 bytes.
So at this point I am inclined to blame the USB driver or the nfcpy which are the only black boxes in this setup.
I have used two different card readers, the Sony S380 and the ACR122, the results on the Sony are slightly better, maybe because it uses a newer version of the PN5XX (PN533) and the ACR122 uses the PN532.
Regarding the drivers I have been using the native drivers, which don't work, and the lisbusb v1.2.6.0, libusbkcv3.0.7.0 which give the above results.
On Linux, the performance increases a bit, to around 250bytes/second, still far from the intended speed.
Does someone have an idea how I can improve the transfer rate on my setup?

my code:

...

if name == 'main':

...

msg = None
with nfc.ContactlessFrontend('usb') as clf:
    print('\nTouch an nfctag containing an ndef message.')
    nfctag = None
    while not nfctag or not nfctag.ndef:
        def onconnect(tag):
            print(tag);
            return False
        def onrelease(tag):
            sys.exit()
        nfctag = clf.connect(rdwr={'on-connect': onconnect, 'on-release': onrelease})
        print(nfctag.ndef.message.type)
        if (packageDebugEnabled):
            printmessage(nfctag.ndef.message)

...

    with open(BinaryFile, "rb") as binaryFile:
        while (transfer == TRANSFER_ONGOING):
           ...
            if (readyForNextPackage):
               ...
                for chunk in iter(lambda: binaryFile.read(dataChuckSize), b""):

...
chunky = list(packageTransferMsgId) + list(CardReaderTag) + list(packagesSizeStringLSB) + list(packagesSizeStringMSB) + list(formattedPackageNumber) + list(chunk) + emptyList

...

                    str1 = ''.join(package)
                    record0 = nfc.ndef.Record(mimeType, '', b'{}'.format(str1))
                    nfctag.ndef.message = nfc.ndef.Message(record0)

...
if nfctag.ndef.has_changed:
message = nfctag.ndef.message
....


Imported from Launchpad using lp2gh.

Breaking change from 0.9.2 to 0.10.0

I just downloaded the latest release (0.10.0) and gave it a quick spin. Unfortunately the first tryout already failed:

/nfcpy-0.10.0/examples# python tagtool.py --device tty:AMA0:pn53x show
[nfc.clf] searching for reader on path tty:AMA0:pn53x
Traceback (most recent call last):
File "tagtool.py", line 569, in
TagTool().run()
File "/root/nfcpy-0.10.0/examples/cli.py", line 415, in run
while self.run_once() and self.options.loop:
File "/root/nfcpy-0.10.0/examples/cli.py", line 344, in run_once
clf = nfc.ContactlessFrontend(path)
File "/root/nfcpy-0.10.0/nfc/clf/init.py", line 72, in init
if path and not self.open(path):
File "/root/nfcpy-0.10.0/nfc/clf/init.py", line 146, in open
self.device = device.connect(path)
File "/root/nfcpy-0.10.0/nfc/clf/device.py", line 104, in connect
device = driver.init(tty)
AttributeError: 'module' object has no attribute 'init'

This does not happen with the previous release 0.9.2. Am I missing any new dependencies?

Regards,
Florian


Imported from Launchpad using lp2gh.

Acr 122 can not be opened.

Hi Stephen,
We've met on the Plugfest, now I am setting up the nfcpy platform.
Here is the output of "sudo python examples/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] device probably used by another process
[nfc.clf] no reader found at 'usb'
[main] no contactless reader found
Could you give me some help?
Thanks!


Imported from Launchpad using lp2gh.

TypeError: must be string or buffer, not None

I'm occasionally seeing this error on my R-Pi... How do I prevent/fix it?

Traceback (most recent call last):
File "mainNfc.py", line 286, in
if (myNfcTag.ndef is None) or (wifiSettings is None):
File "/home/pi/nfcpy/nfc/tag/init.py", line 221, in ndef
if ndef.has_changed:
File "/home/pi/nfcpy/nfc/tag/init.py", line 135, in has_changed
old_data, self._data = self._data, self._read_ndef_data()
File "/home/pi/nfcpy/nfc/tag/tt2.py", line 145, in _read_ndef_data
if not self._read_capability_data(tag_memory):
File "/home/pi/nfcpy/nfc/tag/tt2.py", line 128, in _read_capability_data
if tag_memory[12] != 0xE1:
File "/home/pi/nfcpy/nfc/tag/tt2.py", line 599, in getitem
self._read_from_tag(stop=key+1)
File "/home/pi/nfcpy/nfc/tag/tt2.py", line 620, in _read_from_tag
self._data_from_tag[i:i+16] = self._tag.read(i>>2)
File "/home/pi/nfcpy/nfc/tag/tt2.py", line 456, in read
data = self.transceive("\x30"+chr(page%256), timeout=0.005)
File "/home/pi/nfcpy/nfc/tag/tt2.py", line 565, in transceive
log.debug("<< {0} ({1:f}s)".format(hexlify(data), elapsed))
TypeError: must be string or buffer, not None

Thanks,

-Juan


Imported from Launchpad using lp2gh.

newest nfcpy verison not working on Windows XP and virtualized Linux (Virtualbox)

when trying to access the RC-S330 the error "LookupError: couldn't find any usable nfc reader" is reported and the program terminates. The example scripts work when the nfc module is replaced with an older version. I suspect a timing issue.

Details:
Searching USB bus for contactless reader
found device at USB port bus-0:.\libusb0-0001--0x054c-0x02e1
Traceback (most recent call last):
File "trunk\examples\tagtool.py", line 266, in
main()
File "trunk\examples\tagtool.py", line 200, in main
clf = nfc.ContactlessFrontend()
File "trunk\nfc\clf.py", line 50, in init
raise LookupError("couldn't find any usable nfc reader")
LookupError: couldn't find any usable nfc reader


Imported from Launchpad using lp2gh.

poll(socket, "recv") returns true but recv(socket) returns None

I ran into a bug while using the NPP server. It uses this code to read data:

        while nfc.llcp.poll(socket, "recv"):
            data += nfc.llcp.recv(socket)

But I got this exception:

Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/local/Python/lib/python2.6/threading.py", line 525, in __bootstrap_inner
self.run()
File "/usr/local/Python/lib/python2.6/threading.py", line 477, in run
self.__target(_self.__args, *_self.__kwargs)
File "/Users/andre/Dropbox/cmu/thesis/code/vmachine/nfcpy/nfc/npp/server.py", line 47, in serve
data += nfc.llcp.recv(socket)
TypeError: cannot concatenate 'str' and 'NoneType' objects

So it seems that poll() returned true, so there was something to read, but recv() returned None.


Imported from Launchpad using lp2gh.

Reader broken?

I have two NFC readers, see https://i.imgur.com/bzmcAqu.jpg

Both are detected on Ubuntu Utopic as:

Bus 003 Device 0xy: ID 072f:2200 Advanced Card Systems, Ltd

Where device number 0xy increases when pluging in the other device. The one on the left isn't working properly. The green LED is blinking when connected. Looking at /var/log/sys the differences are minimal. See for left reader in image

Dec 9 14:33:06 *** kernel: [ 512.430663] usb 3-1: new full-speed USB device number 11 using xhci_hcd
Dec 9 14:33:06 *** kernel: [ 512.562084] usb 3-1: New USB device found, idVendor=072f, idProduct=2200
Dec 9 14:33:06 *** kernel: [ 512.562095] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Dec 9 14:33:06 *** kernel: [ 512.562101] usb 3-1: Product: CCID USB Reader
Dec 9 14:33:06 *** kernel: [ 512.562106] usb 3-1: Manufacturer:
Dec 9 14:33:06 *** mtp-probe: checking bus 3, device 11: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1"
Dec 9 14:33:06 *** mtp-probe: bus: 3, device: 11 was not an MTP device

and the right reader:

Dec 9 14:33:46 *** kernel: [ 552.023415] usb 3-1: new full-speed USB device number 12 using xhci_hcd
Dec 9 14:33:46 *** kernel: [ 552.155217] usb 3-1: New USB device found, idVendor=072f, idProduct=2200
Dec 9 14:33:46 *** kernel: [ 552.155227] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Dec 9 14:33:46 *** kernel: [ 552.155233] usb 3-1: Product: ACR122U PICC Interface
Dec 9 14:33:46 *** kernel: [ 552.155238] usb 3-1: Manufacturer: ACS
Dec 9 14:33:46 *** kernel: [ 552.155798] usb 3-1: ep 0x81 - rounding interval to 256 microframes, ep desc says 400 microframes
Dec 9 14:33:46 *** mtp-probe: checking bus 3, device 12: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1"
Dec 9 14:33:46 *** mtp-probe: bus: 3, device: 12 was not an MTP device

One can see that Product and Manufacturer and ep 0x81 (?) differs.

Output of the left reader for tagtool.py show is:

nfcpy-0.9.1$ python examples/tagtool.py show
[nfc.clf] searching for reader with path 'usb'
Traceback (most recent call last):
  File "examples/tagtool.py", line 475, in
    TagTool().run()
  File "/home/_/nfcpy-0.9.1/examples/cli.py", line 283, in run
    while self.run_once() and self.options.loop:
  File "/home/
/nfcpy-0.9.1/examples/cli.py", line 230, in run_once
    try: clf = nfc.ContactlessFrontend(device)
  File "/home/**
/nfcpy-0.9.1/nfc/clf.py", line 105, in init
    if path and not self.open(path):
  File "/home/_/nfcpy-0.9.1/nfc/clf.py", line 156, in open
    self.dev = nfc.dev.connect(path)
  File "/home/
/nfcpy-0.9.1/nfc/dev/init.py", line 64, in connect
    device = driver.init(usb)
  File "/home/**
/nfcpy-0.9.1/nfc/dev/acr122.py", line 121, in init
    chipset = Chipset(transport)
  File "/home/***/nfcpy-0.9.1/nfc/dev/acr122.py", line 46, in init
    log.error("{0} not supported, need 2.xx".format(frame[10:]))
UnboundLocalError: local variable 'frame' referenced before assignment

and the right reader is:

nfcpy-0.9.1$ python examples/tagtool.py show
[nfc.clf] searching for reader with path 'usb'
[nfc.clf] using ACS ACR122U PICC Interface at usb:003:012
[main] touch a tag
[nfc.dev] Driver.set_communication_mode() should be implemented.
Type2Tag ATQ=0200 SAK=18 UID=***

For this I didn't had to add the udev rules or modprobe blacklist to get it working.

Ubuntu Utopic 14.10 had installed:
python 2.7.8-1
libnfc5:amd64 1.7.1-1
python-usb 0.4.3-1


Imported from Launchpad using lp2gh.

Card emulation not working again

Since I failed to setup the LLPC, I switched back to the card emulation method. However, the card emulation seems not working again. I am using adafruit pn532 with Raspi 2

import nfc

sensf_res = bytearray.fromhex('01 03FEFFE011223344 01E0000000FFFF00 12FC')
def on_startup(target):
target.brty = "212F"
target.sensf_res = sensf_res
return target

clf = nfc.ContactlessFrontend('tty:AMA0:pn532')
clf.connect(rdwr={'on_startup': on_startup})

I tried running this code on Raspi, and read it with my Android Phone and another Pi as reader, neither of these works.
Anyone has any idea? Really need some help here!

having trouble with SCL3711

after your changes this morning I tried to use SCL3711. I am getting following error

Traceback (most recent call last):
File "tagtool.py", line 266, in
main()
File "tagtool.py", line 200, in main
clf = nfc.ContactlessFrontend()
File "/home/gsridhara/NFC-dev/nfcpy/nfc/clf.py", line 45, in init
try: self.dev = device()
File "/home/gsridhara/NFC-dev/nfcpy/nfc/dev/pn53x.py", line 237, in init
self.dev = pn53x.search()
File "/home/gsridhara/NFC-dev/nfcpy/nfc/dev/pn53x.py", line 60, in search
try: return pn53x_usb(dev)
File "/home/gsridhara/NFC-dev/nfcpy/nfc/dev/pn53x.py", line 138, in init
self.dh.setConfiguration(dev.configurations[0])
File "/usr/local/lib/python2.7/dist-packages/usb/legacy.py", line 252, in setConfiguration
self.dev.set_configuration(configuration)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 530, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 92, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
AttributeError: 'NoneType' object has no attribute 'bConfigurationValue'
gsridhara@GS-Notebook:~/NFC-dev/nfcpy/examples$ python helloworld.py
Traceback (most recent call last):
File "helloworld.py", line 65, in
main()
File "helloworld.py", line 32, in main
clf = nfc.ContactlessFrontend()
File "/home/gsridhara/NFC-dev/nfcpy/nfc/clf.py", line 45, in init
try: self.dev = device()
File "/home/gsridhara/NFC-dev/nfcpy/nfc/dev/pn53x.py", line 237, in init
self.dev = pn53x.search()
File "/home/gsridhara/NFC-dev/nfcpy/nfc/dev/pn53x.py", line 60, in search
try: return pn53x_usb(dev)
File "/home/gsridhara/NFC-dev/nfcpy/nfc/dev/pn53x.py", line 138, in init
self.dh.setConfiguration(dev.configurations[0])
File "/usr/local/lib/python2.7/dist-packages/usb/legacy.py", line 252, in setConfiguration
self.dev.set_configuration(configuration)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 530, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 92, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
AttributeError: 'NoneType' object has no attribute 'bConfigurationValue'


Imported from Launchpad using lp2gh.

bitcoin URI is not transferred correctly over NFC

Hi Stephen

I'm working on some Bitcoin-related hardware device implementation that includes NFC, and what I need to do with NFC is to send bitcoin URI over it.
I've tested it with beam.py test script and found that http:// URIs work fine, but bitcoin: URI is failing. I've tried debugging it and managed to fix this, although I'm not fully understanding what was the problem, so I doubt that my code is good enough for pull request.
So what I did is this:

in beam.py:

def run_send_link_action(args, llc):
    # sp = nfc.ndef.SmartPosterRecord(args.uri)
    # if args.title:
    #     sp.title = args.title
    sp = nfc.ndef.UriRecord(args.uri)
    send_message(args, llc, nfc.ndef.Message(sp))

in uri_record.py:

@property
def data(self):
    # for i, p in enumerate(protocol_strings):
    #     if i > 0 and self.uri.startswith(p):
    #         return chr(i) + self.uri[len(p):]
    # else:
    #     return "\x00"
    return  "\x00"+self.uri

(commented parts are what was there before)

with this fix bitcoin URI processes fine via NFC and calls relevant application on the phone side to handle it.
You can get more data on bitcoin URI at https://en.bitcoin.it/wiki/URI_Scheme

Regards,
Alex


Imported from Launchpad using lp2gh.

Type2Tag.sector_select makes tag unresponsive

Originally raised as question https://answers.launchpad.net/nfcpy/+question/285533.

With an NXP NTAG I2C, when selecting sector 3 and then reading into the session register pages yields unrecoverable timeout error. Also just selecting sector 3 and then selecting sector 0 yields unrecoverable timeout error, here in the first half of the sector_select(0) call.


Imported from Launchpad using lp2gh.

nfcpy does not use the command timeouts specified by the PMM of the target

When communicating with a Tag Type 3 target, the PMM values of this target are not used by the library. This is an issue in case the response times of the target are lower than the predefined values in nfcpy (e.g. when communicating with a NFC Dynamic Tag that is attached to an Arduino or similar).


Imported from Launchpad using lp2gh.

input/output error while waiting for ack issue after 1st successful run

I have a board with i.mx6 UL processor and running yocto linux. Whenever I try out the following command to read tag
python tagtool.py -v --device tty:mxc1:pn532 show
it runs successfully but after reading tag it shows error
[nfc.clf.pn532] input/output error while waiting for ack
and after this error the above mentioned command fails every time with following error
no contact less reader available
every time till we reset the pn532 module power.

Running following command on successful run (1st time after power reset)
python tagtool.py -d nfc.tag --reltime -v --device tty:mxc1:pn532

shows following output

1360 ms [main] enable debug output for 'nfc.tag'
1362 ms [nfc.clf] searching for reader on path tty:mxc1:pn532
1633 ms [nfc.clf] using PN532v1.6 at /dev/ttymxc1
** waiting for a tag **
8002 ms [nfc.tag] trying to activate 106A sdd_res=E63AE5D5 sel_res=08 sens_res=0400
8004 ms [nfc.tag] trying type 2 tag activation for 106A
Type2Tag ID=E63AE5D5
8016 ms [nfc.tag.tt2] read ndef data
8018 ms [nfc.tag.tt2] read pages 0 to 3
8020 ms [nfc.tag.tt2] >> 3000 (0.005000s)
8049 ms [nfc.tag.tt2] << 04 (0.027840s)
8051 ms [nfc.tag.tt2] received nak response
8092 ms [nfc.tag.tt2] first four memory pages were unreadable
Memory Dump:
8094 ms [nfc.tag.tt2] read pages 0 to 3
8096 ms [nfc.tag.tt2] >> 3000 (0.005000s)
8129 ms [nfc.tag.tt2] << 04 (0.031544s)
8131 ms [nfc.tag.tt2] received nak response
8172 ms [nfc.tag.tt2] read pages 1 to 4
8174 ms [nfc.tag.tt2] >> 3001 (0.005000s)
8209 ms [nfc.tag.tt2] << 04 (0.032929s)
8211 ms [nfc.tag.tt2] received nak response
8252 ms [nfc.tag.tt2] read pages 2 to 5
8254 ms [nfc.tag.tt2] >> 3002 (0.005000s)
8289 ms [nfc.tag.tt2] << 04 (0.033529s)
8291 ms [nfc.tag.tt2] received nak response
8332 ms [nfc.tag.tt2] read pages 3 to 6
8334 ms [nfc.tag.tt2] >> 3003 (0.005000s)
8369 ms [nfc.tag.tt2] << 04 (0.033435s)
8371 ms [nfc.tag.tt2] received nak response
8412 ms [nfc.tag.tt2] read pages 4 to 7
8414 ms [nfc.tag.tt2] >> 3004 (0.005000s)
8449 ms [nfc.tag.tt2] << 04 (0.033399s)
8451 ms [nfc.tag.tt2] received nak response
000: ?? ?? ?? ?? (UID0-UID2, BCC0)
001: ?? ?? ?? ?? (UID3-UID6)
002: ?? ?? ?? ?? (BCC1, INT, LOCK0-LOCK1)
003: ?? ?? ?? ?? (OTP0-OTP3)
8603 ms [nfc.clf.pn532] input/output error while waiting for ack

While same pn532 module work ok with normal pc every time without any error.

nfcpy stops sending queries to RC-S380

I've hit a problem that I believe is caused by a race condition when using a Sony RC-S380.

In the attached USB packet log, nfcpy stops polling the NFC hardware at packet 283 (which is the last USB Bulk out transfer).

This bug only appears is very specific cases:

On a Gigabyte J1900N-D3V motherboard, we have never seen it.

On a Intel i7 laptop, it happens rarely (maybe one time in 50)

On a Intel i5, it appears nearly every time when logging is turned off in nfcpy.

With logging turned on, the Intel i5 machine works about half the time.

These tests are using exactly the same software and OS image.

I'm using the NFC reader in tag emulation mode, to send data to an Android phone (although I doubt that is relevant for the problem).

We are using the following revision:

revno: 268
committer:
branch nick: trunk
timestamp: Wed 2015-11-25 12:01:37 +0100
message: Sony RC-S330 does not support listen as Type 4A Target

Here is the output from the python logging:

INFO Setting up NFC
INFO searching for reader on path usb
DEBUG using pyusb version 1.x
DEBUG path matches '^(usb|)$'
DEBUG loading rcs380 driver for usb:054c:06c1
DEBUG firmware version 1.11
DEBUG package data format 1.00
DEBUG firmware version 1.11
INFO using SONY RC-S380/S NFC Port-100 v1.11 at usb:001:005
DEBUG connect('llcp',)
INFO Setting up Bluetooth, and then car dealer
DEBUG connect options after startup: llcp
INFO Setting up Car Dealer scanner
INFO Scanning for a car dealer access point: car_dealer
INFO Checking wifi status...
DEBUG listen 1.000 seconds for DEP
DEBUG listen_dep for 1.000 sec
DEBUG nfca_params 01015e2ac640
DEBUG nfcf_params 01fe4b5305cc4d700000000000000000ffff
DEBUG wait 1000 ms for activation
DEBUG sense 106A atr_req=D4000D408A75CC20412D73B40000003246666D01011103020003040132070103
DEBUG sense 106A
DEBUG polling for NFC-A technology
DEBUG found None
DEBUG sense 106A
DEBUG polling for NFC-A technology
DEBUG found None
DEBUG listen 1.000 seconds for DEP
DEBUG listen_dep for 1.000 sec
DEBUG nfca_params 010154b7e540
DEBUG nfcf_params 01febe183d0116c30000000000000000ffff
DEBUG wait 1000 ms for activation
DEBUG sense 106A atr_req=D40082F5BBB1771FC28B77580000003246666D01011103020003040132070103
DEBUG sense 106A
DEBUG polling for NFC-A technology
DEBUG found None
DEBUG sense 106A
DEBUG polling for NFC-A technology
DEBUG found None
DEBUG listen 1.000 seconds for DEP
DEBUG listen_dep for 1.000 sec
DEBUG nfca_params 01014e299840
DEBUG nfcf_params 01fe3e437fba250f0000000000000000ffff
DEBUG wait 1000 ms for activation


Imported from Launchpad using lp2gh.

Communication fails with PN532 on UART

I have tried to read a NFC tag with my PN532 plugged the UART of my raspberry pi.

It works fine with nfc-poll from the nfclib.
Nevertheless, with nfcpy, cloned today (14 august), it crashes with the following error message :

pi@raspberrypi ~/nfcpy $ python examples/helloworld.py

INFO:nfc.clf:searching for reader with path 'tty:AMA0:pn53x'
INFO:nfc.clf:using NXP PN532 at /dev/ttyAMA0
Please touch a tag to send a hello to the world
WARNING:nfc.dev:Driver.set_communication_mode() should be implemented.
WARNING:nfc.dev.pn53x:[PN53x Error 0x13] Format error during RF communication

Reproduction steps :
 * with PN532 on UART
 * change nfc.ContactlessFrontend('tty:AMA0:pn53x') in hellopword.py
 * launch the helloword script
 * scan a tag


Imported from Launchpad using lp2gh.

RC-S380 needs to set usb configuration on OSX

After connecting SONY RC-S380 to Mac OS 10.9 (Mavericks), the device is shown up in the output of 'system_profiler SPUSBDataType' as

RC-S380/P:

      Product ID: 0x06c3
      Vendor ID: 0x054c  (Sony Corporation)
      Version:  1.11
      Serial Number: 0122616
      Speed: Up to 12 Mb/sec
      Manufacturer: SONY
      Location ID: 0x04100000 / 4
      Current Available (mA): 500
      Current Required (mA): Unknown (Device has not been configured)

Since RC-S380 "has not been configured" yet, nfcpy didn't detect the device.

So I revert the changes made in revision 204 of trunk, RC-S380 works flawlessly again.


Imported from Launchpad using lp2gh.

USBERROR: Connection timed out

I get this while running helloworld.py

-110
Traceback (most recent call last):
  File "nfcTest.py", line 46, in
    main()
  File "nfcTest.py", line 34, in main
    tag = clf.poll()
  File "/home/islamhassan/Development/python/sooft/loyalityNFC/nfc/clf.py", line 79, in poll
    target = self.dev.poll(protocol_data)
  File "/home/islamhassan/Development/python/sooft/loyalityNFC/nfc/dev/pn53x.py", line 337, in poll
    target = poll()
  File "/home/islamhassan/Development/python/sooft/loyalityNFC/nfc/dev/pn53x.py", line 347, in poll_nfca
    rsp = self.dev.in_list_passive_target("106A", "")
  File "/home/islamhassan/Development/python/sooft/loyalityNFC/nfc/dev/pn53x.py", line 209, in in_list_passive_target
    rsp_data = self.command(0x4A, cmd_data, timeout=1000)
  File "/home/islamhassan/Development/python/sooft/loyalityNFC/nfc/dev/acr122_usb.py", line 45, in command
    self.bus.write(frame)
  File "/home/islamhassan/Development/python/sooft/loyalityNFC/nfc/dev/pn53x_usb.py", line 65, in write
    self.dh.bulkWrite(self.usb_out, frame)
usb.USBError: Connection timed out

The only modifications I did was removing the french and german records.
I'm using ACR122U-AU and ACR122T-E2


Imported from Launchpad using lp2gh.

PN532 Unresponsive After One Successful Scan

My setup:
Raspberry Pi 2 running Raspbian with a PN532 Breakout Board connected using the USB to FTDI cable sold by Adafruit.

Success case #1:
Using NFC Tools version 0.10.0, running tagtool.py, I am able to successfully read MIFARE Ultralight C tags.

Example:

$ python examples/tagtool.py --device tty:USB0:pn532
[nfc.clf] searching for reader on path tty:USB0:pn532
[nfc.clf] using PN532v1.6 at /dev/ttyUSB0
** waiting for a tag **
Type2Tag 'NXP NTAG213' ID=04C461224B3F80
NDEF Capabilities:
  readable  = yes
  writeable = yes
  capacity  = 137 byte
  message   = 3 byte
NDEF Message:
record 1
  type   = ''
  name   = ''
  data   = ''

Success case #2:
If I downgrade to version 0.9.2, I am able to successfully read MIFARE Ultralight C tags, using a script as follows

import nfc

def on_connected(tag):
        print(tag)

clf = nfc.ContactlessFrontend("tty:USB0:pn53x")
clf.connect(rdwr={'on-connect': on_connected})

Note the use of the pn53x driver, not sure if that's significant.

Failure Case:
If, however, using nfcpy 0.10.0 I try to run the same script above except with pn532 in place of pn53x, I am able to read a tag successfully exactly once.

pi@raspberry ~/nfcpy $ python test.py
Type2Tag 'NXP NTAG213' ID=04C461224B3F80
pi@raspberry ~/nfcpy $ python test.py
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    clf = nfc.ContactlessFrontend("tty:USB0:pn532")
  File "/home/pi/nfcpy/nfc/clf/__init__.py", line 72, in __init__
    if path and not self.open(path):
  File "/home/pi/nfcpy/nfc/clf/__init__.py", line 146, in open
    self.device = device.connect(path)
  File "/home/pi/nfcpy/nfc/clf/device.py", line 104, in connect
    device = driver.init(tty)
  File "/home/pi/nfcpy/nfc/clf/pn532.py", line 366, in init
    if (transport.read(timeout=100) == Chipset.ACK and
  File "/home/pi/nfcpy/nfc/clf/transport.py", line 127, in read
    raise IOError(errno.ETIMEDOUT, os.strerror(errno.ETIMEDOUT))
IOError: [Errno 110] Connection timed out

After this happens, tagtool, the script in success case #2, and nfc-poll are all also unable to read tags from the PN532 until I unplug the USB to Serial adapter from the Pi and plug it back in.


Imported from Launchpad using lp2gh.

IndexError when restarting LLCP session without removing SCL3711

Developing a SNEP server for communicating with the Galaxy Nexus, I've been getting the following error for a while. It occurs when I close and start a new LLCP connection, without removing the device in the mean time (the reader is an SCM SCL3711).

searching for a usable reader
searching for a usb bus reader
Exception in thread Thread-5:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner
self.run()
File "/usr/local/lib/python2.7/dist-packages/nfc/llcp/llc.py", line 296, in run
try: data = self.mac.exchange(pdu.to_string(), recv_timeout)
File "/usr/local/lib/python2.7/dist-packages/nfc/dep.py", line 56, in exchange
data = self._dev.dep_exchange(data, timeout)
File "/usr/local/lib/python2.7/dist-packages/nfc/dev/pn53x.py", line 449, in dep_exchange
status, data_in = self.dev.in_data_exchange(0x01, data, timeout)
File "/usr/local/lib/python2.7/dist-packages/nfc/dev/pn53x.py", line 241, in in_data_exchange
rsp = self.command(0x40, chr(tg) + data_out, timeout)
File "/usr/local/lib/python2.7/dist-packages/nfc/dev/pn53x.py", line 152, in command
if frame[3] == 255 and frame[4] == 255:
IndexError: bytearray index out of range

I've temporarily fixed it by adding the following check to pn53x.py:152, although I'm not sure of the consequences to the rest of the system:

    if len(frame) < 5:
        raise FrameError("invalid frame length, too short")

At least this frame error is caught.


Imported from Launchpad using lp2gh.

Problem with Ras pi 3 with pn532

I just upgraded my pi 3 to the latest Rasbian. It turns out that they have make change to the device tree. There is no tty:S0 now and back to tty:AMA0

During llc.connect() sometimes a thread is left dangling

This is the output of nfcpy:

2011-07-26 17:10:44,491 - nfc.llcp.tco - DEBUG - 1866 - tco.py:341 - DLC (16,None) LISTEN dequeue CC PDU
2011-07-26 17:10:44,491 - nfc.llcp.llc - DEBUG - 1866 - llc.py:279 - SEND 16 -> 33 CC MIU=128 RW=2
2011-07-26 17:10:44,492 - nfc.dev.pn53x - DEBUG - 1866 - pn53x.py:200 - write 8 byte
0000: d4 40 01 85 90 05 01 02 .@......
2011-07-26 17:10:44,558 - nfc.dev.pn53x - DEBUG - 1866 - pn53x.py:220 - read 92 byte
0000: d5 41 00 43 21 00 01 00 00 00 01 01 00 00 00 4c .A.C!..........L
0010: d2 13 36 61 70 70 6c 69 63 61 74 69 6f 6e 2f 6d ..6application/m
0020: 54 72 6f 63 6f 73 7b 22 63 22 3a 22 67 53 58 6a Trocos{"c":"gSXj
0030: 36 61 59 41 45 4b 65 50 50 45 6f 71 43 72 6c 73 6aYAEKePPEoqCrls
0040: 70 70 4e 36 6e 56 50 41 72 4f 79 68 76 39 4d 50 ppN6nVPArOyhv9MP
0050: 70 5a 44 4b 69 52 77 3d 5c 6e 22 7d pZDKiRw=\n"}
2011-07-26 17:10:44,559 - nfc.llcp.llc - DEBUG - 1866 - llc.py:290 - RECV 33 -> 16 I N(S)=0 N(R)=0 LEN=86 SDU=0100000001010000004cd213366170706c69636174696f6e2f6d54726f636f737b2263223a226753586a36615941454b655050456f7143726c7370704e366e565041724f796876394d50705a444b6952773d5c6e227d
2011-07-26 17:10:44,559 - nfc.llcp.tco - DEBUG - 1866 - tco.py:341 - DLC (16,33) ESTABLISHED enqueue I PDU
2011-07-26 17:10:44,560 - nfc.llcp.tco - DEBUG - 1866 - tco.py:341 - DLC (16,33) ESTABLISHED voluntary ack DLC 16 <-> 33 ESTABLISHED RW(R)=1 V(S)=0 V(SA)=0 RW(L)=2 V(R)=1 V(RA)=0
2011-07-26 17:10:44,560 - nfc.llcp.llc - DEBUG - 1866 - llc.py:279 - SEND 16 -> 33 RR N(R)=1
2011-07-26 17:10:44,560 - nfc.dev.pn53x - DEBUG - 1866 - pn53x.py:200 - write 6 byte
0000: d4 40 01 87 50 01 [email protected].
2011-07-26 17:10:44,566 - nfc.dev.pn53x - DEBUG - 1866 - pn53x.py:220 - read 3 byte
0000: d5 41 0a .A.
2011-07-26 17:10:44,566 - nfc.llcp.llc - DEBUG - 1866 - llc.py:282 - in exchange => IOError [Errno 10] hardware error
2011-07-26 17:10:44,566 - nfc.llcp.llc - INFO - 1866 - llc.py:286 - shutdown on link disruption
2011-07-26 17:10:44,566 - nfc.llcp.llc - DEBUG - 1866 - llc.py:253 - closing service access point 16
2011-07-26 17:10:44,567 - nfc.llcp.llc - DEBUG - 1866 - llc.py:95 - shutdown socket DLC 16 <-> None LISTEN RW(R)=None V(S)=0 V(SA)=0 RW(L)=2 V(R)=0 V(RA)=0
2011-07-26 17:10:44,567 - nfc.llcp.tco - DEBUG - 1866 - tco.py:341 - DLC (None,None) LISTEN close()
2011-07-26 17:10:44,567 - nfc.llcp.llc - DEBUG - 1866 - llc.py:95 - shutdown socket DLC 16 <-> 33 ESTABLISHED RW(R)=1 V(S)=0 V(SA)=0 RW(L)=2 V(R)=1 V(RA)=1
2011-07-26 17:10:44,567 - nfc.llcp.tco - DEBUG - 1866 - tco.py:341 - DLC (None,33) ESTABLISHED close()
2011-07-26 17:10:44,570 - nfc.llcp.tco - DEBUG - 1866 - tco.py:341 - DLC (None,33) SHUTDOWN close()
2011-07-26 17:10:44,570 - nfc.llcp.tco - DEBUG - 1866 - tco.py:341 - DLC (None,None) SHUTDOWN close()
2011-07-26 17:10:44,571 - nfc.llcp.llc - DEBUG - 1866 - llc.py:253 - closing service access point 1
2011-07-26 17:10:44,571 - nfc.llcp.llc - DEBUG - 1866 - llc.py:253 - closing service access point 0
2011-07-26 17:10:44,571 - nfc.llcp.llc - DEBUG - 1866 - llc.py:335 - llc run thread terminated

Stack trace:
#4 0x080e0721 in call_function (f=

Frame 0xa0d556c, for file /usr/lib/python2.6/threading.py, line 239, in wait (self=<_Condition(_Condition__lock=<_RLock(_Verbose__verbose=False, _RLock__owner=None, _RLock__block=<thread.lock at remote 0xb745e6e0>, _RLock__count=0) at remote 0x9f5f52c>, acquire=<instancemethod at remote 0x987cb6c>, _is_owned=<instancemethod at remote 0x9f60d9c>, _release_save=<instancemethod at remote 0x987ce8c>, release=<instancemethod at remote 0x987ccfc>, _acquire_restore=<instancemethod at remote 0x9f60a04>, _Verbose__verbose=False, _Condition__waiters=[<thread.lock at remote 0xb745e6f0>]) at remote 0x9f5f72c>, timeout=None, waiter=<thread.lock at remote 0xb745e6f0>, saved_state=(2, -1254732944)), throwflag=0) at ../Python/ceval.c:3750

#5 PyEval_EvalFrameEx (f=

Frame 0xa0d556c, for file /usr/lib/python2.6/threading.py, line 239, in wait (self=<_Condition(_Condition__lock=<_RLock(_Verbose__verbose=False, _RLock__owner=None, _RLock__block=<thread.lock at remote 0xb745e6e0>, _RLock__count=0) at remote 0x9f5f52c>, acquire=<instancemethod at remote 0x987cb6c>, _is_owned=<instancemethod at remote 0x9f60d9c>, _release_save=<instancemethod at remote 0x987ce8c>, release=<instancemethod at remote 0x987ccfc>, _acquire_restore=<instancemethod at remote 0x9f60a04>, _Verbose__verbose=False, _Condition__waiters=[<thread.lock at remote 0xb745e6f0>]) at remote 0x9f5f72c>, timeout=None, waiter=<thread.lock at remote 0xb745e6f0>, saved_state=(2, -1254732944)), throwflag=0) at ../Python/ceval.c:2412

#6 0x080e2507 in PyEval_EvalCodeEx (co=0xb71f9410, globals=

{'current_thread': <function at remote 0xb7209f0c>, '_BoundedSemaphore': <type at remote 0x972c344>, 'currentThread': <function at remote 0xb7209f0c>, '_Timer': <type at remote 0x972cb2c>, '_format_exc': <function at remote 0xb71f18ec>, 'Semaphore': <function at remote 0xb7209304>, 'activeCount': <function at remote 0xb720a02c>, '_profile_hook': None, '_sleep': <built-in function sleep>, '_trace_hook': None, 'ThreadError': <type at remote 0x970fdfc>, '_enumerate': <function at remote 0xb720a064>, '_start_new_thread': <built-in function start_new_thread>, 'wraps': <function at remote 0xb71fde9c>, 'BoundedSemaphore': <function at remote 0xb720956c>, '_shutdown': <instancemethod at remote 0xb740861c>, '__all__': ['activeCount', 'active_count', 'Condition', 'currentThread', 'current_thread', 'enumerate', 'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', 'Timer', 'setprofile', 'settrace', 'local', 'stack_size'], '_Event': <type at remote 0x972c7fc>, 'active_count': <function at remote 0xb720a02c...(truncated), locals=0x0, args=0xa0d53dc, argcount=1, kws=0xa0d53e0, kwcount=0, defs=0xb72077d8, defcount=1, closure=0x0) at ../Python/ceval.c:3000

#7 0x080e098b in fast_function (f=

Frame 0xa0d529c, for file /mnt/code/vmachine/nfcpy/nfc/llcp/tco.py, line 123, in recv (self=<DataLinkConnection(lock=<_RLock(_Verbose__verbose=False, _RLock__owner=None, _RLock__block=<thread.lock at remote 0xb745e6e0>, _RLock__count=0) at remote 0x9f5f52c>, send_buf=1, recv_miu=128, send_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cd4c>, _is_owned=<instancemethod at remote 0x9f609dc>, _release_save=<instancemethod at remote 0x987cdec>, release=<instancemethod at remote 0x987cd74>, _acquire_restore=<instancemethod at remote 0x987ccd4>, _Verbose__verbose=False, _Condition__waiters=[]) at remote 0x9f5f6cc>, send_win=None, recv_queue=<collections.deque at remote 0x9f5d144>, addr=32, recv_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cb6c>, _is_owned=<instancemethod at remote 0x9f60d9c>, _release_save=<instancemethod at remote 0x987ce8c>, release=<instancemethod at remote 0x987ccfc>, _acquire_restore=<instancemethod at remote 0x9f60a04>, _Ver...(truncated), throwflag=0) at ../Python/ceval.c:3846

#8 call_function (f=

Frame 0xa0d529c, for file /mnt/code/vmachine/nfcpy/nfc/llcp/tco.py, line 123, in recv (self=<DataLinkConnection(lock=<_RLock(_Verbose__verbose=False, _RLock__owner=None, _RLock__block=<thread.lock at remote 0xb745e6e0>, _RLock__count=0) at remote 0x9f5f52c>, send_buf=1, recv_miu=128, send_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cd4c>, _is_owned=<instancemethod at remote 0x9f609dc>, _release_save=<instancemethod at remote 0x987cdec>, release=<instancemethod at remote 0x987cd74>, _acquire_restore=<instancemethod at remote 0x987ccd4>, _Verbose__verbose=False, _Condition__waiters=[]) at remote 0x9f5f6cc>, send_win=None, recv_queue=<collections.deque at remote 0x9f5d144>, addr=32, recv_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cb6c>, _is_owned=<instancemethod at remote 0x9f60d9c>, _release_save=<instancemethod at remote 0x987ce8c>, release=<instancemethod at remote 0x987ccfc>, _acquire_restore=<instancemethod at remote 0x9f60a04>, _Ver...(truncated), throwflag=0) at ../Python/ceval.c:3771

---Type to continue, or q to quit---
#9 PyEval_EvalFrameEx (f=

Frame 0xa0d529c, for file /mnt/code/vmachine/nfcpy/nfc/llcp/tco.py, line 123, in recv (self=<DataLinkConnection(lock=<_RLock(_Verbose__verbose=False, _RLock__owner=None, _RLock__block=<thread.lock at remote 0xb745e6e0>, _RLock__count=0) at remote 0x9f5f52c>, send_buf=1, recv_miu=128, send_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cd4c>, _is_owned=<instancemethod at remote 0x9f609dc>, _release_save=<instancemethod at remote 0x987cdec>, release=<instancemethod at remote 0x987cd74>, _acquire_restore=<instancemethod at remote 0x987ccd4>, _Verbose__verbose=False, _Condition__waiters=[]) at remote 0x9f5f6cc>, send_win=None, recv_queue=<collections.deque at remote 0x9f5d144>, addr=32, recv_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cb6c>, _is_owned=<instancemethod at remote 0x9f60d9c>, _release_save=<instancemethod at remote 0x987ce8c>, release=<instancemethod at remote 0x987ccfc>, _acquire_restore=<instancemethod at remote 0x9f60a04>, _Ver...(truncated), throwflag=0) at ../Python/ceval.c:2412

#10 0x080e18b0 in fast_function (f=

Frame 0xa0e3374, for file /mnt/code/vmachine/nfcpy/nfc/llcp/tco.py, line 424, in connect (self=<DataLinkConnection(lock=<_RLock(_Verbose__verbose=False, _RLock__owner=None, _RLock__block=<thread.lock at remote 0xb745e6e0>, _RLock__count=0) at remote 0x9f5f52c>, send_buf=1, recv_miu=128, send_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cd4c>, _is_owned=<instancemethod at remote 0x9f609dc>, _release_save=<instancemethod at remote 0x987cdec>, release=<instancemethod at remote 0x987cd74>, _acquire_restore=<instancemethod at remote 0x987ccd4>, _Verbose__verbose=False, _Condition__waiters=[]) at remote 0x9f5f6cc>, send_win=None, recv_queue=<collections.deque at remote 0x9f5d144>, addr=32, recv_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cb6c>, _is_owned=<instancemethod at remote 0x9f60d9c>, _release_save=<instancemethod at remote 0x987ce8c>, release=<instancemethod at remote 0x987ccfc>, _acquire_restore=<instancemethod at remote 0x9f60a04>, _...(truncated), throwflag=0) at ../Python/ceval.c:3836

#11 call_function (f=

Frame 0xa0e3374, for file /mnt/code/vmachine/nfcpy/nfc/llcp/tco.py, line 424, in connect (self=<DataLinkConnection(lock=<_RLock(_Verbose__verbose=False, _RLock__owner=None, _RLock__block=<thread.lock at remote 0xb745e6e0>, _RLock__count=0) at remote 0x9f5f52c>, send_buf=1, recv_miu=128, send_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cd4c>, _is_owned=<instancemethod at remote 0x9f609dc>, _release_save=<instancemethod at remote 0x987cdec>, release=<instancemethod at remote 0x987cd74>, _acquire_restore=<instancemethod at remote 0x987ccd4>, _Verbose__verbose=False, _Condition__waiters=[]) at remote 0x9f5f6cc>, send_win=None, recv_queue=<collections.deque at remote 0x9f5d144>, addr=32, recv_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cb6c>, _is_owned=<instancemethod at remote 0x9f60d9c>, _release_save=<instancemethod at remote 0x987ce8c>, release=<instancemethod at remote 0x987ccfc>, _acquire_restore=<instancemethod at remote 0x9f60a04>, _...(truncated), throwflag=0) at ../Python/ceval.c:3771

#12 PyEval_EvalFrameEx (f=

Frame 0xa0e3374, for file /mnt/code/vmachine/nfcpy/nfc/llcp/tco.py, line 424, in connect (self=<DataLinkConnection(lock=<_RLock(_Verbose__verbose=False, _RLock__owner=None, _RLock__block=<thread.lock at remote 0xb745e6e0>, _RLock__count=0) at remote 0x9f5f52c>, send_buf=1, recv_miu=128, send_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cd4c>, _is_owned=<instancemethod at remote 0x9f609dc>, _release_save=<instancemethod at remote 0x987cdec>, release=<instancemethod at remote 0x987cd74>, _acquire_restore=<instancemethod at remote 0x987ccd4>, _Verbose__verbose=False, _Condition__waiters=[]) at remote 0x9f5f6cc>, send_win=None, recv_queue=<collections.deque at remote 0x9f5d144>, addr=32, recv_ready=<_Condition(_Condition__lock=<...>, acquire=<instancemethod at remote 0x987cb6c>, _is_owned=<instancemethod at remote 0x9f60d9c>, _release_save=<instancemethod at remote 0x987ce8c>, release=<instancemethod at remote 0x987ccfc>, _acquire_restore=<instancemethod at remote 0x9f60a04>, _...(truncated), throwflag=0) at ../Python/ceval.c:2412

#13 0x080e18b0 in fast_function (f=

Frame 0xa0e3084, for file /mnt/code/vmachine/nfcpy/nfc/llcp/llc.py, line 490, in connect (self=<LogicalLinkControl(_Thread__ident=-1271518352, _Thread__block=<_Condition(_Verbose__verbose=False, _Condition__lock=<thread.lock at remote 0xb745e640>, acquire=<built-in method acquire of thread.lock object at remote 0xb745e640>, _Condition__waiters=[], release=<built-in method release of thread.lock object at remote 0xb745e640>) at remote 0x9f5e92c>, _Thread__name='Thread-2', _Thread__daemonic=False, lock=<_RLock(_Verbose__verbose=False, _RLock__owner=None, _RLock__block=<thread.lock at remote 0xb745e650>, _RLock__count=0) at remote 0x9f5e96c>, snl={'urn:nfc:sn:snep': 4, 'urn:nfc:sn:ip': 2, 'urn:nfc:sn:sdp': 1, 'com.android.npp': 16, 'urn:nfc:sn:obex': 3}, cfg={'recv-lto': 1500, 'send-miu': 128, 'send-agf': False, 'send-lto': 1000, 'send-lsc': 3, 'recv-miu': 1024, 'recv-wks': 3, 'send-wks': 1}, _Thread__started=<_Event(_Verbose__verbose=False, _Event__flag=True, _Event__cond=<_Condition(_Verbose__verbose=False, _C...(truncated), throwflag=0) at ../Python/ceval.c:3836

---Type to continue, or q to quit---q

I haven't managed to reproduce it, it happens from time to time, but maybe this is all that is needed to find the bug. What I'm doing is using the NPP server to receive a message, which I do, and then use the npp client to send another message. What I think is happening is that the LLCP link goes down before I try to send the message...


Imported from Launchpad using lp2gh.

Problem with the llcp

Dear Stephen:
I am trying to use the llcp funtion of your library. I used your sample code to setup one side of the nfc. However, this only return some error. Can you take a look for me?

`import nfc
import nfc.llcp
def server(socket):
# note that this server only accepts one connection
# for multiple connections spawn a thread per accept
while True:
client = socket.accept()
while True:
message = client.recv()
print("Client said: {0}".format(message))
client.send("It's me!")

def client(socket):
socket.connect( 'urn:nfc:xsn:nfcpy.org:test-service' )
socket.send("Hi there!")
message = socket.recv()
print("Server said: {0}".format(message))

def startup(clf,llc):
socket = nfc.llcp.Socket(llc, nfc.llcp.DATA_LINK_CONNECTION)
socket.bind( 'urn:nfc:xsn:nfcpy.org:test-service' )
print("server bound to SAP {0}".format(socket.getsockname()))
socket.listen()
Thread(target=server, args=(socket,)).start()
return llc

def connected(llc):
socket = nfc.llcp.Socket(llc, nfc.llcp.DATA_LINK_CONNECTION)
Thread(target=client, args=(socket,)).start()
return True

clf = nfc.ContactlessFrontend('tty:AMA0:pn532')
clf.connect(llcp={'on-startup': startup, 'on-connect': connected})`

`INFO:nfc.clf:searching for reader on path tty:AMA0:pn532

INFO:nfc.clf:using PN532v1.6 at /dev/ttyAMA0

TypeError Traceback (most recent call last)
in ()
31
32 clf = nfc.ContactlessFrontend('tty:AMA0:pn532')
---> 33 clf.connect(llcp={'on-startup': startup, 'on-connect': connected})

/usr/local/lib/python2.7/dist-packages/nfcpy-latest-py2.7.egg/nfc/clf/init.pyc in connect(self, **options)
504
505 llc = nfc.llcp.llc.LogicalLinkController(**llcp_options)
--> 506 llc = llcp_options'on-startup'
507 if isinstance(llc, nfc.llcp.llc.LogicalLinkController):
508 llcp_options['llc'] = llc

TypeError: startup() takes exactly 2 arguments (1 given)
`

documentation LLCP example doesn't work

Hi Stephen

This probably is not an actual bug of the lib itself, but rather a docs problem, yet it heavily affects library usability. Or I'm just doing something wrong. Anyway, I've gone to incorporating NFC into my application, and found that LLCP example not really working. The very last piece of code from here http://nfcpy.readthedocs.org/en/latest/topics/get-started.html#work-with-a-peer says:

import nfc, nfc.snep, threading
clf = nfc.ContactlessFrontend('usb')
connected = lambda llc: threading.Thread(target=llc.run()).start()
llc = clf.connect(llcp={'on-connect': connected})
snep = nfc.snep.SnepClient(llc)
snep.put(nfc.ndef.Message(nfc.ndef.SmartPosterRecord("http://nfcpy.org")))
clf.close()

I've copied it as is into a separate helloworld.py file expecting it to work as is, but it doesn't. It starts NFC, and connection is recognized by the phone, but URL is not transferred.

I've tried to look into beam.py for other sources of simple enough example to start with, yet that script seems to be much more complex to start with unfortunately.

So what's wrong with this script from the manual, or what I'm doing wrong?

Regards
Alex

PS: the actual script on that manual page has a typo, a closing quote is missing on the second line around 'usb' string, and this typo is copypasted in few other places on the same manual page.


Imported from Launchpad using lp2gh.

Exception when closing LLCP socket from both sides simultaneously.

If an LLCP socket is closed by both, acceptor and connector at the same time, in LLCP occurs an uncaught exception "IndexError: pop from an empty deque".

LLCP log and error traceback are listed below.

LLCP: Incoming request for closing socket with id 138735756.
LLCP: Socket in the table: DLC 16 <-> 32 ESTABLISHED RW(R)=1 V(S)=1 V(SA)=0 RW(L)=1 V(R)=1 V(RA)=1
DLC (16,32) close() in state ESTABLISHED
RECV 0 -> 0 SYMM
DLC (16,32) dequeued DISC PDU
SEND 16 -> 32 DISC
RECV 32 -> 16 DISC
DLC (16,32) enqueue DISC
SEND 0 -> 0 SYMM
From this moment on, only symmetry packets are exchanged and there are no further entries considering this socket but an exception occurs:

File "./dbus_readerwriter.py", line 702, in CloseSocket
socket.close()
File ".../nfcpy/nfc/llcp/tco.py", line 515, in close
pdu = super(DataLinkConnection, self).recv()
File ".../nfcpy/nfc/llcp/tco.py", line 122, in recv
return self.recv_queue.popleft()
IndexError: pop from an empty deque


Imported from Launchpad using lp2gh.

Unable to connect to ACR122U-A2 / ACR122U-A9

Hi,

I've been having some issues connecting with the ACR122U-A2. I managed to get the Helloworld to sort of find it after pasting in the entire device ID, but then I get the error below.

Any ideas, or more diagnostics I can provide?

I'm on revno: 205.

Thanks so much!

examples/helloworld.py:
[snip]
57 def main(self):
58 with nfc.ContactlessFrontend('usb:072f:2200') as clf:
[snip]

: lsusb
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 032: ID 0424:2512 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 147e:2020 Upek
Bus 001 Device 004: ID 04f2:b2ea Chicony Electronics Co., Ltd
Bus 003 Device 033: ID 0424:2602 Standard Microsystems Corp. USB 2.0 Hub
Bus 003 Device 034: ID 0424:2228 Standard Microsystems Corp. 9-in-2 Card Reader
Bus 003 Device 045: ID 072f:2200 Advanced Card Systems, Ltd
Bus 003 Device 036: ID 05ac:1006 Apple, Inc. Hub in Aluminum Keyboard
Bus 003 Device 037: ID 046d:c016 Logitech, Inc. Optical Wheel Mouse
Bus 003 Device 038: ID 05ac:024f Apple, Inc.
sgithens@sgithens-ThinkPad-X230:/code/gpii-nfcpy/nfcpy$
: sudo python examples/helloworld.py
INFO:nfc.clf:searching for reader with path 'usb:072f:2200'
Traceback (most recent call last):
File "examples/helloworld.py", line 70, in
HelloWorld().main()
File "examples/helloworld.py", line 58, in main
with nfc.ContactlessFrontend('usb:072f:2200') as clf:
File "/home/sgithens/code/gpii-nfcpy/nfcpy/nfc/clf.py", line 105, in init
if path and not self.open(path):
File "/home/sgithens/code/gpii-nfcpy/nfcpy/nfc/clf.py", line 156, in open
self.dev = nfc.dev.connect(path)
File "/home/sgithens/code/gpii-nfcpy/nfcpy/nfc/dev/init.py", line 64, in connect
device = driver.init(usb)
File "/home/sgithens/code/gpii-nfcpy/nfcpy/nfc/dev/acr122.py", line 92, in init
chipset = Chipset(transport)
File "/home/sgithens/code/gpii-nfcpy/nfcpy/nfc/dev/acr122.py", line 50, in init
super(Chipset, self).init(transport)
File "/home/sgithens/code/gpii-nfcpy/nfcpy/nfc/dev/pn53x.py", line 126, in init
ic, ver, rev, support = self.get_firmware_version()
File "/home/sgithens/code/gpii-nfcpy/nfcpy/nfc/dev/pn53x.py", line 243, in get_firmware_version
else: ic, ver, rev, support = data
ValueError: too many values to unpack
sgithens@sgithens-ThinkPad-X230:
/code/gpii-nfcpy/nfcpy$


Imported from Launchpad using lp2gh.

Does nfcpy always polls when waiting for a NFC tag?

We use the following code to wait for a NFC tag but we are unsure on how nfcpy handles this underneath...

import nfc

def connected(tag):
    """ Print the NFC Tag information"""

clf = nfc.ContactlessFrontend('tty:AMA0:pn532')

timeOut = lambda: time.time() - started > (5 * 60) 
started = time.time()
nfcTag = clf.connect(rdwr={'on-connect': connected}, terminate=timeOut)

""" Do something with the tag here"""

We are concerned that nfcpy always poll waiting for a tag, thus the power consumption on our device is not optional.

Any feedback will be really appreciated...

Error protecting NTAG213 tags

Just tried to make protected tags (readable and unreadable) but got the following error messages:

TypeError: transceive() got an unexpected keyword argument 'rlen'

I can still read it afterwards (after using the readable setting) but it is not possible to renew the password or load new data on it.

The NFC reader I use is the ITEAD PN532 via UART.

pn53x_usb does not catch timeout errors

The read() method of pn53x_usb raises all USB errors except "No error" ones.
When polling for tags or when init as target, USB raises a timeout error that is not catched. Old version of pn53x_usb returned None in case of all USB exceptions and it worked.

Another pont is that when receiving nothing from pn53x during poll request, method command() raises a NoResponse error that is not catched in poll methods that IMO should expect this case.

A patch is attached with corrected read() and adapted in_list_passive_target(). Possibly, in_jump_for_dep() also has to be corrected.


Imported from Launchpad using lp2gh.

acr122 driver throws exception on frame length check

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] <<< 800a000000000002810041435231323255323133
Traceback (most recent call last):
File "tagtool.py", line 479, in
TagTool().run()
File "/home/joggler/nfc/nfcpy/examples/cli.py", line 283, in run
while self.run_once() and self.options.loop:
File "/home/joggler/nfc/nfcpy/examples/cli.py", line 230, in run_once
try: clf = nfc.ContactlessFrontend(device)
File "/home/joggler/nfc/nfcpy/nfc/clf.py", line 105, in init
if path and not self.open(path):
File "/home/joggler/nfc/nfcpy/nfc/clf.py", line 156, in open
self.dev = nfc.dev.connect(path)
File "/home/joggler/nfc/nfcpy/nfc/dev/init.py", line 64, in connect
device = driver.init(usb)
File "/home/joggler/nfc/nfcpy/nfc/dev/acr122.py", line 121, in init
chipset = Chipset(transport)
File "/home/joggler/nfc/nfcpy/nfc/dev/acr122.py", line 40, in init
reader_version = self.ccid_xfr_block(bytearray.fromhex("FF00480000"))
File "/home/joggler/nfc/nfcpy/nfc/dev/acr122.py", line 81, in ccid_xfr_block
if len(frame) != 10 + struct.unpack("<I", frame[1:5])[0]:
struct.error: unpack requires a string argument of length 4


Imported from Launchpad using lp2gh.

SCL3711 reader disappears from USB bus after running LLCP example

After running an LLCP example the reader disappears form the USB bus. Running the same example again produces the error:

$ ./llcp-test-client.py --quirks android -t 9
searching for a usb tty reader
searching for a usb bus reader
Traceback (most recent call last):
File "./llcp-test-client.py", line 658, in
main()
File "./llcp-test-client.py", line 541, in main
clf = nfc.ContactlessFrontend(options.device)
File "/Users/andre/work/nfcpy/nfc/clf.py", line 50, in init
raise LookupError("couldn't find any usable nfc reader")
LookupError: couldn't find any usable nfc reader

I then have to remove and insert the USB reader to have it detected.


Imported from Launchpad using lp2gh.

doesn't work on my Adafruit PN532

I have a PN532 board (http://www.adafruit.com/products/364) hooked up to my Raspberry Pi. I've confirmed it's working using the utilities that come with libnfc:

pi@raspberrypi ~ $ ./libnfc-1.7.0-rc7/examples/nfc-poll
/home/pi/libnfc-1.7.0-rc7/examples/.libs/lt-nfc-poll uses libnfc 1.7.0-rc7
NFC reader: pn532_uart:/dev/ttyAMA0 opened
NFC device will poll during 30000 ms (20 pollings of 300 ms for 5 modulations)
ISO/IEC 14443A (106 kbps) target:
ATQA (SENS_RES): 00 04
UID (NFCID1): 8d 57 c4 78
SAK (SEL_RES): 08

However, when I install nfcpy and run the tagtool.py, I get the following error:

pi@raspberrypi ~/nfcpy $ ./examples/tagtool.py
[nfc.clf] searching for reader with path 'usb'
[nfc.clf] no reader found at 'usb'
[main] no contactless reader found


Imported from Launchpad using lp2gh.

IOError: [Errno 19] No such device

I'm occasionally seen this error message on my R-Pi... How can I prevent it or fix it?

Traceback (most recent call last):
File "mainNfc.py", line 221, in
clf = nfc.ContactlessFrontend('tty:AMA0:pn532')
File "/home/pi/nfcpy/nfc/clf/init.py", line 72, in init
if path and not self.open(path):
File "/home/pi/nfcpy/nfc/clf/init.py", line 146, in open
self.device = device.connect(path)
File "/home/pi/nfcpy/nfc/clf/device.py", line 104, in connect
device = driver.init(tty)
File "/home/pi/nfcpy/nfc/clf/pn532.py", line 368, in init
raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))
IOError: [Errno 19] No such device

Thanks,

-Juan


Imported from Launchpad using lp2gh.

dev.transport._PYUSB1_get_string() parameter mismatch.

I installed nfcmy/trunk and run "exaples/tagtool.py show" as written in the getting started, but got an TypeError.
I found the exception is raised in dev.transport._PYUSB1_get_string(), which calls usb.util.get_string() with 4 arguments.
In pyusb 1.0.0b2, however, util.get_string() takes only 3 arguments.
Though libusb's get_descriptor takes 4 arguments, pyusb always passes length=255 and does not require the length as a parameter.


Imported from Launchpad using lp2gh.

Wrong record verified in handover-test-client 08

In handover-test-client, test 08, there's a check on the first message (record=message[0]) to see if it is a 'ac' record. As the Hr frame includes a 'cr', the first record of the Hs should be a 'cr', and so, you must check message[1] instead..


Imported from Launchpad using lp2gh.

error reading type 1 tag with more than 120 bytes

Tested with a Broadcom Topaz512 Sample card. If the tag conatans a message that needs more than the 120 byte static memory layout structure, reading fails with IndexError "bytearray index out of range" in getitem().


Imported from Launchpad using lp2gh.

Uncaught exception when link breaks during connect().

In the phase when the LLCP client waits for CC or DM PDU, broken link causes closing of sockets. This leads to notifying receiver thread in class TransmissionControllObject that tries thereafter to pop data from empty receiving queue:

File "./dbus_readerwriter.py", line 1015, in _connect
nfc.llcp.connect(socket, service_name)
File ".../nfcpy/nfc/llcp/init.py", line 114, in connect
return _llc.connect(sid, dest)
File ".../nfcpy/nfc/llcp/llc.py", line 478, in connect
socket.connect(dest)
File ".../nfcpy/nfc/llcp/tco.py", line 421, in connect
pdu = super(DataLinkConnection, self).recv()
File ".../nfcpy/nfc/llcp/tco.py", line 122, in recv
return self.recv_queue.popleft()
IndexError: pop from an empty deque


Imported from Launchpad using lp2gh.

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

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
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 "", line 1, in
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
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


Imported from Launchpad using lp2gh.

WindowsError: [Error 126] when import nfc in nfcpy 0.11.1

everything is fine with nfcpy 0.10.0, however when i use the latest release nfcpy 0.11.1, i got the following error.

D:>cd nfcpy-0.11.1

D:\nfcpy-0.11.1>python
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on w
32
Type "help", "copyright", "credits" or "license" for more information.

import nfc
Traceback (most recent call last):
File "", line 1, in
File "nfc__init__.py", line 28, in
from clf import ContactlessFrontend
File "nfc\clf__init__.py", line 35, in
from . import device
File "nfc\clf\device.py", line 39, in
from . import transport
File "nfc\clf\transport.py", line 32, in
import usb1 as libusb
File "C:\Python27\lib\site-packages\usb1.py", line 60, in
import libusb1
File "C:\Python27\lib\site-packages\libusb1.py", line 193, in
libusb = loadLibrary()
File "C:\Python27\lib\site-packages\libusb1.py", line 167, in loadLibrary
return dll_loader('libusb-1.0' + suffix, **loader_kw)
File "C:\Python27\lib\ctypes__init
.py", line 365, in init
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126]

I'm quite sure everything works well if i switch to nfcpy 0.10.0, see the below traces.
D:\nfcpy-0.10.0>python
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

import nfc
clf = nfc.ContactlessFrontend('usb')
print clf
SONY RC-S380/S on usb:000:001
exit()

Need help with LLCP

I am trying to make two Raspberry Pi talk though llpc.
At one end:
import nfc
import nfc.llcp
import threading

def server(socket):
message, address = socket.recvfrom()
socket.sendto("It's me!", address)
socket.close()

def on_startup(llc):
socket = nfc.llcp.Socket(llc, nfc.llcp.LOGICAL_DATA_LINK)
socket.bind(address=32)
threading.Thread(target=server, args=(socket,)).start()
return llc

llcp_options = {
'on-startup': on_startup,
#'on-connect': on_connect,
}
with nfc.ContactlessFrontend('tty:AMA0:pn532') as clf:
clf.connect(llcp=llcp_options)
print("link terminated")

The other end:
import nfc
import nfc.llcp
import threading

def client(socket):
socket.sendto("Hi there!", address=32)
socket.close()

def on_connect(llc):
socket = nfc.llcp.Socket(llc, nfc.llcp.LOGICAL_DATA_LINK)
threading.Thread(target=client, args=(socket,)).start()
return True

llcp_options = {

'on-startup': on_startup,

'on-connect': on_connect,

}
with nfc.ContactlessFrontend('tty:AMA0:pn532') as clf:
clf.connect(llcp=llcp_options)
print("link terminated")

This may work for the first time after reboot, but after that:
link terminated
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(_self.__args, *_self.__kwargs)
File "caonima.py", line 6, in server
message, address = socket.recvfrom()
File "build/bdist.linux-armv7l/egg/nfc/llcp/socket.py", line 141, in recvfrom
return self.llc.recvfrom(self._tco)
File "build/bdist.linux-armv7l/egg/nfc/llcp/llc.py", line 819, in recvfrom
return socket.recvfrom()
File "build/bdist.linux-armv7l/egg/nfc/llcp/tco.py", line 296, in recvfrom
raise err.Error(errno.EPIPE)
Error: nfc.llcp.Error: [EPIPE] Broken pipe

Really need some help here!

ACS ACR122U on Windows

I followed the instructions for installing the necessary libs on Windows, and on the first page of the tutorial I get the error below.

I'm in a bit of a bind to get this working by the end of the month... would appreciate any help or advice. Is there another straightforward means to read the device? I looked in the ACS SDK but don't understand it. Seems very concerned with registers and bits on the wire. I just need to display a message when a card is swiped.

>>> import nfc
>>> cls =  nfc.ContactlessFrontend()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Programs\Python26\lib\site-packages\nfc\clf.py", line 42, in __init__
    self.dev = dev.connect(path)
  File "C:\Programs\Python26\lib\site-packages\nfc\dev\__init__.py", line 102, in connect
    return driver.init(dev)
  File "C:\Programs\Python26\lib\site-packages\nfc\dev\acr122_usb.py", line 107, in init
    bus = acr122_usb(usb_dev)
  File "C:\Programs\Python26\lib\site-packages\nfc\dev\acr122_usb.py", line 71, in __init__
    self.dh.claimInterface(interface[0])

usb.USBError: libusb0-dll:err [claim_interface] could not claim interface 0, win
 error: The device does not recognize the command.

Imported from Launchpad using lp2gh.

No NDEF on new version of dev-tags

I use the dev-tags branch of nfcpy, because of the ntag21X authentication support. On a daily basis, I use a Sony RC-S380 with ntag216 tags on a Windows 8 laptop. I had been using revision 370, and upon updating to the latest rev 431 today, all my tags are reading with an ndef of None.

When I switched back to 370, standard functionality returned.

I've switched back to 370, so that I can resume work, but, if you need more details for debugging, feel free to give me a shout.


Imported from Launchpad using lp2gh.

phdc-test-agent: MIU size not present in CONNECT frame

phdc-test-agent / p2p Test 03 (fragmentation):
The initial handshake specifies a MIUX set to 1024 (PN533: d7 64 fa 00 00 00 00 00 32 46 66 6d 01 01 11 02 02 03 80 03 02 00 03 04 01 32 07 01 03 6b 00) but the real value used is 128 (default) (As this default value (128) is not specified in CONNECT frame (cf pdu.py (282) ), the target is not aware of this change and send 1024 bytes, instead of 128
A workaround is to force the MIUX information (pdu.py - line: 280)
def to_string(self):
data = ""

  •    if self.miu > 128:
    
  •        miux = self.miu - 128
    
  •   miux = self.miu - 128
    

Imported from Launchpad using lp2gh.

npp-test-server failure

I'm using SCM SCL3711 Reader with Nexus S to send npp message from smartphone to reader on a win7 system.

1: When I use npp-test-server I mostly get the following log entries:
searching for a usb bus reader
trying reader at usb port bus-0:.\libusb0-0002--0x04e6-0x5591
chipset is a PN533 version 2.7
ATR_RES(nfcid3=521b05e8f6c1a00cc0be, did=00, bs=00, br=00, to=0e, pp=32, gb=46666d01011003020001040196)
running on Initiator
recv-lto: 1500
recv-miu: 1024
recv-wks: 3
send-agf: True
send-lsc: 3
send-lto: 1000
send-miu: 128
send-wks: 1
npp server bound to port 16
shutdown on link disruption
nfc.llcp.Error: [EPIPE] Broken pipe

Is the connection so sensitive that it mostly gets broken?

2: About every 20th try I get the following log entries:
searching for a usb bus reader
trying reader at usb port bus-0:.\libusb0-0002--0x04e6-0x5591
chipset is a PN533 version 2.7
ATR_RES(nfcid3=521b05e8f6c1a00cc0be, did=00, bs=00, br=00, to=0e, pp=32, gb=46666d01011003020001040196)
running on Initiator
recv-lto: 1500
recv-miu: 1024
recv-wks: 3
send-agf: True
send-lsc: 3
send-lto: 1000
send-miu: 128
send-wks: 1
npp server bound to port 16
accepting CONNECT from SAP 33
serving npp client on remote sap 33
ndef push server got message
ord() expected string of length 1, but Record found
shutdown on link disruption
nfc.llcp.Error: [EPIPE] Broken pipe

In this case I got data from smartphone but then there is a bug in npp-test-server I think. It should be line 43.

Many thanks, MDummy


Imported from Launchpad using lp2gh.

No handlers could be found for logger "nfc.tt2"

I tried running the helloworld.py on an unformatted mifare ultralight tag, when I touch the tag, I get 'No handlers could be found for logger "nfc.tt2" '. It works fine with cards that have been written to before.


Imported from Launchpad using lp2gh.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.