nfc-tools / ifdnfc Goto Github PK
View Code? Open in Web Editor NEWPC/SC IFD Handler based on libnfc
License: GNU General Public License v3.0
PC/SC IFD Handler based on libnfc
License: GNU General Public License v3.0
I have connected a pn532 board via SPI port. I have successfully installed libnfc and it is able to get detected by nfc-list and nfc-poll.
What do I need to do so that it gets detected by pcsc_scan as well????
What steps will reproduce the problem?
1. use 2 card readers. For example an Cyberjack e-com an an PN533 based device.
What is the expected output? What do you see instead?
expected:
./ifdnfc-activate
Activating ifdnfc with "pn53x_usb:002:019"...
IFD-NFC is active using pn53x_usb:002:019.
get:
/ifdnfc-activate
Activating ifdnfc with "pn53x_usb:002:019"...
Internal error.
What version of the product are you using? On what operating system?
Version: Last from Git.
OS: Fedora 20
Please provide any additional information below.
ifdnfc-activate will not search for the right reader.
It will only use the first reader. In this case the cyberjack.
By remove the first device, it will work.
Debug output of the pcscd when it fails:
03896083 winscard_msg_srv.c:230:ProcessEventsServer() Common channel packet
arrival
00000061 winscard_msg_srv.c:242:ProcessEventsServer()
ProcessCommonChannelRequest detects: 14
00000013 pcscdaemon.c:111:SVCServiceRunLoop() A new context thread creation is
requested: 14
00000106 winscard_svc.c:301:ContextThread() Thread is started: dwClientID=14,
threadContext @0x15dbe20
00000028 winscard_svc.c:319:ContextThread() Received command: CMD_VERSION from
client 14
00000010 winscard_svc.c:331:ContextThread() Client is protocol version 4:3
00000006 winscard_svc.c:351:ContextThread() CMD_VERSION rv=0x0 for client 14
00000115 winscard_svc.c:319:ContextThread() Received command: ESTABLISH_CONTEXT
from client 14
00000026 winscard.c:193:SCardEstablishContext() Establishing Context: 0x26370E1F
00000007 winscard_svc.c:412:ContextThread() ESTABLISH_CONTEXT rv=0x0 for client
14
00000161 winscard_svc.c:319:ContextThread() Received command:
CMD_GET_READERS_STATE from client 14
00000123 winscard_svc.c:319:ContextThread() Received command:
CMD_GET_READERS_STATE from client 14
00000125 winscard_svc.c:319:ContextThread() Received command: CONNECT from
client 14
00000021 winscard.c:235:SCardConnect() Attempting Connect to REINER SCT
cyberJack pp_a2 (0235718372) 00 00 using protocol: 0
00000008 readerfactory.c:745:RFReaderInfo() RefReader() count was: 1
00000006 winscard.c:422:SCardConnect() Direct access: no protocol selected
00000006 winscard.c:429:SCardConnect() hCard Identity: b8189e6
00000023 winscard.c:490:SCardConnect() UnrefReader() count was: 2
00000008 winscard_svc.c:453:ContextThread() CONNECT rv=0x0 for client 14
00000112 winscard_svc.c:319:ContextThread() Received command: CONTROL from
client 14
00000025 readerfactory.c:772:RFReaderInfoById() RefReader() count was: 1
00000022 ifdwrapper.c:461:IFDControl() Card not transacted: 614
00000026 ifdwrapper.c:463:IFDControl() ControlCode: 0x00000001 BytesReturned: 0
00000006 TxBuffer 00
00000003 RxBuffer
00000003 winscard.c:1350:SCardControl() UnrefReader() count was: 2
00000005 winscard_svc.c:652:ContextThread() CONTROL rv=0x8010001F for client 14
00004355 winscard_msg_srv.c:230:ProcessEventsServer() Common channel packet
arrival
00000054 winscard_msg_srv.c:242:ProcessEventsServer()
ProcessCommonChannelRequest detects: 15
00000015 pcscdaemon.c:111:SVCServiceRunLoop() A new context thread creation is
requested: 15
00000095 winscard_svc.c:301:ContextThread() Thread is started: dwClientID=15,
threadContext @0x15dc090
00000027 winscard_svc.c:319:ContextThread() Received command: CMD_VERSION from
client 15
00000010 winscard_svc.c:331:ContextThread() Client is protocol version 4:3
00000005 winscard_svc.c:351:ContextThread() CMD_VERSION rv=0x0 for client 15
00000116 winscard_svc.c:319:ContextThread() Received command: ESTABLISH_CONTEXT
from client 15
00000035 winscard.c:193:SCardEstablishContext() Establishing Context: 0x1C82A064
00000007 winscard_svc.c:412:ContextThread() ESTABLISH_CONTEXT rv=0x0 for client
15
00000089 winscard_svc.c:319:ContextThread() Received command:
CMD_GET_READERS_STATE from client 15
00000084 winscard_svc.c:319:ContextThread() Received command: RELEASE_CONTEXT
from client 15
00000008 winscard.c:204:SCardReleaseContext() Releasing Context: 0x1C82A064
00000006 winscard_svc.c:427:ContextThread() RELEASE_CONTEXT rv=0x0 for client 15
00000099 winscard_svc.c:311:ContextThread() Client die: 15
00000016 winscard_svc.c:933:MSGCleanupClient() Thread is stopping:
dwClientID=15, threadContext @0x15dc090
00000004 winscard_svc.c:939:MSGCleanupClient() Freeing SCONTEXT @0x15dc090
00000757 winscard_svc.c:319:ContextThread() Received command: CONTROL from
client 14
00000028 readerfactory.c:772:RFReaderInfoById() RefReader() count was: 1
00000010 ifdwrapper.c:461:IFDControl() Card not transacted: 614
00000005 ifdwrapper.c:463:IFDControl() ControlCode: 0x00000001 BytesReturned: 0
00000008 TxBuffer 01 12 00 70 6E 35 33 78 5F 75 73 62 3A 30 30 32 3A 30 31 39
00
00000003 RxBuffer
00000003 winscard.c:1350:SCardControl() UnrefReader() count was: 2
00000005 winscard_svc.c:652:ContextThread() CONTROL rv=0x8010001F for client 14
00000354 winscard_svc.c:311:ContextThread() Client die: 14
00000013 winscard.c:204:SCardReleaseContext() Releasing Context: 0x26370E1F
00000005 readerfactory.c:772:RFReaderInfoById() RefReader() count was: 1
00000004 readerfactory.c:772:RFReaderInfoById() RefReader() count was: 2
00000004 winscard.c:850:SCardDisconnect() Active Contexts: 1
00000004 winscard.c:851:SCardDisconnect() dwDisposition: 0
00000007 winscard.c:1043:SCardDisconnect() UnrefReader() count was: 3
00000005 winscard_svc.c:817:MSGRemoveContext() UnrefReader() count was: 2
00000004 winscard_svc.c:933:MSGCleanupClient() Thread is stopping:
dwClientID=14, threadContext @0x15dbe20
00000004 winscard_svc.c:939:MSGCleanupClient() Freeing SCONTEXT @0x15dbe20
Original issue reported on code.google.com by [email protected]
on 1 Feb 2015 at 3:06
Please mention the settings for Raspberry Pi SPI port connected PN532 NFC boards detection by pcsc
Dear ifdnfc community,
My goal is to use my PN532 reader in Java@RPi4
I've setup libnfc
properly with pn532_uart
driver
My /etc/nfc/libnfc.conf
looks like this:
allow_autoscan = true
allow_intrusive_scan = false
log_level = 3
device.name = "IFD-NFC"
device.connstring = "pn532_uart:/dev/ttyUSB0:115200"
and nfc-scan-device
returns:
debug libnfc.general log_level is set to 3
debug libnfc.general allow_autoscan is set to true
debug libnfc.general allow_intrusive_scan is set to false
debug libnfc.general 1 device(s) defined by user
debug libnfc.general #0 name: "IFD-NFC", connstring: "pn532_uart:/dev/ttyUSB0:115200"
nfc-scan-device uses libnfc 1.8.0
debug libnfc.general 0 device(s) found using acr122_usb driver
debug libnfc.general 0 device(s) found using pn53x_usb driver
1 NFC device(s) found:
debug libnfc.driver.pn532_uart Attempt to open: /dev/ttyUSB0 at 115200 baud.
debug libnfc.bus.uart Serial port speed requested to be set to 115200 baud.
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 RX: 00 00 ff 00 ff 00
debug libnfc.chip.pn53x PN53x ACKed
debug libnfc.bus.uart RX: 00 00 ff 02 fe
debug libnfc.bus.uart RX: d5 15
debug libnfc.bus.uart RX: 16 00
debug libnfc.bus.uart TX: 00 00 ff 09 f7 d4 00 00 6c 69 62 6e 66 63 be 00
debug libnfc.bus.uart RX: 00 00 ff 00 ff 00
debug libnfc.chip.pn53x PN53x ACKed
debug libnfc.bus.uart RX: 00 00 ff 09 f7
debug libnfc.bus.uart RX: d5 01
debug libnfc.bus.uart RX: 00 6c 69 62 6e 66 63
debug libnfc.bus.uart RX: bc 00
debug libnfc.chip.pn53x GetFirmwareVersion
debug libnfc.bus.uart TX: 00 00 ff 02 fe d4 02 2a 00
debug libnfc.bus.uart RX: 00 00 ff 00 ff 00
debug libnfc.chip.pn53x PN53x ACKed
debug libnfc.bus.uart RX: 00 00 ff 06 fa
debug libnfc.bus.uart RX: d5 03
debug libnfc.bus.uart RX: 32 01 06 07
debug libnfc.bus.uart RX: e8 00
debug libnfc.chip.pn53x SetParameters
debug libnfc.bus.uart TX: 00 00 ff 03 fd d4 12 14 06 00
debug libnfc.bus.uart RX: 00 00 ff 00 ff 00
debug libnfc.chip.pn53x PN53x ACKed
debug libnfc.bus.uart RX: 00 00 ff 02 fe
debug libnfc.bus.uart RX: d5 13
debug libnfc.bus.uart RX: 18 00
debug libnfc.general "IFD-NFC" (pn532_uart:/dev/ttyUSB0:115200) has been claimed.
- IFD-NFC:
pn532_uart:/dev/ttyUSB0:115200
debug libnfc.chip.pn53x ReadRegister
debug libnfc.bus.uart TX: 00 00 ff 0c f4 d4 06 63 02 63 03 63 0d 63 38 63 3d b0 00
debug libnfc.bus.uart RX: 00 00 ff 00 ff 00
debug libnfc.chip.pn53x PN53x ACKed
debug libnfc.bus.uart RX: 00 00 ff 07 f9
debug libnfc.bus.uart RX: d5 07
debug libnfc.bus.uart RX: 00 00 00 00 00
debug libnfc.bus.uart RX: 24 00
debug libnfc.chip.pn53x PN53X_REG_CIU_TxMode (Defines the transmission data rate and framing during transmission)
debug libnfc.chip.pn53x PN53X_REG_CIU_RxMode (Defines the transmission data rate and framing during receiving)
debug libnfc.chip.pn53x WriteRegister
debug libnfc.bus.uart TX: 00 00 ff 08 f8 d4 08 63 02 80 63 03 80 59 00
debug libnfc.bus.uart RX: 00 00 ff 00 ff 00
debug libnfc.chip.pn53x PN53x ACKed
debug libnfc.bus.uart RX: 00 00 ff 02 fe
debug libnfc.bus.uart RX: d5 09
debug libnfc.bus.uart RX: 22 00
debug libnfc.chip.pn53x InRelease
debug libnfc.bus.uart TX: 00 00 ff 03 fd d4 52 00 da 00
debug libnfc.bus.uart RX: 00 00 ff 00 ff 00
debug libnfc.chip.pn53x PN53x ACKed
debug libnfc.bus.uart RX: 00 00 ff 03 fd
debug libnfc.bus.uart RX: d5 53
debug libnfc.bus.uart RX: 00
debug libnfc.bus.uart RX: d8 00
debug libnfc.general set_property_bool NP_ACTIVATE_FIELD False
debug libnfc.chip.pn53x RFConfiguration
debug libnfc.bus.uart TX: 00 00 ff 04 fc d4 32 01 00 f9 00
debug libnfc.bus.uart RX: 00 00 ff 00 ff 00
debug libnfc.chip.pn53x PN53x ACKed
debug libnfc.bus.uart RX: 00 00 ff 02 fe
debug libnfc.bus.uart RX: d5 33
debug libnfc.bus.uart RX: f8 00
debug libnfc.chip.pn53x PowerDown
debug libnfc.bus.uart TX: 00 00 ff 03 fd d4 16 f0 26 00
debug libnfc.bus.uart RX: 00 00 ff 00 ff 00
debug libnfc.chip.pn53x PN53x ACKed
debug libnfc.bus.uart RX: 00 00 ff 03 fd
debug libnfc.bus.uart RX: d5 17
debug libnfc.bus.uart RX: 00
debug libnfc.bus.uart RX: 14 00
Then I've compiled ifdnfc
and while service pcscd status
gives me:
● pcscd.service - PC/SC Smart Card Daemon
Loaded: loaded (/lib/systemd/system/pcscd.service; indirect; vendor preset: enabled)
Active: active (running) since Thu 2022-02-10 15:30:57 GMT; 17s ago
and my /etc/reader.conf.d/libifdnfc
looks like this:
FRIENDLYNAME "IFD-NFC"
LIBPATH /usr/local/lib/libifdnfc.so
CHANNELID 0
Unfortunately ifdnfc-activate
returns:
debug libnfc.general log_level is set to 3
debug libnfc.general allow_autoscan is set to true
debug libnfc.general allow_intrusive_scan is set to false
debug libnfc.general 1 device(s) defined by user
debug libnfc.general #0 name: "IFD-NFC", connstring: "pn532_uart:/dev/ttyUSB0:115200"
debug libnfc.general 0 device(s) found using acr122_usb driver
debug libnfc.general 0 device(s) found using pn53x_usb driver
Activating ifdnfc with "pn532_uart:/dev/ttyUSB0:115200"...
IFD-NFC is inactive.
I'm already on aarch64 bit, because on 32bit systemifdnfc-activate
was returning Insufficient buffer
My Java program:
import java.util.List;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.TerminalFactory;
public class Simple {
public static void main(String[] args) throws CardException {
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
System.out.println("Terminals: " + terminals);
}
}
returns []
terminals...
What can I do in order to make ifdnfc
"active"?
Kind regards
i'm trying to install ifdnfc to be able to read an nfc from Identity Card, but i have this problem after launch make install -B
ifdnfc has been configured with following options:
Version: 0.1.4
Host: aarch64-unknown-linux-gnu
Compiler: gcc
Preprocessor flags:
Compiler flags: -g -O2 -std=c99
Preprocessor flags:
Linker flags:
Libraries:
LIBNFC_CFLAGS: -I/usr/local/include
LIBNFC_LIBS: -L/usr/local/lib -lnfc -lusb
PCSC_CFLAGS: -I/usr/include/PCSC -pthread
PCSC_LIBS: -lpcsclite
BUNDLE_HOST: Linux
DYN_LIB_EXT: so
configure: creating ./config.status
/bin/bash ./config.status
config.status: creating Makefile
config.status: creating src/Info.plist
config.status: creating src/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
make[2]: uscita dalla directory «/home/nolex/ifdnfc-master»
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -I/usr/include/PCSC -pthread -g -O2 -std=c99 -MT libifdnfc_la-ifd-nfc.lo -MD -MP -MF .deps/libifdnfc_la-ifd-nfc.Tpo -c -o libifdnfc_la-ifd-nfc.lo `test -f 'ifd-nfc.c' || echo './'`ifd-nfc.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -I/usr/include/PCSC -pthread -g -O2 -std=c99 -MT libifdnfc_la-ifd-nfc.lo -MD -MP -MF .deps/libifdnfc_la-ifd-nfc.Tpo -c ifd-nfc.c -fPIC -DPIC -o .libs/libifdnfc_la-ifd-nfc.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/local/include -I/usr/include/PCSC -pthread -g -O2 -std=c99 -MT libifdnfc_la-ifd-nfc.lo -MD -MP -MF .deps/libifdnfc_la-ifd-nfc.Tpo -c ifd-nfc.c -o libifdnfc_la-ifd-nfc.o >/dev/null 2>&1
mv -f .deps/libifdnfc_la-ifd-nfc.Tpo .deps/libifdnfc_la-ifd-nfc.Plo
/bin/bash ../libtool --tag=CC --mode=link gcc -I/usr/local/include -I/usr/include/PCSC -pthread -g -O2 -std=c99 -o libifdnfc.la -rpath /usr/local/lib libifdnfc_la-ifd-nfc.lo -L/usr/local/lib -lnfc -lusb -lpcsclite
libtool: link: rm -fr .libs/libifdnfc.a .libs/libifdnfc.la .libs/libifdnfc.lai .libs/libifdnfc.so .libs/libifdnfc.so.0 .libs/libifdnfc.so.0.0.0
libtool: link: gcc -shared .libs/libifdnfc_la-ifd-nfc.o -L/usr/local/lib /usr/local/lib/libnfc.so -lusb -lpcsclite -pthread -pthread -Wl,-soname -Wl,libifdnfc.so.0 -o .libs/libifdnfc.so.0.0.0
libtool: link: (cd ".libs" && rm -f "libifdnfc.so.0" && ln -s "libifdnfc.so.0.0.0" "libifdnfc.so.0")
libtool: link: (cd ".libs" && rm -f "libifdnfc.so" && ln -s "libifdnfc.so.0.0.0" "libifdnfc.so")
libtool: link: ar cru .libs/libifdnfc.a libifdnfc_la-ifd-nfc.o
ar: `u' modifier ignored since `D' is the default (see `U')
libtool: link: ranlib .libs/libifdnfc.a
libtool: link: ( cd ".libs" && rm -f "libifdnfc.la" && ln -s "../libifdnfc.la" "libifdnfc.la" )
/bin/bash /home/nolex/ifdnfc-master/install-sh -d @serialdropdir@
/bin/bash ../libtool --mode=install cp .libs/libifdnfc.so @serialdropdir@/libifdnfc.so.0.1.4
libtool: install: `@serialdropdir@' must be an absolute directory name
libtool: install: Try `libtool --help --mode=install' for more information.
make[1]: *** [Makefile:626: install_ifdnfc] Errore 1
make[1]: uscita dalla directory «/home/nolex/ifdnfc-master/src»
make: *** [Makefile:308: install-recursive] Errore 1
I am using Mikroe-2540 NFC USB Dongle is an NFC Reader-Writer based on NXP’s [PN7150] high-performance full NFC controller, supporting all NFC Forum modes. The USB NFC Dongle is powered through USB connector.
The USB port it is using is named as /dev/hidraw*
I wish to know if support for this device is yet built in ?
If yes then how to configure USB based dongles through IFDNFC.
This dongle is not directly working through PCSC and pcsc_scan command
root@raspberrypi:~$sudo ifdnfc-activate
2 NFC devices found, please select one:
[0] pn532_spi:/dev/spidev0.0 (pn532_spi:/dev/spidev0.0:50000)
[1] pn532_spi:/dev/spidev0.0 (pn532_spi:/dev/spidev0.0:1000000)
0
Activating ifdnfc with "pn532_spi:/dev/spidev0.0:50000"...
Insufficient buffer.
How to deal with this buffer issue ?
What steps will reproduce the problem?
1. make
What is the expected output? What do you see instead?
ifd-nfc.c: In function 'IFDHPowerICC':
ifd-nfc.c:528: warning: suggest parentheses around && within ||
The problematic line is:
if ((ifdnfc->secure_element_as_card) && (ifdnfc_se_is_available(ifdnfc)) || ifdnfc_target_is_available(ifdnfc)) {
I have no idea where to place the parenthesis since I do not really understand
ths code.
Original issue reported on code.google.com by [email protected]
on 19 Jan 2013 at 4:13
Is this project still supported?
If so, do you plan to port the driver to OS X?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.