« Close

Datasheets and User Guides

App Notes

Software & Driver

 

11.2 - Raw In/Out and Other Functions That Require Array Pointers

The Raw In and Raw Out functions (LJ_ioRAW_IN, LJ_ioRAW_OUT), and several other functions of the LabJack require an array pointer. You can pass a pointer to an array, just like you've been passing references to variables, using the @ sign. Just make sure you have preinitialized the array to the correct amount. So, using the example in the LabJack User's Guide for Raw In and Out, the DAQFactory script would look like this (assuming first found and that you've done the using() and include() somewhere else):


private writeArray = {0x70,0x70} 
private readArray = {0x00,0x00} 
private NumBytesToWrite = 2 
private NumBytesToRead = 2 
eGet(0, LJ_ioRAW_OUT, 0, @NumBytesToWrite, @writeArray) 
eGet(0, LJ_ioRAW_IN, 0, @NumBytesToRead, @readArray) 

Internally, DAQFactory will convert the array of double precision values, which is the only numeric data type supported in DAQFactory, to an array of bytes. This means that each element in the array should be between 0 and 255. The array also must be 1 dimensional. Most importantly, the array MUST be preinitialized to the proper length. The driver does not look at the previous parameter to make sure you have the correct array size, any more than the C version would do. If you do not preinitialize, you are likely to crash DAQFactory. Worse, it may work sometimes, but crash others, so be careful with this one.