Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
This question should be moved either to or – erik Oct 10 '13 at 22:45

You must log in to answer this question.

Browse other questions tagged .