« Close

Datasheets and User Guides

App Notes

Software & Driver

 

4.2.2 - OpenLabJack()

Call OpenLabJack() before communicating with a device. This function can be called multiple times, however, once a LabJack is open, it remains open until your application ends (or the DLL is unloaded). If OpenLabJack is called repeatedly with the same parameters, thus requesting the same type of connection to the same LabJack, the driver will simply return the same LJ_HANDLE every time. Internally, nothing else happens. This includes when the device is reset, or disconnected. Once the device is reconnected, the driver will maintain the same handle. If an open call is made for USB, and then Ethernet, a different handle will be returned for each connection type and both connections will be open.

OpenLabJackS() is a special version of open where DeviceType and ConnectionType are strings rather than longs. This is useful for passing string constants in languages that cannot include the header file. The strings should contain the constant name as indicated in the header file (such as “LJ_dtUE9” and ”LJ_ctUSB”). The declaration for the S version of open is the same as below except for (const char *pDeviceType, const char *pConnectionType, …).

Declaration:

LJ_ERROR _stdcall OpenLabJack (  long DeviceType,
                                 long ConnectionType,
                                 const char *pAddress,
                                 long FirstFound,
                                 LJ_HANDLE *pHandle)

Parameter Description:
Returns: LabJack errorcodes or 0 for no error.
Inputs:

  • DeviceType – The type of LabJack to open. Constants are in the labjackud.h file.
  • ConnectionType – Enter the constant for the type of connection, USB or Ethernet.
  • pAddress – For USB, pass the local ID or serial number of the desired LabJack. For Ethernet pass the IP address of the desired LabJack. If FirstFound is true, Address is ignored.
  • FirstFound – If true, then the Address and ConnectionType parameters are ignored and the driver opens the first LabJack found with the specified DeviceType. Generally only recommended when a single LabJack is connected. Currently only supported with USB. If a USB device is not found, it will try Ethernet but with the given Address.

Outputs:

  • pHandle – A pointer to a handle for a LabJack.