Unable to send ATZ command to ELM 327 after establishing connection with ELM327 in android

為{幸葍}努か 提交于 2019-11-27 07:02:31

问题


I have written a code which is successfully able to find the paired OBD and establish the connection with ELM327 but when i am trying to send ATZ command the application gets crash.

Here's the code snippet, I may have done wrong

public HashMap<String, String> startOBDCommunicator(
            BluetoothSocket btSocketConnected, String paramClassName,
            String methodName) {

        HashMap<String, String> dataRetriever = new HashMap<String, String>();
        sendDataToOBD(btSocketConnected, "ATZ\r");
        dataRetriever.put("Reset", readDataFromOBD(btSocketConnected));

        sendDataToOBD(btSocketConnected, "ATS0\r");
        dataRetriever.put("Space Control", readDataFromOBD(btSocketConnected));

        sendDataToOBD(btSocketConnected, "ATE0\r");
        dataRetriever.put("Echo control", readDataFromOBD(btSocketConnected));

        sendDataToOBD(btSocketConnected, "ATL0\r");
        dataRetriever.put("Line feed", readDataFromOBD(btSocketConnected));

        sendDataToOBD(btSocketConnected, "ATAT0\r");
        dataRetriever
                .put("Adaptive Timing", readDataFromOBD(btSocketConnected));

        sendDataToOBD(btSocketConnected, "ATST10\r");
        dataRetriever.put("Time Out", readDataFromOBD(btSocketConnected));

        sendDataToOBD(btSocketConnected, "ATI\r");
        dataRetriever.put("Device Description",
                readDataFromOBD(btSocketConnected));

        sendDataToOBD(btSocketConnected, "ATDP\r");
        dataRetriever.put("Protocol Information1",
                readDataFromOBD(btSocketConnected));

        sendDataToOBD(btSocketConnected, "ATSPA0\r");
        dataRetriever
                .put("Auto Protocol",
                        readBytesFromOBD(btSocketConnected, paramClassName,
                                methodName));

        sendDataToOBD(btSocketConnected, "010C\r");

        dataRetriever
                .put("RPM param",
                        readBytesFromOBD(btSocketConnected, paramClassName,
                                methodName));

        sendDataToOBD(btSocketConnected, "010D\r");

        dataRetriever
                .put("Speed parameters",
                        readBytesFromOBD(btSocketConnected, paramClassName,
                                methodName));

        sendDataToOBD(btSocketConnected, "0104\r");

        dataRetriever
                .put("engine load value parameters",
                        readBytesFromOBD(btSocketConnected, paramClassName,
                                methodName));

        sendDataToOBD(btSocketConnected, "0105\r");

        dataRetriever
                .put("Engine coolant temperature parameters",
                        readBytesFromOBD(btSocketConnected, paramClassName,
                                methodName));

        sendDataToOBD(btSocketConnected, "012F\r");

        dataRetriever
                .put("Fuel Level Input",
                        readBytesFromOBD(btSocketConnected, paramClassName,
                                methodName));

        return dataRetriever;

    }

I m not sure where i have done mistakes , so i m sharing the flow of the entire code as two gist , https://gist.github.com/sankarganesh/6376031, this gist holds the Activity file and one more gist for Bluetooth Socket Listener https://gist.github.com/sankarganesh/6376039


回答1:


The problem might be that after the prompt sign > no CR is sent from the ELM-device to the computer. If your serial input buffer is configured with termination by a CR, a timeout will happen.



来源:https://stackoverflow.com/questions/18528792/unable-to-send-atz-command-to-elm-327-after-establishing-connection-with-elm327

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