在使用python从COM4端口读取串行端口时,我得到以下错误:
----------------------------------------------------------------------------
F:\Invsense\motion_driver_6.12\eMPL-pythonclient>python.exe eMPL-client.py 4
Traceback (most recent call last):
File "eMPL-client.py", line 543, in <module>
data_delegate = data)
File "eMPL-client.py", line 23, in __init__
self.s = serial.Serial(port,115200)
File "C:\Users\admin\AppData\Local\Programs\Python\Python35-32\lib\site-
packages\pyserial-3.1.1-py3.5.egg\serial\serialwin32.py", line 31, in __init__
文件“C:\Users\admin\AppData\Local\Programs\Python35-32\lib\site- 软件包\pyserial-3.1.1-py3.5.egg\serial\串行util.py“,第162行,ininit 文件“C:\Users\admin\AppData\Local\Programs\Python35-32\lib\site- 软件包\pyserial-3.1.1-py3.5.egg\serial\串行util.py“,第206行,左舷 ValueError:“port”必须为None或字符串,而不是
F:\Invsense\motion\u driver_6.12\eMPL pythonclient>
此错误来自串行util.py. 你能帮我解决这个问题吗。我用油灰工具分别检查了COM4端口,效果很好。在
问候 维奈
问题在于Invensense python脚本。在
开放式员工-客户端.py在文本编辑器中搜索行:
comport = int(sys.argv[1]) - 1
将其更改为:
comport = sys.argv[1]
脚本试图将字符串“COM4”转换为整数,然后将其传递给串行函数,后者无论如何都需要字符串。我想也许他们使用的是旧版本的pyserial,因为脚本中还有其他错误。在
注释掉(或删除)这些行:
{/Run with the client
在所有这些之后,我的python客户机正确地显示了MPU数据。我希望这不会太晚!在
相关问题 更多 >
编程相关推荐