我想用ELM327通过OBD2记录数据,我是Python新手。在
我可以发出命令并得到回应。但是我不能发送更多的查询并得到响应,只有第一个命令,其余的响应都是“None”。在
我的代码:
import obd, time
connection = obd.OBD(baudrate=38400, fast=True) # auto-connects to USB or RF port
while True:
for i in commands_list:
cmd1 = obd.commands.RPM # select an OBD command (sensor)
response1 = connection.query(cmd1) # send the command, and parse the response
print(response1.value) # returns unit-bearing values thanks to Pint
# connection.close()
cmd2 = obd.commands.COOLANT_TEMP # select an OBD command (sensor)
response2 = connection.query(cmd2) # send the command, and parse the response
print(response2.value)
# connection.close()
time.sleep(0.5)
输出为:(发动机熄火,点火)
^{pr2}$预期产出:
0.0 revolutions_per_minute
91 degC
0.0 revolutions_per_minute
91 degC
0.0 revolutions_per_minute
91 degC
这是一个工作与关闭连接后,得到每个回应,但它真的很慢。。。我想在最长1秒后得到回复。最佳值至少为0.5秒
有人对此有什么想法或经验吗? 提前谢谢。在
解决方案是将快速模式设置为false:
功能描述:
来源:LINK
相关问题 更多 >
编程相关推荐