1

下面的代码出现“标签丢失”异常。但是,尽管出现异常,数据仍能成功写入。为什么抛出异常,数据写入成功?

   nfc.connect();
   byte[] arrByt = new byte[7];
   arrByt[0] = 0x01; //Command Flag 0x02 works fine
   arrByt[1] = 0x21;
   arrByt[2] = 0x06;
   arrByt[3] = 0x00;
   arrByt[4] = 0x00;
   arrByt[5] = 0x00;
   arrByt[6] = 0x00;           
   byte[] response = nfc.transceive(arrByt);

我的 NFC 芯片

Type V (ISO/IEC 15693 / Vicinity), Tag Type SL2 ICS2001 (ICODE SLI), Manufacturer NXP Semiconductors (Germany)

在这里谈过 但没有结果:(

4

1 回答 1

2

当 NfcV 标签返回不成功代码时,android 的 NFC 堆栈假定它是一个异常并抛出“标签丢失”。
为避免此异常,您可以使用命令 0x02,正确的字节数组变为:
arrByte = {0x02, 0x21, 0x06, 0x00, 0x00, 0x00, 0x00}; 其中0x02是标志命令,0x21是写单块命令,0x06是块号,remaing是4字节数据。希望这会有所帮助。

于 2012-10-09T07:38:34.080 回答