Skip to content

Commit b4fcfaa

Browse files
author
Brendan Whitfield
committed
silence test_cmd output when scanning PID support
1 parent 348e5cf commit b4fcfaa

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

obd/obd.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def __load_commands(self):
104104
for get in pid_getters:
105105
# PID listing commands should sequentialy become supported
106106
# Mode 1 PID 0 is assumed to always be supported
107-
if not self.supports(get):
107+
if not self.test_cmd(get, warn=False):
108108
continue
109109

110110
# when querying, only use the blocking OBD.query()
@@ -214,19 +214,21 @@ def supports(self, cmd):
214214
return cmd in self.supported_commands
215215

216216

217-
def test_cmd(self, cmd):
217+
def test_cmd(self, cmd, warn=True):
218218
"""
219219
Returns a boolean for whether a command will
220220
be sent without using force=True.
221221
"""
222222
# test if the command is supported
223223
if not self.supports(cmd):
224-
logger.warning("'%s' is not supported" % str(cmd))
224+
if warn:
225+
logger.warning("'%s' is not supported" % str(cmd))
225226
return False
226227

227228
# mode 06 is only implemented for the CAN protocols
228229
if cmd.mode == 6 and self.interface.protocol_id() not in ["6", "7", "8", "9"]:
229-
logger.warning("Mode 06 commands are only supported over CAN protocols")
230+
if warn:
231+
logger.warning("Mode 06 commands are only supported over CAN protocols")
230232
return False
231233

232234
return True

0 commit comments

Comments
 (0)