LJUD driver : re-Open with serial number the the firstFound Labjack gives error 1007 | LabJack

LJUD driver : re-Open with serial number the the firstFound Labjack gives error 1007

2 posts / 0 new
Last post
cromda's picture
LJUD driver : re-Open with serial number the the firstFound Labjack gives error 1007


As the happy owner several Labjacks (T7, U6, UE9), i'm writing an application with Delphi to manage both type of drivers, LJUD and LJM.

On start up, the application automatically opens the first found U6 Labjack by a call to the LJUD openLabjack function with the parameter "firstFound" set to 1.

As coding a procedure to open later a Labjack choosen into the list returned by the ListAll function, I noticed that :

- (re)opening the firstFound Labjack by calling openLabjack with pAddress set to local ID or serial number and firstFound set to 0 failed : error 1007 ("Labjack not found"),

- others Labjacks could be opened with local ID or serial number and firstFound set to 0.

This was a little bit of confusing, because according to the §4.2.2 of the U6 datasheet it can be understood that repeated open request to the same Labjack with the same connection type alway give the same handle and should be successfull.

After some investigations, I found that succesfull (re)opening the firstFound Labjack by it's local ID or serial number is possible if the close() function is called just before.

(it seems that the close() function is not documented in the U6 data sheet)

So I concluded that the § 4.2.2 don't applies when the firstFound parameter is changed from 1 to 0.

A workaround can be, by example, to rewrite an openLabjack function witch :

- if the firstFound parameter=1, call the listAll function and then call the original openLabjack with the pAdress set to the first Labjack serial number and the firstFound parameter set to 0.

This is quite simple with Delphi and the issue is not blocking, but (just for my culture) :

=> could you, please, give me some details on what is the (good) use of the function close() ?

With my best congratulations for yor excellent devices and the quality of their documentation.

rémi cormier

(french retired mechanical enginner and Labjack hobbyist)


Attachments : test program output with close function not called and called after open firstfound

for reference :

versions : LJUD driver : 3.5 ; U6 firmware : 1.450 ; BoatLoader : 6.150 ; Hardware : 2.000 ; OS : Win10-64 ; Delphi : 10.3.

LabJack Support
labjack support's picture
Thank you for your kind words

Thank you for your kind words.

The close() function is primarily for letting other programs have access. Only one process can claim the connection to a U6 at once, but some systems need multiple processes taking turns talking to the U6. This is somewhat rare. Most applications don't need to worry about calling close(), because the operating system will clean up when the application exits.