Weird poll() behavior on the character device

This is a forum for the communication between the beta testers and our developers. It is only visible for PEAK-System employees and authorized testers.
Post Reply
Gabriel Guilbert
Posts: 6
Joined: Fri 5. Aug 2022, 15:08

Weird poll() behavior on the character device

Post by Gabriel Guilbert » 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
Attachments
plin.zip
(4.37 KiB) Downloaded 230 times

Gabriel Guilbert
Posts: 6
Joined: Fri 5. Aug 2022, 15:08

Re: Weird poll() behavior on the character device

Post by Gabriel Guilbert » Fri 16. Dec 2022, 22:11

I found the issue, it was caused by the way I read things in my application. The driver seems to be working as expected with the poll() interface. Thanks anyway!

Post Reply