|
|
| Author |
Message |
jpetitti User

Joined: 14 Mar 2007
Posts: 3
|
Posted: Wed Mar 14, 2007 3:28 pm Post subject: TC-08 and VB6 Development |
|
|
Hello,
I'm having problems getting the szSerial number and temp readings to work correctly.
Here is the test sub I wrote to try to get things up and running.
Dim intRetStatus As Integer
Dim hTC08 As Integer
Dim tc08Info As USBTC08_INFO
ReDim temp_buffer(9) As Single
Dim intFlag As Integer
Dim intErrorCode As Integer
hTC08 = usb_tc08_open_unit()
If (hTC08) Then
List1.AddItem ("Device #" & hTC08 & " has been opened")
tc08Info.size = 30
intRetStatus = usb_tc08_get_unit_info(hTC08, tc08Info)
List1.AddItem ("Serial Number #" & tc08Info.szSerial)
Call usb_tc08_set_mains(hTC08, True)
intRetStatus = usb_tc08_set_channel(hTC08, 0, Asc("K"))
intRetStatus = usb_tc08_get_single(hTC08, temp_buffer(0), intFlag, 0)
List1.AddItem ("Channel 0:" & temp_buffer(0))
End If
hTC08 = usb_tc08_close_unit(hTC08)
The output of List1 is:
Device # 1 has been opened
Serial #
Notice that the serial number is blank. I noticed that in your sample VB application the serial number also does not appear.
The serial number is quite important to me as I will be running 8 devices.
At the "get_single" line I get an overflow error, however your sample application works just fine and I can't see the difference between the sample and my test function.
Any assistance here would be much appreciated.
Thanks in advance! |
|
| Back to top |
|
 |
markB Site Admin

Joined: 27 Mar 2007
Posts: 77
Location: Cambridgeshire,UK
|
Posted: Tue Mar 27, 2007 11:11 am Post subject: |
|
|
Try:
| Code: | Declare Function usb_tc08_get_formatted_info Lib "usbtc08.dll" (ByVal handle As Integer, ByVal unit_info As String, ByVal string_length As Integer) As Integer
Dim info as String * 1024
ok = usb_tc08_get_formatted_info Lib(tc08_handle, info, 1024) |
And parse info for the fourth line |
|
| Back to top |
|
 |
jpetitti User

Joined: 14 Mar 2007
Posts: 3
|
Posted: Tue Mar 27, 2007 1:33 pm Post subject: |
|
|
markB,
Thank you for your reply!
I have however tried to use this method before to no effect.
Here is what I wrote to quickly test it again:
(the function declaration is in my module)
Dim intRetVal As Integer
Dim hTC08 As Integer
Dim info As String * 255
hTC08 = usb_tc08_open_unit()
If (hTC08) Then
intRetVal = usb_tc08_get_formatted_info(hTC08, info, 255)
MsgBox (info)
Call usb_tc08_close_unit(hTC08 )
End If
The problem I get here is that anything larger then 255 for the string length causes VB and my project to crash.
However, when I run it at 255 OR with usb_tc08_get_unit_info the return value that I get for both functions is 0. According to the API guide this is an error and usb_tc08_get_last_error should be used. So I use it and it returns 0 as well - no error.
I also know that the device is working correctly because PicoLog Recorder software can get all the device info just fine.
Again, all help is very much appreciated! |
|
| Back to top |
|
 |
markB Site Admin

Joined: 27 Mar 2007
Posts: 77
Location: Cambridgeshire,UK
|
Posted: Tue Mar 27, 2007 2:01 pm Post subject: |
|
|
Be careful to declare second parameter (the String) byVal and not byRef. Use the decalaration in my earlier post.
I tried this with VBA and it all works fine. |
|
| Back to top |
|
 |
jpetitti User

Joined: 14 Mar 2007
Posts: 3
|
Posted: Tue Mar 27, 2007 2:47 pm Post subject: |
|
|
Excellent markB, That worked perfectly!
I knew it had to be something small I was over looking, those always get me in the end.
It should be noted that the original declaration of the get_formated provided by Pico in the sample module, has it declared ByRef and this needs to be changed to use it in this manor.
OK, so that solves get_formated, any ideas on the structured version get_unit_info? |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|