我目前有以下情况:
我正在尝试向UPM Racetrack NFC Tag写一个简单的String
。我正在使用带有javax.smartcardio
的Java。我正在使用ACR1252编写器/阅读器,我为此开发了一个简单的Java应用程序。
有关信用卡的信息
到目前为止,这是我的util类代码:
public abstract class NFCUtils {
public static Card connect() throws Exception {
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
//Get the first terminal in the list
CardTerminal terminal = terminals.get(0);
System.out.println("Waiting for card....");
terminal.waitForCardPresent(0);
//Establish a connection
Card card = terminal.connect("*");
System.out.println("Card: " + card);
//Get ATR
byte[] baATR = card.getATR().getBytes();
System.out.println("ATR: " + NFCUtils.toString(baATR));
return card;
}
public static CommandAPDU createCommand(String data) {
int CLA = 0xFF;
int INS = 0xC2;
int P1 = 0x00;
int P2 = 0x01;
int LE = 0x04;
byte[] byteData = data.getBytes();
//APDU: CLA, INS, P1, P2, Data, Offset, DataLenght
CommandAPDU command = new CommandAPDU((byte) CLA, (byte) INS, (byte) P1, (byte) P2, byteData, 0x00, LE);
return command;
}
public static ResponseAPDU writeCommandToTag(Card card, CommandAPDU command) throws CardException {
CardChannel channel = card.getBasicChannel();
ResponseAPDU commandResponse = channel.transmit(command);
return commandResponse;
}
问题是响应总是:C003016300
,这意味着不会出现错误信息。由于缺乏错误信息,我完全坚持这一点。所以我的问题是:如何调试这个,我的命令可能有明显的错误吗?
非常感谢任何帮助!