如何通过LLRP从EPC RFID标签读取用户数据(内存)?

How can I read user data (memory) from EPC RFID tag through LLRP?

我通过 "NiceLabel Pro" 编码两个 EPC 标签,数据为:

  1. 第一个标签:EPC:555555555,用户数据:9876543210123456789
  2. 第二个标签:EPC:444444444,用户数据:123456789123456789

现在我正尝试通过 LLRP 获取该数据(在我的 Java 应用程序中):

我的LLRPClient(一个函数):

public void PrepareInventoryRequest() {
    AccessCommand accessCommand = new AccessCommand();

    // A list to hold the op specs for this access command.
    accessCommand.setAccessCommandOpSpecList(GenerateOpSpecList());

    // Create a new tag spec.
    C1G2TagSpec tagSpec = new C1G2TagSpec();
    C1G2TargetTag targetTag = new C1G2TargetTag();
    targetTag.setMatch(new Bit(1));
    // We want to check memory bank 1 (the EPC memory bank).
    TwoBitField memBank = new TwoBitField("2");
    targetTag.setMB(memBank);
    // The EPC data starts at offset 0x20.
    // Start reading or writing from there.
    targetTag.setPointer(new UnsignedShort(0));
    // This is the mask we'll use to compare the EPC.
    // We want to match all bits of the EPC, so all mask bits are set.
    BitArray_HEX tagMask = new BitArray_HEX("00");
    targetTag.setTagMask(tagMask);
    // We only only to operate on tags with this EPC.
    BitArray_HEX tagData = new BitArray_HEX("00");
    targetTag.setTagData(tagData);

    // Add a list of target tags to the tag spec.
    List <C1G2TargetTag> targetTagList =
            new ArrayList<>();
    targetTagList.add(targetTag);
    tagSpec.setC1G2TargetTagList(targetTagList);

    // Add the tag spec to the access command.
    accessCommand.setAirProtocolTagSpec(tagSpec);

    accessSpec.setAccessCommand(accessCommand);
...

private List<AccessCommandOpSpec> GenerateOpSpecList() {
    // A list to hold the op specs for this access command.
    List <AccessCommandOpSpec> opSpecList =
            new ArrayList<>();

    // Set default opspec which for eventcycle of accessspec 3.
    C1G2Read opSpec1 = new C1G2Read();
    // Set the OpSpecID to a unique number.
    opSpec1.setOpSpecID(new UnsignedShort(1));
    opSpec1.setAccessPassword(new UnsignedInteger(0));

    // We'll read from user memory (bank 3).
    TwoBitField opMemBank = new TwoBitField("3");
    opSpec1.setMB(opMemBank);

    // We'll read from the base of this memory bank (0x00).
    opSpec1.setWordPointer(new UnsignedShort(0));
    // Read two words.
    opSpec1.setWordCount(new UnsignedShort(0));

    opSpecList.add(opSpec1);

    return opSpecList;
}

我的标签处理函数:

 private void updateTable(TagReportData tag) {
    if (tag != null) {
        EPCParameter epcParam = tag.getEPCParameter();
        String EPCStr;

        List<AccessCommandOpSpecResult> accessResultList = tag.getAccessCommandOpSpecResultList();

        for (AccessCommandOpSpecResult accessResult : accessResultList) {
            if (accessResult instanceof C1G2ReadOpSpecResult) {
                C1G2ReadOpSpecResult op = (C1G2ReadOpSpecResult) accessResult;
                if ((op.getResult().intValue() == C1G2ReadResultType.Success) &&
                        (op.getOpSpecID().intValue() < 1000)) {
                    UnsignedShortArray_HEX userMemoryHex = op.getReadData();
                    System.out.println("User Memory read from the tag is = " + userMemoryHex.toString());
                }
            }
        }
...

对于第一个标签,"userMemoryHex.toString()" = "3938 3736"
对于第二个标签,"userMemoryHex.toString()" = "3132 3334"

为什么?如何获取所有用户数据?

这是my rfid tag

您得到的值似乎是数字的前 4 个字符(解释为 ASCII 字符串):

  • 39383736 = "9876"(将这 4 个字节解释为 ASCII 字符时)
  • 31323334 = "1234"(将这 4 个字节解释为 ASCII 字符时)

因为您标签的 specification

Memory: EPC 128 bits, User 32 bits

您的标签只能包含 32 位(= 4 字节)的用户数据。因此,您的标签根本不能包含您尝试写入为 UserData 的完整值(即 9876543210123456789 或 123456789123456789)(无论这是否被解释为十进制数或字符串)。

相反,您的 writer 应用程序似乎已经获取了这些值的前 4 个字符,将它们编码为 ASCII,并将它们写入标签。