Martyn wrote:I can't check until tomorrow, but the header file in the SDK would be a good starting point.
VB.Net, C#, LabVIEW, VBA, Matlab all have their difficulties, complicated even further when you throw in 64 bit.
NOW this IS a 64Bit system...
Is the header file for the 64 bit version identical to the 32 bit version ?
I see /* must be called at least once per minute to ensure no data is lost */
PREF0 PREF1 long PREF2 PREF3(usb_tc08_get_temp) (
short handle,
float * temp_buffer,
long * times_ms_buffer, /* wraps back to zero after 24 days */
long buffer_length,
short * overflow,
short channel,
short units,
short fill_missing);
If you are compiling 32 bit application against 32 bit drivers you should be Ok, so I would look carefully at what Delphi does with respect to pointers for arrays of Reals, and try a few things out.
If you are compiling 32 bit application against 32 bit drivers you should be Ok, so I would look carefully at what Delphi does with respect to pointers for arrays of Reals, and try a few things out.
That's the sort of area I'm looking at now. If I give the function the arguments
..,temp_buffer[0],times_buffer[0].... it "runs", but I still get error 3.
If you are compiling 32 bit application against 32 bit drivers you should be Ok, so I would look carefully at what Delphi does with respect to pointers for arrays of Reals, and try a few things out.
This looks like the canonical method of addressing the DLL
function usb_tc08_get_temp(
handle : smallint; temp_buffer : Pinteger;
times_ms_buffer : Pinteger; buffer_length : smallint;
var overflow : smallint;
channel : smallint;
units : smallint;
fill_missing : smallint)
: smallint;
You will need to be passing the address of the first element of the temp_buffer and times_ms_buffer arrays, not the actual values in these arrays.
If it is not possible to use the array itself, with some referencing, then you could create a pointer value, which you set to the address of the first element and then pass this pointer value in the call.
Martyn wrote:You will need to be passing the address of the first element of the temp_buffer and times_ms_buffer arrays, not the actual values in these arrays.
If it is not possible to use the array itself, with some referencing, then you could create a pointer value, which you set to the address of the first element and then pass this pointer value in the call.
Its not clear from what I posted, but that's what I have done.
PROCEDURE TMainForm.SystemTimerTimer(Sender: TObject);
var
temp_buffer : array [0..9] of single;
times_buffer : array [0..9] of Integer;
buffer_length : smallint;
overflow : smallint;
samplechannel: smallint;
ok : smallint;
tpower : word;
MytimeNow : real;
errorcode :Smallint;
begin
if (tc08_handle > 0) then
begin
if (not in_timer) then
begin
in_timer := true;
// function usb_tc08_get_temp(
// handle : smallint;
// var temp_buffer : real;
// var times_ms_buffer : longint;
// buffer_length : longint;
// var overflow : smallint;
// channel : smallint;
// units : smallint;
// fill_missing : smallint)
// : smallint;
with insertTestdata DO
BEGIN
ok:=usb_tc08_get_temp (tc08_handle,@temp_buffer[0],@times_buffer[0],100,overflow,0,0,0);
if ok<0 then
BEGIN
errorCode:=usb_tc08_get_last_error(tc08_handle);
showmessage ('Error '+inttostr (errorcode));
END;
You can see my use of @in the call to get_temp, which should pass the address of the first element of the array to the Pinteger type.
This problem seems to be hanging on exactly how many bytes are in which datatype passed to the DLL - changing to real made no difference. Did that C example actually run on real hardware ?