Array of double


Recommended Posts

Hi,

In order to recover the calibration constants of the U6, I have to create an array of 64 double and then to send the adress of the first element of that array to a function of the window driver.

Could you help me create this array under DAQFactory ?

Link to comment
Share on other sites

I'm assuming you are using extern()? This is the only way to call an external DLL from within DAQFactory. It is not available in Express, but is available in all other versions of DAQFactory. With extern, DAQFactory handles all this for you. Just make sure your declaration indicates that you are passing an array of 64 doubles: double[64] and then pass a pointer to a variable using the @ notation. So, if the C prototype for your function is:

void foo(double *pVals)

where pVals must be an array of 64 doubles, the prototype in the extern would be:

void foo(double[64])

and you'd call it something like this (assuming you named it foo in DAQFactory as well):

private values

foo(@values)

Link to comment
Share on other sites

What I understand is that it is impossible to create and array of 64 double with DAQFactoryExpress.

The functyion I would like to use is the AddRequest(...) function of the Labjack Windows driver

AddRequest (Handle, LJ_ioGET_CONFIG, LJ_chCAL_CONSTANTS, Value, x1, UserData)

x1 being the first element of a 64 double array.

I Got DAQFactory Starter but I'm not familiar with extern and it seems me quite complicated to create an array of 64 double.

Link to comment
Share on other sites

You can't use AddRequest() with any of the UD functions that require pointers. You have to load the UD outside the DAQFactory driver using extern() and for that you'd have to upgrade to at least DF Starter (go to www.daqexpress.com to upgrade). It is not particularly difficult to use this method, and there is even a sample for calling a different function from the UD in the Help file for extern(). This won't be in the express help file however since express doesn't support extern. You can always download a trial of the regular DF and see if it works before purchasing.

Link to comment
Share on other sites

  • 9 months later...

Hi,

The function I would like to wrap using extern is (found in LabJAckUD.h) :

LJ_ERROR _stdcall eGet_DblArray(LJ_HANDLE Handle, long IOType, long Channel, double *pValue, double *x1);

I tried :

extern("labjackud.dll","long eGet_DblArray(long, long, long, long,long)","eGet_DblArray(ID,ioType,Channel,pValue,px1","stdcall")

But when I use the new function :

eGet_DblArray(ID, LJ_ioTDAC_COMMUNICATION, LJ_chTDAC_READ_CAL_CONSTANTS,@d,@CONST);

I Get nothing in the array CONST

Link to comment
Share on other sites

Your prototype is all wrong. You put all "long" when the data types are otherwise. Its amazing you didn't crash DAQFactory or your computer, since you likely passed a NULL pointer to the driver. The prototype has to have double[] for the last two parameters. I don't know how big those arrays are supposed to be, so can't say what should be inside the [], but it must match, or the LabJack driver could write into invalid memory.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.