Skip to content

Commit eb789f9

Browse files
author
Brendan Whitfield
committed
disabled ATSP, added generic ATDP, and hardwired chosen protocol decoder
1 parent a42be23 commit eb789f9

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

obd/elm327.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ def __init__(self, portname, baudrate):
107107

108108
# -------------------------- ATE0 (echo OFF) --------------------------
109109
r = self.__send("ATE0")
110+
if len(r) == 0:
111+
self.__error("Could not recieve data from the ELM")
112+
return
113+
110114
if not self.__isok(r, expectEcho=True):
111115
self.__error("ATE0 did not return 'OK'")
112116
return
@@ -127,10 +131,10 @@ def __init__(self, portname, baudrate):
127131

128132

129133
# ---------------------- ATSPA8 (protocol AUTO) -----------------------
130-
r = self.__send("ATSPA8")
131-
if not self.__isok(r):
132-
self.__error("ATSPA8 did not return 'OK'")
133-
return
134+
# r = self.__send("ATSPA8")
135+
# if not self.__isok(r):
136+
# self.__error("ATSPA8 did not return 'OK'")
137+
# return
134138

135139

136140
# -------------- 0100 (first command, SEARCH protocols) --------------
@@ -140,23 +144,24 @@ def __init__(self, portname, baudrate):
140144

141145

142146
# ------------------- ATDPN (list protocol number) -------------------
147+
self.__send("ATDP")
143148
r = self.__send("ATDPN")
144149

145-
if not r:
146-
self.__error("Describe protocol command didn't return ")
147-
return
150+
# if not r:
151+
# self.__error("Describe protocol command didn't return ")
152+
# return
148153

149-
p = r[0]
154+
# p = r[0]
150155

151-
# suppress any "automatic" prefix
152-
p = p[1:] if (len(p) > 1 and p.startswith("A")) else p[:-1]
156+
# # suppress any "automatic" prefix
157+
# p = p[1:] if (len(p) > 1 and p.startswith("A")) else p[:-1]
153158

154-
if p not in self._SUPPORTED_PROTOCOLS:
155-
self.__error("ELM responded with unknown protocol")
156-
return
159+
# if p not in self._SUPPORTED_PROTOCOLS:
160+
# self.__error("ELM responded with unknown protocol")
161+
# return
157162

158163
# instantiate the correct protocol handler
159-
self.__protocol = self._SUPPORTED_PROTOCOLS[p]()
164+
self.__protocol = self._SUPPORTED_PROTOCOLS['6']()
160165

161166
# Now that a protocol has been selected, we can figure out
162167
# which ECU is the primary.

0 commit comments

Comments
 (0)