libnfc can use a configuration file for special setups, or features activation.
This file (/etc/nfc/libnfc.conf under GNU/Linux systems) supports some keywords:
To enable/disable device auto-detection feature. Default is "true"
allow_autoscan = true/false
To enable/disable intrusive auto-detection (ie. serial port probing). Default is "false"
allow_intrusive_scan = true/false
To select library verbosity. See corresponding section below about log levels.
To define a user device. See corresponding section below about connstrings.
device.name="My Reader Name" device.connstring="connstring"
This is the recommended method if the user has a not easily detectable device (ie. a serial one).
A sample is provided in the source code as libnfc.conf.sample
It is also possible to define devices using dedicated configuration files and put them into device search directory (/etc/nfc/devices.d under GNU/Linux).
Example for the OpenPCD2: create /etc/nfc/devices.d/openpcd2.conf with:
name = "OpenPCD2" connstring = "pn532_uart:/dev/ttyACM0" optional = true
The keyword "optional" does not mandate the device to be present always (it detects if the reader is indeed present before using it)
If you compile from sources and don't want SYSCONFDIR to be /usr/local/etc, use ./configure --sysconfdir=/etc
Overwriting "allow_autoscan" defined in the configuration:
LIBNFC_AUTO_SCAN=true/false # only present in libnfc >= 1.7.1
Overwriting "allow_intrusive_scan" defined in the configuration:
Overwriting "log_level" defined in the configuration:
Add a user defined device on top of the list provided through config files:
Replace all possibly configured device by this one only:
LIBNFC_DEVICE="connstring" # only present in libnfc >= 1.7.1
Log levels can be defined globally or for a sub-system.
Log levels are:
- 0 none
- 1 error (default)
- 2 info
- 3 debug
If used alone, they apply globally, e.g.
will run the tool with all possible logging being activated.
To enable log only for one (or more) group, you can use this formula:
log_level = NFC_LOG_PRIORITY(main) + NFC_LOG_PRIORITY(group) * 2 ^ (NFC_LOG_GROUP(group) * 2)
with the following groups:
- 1 general
- 2 config
- 3 chip
- 4 driver
- 5 communication
- 6 libusb
- Main log level is NONE and only communication group log is set to DEBUG verbosity (for rx/tx trace): 0+3072
- Main log level is ERROR and DRIVER layer log is set to DEBUG level: 1+768
- Main log level is ERROR, DRIVER layer is set to INFO and COMMUNICATION is set to DEBUG: 1+512+3072
PN532 Breakout Board
ie. microbuilder.eu / Adafruit devices
PN532 device on R-Pi connected using UART
Note: to use UART port on R-Pi, you have to disable linux serial console, cf http://learn.adafruit.com/adafruit-nfc-rfid-on-raspberry-pi/freeing-uart-on-the-pi
PN532 device on R-Pi connected using I2C
Note: to use SPI port on R-Pi, you have to load kernel modules i2c-bcm2708 and i2c-dev:
Edit /etc/modprobe.d/raspi-blacklist.conf and comment: #blacklist i2c-bcm2708
Edit /etc/modules and add a new line: i2c-dev
If you have an R-Pi revision 2.0, the I2C bus #1 is now routed to connector P1 (instead of the I2C bus #0 routed on same connector on initial board revision), so the configuration to use would probably be:
PN532 device on R-Pi connected using SPI
Note: to use SPI port on R-Pi, you have to load kernel module spi-bcm2708:
Edit /etc/modprobe.d/raspi-blacklist.conf and comment: #blacklist spi-bcm2708