Skip to content

Commit 2f611a6

Browse files
author
Brendan Whitfield
committed
added __version__ file, Async.start() handles cases where no commands are subscribed
1 parent 38618a4 commit 2f611a6

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

obd/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
# #
3737
########################################################################
3838

39-
__version__ = '0.3.0'
40-
39+
from .__version__ import __version__
4140
from .obd import OBD
4241
from .OBDCommand import OBDCommand
4342
from .commands import commands

obd/__version__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
__version__ = '0.3.0'

obd/async.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ def __init__(self, portstr=None, baudrate=38400):
5252
def start(self):
5353
""" Starts the async update loop """
5454
if self.is_connected():
55-
debug("Starting async thread")
56-
self.running = True
57-
self.thread = threading.Thread(target=self.run)
58-
self.thread.daemon = True
59-
self.thread.start()
55+
if len(self.commands) > 0:
56+
debug("Starting async thread")
57+
self.running = True
58+
self.thread = threading.Thread(target=self.run)
59+
self.thread.daemon = True
60+
self.thread.start()
61+
else:
62+
debug("Async thread not started because no commands were registered")
6063
else:
6164
debug("Async thread not started because no connection was made")
6265

obd/obd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
import time
3333

34-
from obd import __version__
34+
from .__version__ import __version__
3535
from .elm327 import ELM327
3636
from .commands import commands
3737
from .utils import scanSerial, Response

0 commit comments

Comments
 (0)