Skip to content

Commit

Permalink
optimise conditional and filterProject
Browse files Browse the repository at this point in the history
  • Loading branch information
Furtif committed Dec 11, 2024
1 parent b84bf30 commit 9ef3b96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions ecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,12 +1007,13 @@ def connect_to_hardware(self, canline=0):
# Can
ecuname = self.ecuname.encode('ascii', errors='ignore')
if self.ecu_protocol == 'CAN':
short_addr = elm.get_can_addr(self.ecu_send_id)
if short_addr is None:
if len(self.ecu_send_id) == 8:
short_addr = elm.get_can_addr_ext(self.ecu_send_id)
if short_addr is None:
print(_("Cannot retrieve functionnal address of ECU") + " %s @ %s" % (self.ecuname, self.ecu_send_id))
return False
else:
short_addr = elm.get_can_addr(self.ecu_send_id)
if short_addr is None:
print(_("Cannot retrieve functionnal address of ECU") + " %s @ %s" % (self.ecuname, self.ecu_send_id))
return False
ecu_conf = {'idTx': self.ecu_send_id, 'idRx': self.ecu_recv_id, 'ecuname': str(ecuname)}

if not options.simulation_mode:
Expand Down
12 changes: 6 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ def __init__(self, ecuscan, treeview_ecu):

for k in vehicles["projects"].keys():
self.vehicle_combo.addItem(k)
ecu.addressing = vehicles["projects"][k]["addressing"]
elm.snat = vehicles["projects"][k]["snat"]
elm.snat_ext = vehicles["projects"][k]["snat_ext"]
elm.dnat = vehicles["projects"][k]["dnat"]
elm.dnat_ext = vehicles["projects"][k]["dnat_ext"]

self.vehicle_combo.activated.connect(self.filterProject)

Expand Down Expand Up @@ -224,6 +219,12 @@ def init(self):

def filterProject(self):
project = str(vehicles["projects"][self.vehicle_combo.currentText()]["code"])
ecu.addressing = vehicles["projects"][self.vehicle_combo.currentText()]["addressing"]
elm.snat = vehicles["projects"][self.vehicle_combo.currentText()]["snat"]
elm.snat_ext = vehicles["projects"][self.vehicle_combo.currentText()]["snat_ext"]
elm.dnat = vehicles["projects"][self.vehicle_combo.currentText()]["dnat"]
elm.dnat_ext = vehicles["projects"][self.vehicle_combo.currentText()]["dnat_ext"]

root = self.list.invisibleRootItem()
root_items = [root.child(i) for i in range(root.childCount())]

Expand Down Expand Up @@ -590,7 +591,6 @@ def about_content_msg(self):
msgbox.setInformativeText(contrib)
msgbox.exec_()


def wiki_about(self):
url = core.QUrl("https://github.com/cedricp/ddt4all/wiki", core.QUrl.TolerantMode)
gui.QDesktopServices().openUrl(url)
Expand Down

0 comments on commit 9ef3b96

Please sign in to comment.