grundid / nfctools-examples

Examples for the nfctools library
69 stars 55 forks source link

No supported card terminal found error on Linux #6

Open uocnb opened 9 years ago

uocnb commented 9 years ago

I have a ACR122U-A9 NFC reader with MIFARE card. Demos work well in Windows, but failed to start in Linux (Ubuntu 15.04 x86_64)

I can execute some command with libnfc. I installed libnfc (from source), a library package provided by ACS.


All demos are failed, the error show as below:

java -cp nfctools-examples.jar org.nfctools.examples.clearcard.ClearCardDemo 
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
java.lang.IllegalArgumentException: No supported card terminal found. Available Terminals 
    at org.nfctools.scio.TerminalHandler.getAvailableTerminal(TerminalHandler.java:59)
    at org.nfctools.examples.TerminalUtils.getAvailableTerminal(TerminalUtils.java:34)
    at org.nfctools.examples.TerminalUtils.getAvailableTerminal(TerminalUtils.java:26)
    at org.nfctools.examples.AbstractDemo.launchDemo(AbstractDemo.java:29)
    at org.nfctools.examples.clearcard.ClearCardDemo.runDemo(ClearCardDemo.java:31)
    at org.nfctools.examples.clearcard.ClearCardDemo.main(ClearCardDemo.java:38)

Is nfctools library support libnfc? Do you have any solution to make it work on linux (or may be cross-platform: linux, windows, osx)?

P/S: thanks for great java library for NFC.

uocnb commented 9 years ago

Well, I found a solution, just install missing package and it work well:

As Java is searching libpcsclite.so.1 in wrong directory (e.g: /lib or /usr/lib), so it is needed to append the path of library to help smartcardio find it. The demo run well with some exceptions as following command: java -Dsun.security.smartcardio.library=/lib/x86_64-linux-gnu/libpcsclite.so.1 -cp .:nfctools-examples.jar org.nfctools.examples.scancard.ScanWholeCardDemo

Sample output from my sample card is:

$ java -Dsun.security.smartcardio.library=/lib/x86_64-linux-gnu/libpcsclite.so.1 -cp .:nfctools-examples.jar org.nfctools.examples.scancard.ScanWholeCardDemo
Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar 
May 07, 2015 12:42:14 AM org.nfctools.scio.TerminalHandler getAvailableTerminal
INFO: Checking terminal: ACS ACR122U 00 00
Waiting for tags, press ENTER to exit
DEBUG: org.nfctools.spi.acs.AcsTag - command: FF82000006D3F7D3F7D3F7
DEBUG: org.nfctools.spi.acs.AcsTag - response: 9000
DEBUG: org.nfctools.spi.acs.AcsTag - command: FF860000050100006000
DEBUG: org.nfctools.spi.acs.AcsTag - response: 6300
INFO : org.nfctools.mf.tools.MfClassicCardScanner - Cannot read sector: 0 with key D3F7D3F7D3F7
DEBUG: org.nfctools.spi.acs.AcsTag - command: FF82000006FFFFFFFFFFFF
DEBUG: org.nfctools.spi.acs.AcsTag - response: 9000
DEBUG: org.nfctools.spi.acs.AcsTag - command: FF860000050100006000
DEBUG: org.nfctools.spi.acs.AcsTag - response: 9000
DEBUG: org.nfctools.spi.acs.AcsTag - command: FFB0000010
DEBUG: org.nfctools.spi.acs.AcsTag - response: 6300
ERROR: org.nfctools.mf.tools.MfClassicCardScanner - Reading block failed. Sector: 0, Block: 0 Key: A, Response: SW1: 99 SW2: 0
org.nfctools.mf.MfException: Reading block failed. Sector: 0, Block: 0 Key: A, Response: SW1: 99 SW2: 0
    at org.nfctools.spi.acs.AcrMfClassicReaderWriter.readBlock(AcrMfClassicReaderWriter.java:64)
    at org.nfctools.mf.tools.MfClassicCardScanner.doWithReaderWriter(MfClassicCardScanner.java:40)
    at org.nfctools.mf.tools.AbstractCardTool.handleTag(AbstractCardTool.java:64)
    at org.nfctools.NfcAdapter.onTag(NfcAdapter.java:81)
    at org.nfctools.spi.acs.InitiatorTerminalTagScanner.handleCard(InitiatorTerminalTagScanner.java:89)
    at org.nfctools.spi.acs.InitiatorTerminalTagScanner.run(InitiatorTerminalTagScanner.java:55)
    at java.lang.Thread.run(Thread.java:745)
DEBUG: org.nfctools.spi.acs.InitiatorTerminalTagScanner - Waiting while card present
DEBUG: org.nfctools.spi.acs.InitiatorTerminalTagScanner - Waiting while card present
...
...
...
DEBUG: org.nfctools.spi.acs.InitiatorTerminalTagScanner - Wait for card absent
DEBUG: org.nfctools.spi.acs.InitiatorTerminalTagScanner - Disconnected
DEBUG: org.nfctools.spi.acs.AcsTag - command: FF82000006D3F7D3F7D3F7
DEBUG: org.nfctools.spi.acs.AcsTag - response: 9000
DEBUG: org.nfctools.spi.acs.AcsTag - command: FF860000050100006000
DEBUG: org.nfctools.spi.acs.AcsTag - response: 6300
INFO : org.nfctools.mf.tools.MfClassicCardScanner - Cannot read sector: 0 with key D3F7D3F7D3F7
DEBUG: org.nfctools.spi.acs.AcsTag - command: FF82000006FFFFFFFFFFFF
DEBUG: org.nfctools.spi.acs.AcsTag - response: 9000
DEBUG: org.nfctools.spi.acs.AcsTag - command: FF860000050100006000
DEBUG: org.nfctools.spi.acs.AcsTag - response: 9000
DEBUG: org.nfctools.spi.acs.AcsTag - command: FFB0000010
DEBUG: org.nfctools.spi.acs.AcsTag - response: 6300
ERROR: org.nfctools.mf.tools.MfClassicCardScanner - Reading block failed. Sector: 0, Block: 0 Key: A, Response: SW1: 99 SW2: 0
org.nfctools.mf.MfException: Reading block failed. Sector: 0, Block: 0 Key: A, Response: SW1: 99 SW2: 0
    at org.nfctools.spi.acs.AcrMfClassicReaderWriter.readBlock(AcrMfClassicReaderWriter.java:64)
    at org.nfctools.mf.tools.MfClassicCardScanner.doWithReaderWriter(MfClassicCardScanner.java:40)
    at org.nfctools.mf.tools.AbstractCardTool.handleTag(AbstractCardTool.java:64)
    at org.nfctools.NfcAdapter.onTag(NfcAdapter.java:81)
    at org.nfctools.spi.acs.InitiatorTerminalTagScanner.handleCard(InitiatorTerminalTagScanner.java:89)
    at org.nfctools.spi.acs.InitiatorTerminalTagScanner.run(InitiatorTerminalTagScanner.java:55)
    at java.lang.Thread.run(Thread.java:745)
DEBUG: org.nfctools.spi.acs.InitiatorTerminalTagScanner - Waiting while card present