Mullen, Patrick wrote:
> [ Look! A post about programming! ;-) ]
Sorry, that's off-topic here. This list is strictly for spam :)
> I am writing a modem program, and was hoping you would be able to help.
> This is a recurring theme, but I finally have a good start on both
> the modem I/O and the surrounding logic (Finally!!).
>
> The simplest way to explain my situation is that I need a simple,
> reliable way to read status codes from the modem, especially the CONNECT
> string. This probably goes hand in hand with the need for a clean way
> to get modem I/O. Currently, I'm not sure how to best extract information
> from the dev file properly; I get repeat information and missing information
> a lot.
Hmm. The main thing is to set the tty driver to a useful state at the
outset, with tcsetattr(). After that, you should just be able to use
fputs() and fgets() to talk to the modem.
> Is there a way to have input reads with a timeout, where I will wait
> a few seconds and if nothing is there it returns and if I'm reading it waits
> until there's a pause before returning?
The usual approaches are to either:
a) install a SIGALRM handler which interrupts system calls (e.g. using
sigaction without the SA_RESTART flag), then use alarm() to set a
timeout. When the signal is delivered, the I/O operation will fail
with the error EINTR.
b) use select() with a non-NULL timeout, and use non-blocking I/O when
reading.
> How do I properly handle lock files
>
> so I don't step on a ppp connection or something?
pppd appears to use fcntl() locks instead of lock files. However,
getty programs and e.g. mincom use lock files.
--
Glynn Clements <[EMAIL PROTECTED]>