读取NXP我code与Android SLI-L标签 [英] Reading a NXP ICODE SLI-L tag with Android

查看:330
本文介绍了读取NXP我code与Android SLI-L标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读通过恩智浦在我的Andr​​oid应用程序开发的NFC标签。它可以读取标签与Android:恩智浦<的应用/ A>和另一个阅读它正确。

I'm trying to read a NFC tag developed by NXP in my Android Application. It is possible to read the tag with Android: the App by NXP and one other read it correctly.

确切的标签类型为I code SLI-L(SL2ICS50)和射频技术是V型/ ISO 15693(从这些工作的应用程序获得的数据)。该存储器由两页与每个4块,该块具有4个字节 - 我只想有存储在存储器整个数据

The exact Tag type is "ICODE SLI-L (SL2ICS50)" and the RF technology is "Type V / ISO 15693" (data taken from those working apps). The memory consists of 2 pages with 4 blocks each, the blocks have 4 bytes each – I just want to have whole data stored in the memory.

标签必须与Android的 NfcV 类处理和标签的数据表的可在这里,但它是很难找到使用 NfcV 任何工作code例子。我想这是我最后的数据表由我自己几件事情,我试图通信样本<一个href="http://www.baracoda.com/baracoda/librairie-doc/RFID-HF-Raw-Read&Write-Examples-v1-02_2525.pdf"相对=nofollow>这个PDF我发现与谷歌的,但没有任何工程。

The tag has to be handled with Android's NfcV class and the datasheet of the tag is available here, but it is hard to find any working code example using NfcV. I tried several things which I concluded by the datasheet by myself and I tried the communication samples from this PDF I found with Google, but nothing works.

在我的活动相应的方法(我用NFC前景调度)看起来是这样的:

The corresponding method in my activity (I use NFC Foreground Dispatch) looks like this:

public void onNewIntent(Intent intent) {
    android.nfc.Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    NfcV tech = NfcV.get(tag);
    try {
        tech.connect();
        byte[] arrByt = new byte[9];
        arrByt[0] = 0x02;
        arrByt[1] = (byte) 0xB0;
        arrByt[2] = 0x08;
        arrByt[3] = 0x00;
        arrByt[4] = 0x01;
        arrByt[5] = 0x04;
        arrByt[6] = 0x00;
        arrByt[7] = 0x02;
        arrByt[8] = 0x00;
        byte[] data = tech.transceive(arrByt);
        // Print data
        tech.close();
    } catch (IOException e) {
        // Exception handling
    }
}

该方法被调用正确的,当我把我的手机上的标签,但 NfcV 收发()方法C>对象总是抛出IOException: android.nfc.TagLostException:标签丢失。这是所有的字节数组我尝试的结果(上面的那个是不太正确的,但在过去的日子里,我尝试了一堆其他所有resultet相同的行为。

The method is called correctly when I place my phone on the tag, but the transceive() method of the NfcV object always throws an IOException: android.nfc.TagLostException: Tag was lost.. This is the result of all byte arrays I tried (the one above is unlikely correct but over the last days I tried a bunch of others which all resultet in the same behaviour.

这是我在网上看了,我的结论是,因为我发出错误的指令到标签发生错误 - 但我不能拿出正确的。任何想法?

From what I read on the Internet, I conclude that the error occurs because I send the wrong commands to the tag – but I just cannot come up with the right ones. Any ideas?

推荐答案

ISO 15693定义不同的读取命令和制造商也可以定义专用的读取命令。我只code标签支持ISO 15693的单块读命令。您可以按以下方式发送的:

ISO 15693 defines different read commands and manufacturers also may define proprietary read commands. All ICODE tags support the ISO 15693 Single Block Read command. You can send it as follows:

public static void processNfcIntent(Intent intent){
    Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    if(tag != null){
      // set up read command buffer
      byte blockNo = 0; // block address
      byte[] readCmd = new byte[3 + id.length];
      readCmd[0] = 0x20; // set "address" flag (only send command to this tag)
      readCmd[1] = 0x20; // ISO 15693 Single Block Read command byte
      byte[] id = tag.getId();
      System.arraycopy(id, 0, readCmd, 2, id.length); // copy ID
      readCmd[2 + id.length] = blockNo; // 1 byte payload: block address

      NfcV tech = NfcV.get(tag);
      if (tech != null) {
        // send read command
        try {
          tech.connect();
          byte[] data = tech.transceive(readCmd); 
        } catch (IOException e) {
          e.printStackTrace();
        } finally {
          try {
            tech.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
    }
}

这篇关于读取NXP我code与Android SLI-L标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