Skip to contentSkip to conversation

serial flow control appears broken

DISCUSSION Lee Howard 4 participants 9 messages Jul 26, 2007 – Jul 27, 2007 TTY layer and serial drivers

lore
Share & tools
lore

Lee Howard

author
#0 lore raw

Hello.

I have fax modems that will, in their proper behavior with certain features, send up to 64 kilobytes of data to the host DTE all at once. (So, the fax modem handles an incoming fax and periodically will send between 256 bytes and 64 kilobytes of data in bursts.)

When the DCE-DTE (modem-to-host) communication rate is established at 115200 bps data loss occurs systems using at least Linux kernels 2.6.5 and 2.6.18 (and probably everything in-beween and then some more). This is because the modem overflows the host's buffer. This is evidenced in kernel logging:

Jul 23 14:01:30 gollum kernel: ttyS1: 1 input overrun(s)
Jul 23 17:09:45 gollum kernel: ttyS1: 1 input overrun(s)

Normally I would blame the modem itself for not honoring the host's flow control signals. However, I have worked with the modem manufacturer closely on this matter for over three months now. In that process they have improved the responsiveness of the modem and have fixed other problems, but the end result is that it truly does appear that the serial tty driver is not using flow control. Whether software flow control (XON/XOFF) or hardware flow control (RTS/CTS) is used the result is the same.

This is evidenced in hardware flow control by a little LED labeled "RTS" that is on the external modem. This LED lights up when pin 7 of the DB9 serial connection is given +12Vdc current (signalling "RTS" is on - that the host can accept data). The LED goes dark when the current is removed (signalling that the host cannot accept data). This "RTS" LED never flickers at all, as it should, when receiving these bursts of data - the LED stays lit as long as the serial cable is connected to the host... and yet I will see those "input overrun" messages. Thus, it seems quite clear that the Linux serial tty driver is not deasserting RTS as it should in hardware flow control. (And probably the analogous problem exists in software flow control, too.)

Please tell me what I can do to help you resove and/or remedy this matter. Also, please let me know if I have contacted the wrong people. (I have cross-posted to linux-kernel as a catch-all. I am not subscribed to either linux-serial or linux-kernel mailing lists. So please CC me in any list responses.)

If it is of any value to know (perhaps they have common code?), the same error occurs on FreeBSD 6.2 as well. The problem does not occur on Windows. The problem does not occur on RedHat 6.0 (kernel 2.2.5).

Thanks,

Lee.

#1 lore raw

Hello,

Quoted 11 lines

This is evidenced in hardware flow control by a little LED labeled "RTS" that is on the external modem. This LED lights up when pin 7 of the DB9 serial connection is given +12Vdc current (signalling "RTS" is on - that the host can accept data). The LED goes dark when the current is removed (signalling that the host cannot accept data). This "RTS" LED never flickers at all, as it should, when receiving these bursts of data
- the LED stays lit as long as the serial cable is connected to the host... and yet I will see those "input overrun" messages. Thus, it seems quite clear that the Linux serial tty driver is not deasserting RTS as it should in hardware flow control. (And probably the analogous problem exists in software flow control, too.)

I don't know the relevant timings for problem, but just to be sure that your prerequisites are correct: How did you check that the LED stays lit all the time? Just from looking might not be accurate. You might want to mesure the signal with an oscilloscope.

Just my 0.02¢
Uwe

Signature · 7 lines
Uwe Kleine-König

fib where fib = 0 : 1 : zipWith (+) fib (tail fib)
-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw
In reply to Lee Howard

Trivial check:

Did you set the CRTSCTS flag in the c_cflag parameter to tcsetattr() in your linux application code ? Or in the corresponding ioctl(..., TCSETA,...) call ?

Quoted 81 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Lee Howard
Sent: Thursday, July 26, 2007 3:53 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Subject: serial flow control appears broken

Hello.

I have fax modems that will, in their proper behavior with certain features, send up to 64 kilobytes of data to the host DTE all at once.
(So, the fax modem handles an incoming fax and periodically will send between 256 bytes and 64 kilobytes of data in bursts.)

When the DCE-DTE (modem-to-host) communication rate is established at 115200 bps data loss occurs systems using at least Linux kernels 2.6.5
and 2.6.18 (and probably everything in-beween and then some more). This
is because the modem overflows the host's buffer. This is evidenced in
kernel logging:

Jul 23 14:01:30 gollum kernel: ttyS1: 1 input overrun(s)
Jul 23 17:09:45 gollum kernel: ttyS1: 1 input overrun(s)

Normally I would blame the modem itself for not honoring the host's flow
control signals. However, I have worked with the modem manufacturer closely on this matter for over three months now. In that process they
have improved the responsiveness of the modem and have fixed other problems, but the end result is that it truly does appear that the serial tty driver is not using flow control. Whether software flow control (XON/XOFF) or hardware flow control (RTS/CTS) is used the result
is the same.

