Re: RS232 Redirector Program in C using Linux
- From: Josef Moellers <josef.moellers@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 21 Jan 2008 15:19:38 +0100
Steffen wrote:
On 21 Jan., 16:42, William Pursell <bill.purs...@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.
Really, Is this better than using the receive interrupt? ... Can some
body give me a skeleton how to do this with polling?
Have a look at the select() or poll() manual page.
In essence the difference is that rather than have signal processing cause you to read *both* fds (you must read both as you don't know which one caused the SIGIO), you create a set of fds and wait for data to be available on one of those, much like:
/*
* Setup fd1 and fd2 for the two serial ports
*/
while (keep_running) {
fd_set infds;
int nfds;
FD_CLR(&infds);
FD_SET(fd1, &infds);
FD_SET(fd2, &infds);
nfds = (fd1 > fd2) ? fd1+1 : fd2+1;
if (select(nfds, &infds, NULL, NULL, NULL) == -1) {
perror("select");
break;
}
if (FD_ISSET(fd1, &infds))
copy(fd1, fd2);
if (FD_ISSET(fd2, &infds))
copy(fd2, fd1);
}
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
.
- 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: Steffen
- RS232 Redirector Program in C using Linux
- Prev by Date: Re: RS232 Redirector Program in C using Linux
- Next by Date: Re: RS232 Redirector Program in C using Linux
- 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
|