List of avalaible Visa Instruments

I have the need to find the availabe Visa instrument connected to system.
Looking in source code of OpenTap, I find a method in VisaDeviceDiscovery class that is

   class VisaDeviceDiscovery : IDeviceDiscovery
        private static string[] GetDeviceAddresses()

but both class and method are private.
So how can I use them?
Thanks a lot for answer.

1 Like

@ralphmagpie where are you using this? You should be able to just use the [VisaAddress] attribute and it will provide you with a list:

        // Using the VisaAddress attribute results in the editor being populated with all available instruments,
        // as discovered by querying VISA.
        public string VisaAddress { get; set; }

1 Like

Hi Brennen,
sincerly speaking I don’t understand how to get list of available visa instruments with VisaAddressAttribute.
I have found another way that is

 Assembly design = Assembly.LoadFile(@"C:\OpenTap.dll");
 var myclass = design.GetType("OpenTap.VisaDeviceDiscovery");
 var method = myclass.GetMethod("GetDeviceAddresses", BindingFlags.NonPublic  | BindingFlags.Static);
 var result = method.Invoke(null, new object[] { });
 foreach(string r in (string[])result)

This works, but it isn’t an elegant solution, and I’m very curious about solution you suggested.

Hi @ralphmagpie ,
The VisaAddressAttribute is to get a list of available VISA devices from the Editor GUI when setting the address for an instrument. It’s not for getting VISA devices in code. Which one are you wanting to do?

1 Like

Hi @john.berlien
my goal is obtain the string of available Visa Addresses di put in a combobox

So it sounds like you’d want to just use the VisaAddress attribute on a string property in your Instrument. That’s OpenTAP’s built-in way to see available VISA instruments in the GUI.

1 Like

Note that the Visa Address attribute works fine in Editor but not in TUI. I’ll post on the appropriate support site…