I'm trying to access my ACR122u with java by sending direct command. The weird thing is i don't get any response and no errors.. This is my code:
final static int IOCTL_SMARTCARD_ACR122_ESCAPE_COMMAND = 0x003136B0;
.....
List<CardTerminal> terminals = null;
TerminalFactory factory = TerminalFactory.getDefault();
terminals = factory.terminals().list();
CardTerminal terminal = terminals.get(0);
Card card = terminal.connect("direct");
CardChannel channel = card.getBasicChannel();
byte[] commandAPDU = {(byte) 0xD4, 0x06, 0x63, 0x05, 0x63, 0x0D, 0x63, 0x38 };
byte[] responseAPDU = card.transmitControlCommand(IOCTL_SMARTCARD_ACR122_ESCAPE_COMMAND, commandAPDU );
System.out.println(bytesToHex(responseAPDU) + "...");
Is there anyone who knows the cause of this situation?
Many thanks in advance!
S.Pols
Finally, i have the solution. I will answer my own question in case there are other people with the same problem.
The fault was that i only send the message here. With new CommandAPDU()
you already define the Class,INS, P1, P2. Besides that you don't need to define the Lc
because javac will do this for us. With transmitControlCommand
you do need to define the Lc
. So with this knowledge the new (working) code is:
List<CardTerminal> terminals = null;
TerminalFactory factory = TerminalFactory.getDefault();
terminals = factory.terminals().list();
CardTerminal terminal = terminals.get(0);
Card card = terminal.connect("direct");
CardChannel channel = card.getBasicChannel();
//Read register
byte[] commandAPDU1 = {(byte)0xFF,0x00,0x00,0x00,0x08, (byte)0xD4, 0x06, 0x63, 0x05, 0x63, 0x0D, 0x63, 0x38 };
byte[] responseAPDU1 = card.transmitControlCommand(IOCTL_SMARTCARD_ACR122_ESCAPE_COMMAND, commandAPDU1 );
System.out.println(bytesToHex(responseAPDU1) + "...");
//Response: D5070707059000...
来源:https://stackoverflow.com/questions/24758072/acr122u-direct-communication-no-response