Skip to content

Commit aeaa3bd

Browse files
author
chrispyduck
committed
allow configurable baudrate
1 parent d2675fd commit aeaa3bd

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

obd/obd.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@
4343
class OBD(object):
4444
""" class representing an OBD-II connection with it's assorted sensors """
4545

46-
def __init__(self, portstr=None):
46+
def __init__(self, portstr=None, baudrate=38400):
4747
self.port = None
4848
self.supported_commands = []
4949

5050
debug("========================== Starting python-OBD ==========================")
51-
self.connect(portstr) # initialize by connecting and loading sensors
51+
self.connect(portstr, baudrate) # initialize by connecting and loading sensors
5252
debug("=========================================================================")
5353

5454

55-
def connect(self, portstr=None):
55+
def connect(self, portstr=None, baudrate=38400):
5656
""" attempts to instantiate an ELM327 object. Loads commands on success"""
5757

5858
if portstr is None:
@@ -61,15 +61,15 @@ def connect(self, portstr=None):
6161
debug("Available ports: " + str(portnames))
6262

6363
for port in portnames:
64-
65-
self.port = ELM327(port)
64+
debug("Attempting to use port: " + str(port))
65+
self.port = ELM327(port, baudrate=baudrate)
6666

6767
if self.port.is_connected():
6868
# success! stop searching for serial
6969
break
7070
else:
7171
debug("Explicit port defined")
72-
self.port = ELM327(portstr)
72+
self.port = ELM327(portstr, baudrate=baudrate)
7373

7474
# if a connection was made, query for commands
7575
if self.is_connected():

0 commit comments

Comments
 (0)