通过RFCOMM蓝牙读取ELM327 OBD2原始数据时终端异常的问题求助
通过RFCOMM蓝牙读取ELM327 OBD2原始数据时终端异常的问题求助
大家好,我现在在尝试用Lubuntu读取汽车的OBD2数据,用的是便宜的ELM327蓝牙连接器,但遇到了一个奇怪的问题——连接后终端异常,每次只能显示一个字符,而且收不到设备的响应,想请教下大家我哪里操作错了?
已完成的操作步骤
1. 蓝牙配对与信任
我先在蓝牙控制台完成了设备配对和信任操作,过程如下:
[bluetooth]# pair 00:10:CC:4F:36:03 Attempting to pair with 00:10:CC:4F:36:03 [CHG] Device 00:10:CC:4F:36:03 Connected: yes Request PIN code [agent] Enter PIN code: 1234 [CHG] Device 00:10:CC:4F:36:03 UUIDs: 00001101-0000-1000-8000-00805f9b34fb [CHG] Device 00:10:CC:4F:36:03 ServicesResolved: yes [CHG] Device 00:10:CC:4F:36:03 Paired: yes Pairing successful [CHG] Device 00:10:CC:4F:36:03 ServicesResolved: no [CHG] Device 00:10:CC:4F:36:03 Connected: no [CHG] Device 00:10:CC:4F:36:03 Connected: yes [CHG] Device 00:10:CC:4F:36:03 Connected: no ...(中间重复的连接断开日志省略) [bluetooth]# info 00:10:CC:4F:36:03 Device 00:10:CC:4F:36:03 (public) Name: OBDII Alias: OBDII Paired: yes Trusted: no Blocked: no Connected: no LegacyPairing: no UUID: Serial Port (00001101-0000-1000-8000-00805f9b34fb) ManufacturerData Key: 0x0100 ManufacturerData Value: 03 36 4f cc 10 00 .6O... ManufacturerData Key: 0x7262 ManufacturerData Value: 32 32 78 78 11 22 33 44 55 66 aa bb 00 00 22xx."3DUf.... RSSI: -54 [bluetooth]# trust 00:10:CC:4F:36:03 [CHG] Device 00:10:CC:4F:36:03 Trusted: yes Changing 00:10:CC:4F:36:03 trust succeeded
2. 建立RFCOMM串口连接
我先用sdptool查到了设备的串口通道:
user@user-20n20009pg:~$ sdptool records 00:10:CC:4F:36:03 Service Name: JL_SPP Service RecHandle: 0x10004 Service Class ID List: "Serial Port" (0x1101) Protocol Descriptor List: "L2CAP" (0x0100) "RFCOMM" (0x0003) Channel: 2 Profile Descriptor List: "Serial Port" (0x1101) Version: 0x0102
然后用rfcomm建立连接:
user@user-20n20009pg:~$ sudo rfcomm connect /dev/rfcomm0 00:10:CC:4F:36:03 2 & [1] 1583 user@user-20n20009pg:~$ Connected /dev/rfcomm0 to 00:10:CC:4F:36:03 on channel 2 Press CTRL-C for hangup
遇到的问题
当我用screen连接到这个串口时,终端出现异常:
user@user-20n20009pg:~$ sudo screen /dev/rfcomm0 38400
打开新终端后,我输入命令(比如ATZ)时,每次只能显示一个字符(比如只显示>a),根本没法完整输入命令,而且也收不到ELM327的任何响应。
我已经试过更换波特率,比如9600、38400、115200,但问题依然存在。有没有朋友知道我哪里漏了什么步骤?
备注:内容来源于stack exchange,提问作者sgt
相关产品推荐
相关产品推荐

