我在使用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 "", line 4, in
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.')
感谢你的支持