Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Get any/all VISA-USB Addresses

Solved!
Go to solution

and you might want to remove the reference to IVI.Visa

0 Kudos
Message 11 of 24
(2,662 Views)

Thanks, but the resource string 

"USB0::0x05E6::0x2601::4018686::INSTR"
is precisely what I would like to retrieve. After retrieving the resource string, I can open communication with the device.
0 Kudos
Message 12 of 24
(2,657 Views)

Sorry , I missed that.

 

Here's some code I wrote a while ago. It's in C# but you should be able to translate it to VB.

I don't have any hardware at my desk so I didn't test it, but I think it works.

 

Curt

 

private bool FindUSBResources()
        {


            HardwareInterfaceType intType;
            short intNum;

            try
            {

                string[] resources = ResourceManager.GetLocalManager().FindResources("?*");
                Trace.WriteLine("FindUSB " + resources.Length); 
                //string[] resources = ResourceManager.GetLocalManager().FindResources(m_resourcename );
                if (resources.Length > 0)
                {

                    foreach (string s in resources)
                    {
                        ResourceManager.GetLocalManager().ParseResource(s, out intType, out intNum);
                        if (s.Contains(m_resourcename) == true)
                        {
                            m_sessiontype = 0;

                            return true;
                        }
                    }
                }
                else
                {
                    return false;
                }
                return false;
            }
            catch (VisaException vex)
            {
                Trace.WriteLine("Visa: " + vex.Message.ToString());
                return false;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message.ToString());
                return false;
            }


        }
0 Kudos
Message 13 of 24
(2,649 Views)

 

In the line: ResourceManager.GetLocalManager().FindResources("?*")

 I get an error saying: GetLocalManager is not a member of ResourceManager

 

ResourceManager is OK as it is a member of Imports NationalInstruments.Visa

0 Kudos
Message 14 of 24
(2,640 Views)

Hi

 

This code worked for me.

 

Here's the output. I don't have any instruments connected.

 

0 ASRL1::INSTR

1 ASRL10::INSTR

2 GPIB0::INTFC

 

GetLocalManager() is listed here...

http://zone.ni.com/reference/en-XX/help/370627F-01/mstudiowebhelp/html/1ab541cb/ 

 

 

Curt

 

   Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim intType As HardwareInterfaceType
        Dim intNum As Short
        Dim j As Integer

        Try

            Dim resources As String()

            resources = ResourceManager.GetLocalManager().FindResources("?*")

            For j = 0 To resources.Length - 1
                Debug.WriteLine(j.ToString() + " " + resources(j))
            Next

        Catch ex As Exception

        End Try
    End Sub

 

0 Kudos
Message 15 of 24
(2,635 Views)

... ResourceManager.GetLocalManager...  doesn't work for me. Are you using VisaNS.dll for reference?  I've got : nationalinstruments.Visa and IVI.Visa referenced. I can't find VisaNS.

 

imports: 

Imports NationalInstruments.Visa
Imports Ivi.Visa

0 Kudos
Message 16 of 24
(2,631 Views)

Hey,

 

I have

 

Imports NationalInstruments.VisaNS

 

The Reference I have is Ver 13.0.35.190

The version of NI-VISA listed in MAX is 14.0.1

 

Curt

 

 

 

 

0 Kudos
Message 17 of 24
(2,629 Views)

Here's what I have. I don't have NationalInstruments.VisaNS and I don't know how to get it.

Untitled.jpg

0 Kudos
Message 18 of 24
(2,625 Views)

Hi,

 

Look in the NI folder under C:\Program Files (x86). It should be in one of the Measurement Studio folders.

 

Mine is located at

 

C:\Program Files (x86)\National Instruments\MeasurementStudioVS2008\DotNET\Assemblies\Current\NationalInstruments.VisaNS.dll

 

If you can't find it, you might have to reinstall and select the option to install support for .NET

 

Curt

0 Kudos
Message 19 of 24
(2,613 Views)

Well I guess that's the problem. I don't have Measurement Studio. Do I need to buy it?

0 Kudos
Message 20 of 24
(2,605 Views)