Nie można wysłać polecenia ATZ do ELM 327 po nawiązaniu połączenia z ELM327 w systemie Android
Napisałem kod, który z powodzeniem jest w stanie znaleźć sparowany OBD i ustanowić połączenie z ELM327, ale kiedy próbuję wysłać polecenie ATZ, aplikacja ulega awarii.
Oto fragment kodu, mogłem zrobić źle
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;
}
Nie jestem pewien, gdzie popełniłem błędy, więc dzielę się przepływem całego kodu jako dwa elementy,https://gist.github.com/sankarganesh/6376031, ten plik zawiera plik aktywności i jeszcze jeden znacznik nasłuchu gniazda Bluetoothhttps://gist.github.com/sankarganesh/6376039