From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Open / connection status

Hej.

 

I am new to C# but have made some GPIB Instrument control in C++ some 10 years ago so I am not a hardcore programmer.

 

My problem is that I want to open a connection to an instrument and then detect if it is there.

If it is not there then I want exit the function.

I have not been able to figure-out how to get the handle status back.

 

I have been looking for a handle that is “null” but found nothing.

And I have been looking for “exceptions” and made some “try and error” but without success.

 

Anyone that can help.

 

 

I am using the VisaNS.

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using NationalInstruments.VisaNS;

 

public void Get_IDN(int i)

   {

     string responseString;

          

     gSession = (GpibSession)ResourceManager.GetLocalManager().Open("GPIB0::20::INSTR");

 

     responseString = gSession.Query("*IDN?\n");

     gSession.ControlRen(RenMode.DeassertAfterGtl);

     gSession.Dispose();

    }

 

/Jan

0 Kudos
Message 1 of 3
(4,871 Views)

Look at the examples in C:\Users\Public\Public Documents\National Instruments\NI-VISA\Examples\DotNET4.0\

 

 

0 Kudos
Message 2 of 3
(4,868 Views)

Hej nyc thanks.

 

I have already been looking on these examples and that was what led me to look for exceptions. More precise I tried to catch "VisaException" but with no luck.

It never registrated any exception though no instrument was connected.

 

So am I searching in the wrong direction.

 

/Jan

 

 

0 Kudos
Message 3 of 3
(4,855 Views)