Open eximius313 opened 2 years ago
Ok, for future generations, terminals are not found due to some bug described here
So I must run my app with java -Dsun.security.smartcardio.library=/usr/lib/aarch64-linux-gnu/libpcsclite.so.1 MyApp
nevetheless ifdnfc-activate
still returns IFD-NFC is inactive.
and no card is found.
Neither from my app, neither from pcsc_scan
:
Using reader plug'n play mechanism
Scanning present readers...
0: IFD-NFC 00 00
Thu Feb 10 21:54:14 2022
Reader 0: IFD-NFC 00 00
Event number: 0
Card state: Card removed,
I got a similar problem with my SCL3711 reader, it shows "Card removed" although nfc-list detects the a card.
The output of pcsc_scan after installing ifdnfc:
Using reader plug'n play mechanism
Scanning present readers...
0: SCM Micro SCL3711 Contactless Reader & NFC 00 00
Sun Nov 20 16:01:48 2022
Reader 0: SCM Micro SCL3711 Contactless Reader & NFC 00 00
Event number: 0
Card state: Card removed,
vs. the output of nfc-list:
nfc-list uses libnfc 1.8.0
NFC device: SCM Micro / SCL3711-NFC&RW opened
1 ISO14443A passive target(s) found:
ATQA (SENS_RES): 00 44
UID (NFCID1): 04 9a 59 8a aa 6c 80
SAK (SEL_RES): 08
Any hints on how to detect the card?
Same here.
I'm trying to bridge a pn532
nfc reader with pcscd
to use a security token as a smartcard with gnupg
(as scdaemon
talks to pcscd
for smartcard interactions).
After installing ccid libnfc pcsclite pcsc-tools ifdnfc-git
packages in Arch, enabling pcscd.socket
and setting up /etc/nfc/libnfc.conf
with:
device.name = "IFD-NFC"
device.connstring = "pn532_uart:/dev/ttyUSB0"
and /etc/reader.conf.d/ifdnfc
with:
FRIENDLYNAME "IFD-NFC"
LIBPATH /usr/lib/libifdnfc.so
CHANNELID 0
All nfc-*
tools from libnfc
seem to be working, but pcsc_scan
stays in:
Using reader plug'n play mechanism
Scanning present readers...
0: IFD-NFC 00 00
Wed Mar 8 13:24:46 2023
Reader 0: IFD-NFC 00 00
Event number: 0
Card state: Card removed,
\
I think I just found out how this is supposed to be used!
If I first fire up pcsc_scan
to activate pcscd
service (and keep it open) and call ifdnfc-activate
after that I get:
2 NFC devices found, please select one:
[0] IFD-NFC (pn532_uart:/dev/ttyUSB0)
[1] IFD-NFC 00 00 (pcsc:IFD-NFC 00 00)
>> 0
Activating ifdnfc with "pn532_uart:/dev/ttyUSB0"...
IFD-NFC is inactive.
Selecting the first option (0) enables the ifdnfc pcsc
driver and scanning in pcsc_scan
works!
I'm not sure though why it still reports the device as inactive, I'll have to dig into the source to find that out
I found the issue! The ifdnfc-activate
binary allocates a single byte receive buffer here:
https://github.com/nfc-tools/ifdnfc/blob/0e48e8e107dc42f68fb472bb06d257503ad45b1d/src/ifdnfc-activate.c#L45
that in turn is passed by to SCardControl
here:
https://github.com/nfc-tools/ifdnfc/blob/0e48e8e107dc42f68fb472bb06d257503ad45b1d/src/ifdnfc-activate.c#L171
that calls the libpcsclite
library here:
https://github.com/LudovicRousseau/PCSC/blob/a98d3858602f94c5e9a0876353e02c0f2cd2dcaa/src/winscard_clnt.c#L2209
that sends a message on the pcscd
here:
https://github.com/LudovicRousseau/PCSC/blob/a98d3858602f94c5e9a0876353e02c0f2cd2dcaa/src/winscard_svc.c#L703
that is passed in the wincard implementation here:
https://github.com/LudovicRousseau/PCSC/blob/a98d3858602f94c5e9a0876353e02c0f2cd2dcaa/src/winscard.c#L1301
that calls the ifdnfc
's IFDHControl
implementation through IFDControl
here:
https://github.com/LudovicRousseau/PCSC/blob/a98d3858602f94c5e9a0876353e02c0f2cd2dcaa/src/winscard.c#L1349
that seems to handle the request successfully, but we get a SCARD_E_INSUFFICIENT_BUFFER as a result, probably from here:
https://github.com/LudovicRousseau/PCSC/blob/a98d3858602f94c5e9a0876353e02c0f2cd2dcaa/src/winscard_clnt.c#L2276
So increasing the receive buffer to fit the whole response (that contains the device name) fixes the inactive message problem!
Dear ifdnfc community,
My goal is to use my PN532 reader in Java@RPi4
I've setup
libnfc
properly withpn532_uart
driver My/etc/nfc/libnfc.conf
looks like this:and
nfc-scan-device
returns:Then I've compiled
ifdnfc
and whileservice pcscd status
gives me:and my
/etc/reader.conf.d/libifdnfc
looks like this:Unfortunately
ifdnfc-activate
returns:I'm already on aarch64 bit, because on 32bit system
ifdnfc-activate
was returningInsufficient buffer
My Java program:
returns
[]
terminals... What can I do in order to makeifdnfc
"active"? Kind regards