C# LJUD.ListAll fails if any U6 resource is being used | LabJack
 

C# LJUD.ListAll fails if any U6 resource is being used

3 posts / 0 new
Last post
NateRoth
NateRoth's picture
C# LJUD.ListAll fails if any U6 resource is being used

I am trying to list all attached U6 devies (much like LJ Control Panel does). If any program has control of a connected U6 device the UD wrapper function LJUD.ListAll will throw an exception with a labjack error code DEVICE_ALREADY_OPEN. If it's not possible to get information about a device that is already in use, is it at least possible to get information about the remaining devices that are available?

I am using the UD wrapper for C# v 3.5

LabJack Support
labjack support's picture
ListAll will look through all

ListAll will look through all of the available devices before returning an error, so you can use it to capture information about all unclaimed devices if you handle the exception LJUD.LJUDERROR.DEVICE_ALREADY_OPEN.

The output parameter numFound should return the correct number of devices total, including claimed devices.

Each of the remaining output parameters will return data entries for each device found, but where there is a claimed device the entry will be equal to the value 1010 (the code for the error LJE_DEVICE_ALREADY_OPEN). For example, if the second device found was claimed then serialNumbers[1], IDs[1], and addresses[1] would equal 1010.

NateRoth
NateRoth's picture
I did not think to check the

I did not think to check the output parameters after the function threw an exception. That's definitely not a common thing in the C# language.

Thank you for you help. I am now able to get the error data as well as information for the rest of the non-occupied labjacks to enumerate.