Closed saifeiLee closed 4 years ago
The device isn't being opened by another process, like before. :)
But really I think the problem may be that the devices
variable is stale. You need to do devices = HID.devices()
to pick up the updated device list after the device insertion. With the code you quote, devices
contains the list of HID devices at the start of the code, not when add
was called.
The device isn't being opened by another process, like before. :)
But really I think the problem may be that the
devices
variable is stale. You need to dodevices = HID.devices()
to pick up the updated device list after the device insertion. With the code you quote,devices
contains the list of HID devices at the start of the code, not whenadd
was called.
Hah.. Pretty sure the device not been opened. In fact, I tried to call HID.devices() when device added. The weirdest part is the new-added device is not in the updated list.
I tried with my mouse, same problem.
Depending on the OS, you will not see the device immediately on usb insertion. It takes time for the OS to hook up the HID driver to the USB device (this can take more than a second sometimes I've seen).
Try doing a setTimeout(function(){console.log(HID.devices()},3000)
in your .on('add')
and see if you see the device then.
Depending on the OS, you will not see the device immediately on usb insertion. It takes time for the OS to hook up the HID driver to the USB device (this can take more than a second sometimes I've seen).
Try doing a
setTimeout(function(){console.log(HID.devices()},3000)
in your.on('add')
and see if you see the device then.
Well. You're right. It is OS delay. This time I tried setTimeout
works. But last time failed.
Anyway, thank you so much! May you have a good day!
Description
I plug in a new device and using
usb-detect
to monitor the changes. As expected, I can detect new device pluged in. And I want to open the new HID device with its vid/pid. But I got the error.Is there anything I went wrong? If you need and further info, please let me know and I will append as soon as possible.
Update
I append the code snippet and the output.
output when I plug in the device:
update#2
I tried to put
HID.HID()
intosetTimout(cb, 5000)
, also failed.