Why Do I Get Buffer Overflows with My Serial Port When Using VISA with Flow Control?
My serial port is reporting a buffer overflow on LabVIEW Real-Time and I am using NI-VISA with hardware or software flow control. Why is the flow control not preventing FIFO overflows?
This problem can be caused by several factors. These include the speed of your computer, the baud rate that you are using, the size of your serial port's FIFO, and the FIFO size of the instrument that is transmitting data to the serial port.
The flow control will wait until a specific number of bytes are in the buffer before asking the processor to send a message or signal to the other device to quit transmitting. At higher baud rates the serial port will receive a few bytes from the time the buffer flow control level is reached and the instrument stops transmitting. These extra bytes coming in will be greater if a higher priority process has control of the real-time target's processor. Since the process is a higher priority than the VISA interrupt, no action will be taken by the processor until the higher priority process is finished with the real-time processor.
The default VISA and Windows settings for a 16 byte FIFO is 14 bytes leaving 2 bytes in the FIFO when the device attempts to send the message to the sending device. At higher baud rates on slower computers it is very possible to receive more than 4 bytes from the time the serial port requests the processor to send the signal the instrument finally stops transmitting.
On LabVIEW Real-Time or using a NI Serial hardware
Open MAX and locate the serial port that is having the problem under Devices and Interfaces. After clicking on the COM port an Advanced Settings tab should appear in the right pane. These settings should allow you to lower the Receive Buffer size. You should lower the buffer size until the issue is resolved.
Depending on the loading of the system (e.g. long periods of time spent in high priority tasks or loops), you may be more likely to starve serial hardware processing tasks. This can result in more RX FIFO overruns since the serial hardware isn't being serviced often enough. To avoid this, configure NI-Serial's interrupt handling mode. Please see Performance on LabVIEW Real-Time in the NI-Serial Help for more information on configuring the interrupt handling mode. This setting has no effect for C Series modules.
On Compact RIO and FieldPoint
Open MAX and find the serial ports attached to the controller, you will notice that Advanced Tab does not appear. Instead of using this tab to set the request level for raising the hardware flow control line, we must modify a file located on the controller. Modify the niserial.dbs file located in the c:\ni-rt\system directory on the controller. Directly under the line SerialPortName = "COM1" add the following lines: RXFIFO = 1. The possible values for the RXFIFO are 1, 4, 8, and 14. Modifying this file will allow you to change the trigger level of the hardware flow control.
To fix this problem you need to open up the Device Manager in Windows. Then, find the COM port you want to modify the settings for and open up it's properties. Next, click on the Advanced Tab. You will see a slider that should allow you to change the size of the receive buffer, so that the UART will enable the flow control sooner.
The default value should be sufficient in most cases. However, if you are getting buffer overflow errors you should decrease this value. This will cause more interrupts to be sent to the processor and slow the bytes into the UART. If you increase this value bytes may overflow the FIFO buffer.
External Link: Settings for the 16550 UART FIFO Buffer
Report Date: 07/15/2004
Last Updated: 12/26/2012
Document ID: 3BE87GW3