This is evidenced in hardware flow control by a little LED labeled "RTS"
that is on the external modem. This LED lights up when pin 7 of the DB9
serial connection is given +12Vdc current (signalling "RTS" is on - that
the host can accept data). The LED goes dark when the current is removed (signalling that the host cannot accept data). This "RTS" LED
never flickers at all, as it should, when receiving these bursts of data
- the LED stays lit as long as the serial cable is connected to the host... and yet I will see those "input overrun" messages. Thus, it seems quite clear that the Linux serial tty driver is not deasserting RTS as it should in hardware flow control. (And probably the analogous
problem exists in software flow control, too.)

Please tell me what I can do to help you resove and/or remedy this matter. Also, please let me know if I have contacted the wrong people.
(I have cross-posted to linux-kernel as a catch-all. I am not subscribed to either linux-serial or linux-kernel mailing lists. So please CC me in any list responses.)

If it is of any value to know (perhaps they have common code?), the same
error occurs on FreeBSD 6.2 as well. The problem does not occur on
Windows. The problem does not occur on RedHat 6.0 (kernel 2.2.5).

Thanks,

Lee.

-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw
In reply to Uwe Kleine-König
Quoted 9 lines · Uwe Kleine-König

Hello,

Quoted 5 lines

This is evidenced in hardware flow control by a little LED labeled "RTS" that is on the external modem. This LED lights up when pin 7 of the DB9 serial connection is given +12Vdc current (signalling "RTS" is on - that the host can accept data). The LED goes dark when the current is removed (signalling that the host cannot accept data). This "RTS" LED never flickers at all, as it should, when receiving these bursts of data
- the LED stays lit as long as the serial cable is connected to the
host... and yet I will see those "input overrun" messages. Thus, it seems quite clear that the Linux serial tty driver is not deasserting RTS as it should in hardware flow control. (And probably the analogous problem exists in software flow control, too.)

Quoted 5 lines

I don't know the relevant timings for problem, but just to be sure that your prerequisites are correct: How did you check that the LED stays lit all the time? Just from looking might not be accurate. You might want to mesure the signal with an oscilloscope.

The manufacturer is using a scope to look for RTS and they're not seeing it, either. I just use my eyes to look at the LED, but I can see the CTS, DTR, DCD, RD, and TD lights blink, flicker, or dim... (and TD, RD, and CTS tend to go on and off rather quickly).

All of that said... even though I don't see RTS flicker or blink or dim when using kernel 2.2.5 (RedHat 6.0) I don't have any problems using 115200 bps DTE-DCE communication rate.

Thanks,

Lee.
-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#8 lore raw
In reply to Tosoni

Yes, CRTSCTS is set. Here is what stty says...

# stty -F /dev/ttyS1 -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O;
min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread clocal crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke
#

Thanks,

Lee.

Quoted 96 lines · Tosoni

Trivial check:

Did you set the CRTSCTS flag in the c_cflag parameter to tcsetattr() in your linux application code ? Or in the corresponding ioctl(..., TCSETA,...) call ?

Quoted 83 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Lee Howard
Sent: Thursday, July 26, 2007 3:53 AM
To: [email protected]; [email protected]; [email protected]; [email protected]
Subject: serial flow control appears broken

Hello.

I have fax modems that will, in their proper behavior with certain features, send up to 64 kilobytes of data to the host DTE all at once.
(So, the fax modem handles an incoming fax and periodically will send between 256 bytes and 64 kilobytes of data in bursts.)

When the DCE-DTE (modem-to-host) communication rate is established at 115200 bps data loss occurs systems using at least Linux kernels 2.6.5
and 2.6.18 (and probably everything in-beween and then some more). This
is because the modem overflows the host's buffer. This is evidenced in
kernel logging:

Jul 23 14:01:30 gollum kernel: ttyS1: 1 input overrun(s)
Jul 23 17:09:45 gollum kernel: ttyS1: 1 input overrun(s)

Normally I would blame the modem itself for not honoring the host's flow
control signals. However, I have worked with the modem manufacturer closely on this matter for over three months now. In that process they
have improved the responsiveness of the modem and have fixed other problems, but the end result is that it truly does appear that the serial tty driver is not using flow control. Whether software flow control (XON/XOFF) or hardware flow control (RTS/CTS) is used the result
is the same.

This is evidenced in hardware flow control by a little LED labeled "RTS"
that is on the external modem. This LED lights up when pin 7 of the DB9
serial connection is given +12Vdc current (signalling "RTS" is on - that
the host can accept data). The LED goes dark when the current is removed (signalling that the host cannot accept data). This "RTS" LED
never flickers at all, as it should, when receiving these bursts of data
- the LED stays lit as long as the serial cable is connected to the host... and yet I will see those "input overrun" messages. Thus, it seems quite clear that the Linux serial tty driver is not deasserting RTS as it should in hardware flow control. (And probably the analogous
problem exists in software flow control, too.)

