Hi there,
My apologies if this isn't the best forum - Please point me to the right place if that is the case.
I'm trying to talk to a 53131A which has the GPIB address "GPIB0::8::INSTR". I'm using the sample code from the "Using VISA COM I/O API in .NET" App Note:
private void DoInstrumentIO()
{
Ivi.Visa.Interop.ResourceManagerClass rm = new Ivi.Visa.Interop.ResourceManagerClass();
Ivi.Visa.Interop.FormattedIO488Class ioobj = new Ivi.Visa.Interop.FormattedIO488Class();
try
{
object[] idnItems;
ioobj.IO = (Ivi.Visa.Interop.IMessage)rm.Open("GPIB0::8::INSTR", Ivi.Visa.Interop.AccessMode.NO_LOCK, 0, "");
ioobj.WriteString("*IDN ?", true);
idnItems = (object[])ioobj.ReadList(Ivi.Visa.Interop.IEEEASCIIType.ASCIIType_Any, ",");
foreach (object idnItem in idnItems)
{
System.Console.Out.WriteLine("IDN Item of type " + idnItem.GetType().ToString());
System.Console.Out.WriteLine("\tValue of item is " + idnItem.ToString());
}
}
catch (Exception e)
{
System.Console.Out.WriteLine("An error occurred: " + e.Message);
}
finally
{
try { ioobj.IO.Close(); } catch { }
try { System.Runtime.InteropServices.Marshal.ReleaseComObject(ioobj); } catch { }
try { System.Runtime.InteropServices.Marshal.ReleaseComObject(rm); } catch { }
}
}
On the ReadList call it's throwing an exception saying "Unexpected I/O data termination".
I'm a complete NOOB in terms of using this API and I can't find any documentation or comments on this exception so any guidance appreciated.
Environment is:
Windows 10 Pro
Visual Studio 2015 Update 1
IO Suite 17.2
Agilent 82357B GPIB to USB Adapter
Windows Form App targeting .NET Framework 4.5.2
Thanks,
TonyG
My apologies if this isn't the best forum - Please point me to the right place if that is the case.
I'm trying to talk to a 53131A which has the GPIB address "GPIB0::8::INSTR". I'm using the sample code from the "Using VISA COM I/O API in .NET" App Note:
private void DoInstrumentIO()
{
Ivi.Visa.Interop.ResourceManagerClass rm = new Ivi.Visa.Interop.ResourceManagerClass();
Ivi.Visa.Interop.FormattedIO488Class ioobj = new Ivi.Visa.Interop.FormattedIO488Class();
try
{
object[] idnItems;
ioobj.IO = (Ivi.Visa.Interop.IMessage)rm.Open("GPIB0::8::INSTR", Ivi.Visa.Interop.AccessMode.NO_LOCK, 0, "");
ioobj.WriteString("*IDN ?", true);
idnItems = (object[])ioobj.ReadList(Ivi.Visa.Interop.IEEEASCIIType.ASCIIType_Any, ",");
foreach (object idnItem in idnItems)
{
System.Console.Out.WriteLine("IDN Item of type " + idnItem.GetType().ToString());
System.Console.Out.WriteLine("\tValue of item is " + idnItem.ToString());
}
}
catch (Exception e)
{
System.Console.Out.WriteLine("An error occurred: " + e.Message);
}
finally
{
try { ioobj.IO.Close(); } catch { }
try { System.Runtime.InteropServices.Marshal.ReleaseComObject(ioobj); } catch { }
try { System.Runtime.InteropServices.Marshal.ReleaseComObject(rm); } catch { }
}
}
On the ReadList call it's throwing an exception saying "Unexpected I/O data termination".
I'm a complete NOOB in terms of using this API and I can't find any documentation or comments on this exception so any guidance appreciated.
Environment is:
Windows 10 Pro
Visual Studio 2015 Update 1
IO Suite 17.2
Agilent 82357B GPIB to USB Adapter
Windows Form App targeting .NET Framework 4.5.2
Thanks,
TonyG
Have you tried our Command Expert tool? It is a very handy free tool that will help put together a sequence of commands for your instrument, then you can export that code to C# with all of the proper terminations and syntax already taken care of.
www.keysight.com/find/commandexpert
Once you are in the C# environment it will actually give you intellisense for the instruments SCPI commands.
There is a tutorial for exporting C# code in the help portion of Command Expert, I would suggest walking through that if you are interested.