2014-07-13 77 views
0

我剛剛讀了this回答關於如何把我的ACR122U在卡模擬模式。我確實瞭解目的,但您需要如何將命令發送到ACR122u。ACR122u卡模擬模式發送PN532命令

據我知道FF000000指:

  • FF [類]
  • 00 [INS]
  • 00 [P1]
  • 00 [P2]

我只是無法弄清楚我可以如何發送實際的PN532命令,例如:

  • FF000000 08 D406 6305 630D 6338
  • FF000000 11 D408 6302 80 6303 80 6305 XX 630D YY 6338 ZZ

我已經走到這一步:

TerminalFactory factory = TerminalFactory.getDefault(); 
    List<CardTerminal> terminals; 

    try { 
      terminals = factory.terminals().list(); 

      CardTerminal terminal = terminals.get(0); 
      Card card    = terminal.connect("*"); 
      CardChannel channel  = card.getBasicChannel(); 
      byte[] command   = {???}; 
      CommandAPDU command1 = new CommandAPDU(0xFF,0x00,0x00,0x00, command); 
      ResponseAPDU response1 = channel.transmit(command1); 
      System.out.println(bytesToHex(response1.getBytes())); 

    } catch (CardException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 

我欣賞你的幫助!

非常感謝提前!

回答

1

假設08 D406 6305 630D 6338裝置

  • 08 [LC]
  • D406 6305 630D 6338 [數據]

它看起來像這樣:

byte[] command = new byte[8] { (byte) 0xD4, 0x06, 0x63, 0x05, 0x63, 0x0D, 0x63, 0x38 }; 

您可以省略8,因爲javac將會我爲你計算字節數。

+0

非常感謝你! –