From a987db98c2f06165f53a27fd774c78da085b725c Mon Sep 17 00:00:00 2001 From: Marianpol Date: Mon, 3 May 2021 13:26:26 +0200 Subject: [PATCH] Double check negative response --- pyren/mod_elm.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pyren/mod_elm.py b/pyren/mod_elm.py index ea6ac0f..73b5111 100644 --- a/pyren/mod_elm.py +++ b/pyren/mod_elm.py @@ -536,6 +536,7 @@ class ELM: currentScreenDataIds = [] #dataids displayed on current screen rsp_cache = OrderedDict() # cashes responses for current screen l1_cache = {} # save number of frames in responces + tmpNotSupportedCommands = {} #temporary list for requests that were positive and became negative for no reason notSupportedCommands = {} # save them to not slow down polling ecudump = {} # for demo only. contains responses for all 21xx and 22xxxx requests @@ -1112,8 +1113,12 @@ class ELM: nr = line[6:8] if line.startswith ("NR"): nr = line.split (':')[1] - if nr in ['12']: # mark this request as unsupported - self.notSupportedCommands[command] = cmdrsp + if nr in ['12']: # mark this request as unsupported only if previous response was also negative + if command in self.tmpNotSupportedCommands.keys(): + del self.tmpNotSupportedCommands[command] + self.notSupportedCommands[command] = cmdrsp + else: + self.tmpNotSupportedCommands[command] = cmdrsp if nr in ['21', '23']: # it is look like the ECU asked us to wait a bit time.sleep (0.5) no_negative_wait_response = False @@ -1898,6 +1903,7 @@ class ELM: def set_can_addr(self, addr, ecu): self.notSupportedCommands = {} + self.tmpNotSupportedCommands = {} if self.currentprotocol == "can" and self.currentaddress == addr: return @@ -1987,6 +1993,7 @@ class ELM: def set_iso_addr(self, addr, ecu): self.notSupportedCommands = {} + self.tmpNotSupportedCommands = {} if self.currentprotocol == "iso" and self.currentaddress == addr and self.currentsubprotocol == ecu['protocol']: return