Just before I checked here for advice on pthread and serials, I
rewrote my code to use poll. Seems I get a hit on both fd's but I
know for sure I'm only passing data to one?!?!?!?
CODE <snipped>:
pfd[GSM].fd = gs64port;
pfd[GSM].events = POLLIN;
pfd[VMC].fd = vmcport;
pfd[VMC].events = POLLIN;
pfd[VMC].revents = 0;
while(1)
{
pfd[GSM].revents = 0;
pfd[VMC].revents = 0;
if(poll(pfd, NPOLL, 2) < 0)
{
err_quit("poll");
}
if(pfd[GSM].revents == POLLIN)
{
// This should only be a text message
handle_gs64();
}
if(pfd[VMC].revents == POLLIN)
{
handle_vmc();
}
printf(".");
}
printf("Shouldn't be here\n");
return 0;
}
void err_quit(char *msg)
{
perror(msg);
exit(EXIT_FAILURE);
}
void handle_gs64()
{
int rc = 0;
int len;
char data[512];
char cmd[64];
char *tstr;
rc = read(gs64port, data, 511);
if(rc < 1)
return;
printf("handle_gs64\n");
}
void handle_vmc()
{
printf("handle_vmc\n");
}
OUTPUT:
......................................................................
..............
handle_vmc
......................................................................
..handle_gs64
handle_vmc
......................................................................
....handle_gs6
handle_vmc
......................................................................
..handle_gs64
handle_vmc
......................................................................
.handle_gs64
handle_vmc
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|