ts-7000
[Top] [All Lists]

[ts-7000] Re: TS7300, Serials and pthread AND POLL

To:
Subject: [ts-7000] Re: TS7300, Serials and pthread AND POLL
From: "pa_ie2000" <>
Date: Tue, 20 Feb 2007 18:25:54 -0000
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/
 

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU