Dear Friends, good day.
I can't solve the problem of non-blocking reading from /dev/input/event.
Linux. Platform ARM.
Found solution (open, O_NONBLOCK, fdopen, ...) is implemented at C and, as I understand, supported C-functions are not insufficient to do this using FB.
I very hope that I'm not right.
I open pipe "cat /dev/input/event" and use Get#. It works perfectly while input stream from /dev/input/event is coming. As soon as the stream ends I catch the block (waiting for stream renewal).
Of course EOF doesn't help.
I tried standart C functions fopen, feof, fgetc/fgets/freads/fscanf - there is block when the stream stops.
Move of the reading procedure into separate thread, via CreateThread, doesn't allow to avoid the block.
Can anyone solve this issue by FB?
Thanks.
Non-blocking reading from /dev/input/event
Re: Non-blocking reading from /dev/input/event
Hi maratus!
Why do you use the indirect route involving the shell and the cat command?
Just open "/dev/input/event" directly, either by FB or C functions. Do asynchronous readings in a thread.
Regards
Code: Select all
open pipe "cat /dev/input/event"
Just open "/dev/input/event" directly, either by FB or C functions. Do asynchronous readings in a thread.
Regards
Re: Non-blocking reading from /dev/input/event
TJF, thank you for advice.TJF wrote:Just open "/dev/input/event" directly, either by FB or C functions. Do asynchronous readings in a thread.
Now it is solved. Yes I used FB code with included C functions (many thanks to Haav).
First I tried to put asynchronous reading into thread. I'm using ARM, not PC Linux. Furthermore there is a lot of graphics in my program. So all this set has led to serious freezes in a random intervals. Each time I was forced to reload the controller. If to remove threads and to place asynchronous reading at the main/root code everything works perfectly. This problem concerns only ARM architecture. PC works fine with threads.
Thank you very much.
Best regards