1
我尝试写一些数据到恩智浦ICODE SLIx的SL2S2002标签(ISO 15693)通过NfcV
对象命令:写多个块命令使用WRITE多个块故障转移NfcV
private void writeTagData(Tag tag) throws Exception {
int offset = 0;
int blocks = 19;
String _writedata = "1hello34567850000071234561815064150220161603201016022018112233445552031033";
byte[] data = _writedata.getBytes(StandardCharsets.UTF_8);
data = Arrays.copyOfRange(data, 0, 4 * blocks);
byte[] id = tag.getId();
boolean techFound = false;
for (String tech : tag.getTechList()) {
if (tech.equals(NfcV.class.getName())) {
techFound = true;
NfcV nfcvTag = NfcV.get(tag);
try {
nfcvTag.connect();
} catch (IOException e) {
Toast.makeText(this, "IO Exception", Toast.LENGTH_LONG).show();
return;
}
try {
byte[] cmd = new byte[] {
(byte)0x20,
(byte)0x24,
(byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
(byte)(offset & 0x0ff),
(byte)((blocks - 1) & 0x0ff)
};
System.arraycopy(id, 0, cmd, 2, 8);
byte[] cmd_plus_data = new byte[88];
System.arraycopy(cmd, 0, cmd_plus_data, 0, cmd.length);
System.arraycopy(data, 0, cmd_plus_data, 12, data.length);
byte[] response = nfcvTag.transceive(cmd_plus_data);
String strResponse = Common.toHexString(response);
} catch (IOException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
return;
}
try {
nfcvTag.close();
} catch (IOException e) {
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
return;
}
}
}
}
从响应transceive(...)
方法是010f
(指示“未知错误”)。以前,我能够使用命令READ MULTIPLE BLOCKS从同一个标签成功读取数据。
我试图调用NfcV
对象上getMaxTransceiveLength()
并且该值是253
您试图写入什么特定标记产品?鉴于您在之前的文章中指出了标签UID值“e004015057da807b”,我猜测它是恩智浦ICODE SLIX SL2S2xx2,对不对? –
恩智浦ICODE SLIX SL2S2002 – ibrahim