Please tell me what I can do to help you resove and/or remedy this matter. Also, please let me know if I have contacted the wrong people.
(I have cross-posted to linux-kernel as a catch-all. I am not subscribed to either linux-serial or linux-kernel mailing lists. So please CC me in any list responses.)

If it is of any value to know (perhaps they have common code?), the same
error occurs on FreeBSD 6.2 as well. The problem does not occur on
Windows. The problem does not occur on RedHat 6.0 (kernel 2.2.5).

Thanks,

Lee.

-
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Lee Howard
Quoted 4 lines

The manufacturer is using a scope to look for RTS and they're not seeing it, either. I just use my eyes to look at the LED, but I can see the CTS, DTR, DCD, RD, and TD lights blink, flicker, or dim... (and TD, RD, and CTS tend to go on and off rather quickly).

And you have

1. The port set up correctly for flow control options in the
kernel ?
2. Verified that the board vendor remembered to wire it ?

author
#4 lore raw
Quoted 10 lines · Alan Cox
Quoted 3 lines

The manufacturer is using a scope to look for RTS and they're not seeing it, either. I just use my eyes to look at the LED, but I can see the CTS, DTR, DCD, RD, and TD lights blink, flicker, or dim... (and TD, RD, and CTS tend to go on and off rather quickly).

And you have

1. The port set up correctly for flow control options in the
kernel ?

I suppose that you mean that the application has properly set up the port using termios/tcsetattr/ioctl and the like... rather than if the kernel build/config options were set to permit flow control (I know of no relevant flow-control-enabling kernel build options). Using hardware flow control this is what stty tells me about the port set up done by the application:

# stty -F /dev/ttyS1 -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O;
min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread clocal crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke
#

Using software flow control this is what stty tells me about the port set up done by the application:

# stty -F /dev/ttyS1 -a
speed 115200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O;
min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon ixoff -iuclc -ixany -imaxbel
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke
#

They seem correct to me, but I am certainly willing to be wrong.

Quoted 2 lines

2. Verified that the board vendor remembered to wire it ?

I don't know how to verify directly that the board manufacturer wired the serial port correctly. I've tested this on two different motherboards made several years apart (but, yes, both were made by the same manufacturer). However, when using RedHat 6.0 (kernel 2.2.5) I have no problems with data corruption occurring in the data coming from the DCE. So that tells me that *something* was working before that isn't working now... and I'm trying to determine what the difference is... whether it be a problem in modern kernels or whether it be something that the application (HylaFAX) is not doing to accomodate whatever changes occurred in modern kernels.

A quick google on "input overrun(s)" may lend some credence (although, certainly this is not in any way conclusive) that I'm not the only one who may be seeking a solution on this matter.

http://www.google.com/search?hl=en&q=%2B%22input+overrun%28s%29%22

Thanks,

Lee.

#5 lore raw
Quoted 1 line

-parenb -parodd cs8 -hupcl -cstopb cread clocal crtscts

Ok so crtscts is set, but you have clocal set too. That shouldn't matter

Quoted 2 lines

Using software flow control this is what stty tells me about the port set up done by the application:

This also looks fine

Quoted 1 line

They seem correct to me, but I am certainly willing to be wrong.

clocal set as well is unusual but if I remember the spec right then clocal would not interfere with rts/cts handshake and certainly not with xon/xoff

Looks correct, two boards so its unlikely both didnt wire it.

Quoted 5 lines

A quick google on "input overrun(s)" may lend some credence (although, certainly this is not in any way conclusive) that I'm not the only one who may be seeking a solution on this matter.

http://www.google.com/search?hl=en&q=%2B%22input+overrun%28s%29%22

Those look different on the whole - there are two reasons you'll get an input overrun with a 16x50 UART. The first is because we ran out of buffers to empty the chip, in which case we would have asserted flow control in software. The second is if we cannot keep up and fail to empty the on chip FIFO within the required time (about 1mS)

As the flow control is driven by software on most 16x50 chips (there are a couple of exceptions) if we fail to empty the fifo fast enough then any flow control will be asserted too late to save the day.

If you stop the application and do the following

	cat /dev/ttywhatever
	^Z
	[stopped]

(so you are asking the OS to buffer data but not ever reading it)

and then fire data at it does the flow control eventually occur ?

Alan

author
#6 lore raw
Quoted 6 lines · Alan Cox

As the flow control is driven by software on most 16x50 chips (there are a couple of exceptions) if we fail to empty the fifo fast enough then any flow control will be asserted too late to save the day.

If you stop the application and do the following

Quoted 8 lines
	cat /dev/ttywhatever
	^Z
	[stopped]

(so you are asking the OS to buffer data but not ever reading it)

and then fire data at it does the flow control eventually occur ?

Yes it does appear to. I told the application to simply sleep(300) at the appropriate moment, and I watched the application and when it began the sleep I ran:

cat /dev/ttyS1
(lots of "garbage" began spewing forth)
^Z
(about 2 or 3 seconds and the RTS light goes dark)

Thanks,

Lee.