11-09-2012 07:34 AM
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
11-09-2012 10:15 AM
Look at the examples in C:\Users\Public\Public Documents\National Instruments\NI-VISA\Examples\DotNET4.0\
11-12-2012 12:50 AM
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