0

I have problem to get whole hex value of variable. I have 2 RFID tags which TID's are: E2 00 68 06 73 D5 E2 1F and E2 00 68 06 73 D5 E0 16

each next tag is identified with E2 00 68 06 73 .. .. .. and last 3 bits are changing to give unique id to each RFID tag.

I am using RFID reader with SDK. I have function to open port and to read TID of RFID in range of reader. Function is declared as following:

Private Declare Function Inventory_G2 Lib “ZK_RFID105.dll” (ByRef ConAddr As Byte, ByVal AdrTID As Byte, ByVal LenTID As Byte, ByVal TIDFlag As Byte, EPClenandEPC As double/BYTE, ByRef Totallen As Long/BYTE, ByRef CardNum As Long, ByVal PortHandle As Long) As Integer

When I call function, in result I receive EPClenandEPC and Totallen.

I am calling function:

k = Inventory_G2(0, 0, 4, 1, EPClenandEPC, Totallen, CardNum, 3)

0,0,4,1, are inputs (it is OK). Function read RFID tag and return: Totallen - amount of bytes readed - it is 9 EPClenandEPC - which is variable with TID value.

Unfortunately when I want to get value of TID which should be: E2 00 68 06 73 D5 E2 1F for first readed RFID tag I receive 08 E2 00 68 06 73 D5 E2 This 08 means length of result (8 bits). I want to get last bit which should be 1F.

What I am doing wrong? How to read whole value of result variable EPClenandEPC ? I do not want this first 08 byte I want to have whole last bit 1F instad of it.

Code which I am using to read EPClenandEPC after functio n is called and done:

dblVar=EPClenandEPC

MsgBox Mem_ReadHex(VarPtr(DBLVAR), 9)

Function memreadhex:

    Public Function Mem_ReadHex(ByVal Ptr As LongPtr, ByVal Length As Long) As String
    Dim bBuffer() As Byte, strBytes() As String, I As Long, ub As Long, b As Byte
    ub = Length - 1
    ReDim bBuffer(ub)
    ReDim strBytes(ub)
    RtlMoveMemory bBuffer(0), ByVal Ptr, Length
    For I = 0 To ub
        b = bBuffer(I)
        strBytes(I) = IIf(b < 16, "0", "") & Hex$(b)
    Next
    Mem_ReadHex = Join(strBytes, "")
End Function

and VarPtr declaration / rtlmovememory:

Private Declare PtrSafe Function VarPtrArray Lib "VBE7" Alias _
"VarPtr" (ByRef Var() As Any) As LongPtr

Private Declare Sub RtlMoveMemory Lib "kernel32" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)

DLL inventory_g2 function result descr: EPClenandEPC: Output, Pointed to the array storing the inventory result. It is the EPC data of tag Reader read. The unit of the array includes 1 byte EPCLen and N (the value of EPCLen) bytes EPC. It is the former high-word, low word in the EPC of each tag. It is the former high-byte, low byte in the each word. Thank you for any support

aptp
  • 1
  • 2
  • Why is `EPClenandEPC` declared as a double if it's a pointer to the array? Can you edit in the C function declaration for `Inventory_G2`? – Comintern May 18 '15 at 23:16
  • When I use "EPClenandEPC as byte" in function declaration I will receive EPClenandEPC = 8 after function is called. I supose that 8 means 8 bits result but how to present this 8 bits in VBA to have hex TID XX XX XX XX XX XX XX XX (E2 00 68 06 73 D5 E2 1F) result? – aptp May 19 '15 at 19:36

1 Answers1

0

I figured out that EPClenandEPC in first bit contains ist result bits amount. TIDs has 8 bits value so last bit is unreadable because of that first is always "08". VBA can hold in Currency data type max 8 bits. Because first bit of TID is always the same because of manufacturer of RFID labels I decided to change read address to have 6 bits TID instead.

Bold are changed: Inventory_G2(0, 1, 3, 1, EPClenandEPC, Totallen, CardNum, 3)

Now I have last 6 bits of each TID. First 2 are not necessary for me.

Thank you.

aptp
  • 1
  • 2