2013-09-04 02:55 AM
Hi there, I am using a CR95HF board from a M24LR discovery kit to read data from a device. If I use the dual-interface EEPROM software from the ST website, select Reader Application and select M24LR64A, then click Read, or alternatively, 'show RF file transfer tools' and then save EEProm into a file' it does what I want, however I want to be able to include this functionality into my own software.
I have not programmed a hardware unit like this before, so am just getting used to it. I have constructed a small simple VB.net application based on the downloadable code examples, however there are some issues:[code]Public Declare Ansi Function CR95HFDll_Echo Lib ''CR95HF.dll'' (ByVal mystring As String) As Long Public Declare Function CR95HFDll_Idn Lib ''CR95HF.dll'' (ByVal mystring As String) As Long Public Declare Function CR95HFDll_Select Lib ''CR95HF.dll'' (ByVal mycmdstring As String, ByVal mystring As String) As Long Public Declare Function CR95HFDll_SendReceive Lib ''CR95HF.dll'' (ByVal mycmdstring As String, ByVal mystring As String) As Long Public Declare Function CR95HFDll_STCmd Lib ''CR95HF.dll'' (ByVal mycmdstring As String, ByVal mystring As String) As Long Public Declare Function CR95HFDll_FieldOff Lib ''CR95HF.dll'' (ByVal mystring As String) As Long Public Declare Function CR95HFDll_GetDLLrev Lib ''CR95HF.dll'' (ByVal mystring As String) As Long Public Declare Function CR95HFDll_ResetSPI Lib ''CR95HF.dll'' (ByVal mystring As String) As Long Public Declare Function CR95HFDll_SendIRQPulse Lib ''CR95HF.dll'' (ByVal mystring As String) As Long Public Declare Function CR95HFDLL_getMCUrev Lib ''CR95HF.dll'' (ByVal mystring As String) As Long 'added in Dll revision 0.4 Public Declare Function CR95HFDLL_getInterfacePinState Lib ''CR95HF.dll'' (ByVal mystring As String) As Long 'added in Dll revision 0.5 Public Declare Function CR95HFDLL_USBconnect Lib ''CR95HF.dll'' () As Long Public Declare Function CR95HFDll_Polling_Reading Lib ''CR95HF.dll'' (ByVal mystring As String) As Long Public Declare Function CR95HFDll_SendNSSPulse Lib ''CR95HF.dll'' (ByVal mystring As String) As Long 'added in DLL revision 0.6 Public Declare Function CR95HFDLL_USBhandlecheck Lib ''CR95HF.dll'' () As Long 'added in DLL revision 0.9 Public Declare Function CR95HFDLL_getHardwareVersion Lib ''CR95HF.dll'' (ByVal mystring As String) As Long Public Const CR95HF_STM32_error = &H1 Public Const CR95HF_empty_argument_error = &H2 Public Const CR95HF_cmd_parameter_error = &H3 Public Const CR95HF_communication_error = &H4 Public Const CR95HF_USB_communication_error = &H5 Public Const CR95HF_ERRORCODE_DEFAULT = &HFE Public Const CR95HF_ERRORCODE_TIMEOUT = &HFD[/code][code]Dim lngStatus As Long = 5 Dim lngStatus2 As Long = 6 Dim strAnswer As New String('' ''c, 256) Dim strTagResponse As New String('' ''c, 256) lngStatus = CR95HFDLL_USBconnect() If (lngStatus = 0) Then lngStatus2 = CR95HFDll_Select(''010D'', strAnswer) CR95HFDll_SendReceive(''260100'', strTagResponse) MsgBox(''RFID Code is: '' & strTagResponse) Else MsgBox(''Warning : DEMO-CR95HF-A not connected'') End If Dim strAnswer2 As New String('' ''c, 256) lngStatus = CR95HFDll_STCmd(''010202010D'', strAnswer2)[/code]Firstly I do not know how to get the data from the code blocks as the EEPROM software does. I have looked through the manuals/documentation and just simply cannot figure it out. Also there are some issues with the return values. for the CR95HFDLL_USBconnect function it correctly returns 0 or 1, but for all the others, it just seems to return gibberish, and I do not know why. It could be to do with the string I am sending it, as vb.net cannot cope with the command ''As String*256''any help would be appreciated! #cr95hf #m24lr-discovery #cr95hf #vbnet #vbnet #vbnet #m24lr-discoverySolved! Go to Solution.
2013-09-23 08:34 AM
Hi,
this is just to let you know I have solved the problem. The issue is in the declaration for the DLLs and also the lngstatus numbers. I would guess the dll has been compiled using a 32bit compiler, whereas the vb.net that I have installed uses a 64 bit compiler, so a 'long' is actually a 64bit number as far as my compiler is concerned. all the lead bits of the return are junk - whatever is in the memory at the time I guess. The problem is remedied by replacing long with uint32, so for example: Public Declare Function CR95HFDll_SendReceive Lib ''CR95HF.dll'' (ByVal mycmdstring As String, ByVal mystring As String) As System.UInt32Dim lngstatus As Uint32lngstatus = CR95HFDll_SendReceive(command, strTagResponse)returns the correct error codes.2013-09-06 04:04 AM
Hello,
Please find here below a peace of code we could get. This can be usefull to set variables and environement on VB.NET.DLL FUNCTIONS DECLARATION :
declaration
Public
Declare
Function
CR95HFDLL_USBconnect
Lib
''CR95HF.dll''
()
As
Integer
Public
Declare
Function
CR95HFDll_Echo
Lib
''CR95HF.dll''
(
ByVal
mystring
As
String
)
As
Integer
Public
Declare
Function
CR95HFDLL_getMCUrev
Lib
''CR95HF.dll''
(
ByVal
mystring
As
String
)
As
Integer
Public
Declare
Function
CR95HFDll_Select
Lib
''CR95HF.dll''
(
ByVal
mycmdstring
As
String
,
ByVal
mystring
As
String
)
As
Integer
Public
Declare
Function
CR95HFDll_SendReceive
Lib
''CR95HF.dll''
(
ByVal
mycmdstring
As
String
,
ByVal
mystring
As
String
)
As
Integer
Public
Declare
Function
CR95HFDll_STCmd
Lib
''CR95HF.dll''
(
ByVal
mycmdstring
As
String
,
ByVal
mystring
As
String
)
As
Long
INVENTORY COMMAND - FUNCTION EXAMPLE :
Dim
strTagReponseCons0 =
New
String
(
CChar
(
''''
), 256)
Dim
lngStatusCons0
As
Long
lngStatusCons0 = CR95HFDll_SendReceive(“260100�?, strTagReponseCons0)
I think that the declaration of Tag answer need to be changed in “
New
String
(
CChar
(
''''
), 256)
“Might you tell us if this solve your issue?
Thanks a lot,ST NFC/RFID dynamic tag support2013-09-09 03:23 AM
2013-09-10 02:48 AM
I've managed to get it to do most of what I want, however the return codes are still giving values like 340187712222920704
2013-09-11 01:14 AM
e don’t have VB.NET application based here, it is not easy to help deeper on programmation syntax.
How have you solve the previous issue?2013-09-23 07:27 AM
I did as you suggested - the code is returning meaningful values in the string, but as I mentioned, the dll is still not returning anything sensible in the lngstatus values.
2013-09-23 08:34 AM
Hi,
this is just to let you know I have solved the problem. The issue is in the declaration for the DLLs and also the lngstatus numbers. I would guess the dll has been compiled using a 32bit compiler, whereas the vb.net that I have installed uses a 64 bit compiler, so a 'long' is actually a 64bit number as far as my compiler is concerned. all the lead bits of the return are junk - whatever is in the memory at the time I guess. The problem is remedied by replacing long with uint32, so for example: Public Declare Function CR95HFDll_SendReceive Lib ''CR95HF.dll'' (ByVal mycmdstring As String, ByVal mystring As String) As System.UInt32Dim lngstatus As Uint32lngstatus = CR95HFDll_SendReceive(command, strTagResponse)returns the correct error codes.