ahackmann
13 years agoOccasional Contributor
Get value from DLL function
Hello,
i am working with TC 8.70 and i am using JScript. Calling functions of a DLL is no problem but i get in trouble when i want to receive a value from DLL function. Any idea what is going wrong?
HEADER FILE OF DLL:
int16_t __stdcall Open(void);
int16_t __stdcall TPDI_POWER(uint16_t Function);
int16_t __stdcall TPDI_READ_Powerconsumptionvi(double *Voltage, double *Current);
SCRIPT:
Def_Environment = DLL.DefineEnvironment(true);
Def_DLL = Def_Environment.DefineDLL"TPDI_DLL");
Def_DLL.DefineProc("Open",VT_INT);
Def_DLL.DefineProc("TPDI_POWER",VT_I1,VT_INT);
Def_DLL.DefineProc("TPDI_READ_Powerconsumptionvi",VT_BYREF | VT_R8 ,
VT_BYREF | VT_R8 ,VT_INT);
//Load into local directory
Project.Variables.DLLvar_Testrack = Def_Environment.Load("../TCAS_Tests/Sources/TPDI_DLL/TPDI_DLL.DLL","TPDI_DLL");
//open connection, working fine
Log.Message("Testrack open "+Project.Variables.DLLvar_Testrack.Open());
//set Power to ON, working fine
Project.Variables.DLLvar_Testrack.TPDI_POWER(1);
var voltage, current;
// Get voltage and current from Power Supply is not working
Project.Variables.DLLvar_Testrack.TPDI_READ_Powerconsumptionvi(voltage ,current);
Log.Message("Voltage:" +voltage + " Current: " + current);
I do not receive any error from TC but the values of “voltage” and “current” are undefined. Any ideas what i am making wrong?
Thanks in advance!
i am working with TC 8.70 and i am using JScript. Calling functions of a DLL is no problem but i get in trouble when i want to receive a value from DLL function. Any idea what is going wrong?
HEADER FILE OF DLL:
int16_t __stdcall Open(void);
int16_t __stdcall TPDI_POWER(uint16_t Function);
int16_t __stdcall TPDI_READ_Powerconsumptionvi(double *Voltage, double *Current);
SCRIPT:
Def_Environment = DLL.DefineEnvironment(true);
Def_DLL = Def_Environment.DefineDLL"TPDI_DLL");
Def_DLL.DefineProc("Open",VT_INT);
Def_DLL.DefineProc("TPDI_POWER",VT_I1,VT_INT);
Def_DLL.DefineProc("TPDI_READ_Powerconsumptionvi",VT_BYREF | VT_R8 ,
VT_BYREF | VT_R8 ,VT_INT);
//Load into local directory
Project.Variables.DLLvar_Testrack = Def_Environment.Load("../TCAS_Tests/Sources/TPDI_DLL/TPDI_DLL.DLL","TPDI_DLL");
//open connection, working fine
Log.Message("Testrack open "+Project.Variables.DLLvar_Testrack.Open());
//set Power to ON, working fine
Project.Variables.DLLvar_Testrack.TPDI_POWER(1);
var voltage, current;
// Get voltage and current from Power Supply is not working
Project.Variables.DLLvar_Testrack.TPDI_READ_Powerconsumptionvi(voltage ,current);
Log.Message("Voltage:" +voltage + " Current: " + current);
I do not receive any error from TC but the values of “voltage” and “current” are undefined. Any ideas what i am making wrong?
Thanks in advance!