Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 8 Mar 1997 00:28:03 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, swallace@ece.uci.edu
Cc:        bugs@freebsd.org, current@freebsd.org, msmith@atrad.adelaide.edu.au
Subject:   Re: serial driver
Message-ID:  <199703071328.AAA16043@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>What I would expect is to receive the data transmitted before DTR was
>dropped.  According to what Bruce says, data not read by the read()
>call is dropped after DTR is dropped in real time.

I checked what sio does.  It reads all the bytes that arrive before
carrier drops as a side effect of some failsafe code in the interrupt
handler.  It usually calls ttymodem() (which flushes the queues and
sets the TS_ZOMBIE flag) before putting the bytes in the tty input
queue.  The bytes are unavailable to read() because TS_ZOMBIE is set.
Not flushing wouldn't help and it would be inconvenient to delay the
setting of TS_ZOMBIE.  Flushing is done for 5 special events: receipt
interrupt, quit and suspend characters, break interrupts, and hangups.
Flushes can be prevented for the first 3 by setting NOFLSH.

>I just tried setting clocal to the device and it received all the data
>its first time through.  The disadvantage is that the cat program
>still sits there waiting for more data to output to the file so
>I had to press ^C to stop it.
>
>Is there any way to get the functionality I desire?  I want the cat
>program to close / read to fail after all data is read before the DTR
>was dropped.  Don't you think that makes more sense anyways?  I'd
>hate to lose data because the load was too high or whatever and
>my process was not able to read() it before DTR/carrier was lost.

It makes sense, especially since the sender tries hard to send all the
data out before dropping its DTR (the receiver's carrier).  However,
you can't get this functionality currently using a simple program like
`cat'.  To get it, the program needs to set CLOCAL and poll for carrier.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703071328.AAA16043>