Re: RS232 Redirector Program in C using Linux
- From: Roger Leigh <rleigh@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 21 Jan 2008 20:16:31 +0000
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
- Follow-Ups:
- Re: RS232 Redirector Program in C using Linux
- From: Grant Edwards
- Re: RS232 Redirector Program in C using Linux
- References:
- RS232 Redirector Program in C using Linux
- From: Steffen
- Re: RS232 Redirector Program in C using Linux
- From: William Pursell
- Re: RS232 Redirector Program in C using Linux
- From: Grant Edwards
- RS232 Redirector Program in C using Linux
- Prev by Date: Re: RS232 Redirector Program in C using Linux
- Next by Date: Re: Timeout timers in an application
- Previous by thread: Re: RS232 Redirector Program in C using Linux
- Next by thread: Re: RS232 Redirector Program in C using Linux
- Index(es):
Relevant Pages
|