Problem detecting and reacting to serial break

Paul Thornton prt at prt.org
Sun Aug 15 00:03:48 UTC 2010


Ed Schouten wrote:
> * Paul Thornton <prt at prt.org> wrote:
>> I'm using 8.0-RELEASE with uftdi and ucom driving the serial port.
> 
> Somewhat unrelated question: have you ever tried running the this code
> on 7.x? If so, did it work?

I've just tried this on 7.2-RELEASE (that was the only 7.x CD I could
find lurking about my desk).

Something is clearly quite different between 7 and 8 here:

On 7.2, it doesn't like my tcsetattr:

[root at test1 /usr/local/src]# ./dmxrx2
Opened /dev/cuaU0 on file handle 3
before: c_iflag=2106 c_oflag=3 c_cflag=cf00 c_lflag=400
tcsetattr: Invalid argument

No amount of fiddling with the options would make it work, so I used
stty to set the paramaters of /dev/cuaU0.init to what I wanted:

stty -f /dev/cuaU0.init speed 250000 -icanon -isig -echo cs8 clocal
  cstopb cread ignpar -ixany -ixon -ixoff -ignbrk brkint -imaxbel -icrnl

... and re-ran with some more debug ...

[root at test1 /usr/local/src]# ./dmxrx2
Opened /dev/cuaU0 on file handle 3
before: c_iflag=6 c_oflag=3 c_cflag=cf00 c_lflag=400
tcsetattr: Invalid argument
after: c_iflag=6 c_oflag=3 c_cflag=8f00 c_lflag=400
calling read with 513 bytes to go
^CCaught a signal: 2

So I now hang in a blocked read().

A quick and dirty test of "hd /dev/cuaU0" gives one line of zeros and
then hangs.  Under 8.0, this continually dumps the data coming in as you
might expect it to.

Were there any significant serial changes between 7.x and 8.0 which
might explain this?  I don't have enough understanding of how FreeBSD's
serial internals should work to debug this on my own, but am more than
happy to try all suggestions made.

Paul.


More information about the freebsd-hackers mailing list