Pyserial,从OBD设备获取更多信息 [英] Pyserial, Getting extra info from OBD Device

查看:136
本文介绍了Pyserial,从OBD设备获取更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是编程新手,正在尝试通过OBD II设备与车辆通信.串行到USB.我已经完成了我想要的操作,但是我得到了输入的命令以打印出来.我该如何从设备中获取信息?

I am new at programming and am trying to communicate with my vehicle with an OBD II device. Serial to USB. I've done what I want it to do but I get the command I entered to print out. How do I just get the information from the device?

这里是我的代码.我正在使用Python 3.2.3

Heres my code. I am using Python 3.2.3

import serial
import time
import string
import io
import os
import sys
ser = serial.Serial("/dev/ttyUSB1")
ser.baudrate = 38400
s = input('Enter AT command --> ')
print ('AT command = ' + s)
ser.write(bytes(s + '\r\n', encoding = 'utf-8'))
ser.timeout = 1
response = ser.read(999).decode('utf-8')
print(response)
ser.close()  

这是我输入命令"atrv"时显示的内容.

And here is what prints out when I enter the command 'atrv'.

>>> 
Enter AT command --> atrv
AT command = atrv
atrv
0.1V
>>>

如何防止打印出高于0.1V的"atrv"?

How do I prevent the 'atrv' above the 0.1V from printing out?

推荐答案

将ATE0发送到ELM设备.

Send ATE0 to the ELM-device.

这将禁用回显,因此不会将atrv发送回给您!

This disables the echo, so atrv won't be send back to you!

对此进行了调查: http://elmelectronics.com/DSheets/ELM327DS.pdf,收集了许多AT命令,可能会有所帮助!

Have a look into this: http://elmelectronics.com/DSheets/ELM327DS.pdf , collection of lots of AT commands, could be helpful!

这篇关于Pyserial,从OBD设备获取更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