Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Interfacing an NFC breakout with Raspberry Pi in Python

There is a python specific module for that (nfcpy) and libnfc isn't listed as a requirement.

The documentation there is also nice and thorough.

Would probably be easier than attempting to use libnfc via python.
Rather than being specific have you tried doing:
Code
$ python
>> import nfc
>> clfusb = nfc.ContactlessFrontend('usb')
>> clftty = nfc.ContactlessFrontend('tty')
>> clfcom = nfc.ContactlessFrontend('com')
>> clfudp = nfc.ContactlessFrontend('udp')
>> findnfc = ("{}\n{}\n{}\n{}".format(clfusb, clftty, clfcom, clfudp))
>> print(findnfc)
To see if it can connect automatically?

If that doesn't find it.. I'm not sure what is wrong.
(Oct 2, 2015 06:45 PM)Clutch Wrote:  The "clf" lines failed except for clftty. I skipped the findnfc line and did "print clftty" which output:
Code
on /dev/ttyAMA

That's great news right? Where is the nfc library that I'm importing? I'm trying to find documentation on what methods I can use, but it doesn't look like it's from the actual python language.

Its probably located in site-packages in the python/Lib directory.

When you installed nfcpy it became importable, just need to add: import nfc to the top of any scripts you write using it and you're golden.

And yeah you would need to look up nfcpy's specific functions and such. You can find those here: http://nfcpy.org/latest/topics/get-start...n-a-reader
Redirect? So it couldn't find a certain file/directory and you needed to create a symlink? Strange.

As far as I know nfcpy is installed the same way in windows and OSX, its just a python module after all so: pip install nfcpy will do the trick

You could make a simple shell script for linux/OSX to create the symlink if it turns out to be needed every time and grab the python module at the same time.

Heck you could even get your id reading script setup and have an alias made for it ready to go so you can just do: scriptname args rather than need to type: python fullscriptname args every time.

Windows would of course require python to be installed manually.. and maybe OSX (not something I mess with)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[C#] by gigajewApr 27, 2021 01:34 AM 1 184 Apr 27, 2021 01:34 AM
Last Post: SaketSaket
[Python] by 0u1lawSep 6, 2020 02:52 AM 3 220 Sep 6, 2020 02:52 AM
Last Post: Argonaut.exe