I am currently writing a C application for my connex which uses the gpio-event driver as supplied by Dave Hylands. I am tring to get the read part to time out if there is no events after a set amount of time. I am tring to use the  "select()" function to do this as the docs for select seem to be saying this is what it is for. My app builds and runs but select returns straight away saying there is data to read even if there is no GPIO event. Has anyone else tried this and got it working or know of a better way of doing it?

i have supplied some psuedo code below.
I have tried using the fopen, fread functions and the open, read type functions both seem to give the same result.


    GPIO_EventMonitor_t monitor;
    int result = 0;

    filedes = open( "/dev/gpio-event", O_RDONLY ));
    ioctl( filedes, GPIO_EVENT_IOCTL_SET_READ_MODE, gBinary );

    monitor.gpio = GPIO_PIN;
    monitor.onOff = 1;
    monitor.edgeType = GPIO_EventBothEdges;
    monitor.debounceMilliSec = BUTTON_DEBOUNCE_MILLISECS;

    ioctl( filedes, GPIO_EVENT_IOCTL_MONITOR_GPIO, &monitor );

    FD_ZERO (&file_des_set);
    FD_SET (filedes, &file_des_set);
    timeout.tv_sec = TIME_OUT;
    timeout.tv_usec = 0;

     result = select( FD_SETSIZE, &file_des_set, NULL, NULL, &timeout);

    if ( 0 == result )    {
          //Time out
    else if ( 1== result )   {
          //gpio event
    else   {

    close ( filedes);

For ideas on reducing your carbon footprint visit Yahoo! For Good this month.