CAF1
This commit is contained in:
parent
350a9e2e5b
commit
6554c69438
101
pyren/mod_elm.py
101
pyren/mod_elm.py
@ -1214,12 +1214,13 @@ class ELM:
|
|||||||
else:
|
else:
|
||||||
if mod_globals.opt_obdlink:
|
if mod_globals.opt_obdlink:
|
||||||
rsp = self.send_can_cfc(command)
|
rsp = self.send_can_cfc(command)
|
||||||
|
# rsp = self.send_can_cfc_caf(command)
|
||||||
else:
|
else:
|
||||||
rsp = self.send_can (command)
|
rsp = self.send_can (command)
|
||||||
if self.error_frame > 0 or self.error_bufferfull > 0: # then fallback to cfc0
|
# if self.error_frame > 0 or self.error_bufferfull > 0: # then fallback to cfc0
|
||||||
self.ATCFC0 = True
|
# self.ATCFC0 = True
|
||||||
self.cmd ("at cfc0")
|
# self.cmd ("at cfc0")
|
||||||
rsp = self.send_can_cfc0 (command)
|
# rsp = self.send_can_cfc0 (command)
|
||||||
return rsp
|
return rsp
|
||||||
|
|
||||||
def send_can(self, command):
|
def send_can(self, command):
|
||||||
@ -1357,6 +1358,66 @@ class ELM:
|
|||||||
else:
|
else:
|
||||||
return "WRONG RESPONSE"
|
return "WRONG RESPONSE"
|
||||||
|
|
||||||
|
def send_can_cfc_caf(self, command):
|
||||||
|
if len(command) == 0:
|
||||||
|
return
|
||||||
|
if len(command) % 2 != 0:
|
||||||
|
return "ODD ERROR"
|
||||||
|
if not all(c in string.hexdigits for c in command):
|
||||||
|
return "HEX ERROR"
|
||||||
|
|
||||||
|
frsp = self.send_raw('STPX D:' + command + ',R:' + '1' + ', T:50')
|
||||||
|
|
||||||
|
responses = []
|
||||||
|
|
||||||
|
for s in frsp.split('\n'):
|
||||||
|
if s.strip()[:4] == "STPX": # echo cancelation
|
||||||
|
continue
|
||||||
|
|
||||||
|
s = s.strip().replace(' ', '')
|
||||||
|
if len(s) == 0: # empty string
|
||||||
|
continue
|
||||||
|
|
||||||
|
responses.append(s)
|
||||||
|
|
||||||
|
result = ""
|
||||||
|
noerrors = True
|
||||||
|
|
||||||
|
if len (responses) == 0: # no data in response
|
||||||
|
return ""
|
||||||
|
|
||||||
|
nodataflag = False
|
||||||
|
for s in responses:
|
||||||
|
|
||||||
|
if 'NO DATA' in s:
|
||||||
|
nodataflag = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if all(c in string.hexdigits for c in s): # some data
|
||||||
|
result = s
|
||||||
|
|
||||||
|
# Check for negative
|
||||||
|
if result[:2] == '7F': noerrors = False
|
||||||
|
|
||||||
|
if noerrors:
|
||||||
|
# split by bytes and return
|
||||||
|
result = ' '.join(a + b for a, b in zip(result[::2], result[1::2]))
|
||||||
|
return result
|
||||||
|
else:
|
||||||
|
# check for negative response (repeat the same as in cmd())
|
||||||
|
# debug
|
||||||
|
# print "Size error: ", result
|
||||||
|
if result[:2] == '7F' and result[4:6] in negrsp.keys():
|
||||||
|
if self.vf != 0:
|
||||||
|
tmstr = datetime.now().strftime("%H:%M:%S.%f")[:-3]
|
||||||
|
self.vf.write(
|
||||||
|
tmstr + ";" + dnat[self.currentaddress] + ";" + command + ";" + result + ";" + negrsp[
|
||||||
|
result[4:6]] + "\n")
|
||||||
|
self.vf.flush()
|
||||||
|
return "NR:" + result[4:6] + ':' + negrsp[result[4:6]]
|
||||||
|
else:
|
||||||
|
return "WRONG RESPONSE"
|
||||||
|
|
||||||
def send_can_cfc(self, command):
|
def send_can_cfc(self, command):
|
||||||
|
|
||||||
command = command.strip().replace(' ', '').upper()
|
command = command.strip().replace(' ', '').upper()
|
||||||
@ -1397,15 +1458,25 @@ class ELM:
|
|||||||
# if Fn > 1:
|
# if Fn > 1:
|
||||||
# self.send_raw('at cfc1')
|
# self.send_raw('at cfc1')
|
||||||
# print 'cfc1', raw_command
|
# print 'cfc1', raw_command
|
||||||
|
timeout1 = '25'
|
||||||
|
timeout2 = '200'
|
||||||
|
|
||||||
|
moreTimeout = ['10C0', '2181']
|
||||||
|
|
||||||
if raw_command[Fc].startswith('0'):
|
if raw_command[Fc].startswith('0'):
|
||||||
if uncutCommand in self.l1_cache.keys():
|
if uncutCommand in self.l1_cache.keys():
|
||||||
frsp = self.send_raw ('STPX D:' + raw_command[Fc] + ',R:' + self.l1_cache[uncutCommand]) # we'll get only 1 frame: fc, ff or sf
|
if uncutCommand in moreTimeout:
|
||||||
|
frsp = self.send_raw ('STPX D:' + raw_command[Fc] + ' ,R:' + self.l1_cache[uncutCommand] + ' ,T:' + timeout2) # we'll get only 1 frame: fc, ff or sf
|
||||||
|
else:
|
||||||
|
frsp = self.send_raw ('STPX D:' + raw_command[Fc] + ' ,R:' + self.l1_cache[uncutCommand] + ' ,T:' + timeout1) # we'll get only 1 frame: fc, ff or sf
|
||||||
else:
|
else:
|
||||||
frsp = self.send_raw ('STPX D:' + raw_command[Fc])
|
if uncutCommand in moreTimeout:
|
||||||
|
frsp = self.send_raw ('STPX D:' + raw_command[Fc] + ' ,T:' + timeout2)
|
||||||
|
else:
|
||||||
|
frsp = self.send_raw ('STPX D:' + raw_command[Fc] + ' ,T:' + timeout1 )
|
||||||
|
|
||||||
if raw_command[Fc].startswith('1'):
|
if raw_command[Fc].startswith('1'):
|
||||||
frsp = self.send_raw ('STPX D:' + raw_command[Fc] + ',R:' + '1')
|
frsp = self.send_raw ('STPX D:' + raw_command[Fc] + ',R:' + '1' + ' ,T:50')
|
||||||
|
|
||||||
while Fc < Fn:
|
while Fc < Fn:
|
||||||
# if Fn > 1 and (Fn - Fc) == 1:
|
# if Fn > 1 and (Fn - Fc) == 1:
|
||||||
@ -1481,11 +1552,11 @@ class ELM:
|
|||||||
|
|
||||||
if burstSizeCommand.endswith(raw_command[-1]):
|
if burstSizeCommand.endswith(raw_command[-1]):
|
||||||
if uncutCommand in self.l1_cache.keys():
|
if uncutCommand in self.l1_cache.keys():
|
||||||
burstSizeCommandRequest = 'STPX D:' + burstSizeCommand + ",R:" + self.l1_cache[uncutCommand]
|
burstSizeCommandRequest = 'STPX D:' + burstSizeCommand + ",R:" + self.l1_cache[uncutCommand] + ' ,T:50'
|
||||||
else:
|
else:
|
||||||
burstSizeCommandRequest = 'STPX D:' + burstSizeCommand
|
burstSizeCommandRequest = 'STPX D:' + burstSizeCommand + ' ,T:50'
|
||||||
else:
|
else:
|
||||||
burstSizeCommandRequest = 'STPX D:' + burstSizeCommand + ",R:1"
|
burstSizeCommandRequest = 'STPX D:' + burstSizeCommand + ",R:1" + ' ,T:50'
|
||||||
|
|
||||||
# Ensure time gap between frames according to FlowControl
|
# Ensure time gap between frames according to FlowControl
|
||||||
tc = time.time() # current time
|
tc = time.time() # current time
|
||||||
@ -1932,10 +2003,14 @@ class ELM:
|
|||||||
self.check_answer(self.cmd("at l0"))
|
self.check_answer(self.cmd("at l0"))
|
||||||
self.check_answer(self.cmd("at al"))
|
self.check_answer(self.cmd("at al"))
|
||||||
self.check_answer(self.cmd("at caf0"))
|
self.check_answer(self.cmd("at caf0"))
|
||||||
|
# self.check_answer(self.cmd("at caf1"))
|
||||||
if self.ATCFC0:
|
if self.ATCFC0:
|
||||||
self.check_answer(self.cmd("at cfc0"))
|
self.check_answer(self.cmd("at cfc0"))
|
||||||
else:
|
else:
|
||||||
self.check_answer(self.cmd("at cfc1"))
|
self.check_answer(self.cmd("at cfc1"))
|
||||||
|
|
||||||
|
# self.check_answer(self.cmd("STCSEGR 1"))
|
||||||
|
# self.check_answer(self.cmd("STCSEGT 1"))
|
||||||
|
|
||||||
self.lastCMDtime = 0
|
self.lastCMDtime = 0
|
||||||
|
|
||||||
@ -2035,6 +2110,12 @@ class ELM:
|
|||||||
|
|
||||||
self.check_answer (self.cmd ("at at 1")) # reset adaptive timing step 3
|
self.check_answer (self.cmd ("at at 1")) # reset adaptive timing step 3
|
||||||
self.check_answer (self.cmd ("at cra " + RXa))
|
self.check_answer (self.cmd ("at cra " + RXa))
|
||||||
|
self.check_answer (self.cmd ("STCFCPA " + TXa + ", " + RXa))
|
||||||
|
self.send_raw("STFBA 763037F01, 7FFFFFFFF")
|
||||||
|
self.check_answer (self.cmd ("at sh 35C"))
|
||||||
|
self.send_raw ("FA 40 00 00 00 20 60 04")
|
||||||
|
self.check_answer (self.cmd ("at sh " + TXa))
|
||||||
|
# self.send_raw("STFBA 7E80040, 7FFF8F8")
|
||||||
|
|
||||||
self.check_adapter ()
|
self.check_adapter ()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user