When reading data from HID device via hidraw, sometimes I miss some data. I can see that the data is transmitted OK over USB using a hardware snooping device, but for some reason I don't always get the data when reading hidraw.

The problem became less noticeable when I killed a process on the system that was consuming large amounts of CPU, so I'm thinking that my issue is somehow related to CPU starvation.

The reading of the HID data is done via a thread waiting on a blocking select.

For example:

FD_ZERO ( &fdset_device );
FD_SET ( fd, &fdset_device );

// fd is file descriptor for /dev/hidraw0

fd_set read_set;
read_set = fdset_device;

for ( ;; ) {
    if ( ( select_result = select ( fd + 1, &read_set, NULL, NULL, NULL ) ) >= 0 ) {
    int report_len = read ( fd, report_buffer, sizeof ( report_buffer ) );
    ...
    …

So under correct conditions, the packets A,B,C,D,E,F are sent & I receive hidraw packets A,B,C,D,E,F, but when the error happens I will receive maybe A,B,E,F or A,B,C,F

I'm not sure why and under what circumstances I would miss data like this. Has anyone seen issues with hidraw loosing data?

link|improve this question
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.