Can't use select() ?

Hi guys,
I am working with comedi but have problems now.
I tried to use select() call to scan data incoming, it
seemed that I always got timeout and the device file
change couldn't be reported (my digital I/O card
 doesn't support comedi_command). 
Does anyone know the reason ? Or give me some
other suggestion. Thank you in advance for your
time and consideration.

Cheers,

Wensheng

Here's my code:
1.
  fd_set rdset;
  struct timeval timeout;
  int ret, i;

  for(i = 0; i < 100; i++)
  {
    FD_ZERO(&rdset);
    FD_SET(comedi_fileno(device),&rdset);
    timeout.tv_sec = 2;
    timeout.tv_usec = 0;
    ret = select(comedi_fileno(dev)+1,&rdset,NULL,NULL,&timeout);
    printf("%d select returned %d\n",i,ret);
    if(ret<0){
      perror("select");
    }
    else if(ret)
    {
      printf("comedi file descriptor ready\n");
    }
    else
    {
      printf("timeout\n");
    }
  }
2.
  int fd0;

  if((fd0 = open("/dev/comedi0", O_RDONLY)) < 0)
  {
    perror(": Error opening ");
    return(0);
  }
 
  for(i = 0; i < 100; i++)
  {
    FD_ZERO(&rdset);
    FD_SET(fd0, &rdset);    //Put the device file into monitoring list.
    timeout.tv_sec=1;
    timeout.tv_usec=0;
//    retval = select(FD_SETSIZE, &rdset, NULL, NULL, &timeout);
    retval = select(fd0 + 1, &rdset, NULL, NULL, &timeout);
    ......

Received on 2006-09-19Z05:04:35