Skip to content

Commit

Permalink
Fixes + CQN Line speed switch and update time info
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricp committed Nov 1, 2020
1 parent f049290 commit 6acccf5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
30 changes: 23 additions & 7 deletions ddt4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,6 @@ def __init__(self, parent = None):

self.canlinecombo = widgets.QComboBox()
self.canlinecombo.setFixedWidth(150)
self.canlinecombo.currentIndexChanged.connect(self.changecanspeed)
self.canlinecombo.addItem("CAN Line 1")
self.canlinecombo.addItem("CAN Line 2@500K")
self.canlinecombo.addItem("CAN Line 2@250K")
self.canlinecombo.addItem("CAN Line 2@125K")
if options.elm is not None and not options.elm.adapter_type == "ELS":
self.canlinecombo.setEnabled(False)

self.sdscombo = widgets.QComboBox()
self.sdscombo.setFixedWidth(300)
Expand Down Expand Up @@ -551,6 +544,27 @@ def __init__(self, parent = None):
self.setConnected(True)
self.tabbedview.setCurrentIndex(1)

def set_can_combo(self, bus):
self.canlinecombo.clear()
try:
self.canlinecombo.clicked.disconnect()
except Exception:
pass
if bus == "CAN":
self.canlinecombo.addItem("CAN Line 1 Auto")
self.canlinecombo.addItem("CAN Line 1@500K")
self.canlinecombo.addItem("CAN Line 1@250K")
if options.elm is not None and not options.elm.adapter_type == "ELS":
self.canlinecombo.addItem("CAN Line 2@500K")
self.canlinecombo.addItem("CAN Line 2@250K")
self.canlinecombo.addItem("CAN Line 2@125K")
self.canlinecombo.currentIndexChanged.connect(self.changecanspeed)
else:
if bus == "KWP2000":
self.canlinecombo.addItem("KWP2000")
if bus == "ISO8":
self.canlinecombo.addItem("ISO8")

def flow_control(self):
enabled = self.fctrigger.isChecked()
options.opt_cfc0 = enabled
Expand Down Expand Up @@ -938,6 +952,7 @@ def changeScreen(self, index):
self.buttonEditor.set_layout(self.paramview.layoutdict['screens'][screen])

self.paramview.setRefreshTime(self.refreshtimebox.value())
self.set_can_combo(self.paramview.ecurequestsparser.ecu_protocol)

def closeEvent(self, event):
if self.paramview:
Expand Down Expand Up @@ -1001,6 +1016,7 @@ def set_param_file(self, ecu_file, ecu_addr, ecu_name, isxml):
self.paramview.destroy()

self.paramview = parameters.paramWidget(self.scrollview, ecu_file, ecu_addr, ecu_name, self.logview, self.protocolstatus, self.canlinecombo.currentIndex())
self.paramview.infobox = self.infostatus
if options.simulation_mode:
self.requesteditor.set_ecu(self.paramview.ecurequestsparser)
self.dataitemeditor.set_ecu(self.paramview.ecurequestsparser)
Expand Down
16 changes: 13 additions & 3 deletions elm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,13 +1283,23 @@ def set_can_addr(self, addr, ecu, canline=0):
self.cmd("AT SP 7")
else:
self.cmd("AT SP 6")
elif canline == 1:
if extended_can:
self.cmd("AT SP 7")
else:
self.cmd("AT SP 6")
elif canline == 2:
if extended_can:
self.cmd("AT SP 9")
else:
self.cmd("AT SP 8")
else:
self.cmd("STP 53")
if canline == 1:
if canline == 3:
self.cmd("STPBR 500000")
elif canline == 2:
elif canline == 4:
self.cmd("STPBR 250000")
elif canline == 3:
elif canline == 5:
self.cmd("STPBR 125000")

if options.cantimeout > 0:
Expand Down
12 changes: 9 additions & 3 deletions parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def __init__(self, parent, ddtfile, ecu_addr, ecu_name, logview, prot_status, ca
self.allow_parameters_update = True
self.record_values = []
self.record_keys = {}
self.infobox = None

def set_soft_fc(self, b):
if options.elm is not None:
Expand Down Expand Up @@ -1310,7 +1311,8 @@ def updateDisplays(self, update_inputs=False):
self.record_values.append(lst)

elapsed_time = time.time() - start_time
print('Page update time {:.3f} ms'.format(elapsed_time*1000.0))
if self.infobox:
self.infobox.setText('Update time {:.3f} ms'.format(elapsed_time*1000.0))
# Stop log
self.updatelog = False
if options.auto_refresh:
Expand All @@ -1337,15 +1339,19 @@ def updateDisplay(self, request_name, update_inputs=False):
ecu_data = data_struct.data
data_item = request.dataitems[ecu_data.name]
value = ecu_data.getDisplayValue(elm_response, data_item, request.ecu_file.endianness)
logdict[data_item.name] = value
self.recorddict[data_item.name] = value.replace(".", ",")

if value is None:
qlabel.setStyleSheet("background-color: red;color: black")
value = "NO DATA"
else:
qlabel.resetDefaultStyle()

if value is not None:
logdict[data_item.name] = value
else:
logdict[data_item.name] = "N/A"
self.recorddict[data_item.name] = logdict[data_item.name].replace(".", ",")

qlabel.setText(value + ' ' + ecu_data.unit)

if update_inputs:
Expand Down

0 comments on commit 6acccf5

Please sign in to comment.