Libnfc:configuration

From NFC Tools
(Difference between revisions)
Jump to: navigation, search
(Configuration file)
(PN532 device on R-Pi connected using UART)
Line 76: Line 76:
 
  pn532_uart:/dev/ttyAMA0
 
  pn532_uart:/dev/ttyAMA0
 
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
 
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===
 +
pn532_i2c:/dev/i2c-0
 +
Note: to use SPI port on R-Pi, you have to load kernel modules i2c-bcm2708 and i2c-dev:
 +
<br>Edit /etc/modprobe.d/raspi-blacklist.conf and comment: #blacklist i2c-bcm2708
 +
<br>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_i2c:/dev/i2c-1
 +
===PN532 device on R-Pi connected using SPI===
 +
pn532_spi:/dev/spidev0.0:500000
 +
Note: to use SPI port on R-Pi, you have to load kernel module spi-bcm2708:
 +
<br>Edit /etc/modprobe.d/raspi-blacklist.conf and comment: #blacklist spi-bcm2708

Revision as of 23:23, 3 October 2013

Contents

Configuration file

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.

log_level=n

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

Environment variables

Overwriting "allow_autoscan" defined in the configuration:

LIBNFC_AUTO_SCAN=true/false

Overwriting "allow_intrusive_scan" defined in the configuration:

LIBNFC_INTRUSIVE_SCAN=true/false

Overwriting "log_level" defined in the configuration:

LIBNFC_LOG_LEVEL=n

Add a user defined device on top of the list provided through config files:

LIBNFC_DEFAULT_DEVICE="connstring"

Replace all possibly configured device by this one only:

LIBNFC_DEVICE="connstring"

Log levels

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.

LIBNFC_LOG_LEVEL=3 nfc-list

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

Examples:

  • Main log level is NONE and only communication group log is set to DEBUG verbosity (for rx/tx trace): 0+3072
LIBNFC_LOG_LEVEL=3072
  • Main log level is ERROR and DRIVER layer log is set to DEBUG level: 1+768
LIBNFC_LOG_LEVEL=769
  • Main log level is ERROR, DRIVER layer is set to INFO and COMMUNICATION is set to DEBUG: 1+512+3072
LIBNFC_LOG_LEVEL=3585

Connstrings

Examples:

OpenPCD2

pn532_uart:/dev/ttyACM0

Arygon PN531

arygon:/dev/ttyUSB0:9600

Arygon/IDentive

arygon:/dev/ttyS0

PN532 Breakout Board

ie. microbuilder.eu / Adafruit devices

pn532_uart:/dev/ttyUSB0:115200

PN532 device on R-Pi connected using UART

pn532_uart:/dev/ttyAMA0

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

pn532_i2c:/dev/i2c-0

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_i2c:/dev/i2c-1

PN532 device on R-Pi connected using SPI

pn532_spi:/dev/spidev0.0:500000

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

Personal tools
Namespaces

Variants
Actions
Navigation
Documentation
Misc
Toolbox
Partners