Я пытаюсь использовать плату PN532 (v3) с Arduino UNO и libnf c для моего университетского проекта. Одна проблема, с которой я столкнулся, заключается в том, что libnf c -1.7.1 выдает мне следующую ошибку при вызове nf c -list:
debug libnfc.general log_level is set to 3
debug libnfc.general allow_autoscan is set to false
debug libnfc.general allow_intrusive_scan is set to false
debug libnfc.general 1 device(s) defined by user
debug libnfc.general #0 name: "PN532 NFC Board on Arduino", connstring: "pn532_uart:/dev/ttyUSB0:115200"
nfc-list uses libnfc 1.7.1
debug libnfc.driver.pn532_uart Attempt to open: /dev/ttyUSB0 at 115200 bauds.
debug libnfc.bus.uart Serial port speed requested to be set to 115200 bauds.
debug libnfc.chip.pn53x Diagnose
debug libnfc.chip.pn53x Timeout value: 500
debug libnfc.bus.uart TX: 55 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00
debug libnfc.chip.pn53x SAMConfiguration
debug libnfc.chip.pn53x Timeout value: 1000
debug libnfc.bus.uart TX: 00 00 ff 03 fd d4 14 01 17 00
debug libnfc.bus.uart Timeout!
debug libnfc.driver.pn532_uart Unable to read ACK
error libnfc.driver.pn532_uart pn53x_check_communication error
debug libnfc.chip.pn53x InRelease
debug libnfc.bus.uart TX: 00 00 ff 03 fd d4 52 00 da 00
debug libnfc.bus.uart Timeout!
debug libnfc.driver.pn532_uart Unable to read ACK
debug libnfc.general Unable to open "pn532_uart:/dev/ttyUSB0:115200".
nfc-list: ERROR: Unable to open NFC device: pn532_uart:/dev/ttyUSB0:115200
У меня нет проблем с использованием ридера с Arduino, Я могу загружать эскизы, и читатель взаимодействует с тегами. Читатель находится в режиме SPI, и когда я запускаю nf c -list, светодиоды мигают, поэтому единственное, о чем я могу думать, это какая-то проблема с libnf c.
Я надеюсь, что кто-то сможет помогите, любые предложения будут удивительными! :) Спасибо!
Соединения
PN532 V3
Arduino.1
Arduino.2
Конфигурации файлов
/ etc / nfc / libnf c .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 = false
# 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 = 3
# 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 = "PN532 NFC Board on Arduino"
device.connstring = "pn532_uart:/dev/ttyUSB0:115200"
uartnf c .info
#include <PN532.h>
#define SCK 13
#define MOSI 11
#define SS 10
#define MISO 12
PN532 nfc(SCK, MISO, MOSI, SS);
uint8_t buffer[32];
void setup(void) {
Serial.begin(115200); //460800, 115200
Serial.flush();
nfc.begin();
}
void loop(void) {
int b = Serial.available();
if (b >= 5){
Serial.readBytes((char*)buffer, 5);
if(buffer[0] == 0x55){
//handle wake up case
while(Serial.available() < 5); //wait the command
b = Serial.readBytes((char*)buffer+5, 5);
//send raw command to pn532
//get length of package :
// (PREAMBLE + START + LEN + LCS) + (TFI + DATA[0...n]) + (DCS + POSTAMBLE)
uint8_t l = buffer[8] + 2;
while(Serial.available() < l); //wait the command
//read command from uart
Serial.readBytes((char*)buffer+10, l);
//send raw command to pn532
nfc.sendRawCommandCheckAck(buffer, l+10);
//read pn532 answer
nfc.readRawCommandAnswer(buffer, l+10);
}else{
//normal case
//get length of package :
// (PREAMBLE + START + LEN + LCS) + (TFI + DATA[0...n]) + (DCS + POSTAMBLE)
uint8_t l = buffer[3] + 2;
//read command from uart
//while(Serial.available() < l); //wait the command
//Serial.readBytes((char*)buffer+5, l);
uint8_t br = l;
uint8_t* bufptr = buffer + 5;
while(br){
if(Serial.available()){
*bufptr++ = Serial.read();
--br;
}
}
//send raw command to pn532
nfc.sendRawCommandCheckAck(buffer, l+5);
//read pn532 answer
nfc.readRawCommandAnswer(buffer, l+5);
}
}
}
Использованные ресурсы
http://nfc-tools.org/index.php/Libnfc: Arduino - используется для установки libnf c
https://github.com/gunmetal313/mfocuino - загружен эскиз uartnf c .ino и импортировал библиотеки ( mfocuino / mfocuino-только для чтения / nfcreader / arduino / library / PN532 / ) в IDE Arduino.
Вещи, которые я уже пытался устранить проблему
Почему «Устройство NF C не найдено» с помощью libnf c и PN532 SHIELD
PN532 Невозможно открыть устройство NF C
https://github.com/nfc-tools/libnfc/issues/507
https://forums.adafruit.com/viewtopic.php?f=19&t=58188
https://superuser.com/questions/1409108/nfc-unable-to-open-nfc-device