Almost the complete libudev functionality is exposed. You can:
Enumerate devices, filtered by specific criteria (pyudev.Context)
Query device information, properties and attributes,
Monitor devices, both synchronously and asynchronously with background threads, or within the event loops of Qt (pyudev.pyqt4,
pyudev.pyside), glib (pyudev.glib) and wxPython (pyudev.wx).
另一种方法(也适用于windows)可以是使用PySerial。您可以在单线程或多线程配置中使用
QTimer
(来自PyQt)而不是while
循环。基本示例(不带QTimer
或线程):这取决于操作系统
在linux中,您可以使用
pyudev
来执行以下操作:https://pyudev.readthedocs.io/en/latest/
源代码在http://pyudev.readthedocs.io/en/v0.14/api/monitor.html中,请参见
receive_device()
函数在windows中,您可以使用WMI(windows管理规范)如https://blogs.msdn.microsoft.com/powershell/2007/02/24/displaying-usb-devices-using-wmi/(Python Read the Device Manager Information)或python绑定如https://pypi.python.org/pypi/infi.devicemanager
相关问题 更多 >
编程相关推荐