Poll() on imx6sl

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Poll() on imx6sl

514件の閲覧回数
stephangm
Contributor I

This may not be the right place to ask but.... Im trying to use poll() on a board using the IMX6SL. It hangs on poll() on the second loop iteration. The commented out code and comment above it shows says what happens when this code is added. Does the interrupt need to be unmasked or something? I've seen code almost identical to mine in a few places, yet this hasn't seemed to work.

This is the c code:

int read_gpio(char *path, void (*callback)(int)){

   int fd = open(path, O_RDONLY);
   if(fd == -1){

       perror("error opening file");
   return -1;
   }

   char buf[11];
   int res, off;
   char c;
   struct pollfd pfd = {

       .fd = fd,
       .events = POLLPRI,
       .revents = 0
   };
   for(;;){

       LOGD("for begins");
     // dummy read causes poll never to run
     // read(fd, &buf[],1);
    // lseek(fd, 0, SEEK_SET);
       res = poll(&pfd,1,-1);
       LOGD("polling ended");
       if(res == -1){

          perror("error polling");
          break;
   }

   if((pfd.revents & POLLPRI) == POLLPRI){

       LOGD("POLLPRI");
       off = lseek(fd, 0, SEEK_SET);
       if(off == -1) break;
       memset(&buf[0], 0, 11);
       read(fd, &buf[0], 10*sizeof(char));
    // These two lines will cause it to poll constantly
    // close(fd);
   // fd = open(path, O_RDONLY);
       LOGD("Before callback");
       callback(atoi(buf));
       LOGD("After Callback");
   }

      LOGD("for ends");
   }

  close(fd);
   LOGD("for exits");

   return 0;
}

タグ(2)
0 件の賞賛
返信
1 返信

409件の閲覧回数
stephangm
Contributor I

I have no idea how NXP ended up sending my question here, apologies.

0 件の賞賛
返信