【问题标题】:Android - Writing to ISO15693 TagsAndroid - 写入 ISO15693 标签
【发布时间】:2016-04-04 22:12:45
【问题描述】:

我目前正在尝试将几个字节写入特定块。我的读取命令工作正常,我可以使用以下代码读取标签的任何块:

command = new byte[]{
            (byte) 0x02, // Flags
            (byte) 0x23, // Command: Read multiple blocks
            (byte) 0x09, // First block (offset)
            (byte) 0x03  // Number of blocks // MAX READ SIZE: 32 blocks:1F
    };
byte[] data = nfcvTag.transceive(command);

当我尝试使用下面的代码编写时,我的应用程序崩溃了。

Write = new byte[]{
                (byte) 0x02, // Flags
                (byte) 0x21, // Command: Write 1 blocks
                (byte) 0x5A, // First block (offset)
                (byte) 0x41  // Data
        };
    nfcvTag.transceive(Write);

我在 AsyncTask 中执行此操作并获得 java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 异常。

有什么建议吗?标签是 STMicroelectronics M24LR04E-R

【问题讨论】:

    标签: java android nfc iso-15693


    【解决方案1】:

    想通了。我只写了 8 位数据,而标签每个块有 32 位。添加了3个0x00,写入成功。

    Write = new byte[]{
                (byte) 0x02, // Flags
                (byte) 0x21, // Command: Write 1 blocks
                (byte) 0x5A, // First block (offset)
                (byte) 0x41,
                (byte) 0x00,
                (byte) 0x00,
                (byte) 0x00  
        };
    nfcvTag.transceive(Write);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-19
      • 1970-01-01
      相关资源
      最近更新 更多