将多个OBD命令一起发送并同时获得响应 [英] Send multiple OBD commands together and get response simultaneously

查看:215
本文介绍了将多个OBD命令一起发送并同时获得响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究连接OBD2适配器并获取速度,转速,油门位置等实时数据的应用程序。当我一次读取一个命令时,它可以像发送命令010C\r一样正常工作,我得到当前的RPM。

I'm working on application which connects OBD2 adapter and getting the real time data like speed,rpm,throttle position etc..When I read one command at a time, it works fine like by sending command "010C\r", I get current RPM.

我认为在一个请求中发送多个命令是不可能的。但在其他应用程序如EngineLink HD,Dashcommand中,我们发现有多个组件如果我们正在驾驶汽车并检查RPM,Sped和Throttle,那么它们会在每1秒更新一次。它看起来像实时数据。

I think that sending multiple commands in one request is not possible.But in other applications like EngineLink HD ,Dashcommand, we found that multiple components are updated at a time like if we are driving the car and check the RPM,Sped and Throttle then they are updating at every 1 second. It looks like real time data.

我很惊讶它怎么可能?

我们已添加代码就像用户想要显示3个组件一样,然后对于每个组件,生成一个线程并处理该命令的请求和响应。因此在这种情况下,会生成3个线程,我们得到响应,但是如果我们正在观看3个PID中的速度,则会花费太多时间,然后在3-4秒延迟后更新速度。

We have added code like if user wants to show 3 components, then for every component, one thread is generated and it handles request and response of that command. So in this case , 3 threads are generated and we get response but it takes too much time like if we are watching on Speed out of 3 PIDs then speed is updated after 3-4 seconds delay.

我们还需要锁定发送请求的代码并获取响应bcoz OBD2适配器一次处理一个请求和响应。

We also need to lock the code where it sends the request and get response bcoz OBD2 adapter handles one request and response at a time.

如果我们没有锁定代码然后我们得到不可预测的结果,这可能是由于应用程序和obd2适配器之间的套接字通信使用的公共共享流。

And if we don't lock the code then we get unpredicted results which might be due to common shared stream used by socket communication between the application and obd2 adapter.

但是现在我想要一次读取多个命令。
我的意思是在一个时间点,我想知道速度,转速和油门位置等。所以我想在一个请求中发送上述命令并一次得到响应。

But now I want to read multiple commands at a time. I mean at a point of time, I want to know speed,RPM and throttle position etc..So I want to send above commands in one request and get a response at a time.

怎么可能?有人可以指导我。

How is it possible ? Someone can guide me.

推荐答案

ELM327数据表在第45页提供了以下信息:

The ELM327 datasheet gives the following information on page 45:

多个PID请求
SAE J1979(ISO 15031-5)标准允许
通过一条消息请求多个PID,但仅当
时使用CAN(ISO 15765-4)连接到车辆。
一次最多可以请求六个参数,
回复是一条包含所有
响应的消息。
例如,让我们说你需要知道
发动机负荷(04),发动机冷却液温度(05),
歧管压力(0B)和发动机转速(0C)
定期。您可以为他们发送四个单独的请求
(01 04,然后是01 05,然后是01 0B等),或者你
可以将它们全部放入一个这样的消息中:

Multiple PID Requests The SAE J1979 (ISO 15031-5) standard allows requesting multiple PIDs with one message, but only if you connect to the vehicle with CAN (ISO 15765-4). Up to six parameters may be requested at once, and the reply is one message that contains all of the responses. For example, let us say that you need to know engine load (04), engine coolant temperature (05), manifold pressure (0B), and engine rpm (0C) on a regular basis. You could send four separate requests for them (01 04, then 01 05, then 01 0B, etc.) or you could put them all into one message like this:


01 04 05 0B 0C
,典型回复可能是:
00A
0:41 04 3F 05 44 0B
1:21 0C 17 B8 00 00 00

01 04 05 0B 0C to which, a typical reply might be: 00A 0: 41 04 3F 05 44 0B 1: 21 0C 17 B8 00 00 00

这篇关于将多个OBD命令一起发送并同时获得响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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