手动安装 主要参考https://github.com/nfc-tools/libnfc
1.安装libnfc的依赖:
apt update && apt upgrade
apt install build-essential
安装lrzsz软件 apt install lrzsz
apt install cmake 安装构建工具CMake
apt-get install libusb-dev dh-autoreconf
下面不一定需要的操作,列在这里,只是方便参考:
apt install libusb
apt install libusb-dev
2.下载、解压
用rz把从windows10下载的libnfc-1.8.0.tar.bz2复制到ubuntu的~目录下()
tar -jxvf libnfc-1.8.0.tar.bz2 -C ./
3.Installation
#Additionnally, you may need to grant permissions to your user to drive your device. Under GNU/Linux systems, if you use udev, you could use the provided udev rules. e.g. under Debian, Ubuntu, etc.
sudo cp contrib/udev/93-pn53x.rules /lib/udev/rules.d/
4.Configuration、make、make install
cd libnfc-1.8.0 #注意!!!!首先要进入到待编译、安装的libnfc的源码目录内部。
you can make configuration directory and copy the sample file:
sudo mkdir /etc/nfc
sudo cp libnfc.conf.sample /etc/nfc/libnfc.conf
sudo vi /etc/nfc/libnfc.conf
# Allow device auto-detection (default: true)
# Note: if this auto-detection is disabled, user has to set manually a device
# configuration using file or environment variable
#allow_autoscan = true
# Allow intrusive auto-detection (default: false)
# Warning: intrusive auto-detection can seriously disturb other devices
# This option is not recommended, user should prefer to add manually his device.
#allow_intrusive_scan = false
# Set log level (default: error)
# Valid log levels are (in order of verbosity): 0 (none), 1 (error), 2 (info), 3 (debug)
# Note: if you compiled with --enable-debug option, the default log level is "debug"
#log_level = 1
# Manually set default device (no default)
# To set a default device, you must set both name and connstring for your device
# Note: if autoscan is enabled, default device will be the first device available in device list.
device.name = "microBuilder.eu"
#因为我用的是TTL转USB,所以下面的是正确的设置
device.connstring = "pn532_uart:/dev/ttyUSB1"
To configure multiple devices, you can either modify libnfc.conf or create a file per device in a nfc/devices.d directory: (qzm这步没做)
sudo mkdir -p /etc/nfc/devices.d
printf 'name = "My first device"\nconnstring = "pn532_uart:/dev/ttyACM0"\n' | sudo tee /etc/nfc/devices.d/first.conf
printf 'name = "My second device"\nconnstring = "pn532_uart:/dev/ttyACM1"\n' | sudo tee /etc/nfc/devices.d/second.conf
In order to change the default behavior of the library, the libnfc uses a configuration file located in sysconfdir (as provided to ./configure).
A sample commented file is available in sources: libnfc.conf.sample
If you have compiled using:
./configure --prefix=/usr --sysconfdir=/etc
make
make install
5.测试
Troubleshooting(只列出qzm用到的)
PN533 USB device on Linux >= 3.1:
Since Linux kernel version 3.1, a few kernel-modules must not be loaded in order to use libnfc : "nfc", "pn533" and "pn533_usb". To prevent kernel from loading automatically these modules, you can blacklist them in a modprobe conf file. This file is provided within libnfc archive:
sudo cp contrib/linux/blacklist-libnfc.conf /etc/modprobe.d/blacklist-libnfc.conf