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