ACR122u direct communication no response

后端 未结 1 1252
有刺的猬
有刺的猬 2021-01-07 01:13

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 sta         


        
相关标签:
1条回答
  • 2021-01-07 01:53

    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...
    
    0 讨论(0)
提交回复
热议问题