« Close

Datasheets and User Guides

App Notes

Software & Driver

 

4.3.1 - Open

The initial step is to open the LabJack and get a handle that the driver uses for further interaction. The DeviceType for the UE9 is:

LJ_dtUE9

There are two choices for ConnectionType for the UE9:

LJ_ctUSB
LJ_ctETHERNET

Following is example pseudocode to open a UE9 over USB:

//Open the first found LabJack UE9 over USB.
OpenLabJack (LJ_dtUE9, LJ_ctUSB, "1", 1, &lngHandle);

Following is example pseudocode to open a UE9 over Ethernet:

//Open a specified LabJack UE9 over Ethernet.
OpenLabJack (LJ_dtUE9, LJ_ctETHERNET, "192.168.1.209", 0, &lngHandle);

The reason for the quotes around the address is because the address parameter is a string in the OpenLabJack function.

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 UE9s over USB with Local ID #2 and #3.
OpenLabJack (LJ_dtUE9, LJ_ctUSB, "2", FALSE, &lngHandleA);
OpenLabJack (LJ_dtUE9, LJ_ctUSB, "3", FALSE, &lngHandleB);

… then when making further calls use the handle for the desired device.