我有一个问题,打开我的Python代码在Windows 7中的串行USB端口。无法打开串口蟒蛇
TeraTerm和Docklight能够打开端口没有任何问题。
当我尝试打开它,出现以下错误
SerialException出现的端口:无法配置端口,出事了。原始消息:WindowsError(31,'连接到系统的设备无法运行')
我需要知道我是否正在使用正确的串行库。也许有人可以打开它而不会弄乱操作系统。
下面的代码返回上述
ser = serial.Serial()
ser.port = 'COM5'
ser.open()
错误的整个信息如下:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 2883, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-13-882203061f11>", line 4, in <module>
ser.open()
File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 78, in open
self._reconfigure_port()
File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 220, in _reconfigure_port
raise SerialException("Cannot configure port, something went wrong. Original message: %r" % ctypes.WinError())
SerialException: Cannot configure port, something went wrong. Original message: WindowsError(31, 'A device attached to the system is not functioning.')
感谢支持
很确定COM5不是USB端口......但我可能是错的! –
你错了。 COM端口可以是USB端口。甚至还在设备管理器中列出。例如USB串行端口(COM1)。 –