Weird poll() behavior on the character device
Posted: Fri 16. Dec 2022, 17:01
Hi all,
We have a thread that does many things, including reading frame from the PLIN device. In order not to block, we poll() the character device and then read() the frame if polling was successful.
For a LIN master with a disabled schedule table, I am not expecting poll() to return a positive number since we shouldn't be receiving any frames. On the first poll() call, it returns zero, but then on the following poll(), it returns 1. My thread thinks there is a frame, so it executes read() on the device, but then blocks because there is not frame.
I've attached an example project that poll() and read() if it is successful. And it should block on read() even thought poll() returned 1 just before.
Thanks,
Gabriel
We have a thread that does many things, including reading frame from the PLIN device. In order not to block, we poll() the character device and then read() the frame if polling was successful.
For a LIN master with a disabled schedule table, I am not expecting poll() to return a positive number since we shouldn't be receiving any frames. On the first poll() call, it returns zero, but then on the following poll(), it returns 1. My thread thinks there is a frame, so it executes read() on the device, but then blocks because there is not frame.
I've attached an example project that poll() and read() if it is successful. And it should block on read() even thought poll() returned 1 just before.
Thanks,
Gabriel