Skip to content

ofxNFCReader is an openFrameworks addon to read nfc tags. It is based on libnfc.

Notifications You must be signed in to change notification settings

soixantecircuits/ofxNFCReader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ofxNFCReader

Copyright (c) 2013 Soixante circuits

MIT License.

For information on usage and redistribution, and for a DISCLAIMER OF ALL WARRANTIES, see the file, "LICENSE.txt," in this distribution.

See https://github.com/soixantecircuits/ofxNFCReader for documentation as well as the OF forums.

Description

ofxNFCReader is an openFrameworks addon to read nfc tags. It is based on libnfc.

It is under development.

It has been tested with a ACR122 NFC reader and ISO14443A tags.

It has been tested on linux mint, os x 10.8 and 10.6.

The roadmap is:

  • write tags
  • mutiple devices connected

openFrameworks is a cross platform open source toolkit for creative coding in C++. http://www.openframeworks.cc/

Installation

To use ofxNFCReader, first you need to download and install Open Frameworks.

To get a copy of the repository you can download the source from http://github.com/soixantecircuits/ofxNFCReader or, alternatively, you can use git clone:

git clone git://github.com/soixantecircuits/ofxNFCReader.git

The addon should sit in openFrameworks/addons/ofxNFCReader/.

Running the Example Project

The example projects are in the example folder.

OSX

Xcode3: Open the Xcode project and hit "Build and Run". You might want to choose "Release" instead of "Debug" for faster performance.

Xcode4: Open the Xcode project, select the "ofxNFCReaderExample" scheme, and hit "Run".

Since OS X Lion, the PC/SC Smartcard Daemon (pcscd) recognizes NFC Reader and automatically starts a communication with it.

Therefore, if you see this in the console:

error libnfc.driver.acr122_usb Unable to claim USB interface (Permission denied)

It must be pcscd using your NFC Reader. To claim the device for your program, you can kill the processus like this:

$ sudo launchctl list | grep pcscd
$ sudo kill -9 thePID

or use the oneliner: $ kill $(ps aux | grep '[p]cscd' | awk '{print $2}')

Linux

Install the libusb-1.0 library. On Ubuntu, you can do this with:

sudo apt-get install libusb-1.0-0-dev

Open the Code::Blocks .cbp and hit F9 to build. Optionally, you can build the example with the Makefile.

To run it, use the terminal:

make
cd bin
./example_debug

Also, you should create some udev rules in order to run the app without root privileges. As the root user, write this to /etc/udev/rules.d/51-ACR122.rules (this works on Ubuntu 10.10):

SUBSYSTEM=="usb", SYSFS{idVendor}=="072f", SYSFS{idProduct}=="2200", MODE="0660", GROUP="plugdev"

From Ubuntu 12.10 the correct settings for udev rules are:

SUBSYSTEM=="usb", ATTR{idVendor}=="072f", ATTR{idProduct}=="2200", MODE="0660", GROUP="plugdev"

Windows

Not supported yet.

How to Create a New ofxNFCReader Project

To develop your own project based on ofxNFCReader, simply copy the example project and rename it. You probably want to put it in your apps folder, for example, after copying:

openFrameworks/addons/ofxNFCReader/example/ => openFrameworks/apps/myApps/example/

Then after renaming:

openFrameworks/apps/myApps/myProject/

Mac (Xcode):

Rename the project in Xcode (do not rename the .xcodeproj file in Finder!): XCode Menu->Project->Rename (Xcode3) / Slow double click the project name and rename (Xcode4)

Codeblocks (Win & Linux):

Close Codeblocks and rename the *.cbp and *.workspace files to the same name as the project folder. Open the workspace and readd the renamed project file.

Windows (Visual Studio):

Close Visual Studio and rename the *.sln file. Open the solution, right click on the project in the project broswer and select "Rename ...".

Adding ofxNFCReader to an Existing Project

If you want to add ofxNFCReader to another project, you need to make sure you include the src folder and the :

openFrameworks/addons/ofxNFCReader/src

as well as search paths for the libs (lbnfc, libusb) required by ofxNFCReader.

Mac (Xcode):

In the Xcode project browser:

  • add the ofxNFCReader sources to the project:
    • create a new group "ofxNFCReader"
    • drag these directories from ofxNFCReader into this new group: ofxNFCReader/src & ofxNFCReader/libs
  • add a search path to the libusb headers: ../../../addons/ofxNFCReader/libs/libusb/include/libusb-1.0 to your project Target build settings
    • Xcode3: under Targets->YourApp->Build->Header Search Paths (make sure All Configurations and All Settings are selected) and add the path
    • Xcode4: add the lib path to your Project.xconfig, see the example
  • add the path to the libusb precompiled library: ../../../addons/ofxNFCReader/libs/libusb/osx/libs/usb-1.0.a
    • Xcode3: under Targets->YourApp->Build->Library Search Paths (make sure All Configurations and All Settings are selected) and add the path
    • Xcode4: add the lib path to your Project.xconfig, see the example

Linux (Makefiles & Codeblocks):

Edit the Makefile config files:

  • edit addons.make in your project folder and add the following line to the end of the file:
    ofxNFCReader
  • edit config.make in your project folder and change the lines for USER_LIBS to:
      USER_LIBS = -lusb
      

Notes

Linux: Unable to claim USB interface

If you get an error like Unable to claim USB interface when executing nfc-list, follow these instructions by Romuald Conty (post number 3):

On recent Linux kernel (>= 3.1) you need to prevent modprobe from autoload pn533 and nfc modules. To do that, create /etc/modprobe.d/blacklist-libnfc.conf with this content:

blacklist pn533
blacklist nfc

Then, restart or unplug the device, unload modules (sudo modprobe -r pn533 nfc), then re-plug the devive.

Using multiple NFC Readers

Not supported yet.

Troubleshooting

Developing ofxNFCReader

Feel free to log bug reports and issues to the ofxNFCReader Github page: https://github.com/soixantecircuits/ofxNFCReader/issues

If you wish to help in ofxNFCReader development, please do!

About

ofxNFCReader is an openFrameworks addon to read nfc tags. It is based on libnfc.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published