Re: RS232 Redirector Program in C using Linux



Grant Edwards <grante@xxxxxxxx> writes:

On 2008-01-21, William Pursell <bill.pursell@xxxxxxxxx> wrote:
On Jan 21, 5:42 am, Steffen <steffen.ku...@xxxxxxxxx> wrote:

I need some help with a c program I am writing.

I can't answer your immediate questions, but I do have a
thought: you don't need to use signals. You might be happier
if you use select/poll/epoll instead. That might simplify the
design and make it easier to track down the error, if it
doesn't eliminate the error completely.

You definitely want to avoid signals if possible. You have to
be very careful about what you're allowed to do in a signal
handler.

Use poll or select. It's a lot simpler. Another option is to
use two threads or processes (IIRC, that's how some serial
programs like kermit used to work back in the days before
poll/select). But poll/select is a lot easier.

It doesn't simulate blocking on both ends as nicely as when using
blocking I/O in two threads though, IMHO.

This example uses two PTYs to simulate two serial endpoints in
software, but it would be trivial to adapt it to link to one or two
real serial ports. The iochannel and thread stuff can be used
directly. Just fix up main() to open the ports, and pass those fds
into the iochannel constructor.

http://people.debian.org/~rleigh/ptyjoin.cc


Regards,
Roger

--
.''`. Roger Leigh
: :' : Debian GNU/Linux http://people.debian.org/~rleigh/
`. `' Printing on GNU/Linux? http://gutenprint.sourceforge.net/
`- GPG Public Key: 0x25BFB848 Please GPG sign your mail.

Attachment: pgpol8ftTQXLv.pgp
Description: PGP signature



Relevant Pages

  • Re: Using operator->
    ... * This class is used to represent a single field in a row of a ... * signals when the field value is changed. ... }; // namespace pqxxobject ... http://gimp-print.sourceforge.net/ GPG Public Key: 0x25BFB848. ...
    (comp.lang.cpp)
  • Re: RS232 Redirector Program in C using Linux
    ... You definitely want to avoid signals if possible. ... using blocking I/O in two threads though, ... or two real serial ports. ... pass those fds into the iochannel constructor. ...
    (comp.os.linux.development.apps)