首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我想要通过蓝牙应用程序使用obd的数据。

我想要通过蓝牙应用程序使用obd的数据。
EN

Stack Overflow用户
提问于 2013-12-11 09:12:30
回答 1查看 351关注 0票数 0

我想通过蓝牙应用从obd接收数据,但是数据是分开的,我要做什么?

我想要完整的数据。

救救我!

代码语言:javascript
复制
{

case MESSAGE_STATE_CHANGE:
                if(D) Log.i(TAG, "MESSAGE_STATE_CHANGE: " + msg.arg1);
                switch (msg.arg1) {
                case BluetoothChatService.STATE_CONNECTED:
                    setStatus(getString(R.string.title_connected_to, mConnectedDeviceName));
                    mConversationArrayAdapter.clear();
                    break;
                case BluetoothChatService.STATE_CONNECTING:
                    setStatus(R.string.title_connecting);
                    break;
                case BluetoothChatService.STATE_LISTEN:
                case BluetoothChatService.STATE_NONE:
                    setStatus(R.string.title_not_connected);
                    break;
                }
                break;
            case MESSAGE_WRITE:
                byte[] writeBuf = (byte[]) msg.obj;
                // construct a string from the buffer
                String writeMessage = new String(writeBuf);
//                mConversationArrayAdapter.add("Me:  " + writeMessage);
                break;
            case MESSAGE_READ:
                byte[] readBuf = (byte[]) msg.obj;
                Log.d("hoy", "readBuf===="+ readBuf);
                // construct a string from the valid bytes in the buffer
                String readMessage = new String(readBuf, 0, msg.arg1);
//                mConversationArrayAdapter.add(mConnectedDeviceName+":  " + readMessage);

                reciveData = readMessage;
                Log.d("hoy", "ReciveData==="+reciveData);}

日志:

代码语言:javascript
复制
12-11 17:36:22.184: D/hoy(26303): send ok
12-11 17:36:22.184: D/hoy(26303): display protocol
12-11 17:36:22.219: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:22.219: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:22.219: D/hoy(26303): ReciveData===A
12-11 17:36:22.219: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:22.219: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:22.219: D/hoy(26303): ReciveData===UTO

12-11 17:36:26.214: V/BluetoothSocket.cpp(26303): writeNative
12-11 17:36:26.214: D/hoy(26303): send ok
12-11 17:36:26.214: D/hoy(26303): get rpm button clicked
12-11 17:36:26.249: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:26.249: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:26.249: D/hoy(26303): ReciveData===S
12-11 17:36:26.249: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:26.249: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:26.249: D/hoy(26303): ReciveData===EARC
12-11 17:36:26.249: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:26.249: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:26.254: D/hoy(26303): ReciveData===HIN
12-11 17:36:26.254: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:26.254: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:26.254: D/hoy(26303): ReciveData===G..
12-11 17:36:30.339: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:30.344: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:30.344: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:30.344: D/hoy(26303): ReciveData===410C10
12-11 17:36:30.344: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:30.349: D/hoy(26303): ReciveData===410C100CEF

12-11 17:36:30.399: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:30.404: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:30.404: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:30.404: D/hoy(26303): ReciveData===3
12-11 17:36:30.404: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:30.404: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:30.404: D/hoy(26303): ReciveData===01121E

12-11 17:36:30.409: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:30.409: D/hoy(26303): ReciveData===01121E

12-11 17:36:30.609: V/BluetoothSocket.cpp(26303): readNative
12-11 17:36:30.614: D/hoy(26303): readBuf====[B@42199000
12-11 17:36:30.614: D/hoy(26303): ReciveData===
>
12-11 17:36:56.304: E/BluetoothChat(26303): - ON PAUSE -
12-11 17:36:56.339: E/BluetoothChat(26303): -- ON STOP --
12-11 17:36:56.404: W/IInputConnectionWrapper(26303): getSelectedText on inactive InputConnection
12-11 17:36:56.404: W/IInputConnectionWrapper(26303): setComposingText on inactive InputConnection
12-11 17:36:56.404: W/IInputConnectionWrapper(26303): getExtractedText on inactive InputConnection

发送的数据: s/// erch/// ing

EN

回答 1

Stack Overflow用户

发布于 2013-12-13 10:47:15

据我所知,您正在尝试从ELM327蓝牙设备中检索数据。有一个库可以帮助您管理Android设备与OBD-II dongle之间的通信。我用了它,它帮了我很多。你可以在这里找到它:https://github.com/pires/android-obd-reader

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20514966

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档