Topic: Pynfc: Python wrapper for libnfc

Hi everybody,

Just to let you know that I've started a project called pynfc, designed to offer python bindings for the libnfc code.  They currently offer good support transceiving both bits and bytes in an intuitive fashion as both initiator and responder.  It comes with a small amount of example code that will offer a Mifare read request for a block, and verify the that the returned tag nonce is as expected.

It currently doesn't offer the full support that libnfc does, most notably it works primarily with 14443A tags only (although adding support for other card types shouldn't be difficult, I don't really have any others to test out).  It also currently won't allow choosing which reader to read from, since that was all added in libnfc-1.3.3 and I haven't had time to catch up on it.  5:)

>= python-2.6
>= libnfc-1.3.1

Website & Bug tracker:

If you'd like to help work on the code, or have any problems with it, do feel free to get in touch with me (or file a bug report).  Hope it's of some use...

Mike  5:)

2 (edited by thomasrichter 2010-04-28 12:59:34)

Re: Pynfc: Python wrapper for libnfc

Hi Mike,
pynfc is great work!
I am looking for something like your code for a while.
I downloaded and compiled it and the example works well. but I can not select a MifareUltralight tag.

import pynfc
nfc = pynfc.nfc_initiator()

-> get segmentation fault
what is the "data" parameter in select_tag() for?

in meantime I found a way not go into the segmentation foault:
here the console output:
>>> import pynfc
>>> nfc = pynfc.nfc_initiator()
>>> nfc.connect()
>>> nfc.select_tag(pynfc.NM_ISO14443A_106, "\x00")
>>> nfc.get_name()
'ACS ACR 38U-CCID 00 00 / ACR122U102 - PN532 v1.4 (0x07)\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb9\x00\x00\x00\xd0\xe32\x00\x80\xbc!\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00d\x00"\\e[1;5D"\x00 backward-word\x00"\\e[5C"\x00 forward-word\x00"\\e[5D"\x00 backward-word\x00"\\e\\e[C"\x00 forward-word\x00"\\e\\e[D"\x00 backward-word\x00\x00$if'

but it don't deliver the

regards Thomas

3 (edited by rena2019 2013-07-10 19:12:04)

Re: Pynfc: Python wrapper for libnfc

Anybody who has tried to setup pynfc? I have the following problem:

rena@rena:~/Downloads/nfc/pynfc-0.0.4$ python build_ext
running build_ext
building '_nfc' extension
swigging nfc.i to nfc_wrap.c
swig -python -I/usr/include -module nfc -interface _nfc -O -o nfc_wrap.c nfc.i
nfc.i:153: Error: Unable to find 'nfc/nfc.h'
nfc.i:154: Error: Unable to find 'nfc/nfc-types.h'
error: command 'swig' failed with exit status 1