4.1.1 - Open [U3 Datasheet]
The initial step is to open the LabJack and get a handle that the driver uses for further interaction. The DeviceType for the U3 is:
There is only one valid ConnectionType for the U3:
Following is example pseudocode to open a U3 over USB:
The reason for the quotes around the address (“1”), is because the address parameter is a string in the OpenLabJack function.
LJ_dtU3
LJ_ctUSB
//Open the first found LabJack U3 over USB.
OpenLabJack (LJ_dtU3, LJ_ctUSB, "1", TRUE, &lngHandle);
The ampersand (&) in front of lngHandle is a C notation that means we are passing the address of that variable, rather than the value of that variable. In the definition of the OpenLabJack function, the handle parameter is defined with an asterisk (*) in front, meaning that the function expects a pointer, i.e. an address.
In general, a function parameter is passed as a pointer (address) rather than a value, when the parameter might need to output something. The parameter value passed to a function in C cannot be modified in the function, but the parameter can be an address that points to a value that can be changed. Pointers are also used when passing arrays, as rather than actually passing the array, an address to the first element in the array is passed.
Talking to multiple devices from a single application is no problem. Make multiple open calls to get a handle to each device and be sure to set FirstFound=FALSE:
//Open U3s with Local ID #2 and #3.
OpenLabJack (LJ_dtU3, LJ_ctUSB, "2", FALSE, &lngHandleA);
OpenLabJack (LJ_dtU3, LJ_ctUSB, "3", FALSE, &lngHandleB);
… then when making further calls use the handle for the desired device.