4.3.8 - Raw Output/Input [U3 Datasheet] | LabJack
« Close

Datasheets and User Guides

App Notes

Software & Driver


4.3.8 - Raw Output/Input [U3 Datasheet]

There are two IOTypes used to write or read raw data. These can be used to make low-level function calls (Section 5) through the UD driver. The only time these generally might be used is to access some low-level device functionality not available in the UD driver.


When using these IOTypes, channel # specifies the desired communication pipe. For the U3, 0 is the normal pipe while 1 is the streaming pipe. The number of bytes to write/read is specified in value (1-16384), and x1 is a pointer to a byte array for the data. When retrieving the result, the value returned is the number of bytes actually read/written.

Following is example pseudocode to write and read the low-level command ConfigTimerClock (Section 5.2.4).

writeArray[10] = {0x05,0xF8,0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00};
numBytesToWrite = 10;
numBytesToRead = 10;

//Raw Out.  This command writes the bytes to the device.
eGetPtr(lngHandle, LJ_ioRAW_OUT, 0, &numBytesToWrite, writeArray);

//Raw In.  This command reads the bytes from the device.
eGetPtr(lngHandle, LJ_ioRAW_IN, 0, &numBytesToRead, readArray);


I don't see how this pseudo code can work in C++.
I am trying to communicate with a 1 wire device using the Raw Input/Output in C++.

In LJUD_DynamicLinking.h the prototype for the eget command is:
typedef LJ_ERROR (CALLBACK *teGet) (LJ_HANDLE, long, long, double *, long);
This matches the documentation for eGet
LJ_ERROR _stdcall eGet (LJ_HANDLE Handle,
                                    long IOType,
                                    long Channel,
                                    double *pValue,
                                    long x1)

but the example
eGet(lngHandle, LJ_ioRAW_OUT, 0, &numBytesToWrite, pwriteArray);
implies a prototype of
typedef LJ_ERROR (CALLBACK *teGet) (LJ_HANDLE, long, long, long *, double *);

It's hard to tell because the data types are not specified in this example.

My 1-wire device takes a 64-byte command so I create an array of 8 doubles.
I set the bytes according to the specs of the device and pass this in for the pValue array.
It's not clear what x1 should be so I set it to the number of bytes=64.
I get INVALID_RAW_IN_OUT_ERROR which tells me very little.

I feel like I am missing something.
Any clarification on this pseudo code would be appreciated.


The short answer is that the pseudo code is correct, though a bit confusing.  The numBytesToWrite parameter is a double and passed by reference (&) into eGet.  pWriteArray is technically a pointer, but in this case cast to an int and passed as the x1 parameter.

For a more in depth explanation about why this is the case please see this.