我有一些ISO15693 /标签-它的高频-I+芯片,并需要写一些东西在它们上。这些薯片是完全新鲜的,我现在读了一吨pdf告诉我所有的。但是什么都不起作用,我得到了所有的时间外受孕失败的错误。
我在收发信命令中发送这些数据:
Byte: <data>
0: 0x00 // pdf says the tag understands only flag = 0x00
1: 0x21 // write single block
2-10: ID // needs to be send for this tag, only supports addressed mode
11: 0x00 // Block ID, try to write to block 0
12-16: DATA // LSB First
17-18: CRC16 // do i need to send this? and if yes, LSB first?我尝试了非常不同的标志和写模式,但它们都不起作用:
Flags: 0x01, 0x02, 0x20,0x22,0x42,0x40,0x80,0x82
Modes: 0x21,0xA2 (+ Vendor Mode 0x07)这是我的写作功能:
private void write(Tag tag) throws IOException, FormatException {
if (tag == null) {
return;
}
NfcV nfc = NfcV.get(tag);
byte[] ID = tag.getId();
nfc.connect();
Log.d(TAG, "Data: " + new String(((EmergencyApplication) getApplication()).getData()));
byte[] data = ((EmergencyApplication) getApplication()).getData();
// NfcV Tag has 64 Blocks with 4 Byte
if ((data.length / 4) > 64) {
// ERROR HERE!
Log.d(TAG, "too much data...");
}
for (int i = 0; i < data.length; i++) {
byte[] arrByte = new byte[17];
// Flags
arrByte[0] = 0x00; // Tag only supports flags = 0
// Command
arrByte[1] = 0x21;
// ID
Log.d(TAG, "Found ID length: " + ID.length + "... ID: " + Arrays.toString(ID));
System.arraycopy(ID, 0, arrByte, 2, 8);
// block number
arrByte[10] = (byte) (i);
// data
// TODO send LSB first...
System.arraycopy(data, i * 4, arrByte, 11, 4);
// CRC 16 of all command
byte[] check = new byte[15];
System.arraycopy(arrByte, 0, check, 0, 15);
int crc = CRC.crc16(check);
arrByte[15] = (byte) (crc >> 8);
arrByte[16] = (byte) (crc & 0xFF);
Log.d(TAG, "Writing Data: " + Arrays.toString(arrByte));
byte[] result = nfc.transceive(arrByte);
Log.d(TAG, "got result: " + Arrays.toString(result));
}
nfc.close();
Toast.makeText(this, "wrote to tag", Toast.LENGTH_LONG).show();
}是Nexus S的另一个窃听器吗?我用的是Cyanogenmod 10.1.2,所以我想这个标签是固定在这里的。显然,我可以读取标签,如果我使用NFC标记信息应用程序,它会向我展示所有的块清晰和可写性。我让这些PDF读到:
http://rfidshop.com.hk/datasheet%20tag/philip%20icode%20SLI.pdf -我的标签数据表http://www.waazaa.org/download/fcd-15693-3.pdf -I 15693-3数据表http://www.ti.com/lit/ug/scbu003a/scbu003a.pdf -标签-it HF-I Plus数据表
我用下面的代码测试了阅读:Reading a NXP ICODE SLI-L tag with Android --它可以在所有64个块上工作,但是编写仍然不能工作.即使有旗= 0x20..。
编辑:我现在看到卡上的DSFID是0x00,这意味着is 15693-3卡根本不能写:
如果VICC不支持其编程,则VICC应响应值为零('00')
这是发送byte[]时的0x2B
DSFID \ / AFI
| |
v v
infoRmation: [0, 15, 120, 40, -51, -51, 119, -128, 7, -32, 0, 0, 63, 3, -117]发布于 2013-08-20 16:37:57
发现一些事情,我想和大家分享:
但最糟糕的是,标记在编译到标记编写器的时间内没有响应。您将得到一个Tag is lost.异常,但数据将被写入标记!因此,解决方案就是忽略这个异常,在编写完数据后可能会验证它,如果它不起作用,再试一次。
我当前的编写代码如下所示:
public static void write(Tag tag, byte[] data) throws IOException, FormatException,
InterruptedException {
if (tag == null) {
return;
}
NfcV nfc = NfcV.get(tag);
nfc.connect();
Log.d(TAG, "Max Transceive Bytes: " + nfc.getMaxTransceiveLength());
// NfcV Tag has 64 Blocks with 4 Byte
if ((data.length / 4) > 64) {
// ERROR HERE!
Log.d(TAG, "too much data...");
}
if ((data.length % 4) != 0) {
byte[] ndata = new byte[(data.length) + (4 - (data.length % 4))];
Arrays.fill(ndata, (byte) 0x00);
System.arraycopy(data, 0, ndata, 0, data.length);
data = ndata;
}
byte[] arrByte = new byte[7];
// Flags
arrByte[0] = 0x42;
// Command
arrByte[1] = 0x21;
for (int i = 0; i < (data.length / 4); i++) {
// block number
arrByte[2] = (byte) (i);
// data, DONT SEND LSB FIRST!
arrByte[3] = data[(i * 4)];
arrByte[4] = data[(i * 4) + 1];
arrByte[5] = data[(i * 4) + 2];
arrByte[6] = data[(i * 4) + 3];
Log.d(TAG, "Writing Data to block " + i + " [" + printHexString(arrByte) + "]");
try {
nfc.transceive(arrByte);
} catch (IOException e) {
if (e.getMessage().equals("Tag was lost.")) {
// continue, because of Tag bug
} else {
throw e;
}
}
}
nfc.close();
}而且效果很好。如果存在真正的错误,比如消息不被理解,您将得到Transceive Failed消息。
https://stackoverflow.com/questions/18211548
复制相似问题