PicoScope 7 Software
Available on Windows, Mac and Linux
Code: Select all
/* Structures *****************************************************/
typedef struct tUSBTC08Info
{
short size;
short DriverVersion;
short PicoppVersion;
short HardwareVersion;
short Variant;
char szSerial[USBTC08_MAX_SERIAL_CHARS];
char szCalDate[USBTC08_MAX_DATE_CHARS];
} USBTC08_INFO, *LPUSBTC08_INFO;
/*====================================================================
PREF0 PREF1 short PREF2 PREF3(usb_tc08_get_unit_info) (short handle, USBTC08_INFO * info);
Code: Select all
type
TUSBTC08_INFO = record
size: smallint;
DriverVersion: smallint;
PicoppVersion: smallint;
HardwareVersion: smallint;
Variant: smallint;
szSerial: Array[0..11] of Char;
szCalDate: Array[0..9] of Char;
end;
PUSBTC08_INFO = ^TUSBTC08_INFO;
function usb_tc08_get_unit_info (handle: smallint; info: PUSBTC08_INFO):smallint; stdcall; external 'usbtc08.dll';
Yes, all these are included, since it is not possible to compile program if you do not pass specified number of arguments. In the original pascal version of the driver you supply, unit_info is type: BYTE, instead of char* equivalent. ANyway I tried all possible combinations of datatypes, and nothing.Sarah wrote: The usb_tc08_get_formatted_info routine:
short usb_get_formatted_info ( short handle, char * unit_info, short string_length)
Needs to include the arguments listed, are you including these?
That one is included in my first post. In the original version of pascal driver, this routine is not declared at all, so I declared it, based on the information from C header file (details in my first post).Sarah wrote:Have you tried the usb_tc08_get_unit_info() routine?
Code: Select all
/**************************************************************************
* C program for getting Serial Number of TC-08 (USB) device
* author: Dusan P Djurdjevic, Edinburgh UNI, 2005.
***************************************************************************/
#include
#include "usbtc08.h"
#define TC_TYPE_K 'K'
int main()
{
short hTC08;
USBTC08_INFO devinfo;
char str[50];
int ok;
float temp_buffer;
short temp_int_buffer;
short overflow;
// open unit
hTC08 = usb_tc08_open_unit ();
// check if everything OK
if (hTC08 <= 0)
{
printf("Error Code: %d\n",usb_tc08_get_last_error (0));
return(99);
}
// set one channel to verify that device is working
ok = usb_tc08_set_channel (hTC08, 0, TC_TYPE_K);
usb_tc08_get_single(hTC08, &temp_buffer, &overflow,0);
printf("Temperature reading on Chanel 0: %.3f\n\n", temp_buffer);
// get device information
// 1.
usb_tc08_get_unit_info(hTC08, &devinfo);
printf ("1. usb_tc08_get_unit_info(handle, *info):\n");
printf ("\tSize: %d\n",devinfo.size);
printf ("\tDriverVersion: %d\n",devinfo.DriverVersion);
printf ("\tHardwareVersion: %d\n",devinfo.HardwareVersion);
printf ("\tVariant: %d\n",devinfo.Variant);
printf ("\tszSerial: %s\n",devinfo.szSerial);
printf ("\tszCalDate: %s\n\n",devinfo.szCalDate);
// 2.
usb_tc08_get_formatted_info(hTC08, str, 50);
printf ("2. usb_tc08_get_formatted_info (handle, *unit_info, string_length):\n");
printf ("\tunit_info: %s\n\n",str);
// 3.
ok = usb_tc08_legacy_get_driver_version();
printf ("3. usb_tc08_legacy_get_driver_version:\n");
printf ("\tResult: %d\n\n",ok);
// 4.
usb_tc08_legacy_get_version(&temp_int_buffer,hTC08);
printf ("4. usb_tc08_legacy_get_version(*version, handle):\n");
printf ("\tVersion: %d\n\n",temp_int_buffer);
}
Code: Select all
D:\Projects\Experiments_SEE\Driver\Drivers\Win32>usbtc08.exe
Temperature reading on Chanel 0: 26.531
1. usb_tc08_get_unit_info(handle, *info):
Size: 16048
DriverVersion: 30659
HardwareVersion: 30657
Variant: -1
szSerial: 3½┬wHô├wP$ò
szCalDate: $ò
2. usb_tc08_get_formatted_info (handle, *unit_info, string_length):
unit_info:
3. usb_tc08_legacy_get_driver_version:
Result: 257
4. usb_tc08_legacy_get_version(*version, handle):
Version: 1
Yes this works now, and Delphi example works fine as well with it. Perhaps it should be better if this initialisation of devinfo structure take place inside the driver.Sarah wrote:Hi
You need to add the following line of code:
devinfo.size = sizeof(USBTC08_INFO);
Above the line:
usb_tc08_get_unit_info(hTC08, &devinfo);
Code: Select all
=========================================================================================
Type
TUSBTC08_INFO = record
size: smallint;
DriverVersion: smallint;
PicoppVersion: smallint;
HardwareVersion: smallint;
Variant: smallint;
szSerial: Array[0..11] of Char;
szCalDate: Array[0..9] of Char;
end;
PUSBTC08_INFO = ^TUSBTC08_INFO;
function usb_tc08_get_unit_info (handle: smallint; info: PUSBTC08_INFO):smallint; stdcall; external 'usbtc08.dll';
.
.
.
procedure TForm1.StartClick(Sender: TObject);
var
ok : boolean; s : string; error_code : smallint; ascii : smallint;
info : TUSBTC08_INFO;
begin
// first TC-08
if (tc08_handle < 1) then
begin
lbStatus.Text := 'Opening TC08 No.1';
repaint;
tc08_handle := usb_tc08_open_unit ();
if (tc08_handle > 0) then begin
info.size := sizeof(TUSBTC08_INFO);
usb_tc08_get_unit_info(tc08_handle,@info);
===================================================================================
Code: Select all
typedef struct tUSBTC08Info
{
short size;
char DriverVersion[USBTC08_MAX_VERSION_CHARS]; // different from Dusan's example
short PicoppVersion;
short HardwareVersion;
short Variant;
char szSerial[USBTC08_MAX_SERIAL_CHARS];
char szCalDate[USBTC08_MAX_DATE_CHARS];
} USBTC08_INFO, *LPUSBTC08_INFO;
Note: the DriverVersion parameter is of char type NOT a short (unless you were using an earlier driver or other logical explanation).
I found the USBTC08_MAX variables also from the C header USBTC08.h
/* General Defines **************************************************/
#define USBTC08_MAX_FILTER_SIZE 255
#define USBTC08_MAX_SAMPLE_BUFFER 600 /* Max readings that usb_tc08_get_temp will ever return */
#define USBTC08_MAX_INFO_CHARS 256
#define USBTC08_MAX_DATE_CHARS 9
#define USBTC08_MAX_SERIAL_CHARS 11
#define USBTC08_MAX_VERSION_CHARS 12
So my final Delphi code is:
private
{ Private declarations }
public
{ Public declarations }
end;
Type
TUSBTC08_INFO = record
size: smallint;
DriverVersion: Array[0..11] of char;
PicoppVersion: smallint;
HardwareVersion: smallint;
Variant: smallint;
szSerial: Array[0..10] of Char;
szCalDate: Array[0..8] of Char;
end;
PUSBTC08_INFO = ^TUSBTC08_INFO;
function usb_tc08_get_unit_info (handle: smallint; info: PUSBTC08_INFO):smallint; stdcall; external 'usbtc08.dll';
.
Your code here etc
.
procedure Tform1. get serial and cal date(Sender: TObject);
var
info : TUSBTC08_INFO;
begin
if (tc08_handle > 0) then
begin
info.size := sizeof(TUSBTC08_INFO);
usb_tc08_get_unit_info(tc08_handle,@info);
tcserial:=info.szSerial;
.
more code etc
.