08-02-05 12:51 PM
"Simon Elliott" <Simon at ctsn.co.uk> wrote:
>On 02/08/2005, Floyd L. Davidson wrote:
>
>
>By EOF do you mean DCD dropping?
No. If you read from a file... EOF of course is an indication
that the read asked for data past the end of the file. There is
no physical "end of the file" when reading from a serial port,
but unix implements a method (with ICANON set) where a "special
character" (c_cc[VEOF], which is usually ^D) will cause the
device driver to indicate an end of file condition to a read()
request.
All of which is to say, your use of the serial port might never
need to look for an "EOF"... but if it does you'll need to
configure the port so that it can detect EOF!
>I need to read bytes as they are sent, irrespective of DCD, and monitor
>DCD separately via ioctl and TIOCMGET. I hope CRTSCTS implements a
>"real" RTS/CTS flow control with the RTS and CTS lines only, and
>ignores DCD, otherwise I'm going to have to very rapidly learn about
>Linux device drivers!
If you clear CLOCAL and enable CRTSCTS, you will in fact have
effective hardware flow control. You can use/monitor the other
modem control lines for whatever purpose you like!
Note all of the various ways that you can also use signals to
interact with the device driver too, though using any of them
except perhaps SIGINT and SIGHUP will get complicated.
In addition to the ones I mentioned in the other article, you
can also get SIGIO to notify when a data is received. Most
people avoid that like the plague... but there is a good
example of how to use it on my web site at the URL previously
mentioned.
>
>Looks like this is what I need. Thanks again for your help.
You've got me scratching my head and opening a few books to make
sure I get this right! (In addition to APUE, Stevens wrote a
couple volumes on networking and interprocess communications
that most unix programmers can't live without. He also used to
post to Usenet before his untimely death, and unfortunately all
the rest of us put together can't make up for what we lost.)
--
Floyd L. Davidson <http://www.apaflo.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd@apaflo.com
[ Post a follow-up to this message ]
|