Skip to main content
Skip table of contents

11.1 - Opening A LabJack Manually (Applies to UD-Series)

There may be applications, most likely ones running in the Runtime version of DAQFactory, where you do not know the ID or address of the LabJack when creating the application and so can't hard code this in. Because of this, the LabJack driver has a function to allow you to manually open a LabJack, returning a device number that you can use with the rest of the functions just like before. For example, to open a UE9 at Ethernet address 192.168.2.1, you might do:

global DNum
private err
err = OpenLabJack(LJ_dtUE9, LJ_ctETHERNET, "192.168.2.1", 0, @DNum)
if (err != LJE_NOERROR)
// failed to open
endif

This of course assumes you've done your using() and include() calls elsewhere already. In this example we used static parameters, but there is no reason you couldn't replace any or all of the parameters with variables that could be edited by the end user from pages you created.

Once successfully called, you should then use the DNum variable in all your other LabJack function calls.

A few points:

  • There is no way to close a LabJack. This is handled automatically when you quit DAQFactory. That said, you don't want to go randomly opening LabJacks that don't exist as each attempt will use a little memory that can't be recovered until you quit DAQFactory.
  • If you call OpenLabJack() with the exact same parameters, the function will not reopen the LabJack, but rather will return Device Number of the previously opened LabJack. Of course if the first call to OpenLabJack() failed, it will try again.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.