libusb and poll / select

南笙酒味 提交于 2019-12-12 15:44:28

问题


I'm using a linux OS and was wondering if there were any file descriptors I could poll/select which would trigger when data was waiting to be read from a usb device. I am also using the libusb library and have yet to find file descriptors which I can use.


回答1:


Use libusb's polling functions to hook its file descriptors into your event loop. select will wake up whenever there's activity that libusb will need to handle, which includes but probably is not limited to data being available for reading.




回答2:


No, USB devices are not always "stream" devices, so reading from a file descriptor doesn't always make sense. However, if your USB device provides a serial port driver, you can listen for incoming data on the serial port device (just like any other serial port handled by your OS).



来源:https://stackoverflow.com/questions/16765429/libusb-and-poll-select

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