Hey all,
I'm using C# and importing the following DLLs:
NationalInstruments.Common
NationalInstruments.NI4882
NationalInstruments.VisaNS
I have a pretty complex system setup with about 7 different pieces of instrumentation on teh GPIB bus, and a lod of serial devices.
I have a function called VisaSend()
Everytime this function gets called, which is very frequently, I perform the following:
void VisaSend(string devAddr, string cmd);
{
GpibSession gpib = null;
gpib = new GpibSession(devAddr);
gpib.Timeout = 3000; // 3 sec timeout
gpib.Write(cmd);
Thread.Sleep(55); // let the command simma'
// dispose of the session
(MessageBasedSession)(gpib).~MessageBasedSession();
}
Now, my system will run for hours and hours, but at some point during the night I will get the error:
System.ArgumentException: The given session or object reference is invalid.
VISA error code -1073807346 (0xBFFF000E), ErrorInvalidObject --->
NationalInstruments.VisaNS.VisaException: The given session or object reference is invalid.
VISA error code -1073807346 (0xBFFF000E), ErrorInvalidObject
The bad news is that it happens on random commands, and after random amounts of time.
The good news is, that it seems to be happening on the same device (HP 89441A VSA).
But I serously send it about 2000 different GPIB commands, and it seems fine...I just don't know why
it chokes, and chokes so hard.
My first suspision is that creating and destroying so many GpibSessions may be taking it's toll on the .NET garbage collector.
I don't know. Its so hard to debug when it happens as randomly as this does.
Does anyone have any suggestions?