obd: Allow starting OBD with low power enabled · MasterCodeIT/python-OBD@d2c9291 · GitHub
Skip to content

Commit d2c9291

Browse files
committed
obd: Allow starting OBD with low power enabled
Add support for connecting to an ELM device that is already in low power mode. Signed-off-by: Alistair Francis <alistair@alistair23.me>
1 parent 6e5564d commit d2c9291

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

docs/Connections.md

Lines changed: 3 additions & 1 deletion

obd/asynchronous.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ class Async(OBD):
4646
"""
4747

4848
def __init__(self, portstr=None, baudrate=None, protocol=None, fast=True,
49-
timeout=0.1, check_voltage=True, delay_cmds=0.25):
49+
timeout=0.1, check_voltage=True, start_low_power=False,
50+
delay_cmds=0.25):
5051
super(Async, self).__init__(portstr, baudrate, protocol, fast,
51-
timeout, check_voltage)
52+
timeout, check_voltage, start_low_power)
5253
self.__commands = {} # key = OBDCommand, value = Response
5354
self.__callbacks = {} # key = OBDCommand, value = list of Functions
5455
self.__thread = None

obd/elm327.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class ELM327:
104104
_TRY_BAUDS = [38400, 9600, 230400, 115200, 57600, 19200]
105105

106106
def __init__(self, portname, baudrate, protocol, timeout,
107-
check_voltage=True):
107+
check_voltage=True, start_low_power=False):
108108
"""Initializes port by resetting device and gettings supported PIDs. """
109109

110110
logger.info("Initializing ELM327: PORT=%s BAUD=%s PROTOCOL=%s" %
@@ -134,6 +134,11 @@ def __init__(self, portname, baudrate, protocol, timeout,
134134
self.__error(e)
135135
return
136136

137+
# If we start with the IC in the low power state we need to wake it up
138+
if start_low_power:
139+
self.__write(b" ")
140+
time.sleep(1)
141+
137142
# ------------------------ find the ELM's baud ------------------------
138143

139144
if not self.set_baudrate(baudrate):

obd/obd.py

Lines changed: 8 additions & 5 deletions

0 commit comments

Comments
 (0)