<div dir="ltr"><div><div><div><div><div><div>Dear all,<br><br></div>I have an application that waits on several handles and hence being able to select on a pps handle (or, as in this instance, the raw file descriptor) is desirable.  However, select() appears to return immediately, reporting that the FD has data.  For example, the strace -p output is:<br>
<br></div>select(32, [9 23 24 25 26 27 29 30 31], [], NULL, {0, 100000}) = 1 (in [23], left {0, 99977})<br>ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0<br>gettimeofday({1367365708, 582135}, NULL) = 0<br>select(32, [9 23 24 25 26 27 29 30 31], [], NULL, {0, 100000}) = 1 (in [23], left {0, 99986})<br>
ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0<br>gettimeofday({1367365708, 582758}, NULL) = 0<br>select(32, [9 23 24 25 2[   90.878840] pps pps0: echo assert <br>[   90.882760] pps pps0: echo  clear<br>6 27 29 30 31], [], NULL, {0, 100000}) = 1 (in [23], left {0, 99987})<br>
ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0<br>gettimeofday({1367365708, 583401}, NULL) = 0<br>select(32, [9 23 24 25 26 27 29 30 31], [], NULL, {0, 100000}) = 1 (in [23], left {0, 99991})<br>ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0<br>
gettimeofday({1367365708, 584043}, NULL) = 0<br>select(32, [9 23 24 25 26 27 29 30 31], [], NULL, {0, 100000}) = 1 (in [23], left {0, 99990})<br>ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0<br>gettimeofday({1367365708, 584623}, NULL) = 0<br>
select(32, [9 23 24 25 26 27 29 30 31], [], NULL, {0, 100000}) = 1 (in [23], left {0, 99990})<br>ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0<br>gettimeofday({1367365708, 585176}, NULL) = 0<br><br></div>(The gettimeofday calls can safely be ignored; they are for my application to calculate latency)<br>
<br></div>As can be seen, the select returns after 100us or so, even through the timeout is 100ms, reporting that the [23] (which, in this instance, is the PPS FD) is waiting to be read.    The API call that follows returns successfully.<br>
<br></div>The API call is as follows:<br><br>    // According to RFC2783, a timeout of zero will return immediately<br>    struct timespec zero;<br>    zero.tv_sec = 0;<br>    zero.tv_nsec = 0;<br><br>    pps_info_t info;<br>
    int return_value = time_pps_fetch(m_handle, PPS_TSFMT_TSPEC, &info, &zero);<br><br></div>The PPS handle and the raw FD should be the same value (from <timepps.h>):<br><br>    /* ... then since in LinuxPPS there are no differences between a<br>
     * "PPS source" and a "PPS handle", we simply return the same value.<br>     */<br>    *handle = source;<br><div><div><div><div><div><br></div><div>The PPS client driver is the GPIO client, modified to use the devicetree [1], should be declared PPS_CANWAIT.<br>
</div><div><br></div><div>Is this the expected behaviour from select()?  If so, what work needs to be done in order for the driver to be select()-able?<br><br></div><div>  --- Damien<br><br>[1] <a href="http://www.linuxpps.org/pipermail/discussions/2013-April/004416.html">http://www.linuxpps.org/pipermail/discussions/2013-April/004416.html</a><br>
<br></div></div></div></div></div></div>