Have you tried using strace on your executable to see what is happening
behind the scenes ?

On Fri, Apr 17, 2015 at 1:38 AM, matevzb <[email protected]> wrote:

> We just updated the OS from Ubuntu 12 to latest Ubuntu 14.04 with 3.14.37
> kernel.
> Since we are using UART4 and ADC, we had to update the initialization, but
> it appears to be working. Doing a 'cat
> /sys/bus/iio/devices/iio:device0/in_voltage0_raw', we get the ADC results.
>
> However, sometimes, we get 'Resource temporarily unavailable' when reading
> from that file. The cat survives it and just exits. The problem is that we
> use the following C++ code to read the analog value from file
>
>     int fp = 0;
>     char pathTmp[128] = {0};
>     char readBuffer[10] = {0};
>     int ret = -1;
>     int adcVal = 0;
>
>     ret = sprintf(pathTmp,
> "/sys/bus/iio/devices/iio:device%d/in_voltage%d_raw", 0, inputNum);
>     fp = open(pathTmp, O_RDONLY | O_NONBLOCK);
>     if (fp < 0)
>     {
>         printf("Failed to open %s\r\n", pathTmp);
>         return -1;
>     }
>
> printf("_aR");
>
>     fd_set read_fds;
>
>     FD_ZERO(&read_fds);
>     FD_SET(fp, &read_fds);
>
>     struct timeval timeout;
>     timeout.tv_sec = 0;
>     timeout.tv_usec = 1000;
>
>     if (select(fp + 1, &read_fds, NULL, NULL, &timeout) != 1)
>     {
>         printf("_aT!");
>         close(fp);
>         return -1;
>     }
>
>     if (read(fp, readBuffer, 5) < 0)
>     {
>     printf("Failed to read\r\n");
>     close(fp);
>     return -1;
>     }
>     close(fp);
>
> printf("_aC");
>
>     adcVal = atoi(readBuffer);
>
> In this code, the execution just randomly hangs on executing 'read'
> command (the buffer size doesn't effect), but as more tasks (ROS nodes) are
> executed on BeagleBone, earlier it happens.
> The problem is that when the application hangs at 'read' command, the
> whole ROS node hangs...
>
> We have checked the source code of 'cat' command and it doesn't have
> anything obviously different than what we are using.
>
> Does anybody has any idea on how to proceed?
>
> Regards,
> Matevž
>
>
>  --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to