Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 unix.stackexchange.com or stackoverflow.com –  erik Oct 10 '13 at 22:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.