Skip to content

Commit

Permalink
Merge branch 'master' into python3
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricp committed Feb 19, 2019
2 parents a7ab047 + ed2fd3a commit 3f6f964
Show file tree
Hide file tree
Showing 28 changed files with 195 additions and 3,578 deletions.
11 changes: 11 additions & 0 deletions ddt4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ def __init__(self, parent = None):
self.cominput.triggered.connect(self.command_editor)
self.cominput.setEnabled(False)

self.fctrigger = widgets.QAction(gui.QIcon("icons/flowcontrol.png"), _("Software flow control"), self)
self.fctrigger.setCheckable(True)
self.fctrigger.triggered.connect(self.flow_control)

self.canlinecombo = widgets.QComboBox()
self.canlinecombo.setFixedWidth(150)
self.canlinecombo.currentIndexChanged.connect(self.changecanspeed)
Expand Down Expand Up @@ -474,6 +478,7 @@ def __init__(self, parent = None):
self.toolbar.addAction(self.hexinput)
self.toolbar.addSeparator()
self.toolbar.addAction(self.cominput)
self.toolbar.addAction(self.fctrigger)
self.toolbar.addSeparator()
self.toolbar.addWidget(self.canlinecombo)
self.toolbar.addSeparator()
Expand Down Expand Up @@ -551,6 +556,12 @@ def __init__(self, parent = None):
self.setConnected(True)
self.tabbedview.setCurrentIndex(1)

def flow_control(self):
enabled = self.fctrigger.isChecked()
options.opt_cfc0 = enabled
if self.paramview is not None:
self.paramview.set_soft_fc(enabled)

def identEcu(self):
dialog = Ecu_finder(self.ecu_scan)
dialog.exec_()
Expand Down
23 changes: 16 additions & 7 deletions elm.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,11 @@ def send_cmd(self, command):
return self.send_can_cfc0(command)
else:
rsp = self.send_can(command)
if self.error_frame > 0 and not self.isels: #then fallback to cfc0
self.ATCFC0 = True
self.cmd("at cfc0")
rsp = self.send_can_cfc0(command)
# Disabled this because it's now possible to control it via UI
# if self.error_frame > 0 and not self.isels: #then fallback to cfc0
# self.ATCFC0 = True
# self.cmd("at cfc0")
# rsp = self.send_can_cfc0(command)
return rsp

def send_can(self, command):
Expand Down Expand Up @@ -923,6 +924,9 @@ def send_can_cfc0(self, command):
Fc = 0 # Current frame
Fn = len(raw_command) # Number of frames

if Fn > 1 or len(raw_command[0])>15: # set elm timeout to 300ms for first response
self.send_raw('ATST4B')

while Fc < Fn:

# enable responses
Expand All @@ -932,10 +936,15 @@ def send_can_cfc0(self, command):

tb = time.time() # time of sending (ff)

if len(raw_command[Fc]) == 16:
frsp = self.send_raw(raw_command[Fc]) # we'll get only 1 frame: fc, ff or sf
if Fn > 1 and Fc == (Fn-1): # set elm timeout to maximum for last response on long command
self.send_raw('ATSTFF')
self.send_raw('ATAT1')

if (Fc == 0 or Fc == (Fn-1)) and len(raw_command[Fc])<16: #first or last frame in command and len<16 (bug in ELM)
frsp = self.send_raw (raw_command[Fc] + '1') # we'll get only 1 frame: nr, fc, ff or sf
else:
frsp = self.send_raw(raw_command[Fc] + '1') # we'll get only 1 frame: fc, ff or sf
frsp = self.send_raw (raw_command[Fc])

Fc = Fc + 1

# analyse response
Expand Down
Binary file added icons/flowcontrol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3f6f964

Please sign in to comment.