Is it possible to use winusb to communicate with multiple identical usb devices simultaneously?

╄→尐↘猪︶ㄣ 提交于 2019-12-26 18:23:47

问题


I am using multiple identical devices and i would like to be able to read from them simultaneously. So the Product and Vendor ID are the same for all devices. I am wondering if i will be able to read from them in parallel.

In my opinion i would think that it should be possible because for specific device path, you create a unique winusb handle as well as a unique createfile handle.

However in practice, i realized that it didn't work. I didn't use overlapped structure as i though they were completely separate due to unique createfile handles. The data read from the devices isn't read in parallel, instead it just reads the first device, second, third etc...

I wrote the code in c++ and i would like some advice, thank you.
Would using overlapped structure fix the problem? Or is winusb not meant to be used this way?

Here is the link to my code, https://drive.google.com/drive/folders/1qvcGwNLxzJ0oRrFZbtyZ7g0zCU0XUG1n?usp=sharing


回答1:


Yes, you can use WinUSB to talk to two different USB devices in parallel, whether or not they are identical. You would call CreateFile twice with two different paths. To actually get parallelism, you would either need to use overlapped I/O or use multiple threads.

The point of overlapped I/O is that you can start multiple requests very quickly from a single thread, and the operating system will work on them in parallel, and you can later query to see whether they have been completed.



来源:https://stackoverflow.com/questions/53112534/is-it-possible-to-use-winusb-to-communicate-with-multiple-identical-usb-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!