02-20-2013 08:49 AM - edited 02-20-2013 09:17 AM
Hello,
I use CNT-90 timer/counter/analyzer. I communicite with usb port with NationalInsturements.VisaNS dll.You can see following c# code for usb communication.
string resourceName = "";
privateboolOpen_Device()
{
string[] resources = ResourceManager.GetLocalManager().FindResources("?*");
foreach (string s inresources)
{
if (s.IndexOf("USB") != -1)
{
resourceName = s;
break;
}
}
try
{
mbSession = (
MessageBasedSession)ResourceManager.GetLocalManager().Open(resourceName);
string query = "*IDN?";
stringresponseString = mbSession.Query(query);
if (string.IsNullOrEmpty(responseString))
returnfalse;
}
catch (InvalidCastException)
{
returnfalse;
//MessageBox.Show("Resource selected must be a message-based session");
}
catch (Exceptionexp)
{
returnfalse;
//MessageBox.Show(exp.Message);
}
returntrue;
}
publicbool Measure_Frequency_MessageBasedSession()
{
string measureKomut = ":MEASure:FREQuency?";
string buffer = mbSession.Query(measureKomut);
//other process...........
return true;
}
When I call my Measure_Frequency_MessageBasedSession function repeatedly (for example more than 100 times) usb communication breaks with the device.Windows usb 2.0 warnin ballon shows on task bar(Warning message="This USB device can run faster than a high-speed USB 2.0 port is connected to") and usb communication breaks.I can access the device when I unplug and plug usb cable with above my code.
Why after a while usb communication break? and Why I have to unplug and plug cable? What can I do for this error?
Thanks in advance.
Note(I use VISA 5.1.2. I reinstall driver but did not work.)