libusb / hidapi

A Simple cross-platform library for communicating with HID devices

Home Page:https://libusb.info/hidapi/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call to `hid_read_timeout` sometimes never returns on Windows

shufps opened this issue · comments

We have an application that works perfectly on Linux and Mac and most of the time for Windows.

But on Windows it happens that the call to read_timeout never returns and the entire app is hanging because we are cleanly using mutexes to prevent parallel accessing the USB device.

We tracked our problem down to the call of hid_read_timeout

    fn read_timeout(&self, buf: &mut [u8], timeout: i32) -> HidResult<usize> {
        let res = unsafe {
            ffi::hid_read_timeout(
                self._hid_device,
                buf.as_mut_ptr(),
                buf.len() as size_t,
                timeout,
            )
        };
        self.check_size(res)
    }

Timeout value is 10s but we can see in our logs that it's waiting forever there.

Has anyone heared about problem specific to Windows that the hid_read_timeout call would hang forever even if a timeout value of 10000 is specified?

Thx a lot for help - we are a bit clueless at this point.

upsi ... timeout is 10mio and not 10k 😑

closing this issue