Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Why do my Serial Reads result in BFFF003E errors?

I am connecting to a device that communicates on RS-422.  Using an NI PXI RS-485/22 card and NI-VISA.  Usually (but not always) when the device is powered off, I get an error on my periodic polls of the port.  The only solution so far is to close the port and reopen it, but the very next read attempt ends in the same failure. 

 

Lather, rinse, repeat.

 

It wouldn't be so bad, but all this opening and closing is really bogging down my application so that if the device is off upon startup, my software starts up noticeably slower and the overall performance is greatly impacted. 

 

Is there some sort of hardware situation (state of lines) that would be causing this?  Am I simply reading the same single error over and over without clearing it (until I get a successful read)?  Am I going mad?

 

Please advise.

Dan

0 Kudos
Message 1 of 7
(3,514 Views)

Hello Dan,

 

Thank you for bring this issue to the forums. Firstly, you are not mad. I found other people had this similar issue and I think I have a Knowledge Base (KB) which could fix your error.

 

Please follow this link: http://digital.ni.com/public.nsf/allkb/60DDFED7EFEFE7188625705700750821?OpenDocument

 

This KB explains how the problems arises from the VISA Write function which causes an Invalid Device Request. The KB also outlines a workaround.

 

Let me know if this works.

 

Thank you,

Vimal Fernandez

Applications Engineer
National Instruments
0 Kudos
Message 2 of 7
(3,502 Views)

The error only occurs after a serial read attempt.  During the time that the device is powered off and no messages should be available at my serial port.  There appears to be a number of bytes available (keeping in mind that the attached device is not yet operational), after my attempted read of these "ghost" bytes, I receive the error.  I then flush both buffers, close the port, and then reopen the port.  I then cycle through my loop.

 

Other areas of the software are transmitting periodic data also regardless of the power state of the connected device and are not erroring out.

0 Kudos
Message 3 of 7
(3,499 Views)

Hi,

 

So, a solution would be to somehow get rid of these "ghost" bytes? And you accomplish this by " flush[ing] both buffers, clos[ing] the port, and then reopen[ing] the port." But, this adveresly affects the speed of your loop. Is this correct?

 

Also, in the previous KB, have you tried to change the VISA Buffer setting? 

From the KB I see, " By default, each VISA Read and Write is followed by a VISA Flush call when communicating via RS-232. You can change the VISA Buffer setting to keep VISA from executing the flush call to avoid this error."

 

Thank you,

Vimal Fernandez

Applications Engineer
National Instruments
0 Kudos
Message 4 of 7
(3,497 Views)

Your summary appears correct.  I have attached the code for reading and resetting the connection.

 

I have not attempted yet to modify the buffer settings.  I will do so and reattempt. 

 

Dan

0 Kudos
Message 5 of 7
(3,494 Views)

No luck.  I have implemented the attached code.  I added the buffer size update and some code that identifies just how many bytes are appearing at the port.

 

The current behavior is as follows:  Returning --1073807298 errors with non-zero byte counts.  The byte counts sometimes drop in number, but do not approach zero (ie--48, 57, 52, 59, ... no discernable pattern).  As the number gets larger, however, there are no drops in count and the errors keep coming.  Eventually, I hit 4096 bytes available and the error switches to -1073807252 (which I think is a buffer overflow, which makes sense considering the size of buffer I ordered). 

 

Again, this error occurs during the only scenario when I should be receiving ZERO bytes at the serial port.  The biggest message I should be receiving regardless would be three bytes long.  It should take me almost 20 minutes of no buffer servicing to fill a 4k buffer, but I am doing it in 30 seconds when I'm connected to a device that is powered off.

 

It's not making any sense...

 

Dan

0 Kudos
Message 6 of 7
(3,478 Views)

Hey Dan,

 

It's a possibility that you're hitting a limitation of your current driver version. Have you tried updating your NI-VISA driver? Navigate to the link below and update your driver. Let me know if that changes anything.

 

http://www.ni.com/nisearch/app/main/p/bot/no/ap/tech/lang/en/pg/1/sn/catnav:du,n8:3.25.123.1640,ssna...

 

As far as your second error you were receiving, I found the following KB (Knowledge Base):

 

http://digital.ni.com/public.nsf/allkb/D776A9D834B132AB86256ED2004E18EF

 

Spend a minute examining this KB and try implementing it.

 

 

Regards,

Renée M
Applications Engineer
National Instruments
Message 7 of 7
(3,467 Views)