Receiving data from elm327 device

馋奶兔 提交于 2019-12-08 13:31:34

问题


I want to receive data from elm327 device. in line 7 I receive AT+BRSF=24\r string instead of string with the speed.

1.private async Task<string> GetSpeed()
2.    {
3.        string retVal;
4.        _dataWriter.WriteString("010D\r"); // send pid for speed information
5.        await _dataWriter.FlushAsync(); 
6.        await _dataReader.LoadAsync(30);  // get answer
7.       String Message = _dataReader.ReadString(11);
8.        retVal = Message;
9.        if (retVal.Contains('<'))
10.        {
11.        retVal.Substring(0, retVal.IndexOf("<"));

12.        }
13.        return retVal.Replace("\n", "");
14.    }

I'm using SDP Bluetooth protocol:

PeerFinder.AlternateIdentities["Bluetooth:SDP"] = "{00001101-0000-1000-8000-00805F9B34FB}";

回答1:


the problem is with the connecting channel, I first tried with the next line:

_stream = await socket.ConnectAsync(selectedDevice.HostName,"1");

but the working channel is 16 and not 1, and the working line is:

_stream = await socket.ConnectAsync(selectedDevice.HostName,"16"):


来源:https://stackoverflow.com/questions/22073887/receiving-data-from-elm327-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!