prevent hidapi from receiving more data

asked 2020-07-07 09:25:34 -0500

updated 2020-07-07 17:12:23 -0500

I have a usb2 video camera and an hid usb device connected on the same board.

I can read data from the hid device using hidapi and it works fine.

However, as soon as I do:

success, frame = will never return anything anymore. Freezes there forever (if I use a timeout of 0).

Any idea why it would do this? Does the read() function do anything to reserve the usb bus or anything?


Some more info:

If I do video_capture.release() then I can read from hid again. Until I do which re-freezes hid.

Also the will block hid reads even if 2 different python scripts.

  • I start a first script that reads from hid in a loop first and it does it's thing reading and printing the result.
  • Then I start a second script that reads from the webcam.

Once the webcam script is started, the hid script freeze at read(). The webcam script is fine.


This will reproduce the issue. It will print 1 hid report and then 1 time True and stop on the next hid read.

import cv2
import time
import hid

_hid = hid.device(), 0x00DD)

video_capture = cv2.VideoCapture(0)
video_capture.set(cv2.CAP_PROP_BUFFERSIZE, 1)
video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, 320)
video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)

while True:
    report = b"\x10"
    _hid.write(b"\0" + report + b"\0" * (64 - len(report)))

    success, frame =

I'm running

  • Language => Python 3.8.3
  • OpenCV => 4.3.0
  • Operating System / Platform => Debian GNU/Linux 10 on armv7l
edit retag flag offensive close merge delete


have you tried with other usb devices (i.e a mouse) ?

an hid usb device

can you be more specific ?

berak gravatar imageberak ( 2020-07-07 09:56:30 -0500 )edit


# read back the answer
    print(f"Read the data")
    while True:
        d =
        if d:
print(f"Closing the device")
supra56 gravatar imagesupra56 ( 2020-07-07 13:57:14 -0500 )edit

No I tried only the mcp2221a, I'll give a mouse a try.

Francois Gervais gravatar imageFrancois Gervais ( 2020-07-07 16:08:08 -0500 )edit