Skip to content

Commit

Permalink
Fixed issue with sniffing commands encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
josefe17 committed Sep 14, 2023
1 parent 0868a18 commit 161d399
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions elm.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def __init__(self, portName, rate, adapter_type="STD", maxspeed="No"):

def raise_odb_speed(self, baudrate):
# Software speed switch
res = self.port.write(("ST SBR " + str(baudrate) + "\r").encode('utf8'))
res = self.port.write(("ST SBR " + str(baudrate) + "\r").encode('utf-8'))

# Command echo
res = self.port.expect_carriage_return()
Expand All @@ -646,13 +646,13 @@ def raise_odb_speed(self, baudrate):
def raise_elm_speed(self, baudrate):
# Software speed switch to 115Kbps
if baudrate == 57600:
res = self.port.write("ATBRD 45\r".encode("utf8"))
res = self.port.write("ATBRD 45\r".encode("utf-8"))
elif baudrate == 115200:
res = self.port.write("ATBRD 23\r".encode("utf8"))
res = self.port.write("ATBRD 23\r".encode("utf-8"))
elif baudrate == 230400:
res = self.port.write("ATBRD 11\r".encode("utf8"))
res = self.port.write("ATBRD 11\r".encode("utf-8"))
elif baudrate == 500000:
res = self.port.write("ATBRD 8\r".encode("utf8"))
res = self.port.write("ATBRD 8\r".encode("utf-8"))
else:
return

Expand All @@ -665,7 +665,7 @@ def raise_elm_speed(self, baudrate):
self.port.change_rate(baudrate)
version = self.port.expect_carriage_return()
if "ELM327" in version:
self.port.write('\r'.encode('utf8'))
self.port.write('\r'.encode('utf-8'))
res = self.port.expect('>')
if "OK" in res:
print("ELM full speed connection OK ")
Expand All @@ -681,7 +681,7 @@ def raise_elm_speed(self, baudrate):
def __del__(self):
try:
print("ELM reset...")
self.port.write("ATZ\r".encode("utf8"))
self.port.write("ATZ\r".encode("utf-8"))
except:
pass

Expand Down Expand Up @@ -1190,7 +1190,7 @@ def monitor_can_bus(self, callback):
if options.simulation_mode:
pass
else:
self.port.write("AT MA\r")
self.port.write("AT MA\r".encode('utf-8'))
stream = ""
while not self.monitorstop:
byte = self.port.read()
Expand All @@ -1208,7 +1208,7 @@ def monitor_can_bus(self, callback):
if byte:
stream += byte

self.port.write("AT\r")
self.port.write("AT\r".encode('utf-8'))
self.port.expect('>')

def init_can(self):
Expand Down

0 comments on commit 161d399

Please sign in to comment.