LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Why do I get VISA read and write failures talking to Cisco switch?

Hello, all--I have a Cisco 2960 Enet switch I am controlling by sending CLI commands via USB.  I am using LW/CVI 2009 and VISA 5.0.  Despite the errors I am getting with each viread and viwrite, I am controlling it, as it does exactly what I want once I continue through the errors.  With every VISA write I get error 0xBFFF003E: Could not perform operation because of IO error (which is not quite true, because it did write what I wanted it to to the switch).  Then on almost every VISA read I get 0xBFFF0015:  Timeout expired before operation completed.  Once in a great while, a read happens without an error.  But I do read back everything I expect to from the switch.  So what is the deal with VISA and Cisco, and how can I fix the bogus erroring?

0 Kudos
Message 1 of 14
(4,420 Views)

Hello,

 

I was wondering if you get these errors if you perform this operation in VISA test panels in Measurement & Automation Explorer. Also if you use any pre built examples in CVI do you also get these errors?

 

Best Regards,

 

Adam G 

National Instruments
Applications Engineer
0 Kudos
Message 2 of 14
(4,389 Views)

Hi, Adam--

 

Yes, I get the same errors if I use MAX or VIC to talk to the Cisco.  I'll have to take a look at the examples to see if they do anything differently than I am doing in my code, but I'm doubting it at this time.

0 Kudos
Message 3 of 14
(4,383 Views)

Hello,

 

Do you still get the data back when you use the VISA Test Panels? Also does your device require any termination characters? 

 

Best Regards,

 

Adam G 

National Instruments
Applications Engineer
0 Kudos
Message 4 of 14
(4,345 Views)

Sometimes I do, sometimes I don't get the data back using VISA test.  The Cisco uses 0x0D for a termination character, which I've set using

 

  iBaudRate = 9600;
  iDataBits = 8;
   iMode = VI_ASRL_WIRE_232_DTE;
  iParity = VI_ASRL_PAR_NONE;
  iStopBits = VI_ASRL_STOP_ONE;
  iFlowCtrl = VI_ASRL_FLOW_NONE;
  

  ChkErr(viSetAttribute(iHandle, VI_ATTR_ASRL_BAUD, iBaudRate));
  ChkErr(viSetAttribute(iHandle, VI_ATTR_ASRL_DATA_BITS, iDataBits));
  ChkErr(viSetAttribute(iHandle, VI_ATTR_ASRL_PARITY, iParity));
  ChkErr(viSetAttribute(iHandle, VI_ATTR_ASRL_STOP_BITS, iStopBits));
  ChkErr(viSetAttribute(iHandle, VI_ATTR_ASRL_FLOW_CNTRL, iFlowCtrl));
  ChkErr(viSetAttribute(iHandle, VI_ATTR_ASRL_WIRE_MODE, iMode));
  ChkErr(viSetAttribute (iHandle, VI_ATTR_TERMCHAR, 0xD));
  ChkErr(viSetAttribute (iHandle, VI_ATTR_ASRL_END_OUT, VI_ASRL_END_TERMCHAR));
  ChkErr(viSetAttribute (iHandle, VI_ATTR_SEND_END_EN, VI_TRUE));
 
 ChkErr(viSetAttribute (iHandle, VI_ATTR_ASRL_END_IN, VI_ASRL_END_NONE));
  ChkErr(viSetAttribute (iHandle, VI_ATTR_TMO_VALUE, 5000));
  

I've played around with setting the timeout value and flow control and the receive termination character, but this last is kind of tricky since the received data varies too much in format--doesn't always end in a return.

0 Kudos
Message 5 of 14
(4,342 Views)

Hi,

 

I think the problem is the changing termination character. When doing the viRead it is expecting a termination character and never receives one so it times out. If you take off the error checking you might be able to avoid this problem.

 

Best Regards,

 

Adam G 

National Instruments
Applications Engineer
0 Kudos
Message 6 of 14
(4,319 Views)

Ummmm, sorry, no!   ChkErr is on the viSetAttribute.  I don't receive an error there.  The errors I get are when I do a viWrite or viRead (not always the same viRead).  I've removed the error checking from those steps and just collect a viStatus to check what it comes back with--the actual error comes from viRead itself though I guess I won't get the popup in release mode. 

 

      viStatus = viRead(viInstHandle, sReturnString, iStrLen, (ViPUInt32) &iReturnCount);
      if (viStatus == VI_ERROR_TMO)
      {
         return(0);
      }


 I've had to set the receive termination character to "none" because I don't always get a new line back at the end.  Call me picky, but it bothers me that I'm getting an error on almost every communication with the switch, especially the viWrite errors. 

0 Kudos
Message 7 of 14
(4,312 Views)

In your original posting you said you are using USB but the program shows you configuring a serial port. So can I assume you are using a USB-RS232 converter?

 

If so then why don't you try using a regular com port in the PC, which I know most PC's don't have them now a days. If this work then you can point the finger at the converter.

0 Kudos
Message 8 of 14
(4,285 Views)

I connecting from a USB port on my PC to the mini USB on the Cisco.  Since that USB port shows up in MAX as a serial port (COM12), I figured I needed to use serial communication to it.  Am I figuring wrong?  It is working, effective communication is getting back and forth, except for the errors.

0 Kudos
Message 9 of 14
(4,271 Views)

Since your Cisco shows up as serial device, there should be an USB to serial converter build into the Cisco. How did you install the driver for that converter ? Might it be that there was an outdated version of the converter driver ( There are only a few manufacturers for USB to serial converter chips) allready on your PC ?    

0 Kudos
Message 10 of 14
(4,252 Views)