Re: write
Andreas Fink <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
On Freitag, Oktober 25, 2002, at 12:13 Uhr, Andrea Viscovich wrote:
<image.tiff>
>
>
> I'm trying to be warned when a serial is disconnected from modem.
> There is a problem.
> in at2_write_line
> debug("bb.smsc.at2", 0, "AT2: Before write");
>
> s = write(privdata->fd, octstr_get_cstr(linestr), count);
>
> debug("bb.smsc.at2", 0, "AT2: After write");
>
> If I disconnect the modem from serial, in the log I see AT+CSQ (my
> keepalive)
>
> then I see "Before write" and never see "After write", so I'm sure
>
> write stays there and freezes the thread.
>
> How to solve this? Maybe is only related to cygwin?
I think its related to the fact that the write command uses hardware
handshake.
If the receiving device is physically disconnected, the write never
finishes because its being stopped by the serial port hardware
handshake lines which indicate that the device doesn't accept any data
at the moment.
Maybe a buffered write would make more sense or some ioctl to indicate
a timeout.