Skip to content

Commit

Permalink
Merge branch 'master' into winXP
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric PAILLE committed Oct 3, 2017
2 parents 36705f1 + 9f4c8cd commit 3ba56d9
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 123 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DDT4all

DDT4all is a DDT2000 clone able to parse DDT2000's database, create/modifiy your own ECU parameters screens and connect to your vehicle with an ELM327 cable.
DDT4all is tool to create your own ECU parameters screens and connect to your vehicle with an ELM327 cable.

This application is work in progress, so be very carful when using expert mode. If you're brave enough to use it and it's working (or not), please tell me so I can update the tested ECUs database.
Using the application in non expert mode should not be harmful for your vehicle (leave the expert mode button released).
Expand Down Expand Up @@ -33,7 +33,7 @@ Get the fully packaged installer here : [Release area](https://github.com/cedric

## How to install database ?

Copy the 'ecus' directory from your DDT2000 database to the root of the sources tree and launch ddt4all.py, you are now ready to use it
Copy the 'ecus' directory from your database to the root of the sources tree and launch ddt4all.py, you are now ready to use it

## How to launch the application ?

Expand Down
45 changes: 37 additions & 8 deletions ddt4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import PyQt4.QtGui as gui
import PyQt4.QtCore as core
import PyQt4.QtWebKit as webkit
import parameters, ecu
import elm, options, locale
import dataeditor
Expand Down Expand Up @@ -34,18 +35,20 @@ def __init__(self, ecuscan, treeview_ecu):
self.vehicle_combo = gui.QComboBox()

self.ecu_map = {}

vehicles = [
"ALL", "XBA - KWID CN", "XBB - KWID BR", "X06 - TWINGO", "X44 - TWINGO II",
"X07 - TWINGO III", "X77 - MODUS", "X35 - SYMBOL/THALIA", "X65 - CLIO II",
"X07 - TWINGO III", "X77 - MODUS", "X35 - SYMBOL/THALIA",
"X65 - CLIO II",
"X85 - CLIO III", "X98 - CLIO IV", "XJA - CLIO V", "X87 - CAPTUR",
"XJB - CAPTUR II", "X38 - FLUENCE", "XFF - FLUENCE II", "X64 - MEGANE/SCENIC I",
"X84 - MEGANE/SCENIC II", "X95 - MEGANE/SCENIC III", "XFB - MEGANE IV",
"XFA - SCENIC IV", "X56 - LAGUNA", "X74 - LAGUNA II", "X91 - LAGUNA III",
"X47 - LAGUNA III (tricorps)", "X66 - ESPACE III", "X81 - ESPACE IV", "XFC - ESPACE V",
"X73 - VELSATIS", "X43 - LATITUDE", "XFD - TALISMAN", "H45 - KOLEOS", "XZG - KOLEOS II", "XFE - KADJAR",
"X33 - WIND", "X09 - TWIZY", "X10 - ZOE", "X76 - KANGOO I", "X61 - KANGOO II", "XFK - KANGOO II",
"X24 - MASCOTT", "X83 - TRAFFIC II", "X82 - TRAFFIC III", "X70 - MASTER II", "X62 - MASTER III",
"X33 - WIND", "X09 - TWIZY", "X10 - ZOE", "X76 - KANGOO I",
"X61 - KANGOO II", "XFK - KANGOO III",
"X24 - MASCOTT", "X83 - TRAFFIC II", "X82 - TRAFFIC III",
"X70 - MASTER II", "X62 - MASTER III",
"X90 - LOGAN/SANDERO", "X52 - LOGAN/SANDERO II", "X79 - DUSTER", "XJD - DUSTER II", "X67 - DOKKER",
"X92 - LODGY", "X02 - MICRA (NISSAN)", "X21 - NOTE (NISSAN)"
]
Expand Down Expand Up @@ -176,6 +179,11 @@ def __init__(self, parent = None):
print ("%i " + _("loaded ECUs in database.")) % self.ecu_scan.getNumEcuDb()

self.paramview = None
self.docview = webkit.QWebView()
self.docview.load(core.QUrl("https://github.com/cedricp/ddt4all/wiki"))
self.docview.settings().setAttribute(webkit.QWebSettings.JavascriptEnabled, True)
self.docview.settings().setAttribute(webkit.QWebSettings.PluginsEnabled, True)
self.docview.settings().setAttribute(webkit.QWebSettings.AutoLoadImages, True)
self.screennames = []

self.statusBar = gui.QStatusBar()
Expand All @@ -199,10 +207,11 @@ def __init__(self, parent = None):
refrestimelabel = gui.QLabel(_("Refresh rate (ms):"))

self.cantimeout = gui.QSpinBox()
self.cantimeout.setRange(200, 1000)
self.cantimeout.setRange(0, 1000)
self.cantimeout.setSingleStep(200)
self.cantimeout.setValue(options.cantimeout)
self.cantimeout.valueChanged.connect(self.changeCanTimeout)
cantimeoutlabel = gui.QLabel(_("Can timeout (ms):"))
cantimeoutlabel = gui.QLabel(_("Can timeout (ms) [0:AUTO] :"))

self.statusBar.addWidget(self.connectedstatus)
self.statusBar.addWidget(self.protocolstatus)
Expand All @@ -221,6 +230,7 @@ def __init__(self, parent = None):

self.snifferview = sniffer.sniffer()

self.tabbedview.addTab(self.docview, _("Documentation"))
self.tabbedview.addTab(self.scrollview, _("Screen"))
self.tabbedview.addTab(self.snifferview, _("CAN Sniffer"))

Expand All @@ -238,6 +248,8 @@ def __init__(self, parent = None):
self.treedock_widget = gui.QDockWidget(self)
self.treedock_widget.setWidget(screen_widget)
self.treeview_params = gui.QTreeWidget()
self.treeview_params.setSortingEnabled(True)
self.treeview_params.sortByColumn(0, core.Qt.AscendingOrder)
self.screenmenu = gui.QMenuBar()
treedock_layout = gui.QVBoxLayout()
treedock_layout.addWidget(self.screenmenu)
Expand Down Expand Up @@ -313,6 +325,11 @@ def __init__(self, parent = None):
self.sdscombo.currentIndexChanged.connect(self.changeSds)
self.sdscombo.setEnabled(False)

self.zoominbutton = gui.QPushButton("Zoom In")
self.zoomoutbutton = gui.QPushButton("Zoom Out")
self.zoominbutton.clicked.connect(self.zoomin)
self.zoomoutbutton.clicked.connect(self.zoomout)

self.toolbar.addAction(scanaction)
self.toolbar.addSeparator()
self.toolbar.addAction(self.log)
Expand All @@ -326,8 +343,12 @@ def __init__(self, parent = None):
self.toolbar.addAction(self.hexinput)
self.toolbar.addSeparator()
self.toolbar.addWidget(self.sdscombo)
self.toolbar.addSeparator()
self.toolbar.addWidget(self.zoominbutton)
self.toolbar.addWidget(self.zoomoutbutton)

if options.simulation_mode:
self.toolbar.addSeparator()
self.ui_edit_button = gui.QPushButton("UI Edit")
self.ui_edit_button.setCheckable(True)
self.toolbar.addSeparator()
Expand Down Expand Up @@ -390,6 +411,14 @@ def __init__(self, parent = None):

self.setConnected(True)

def zoomin(self):
if self.paramview:
self.paramview.zoomin_page()

def zoomout(self):
if self.paramview:
self.paramview.zoomout_page()

def toggle_edit(self):
options.mode_edit = self.ui_edit_button.isChecked()

Expand Down Expand Up @@ -473,7 +502,7 @@ def newScreen(self):
self.screennames.append(newscreenname)

def showDataTab(self, name):
self.tabbedview.setCurrentIndex(3)
self.tabbedview.setCurrentIndex(4)
self.dataitemeditor.edititem(name)

def hexeditor(self):
Expand Down Expand Up @@ -717,7 +746,7 @@ def changeECU(self, index):
ecu_addr = ecu.addr

if self.snifferview.set_file(ecu_file):
self.tabbedview.setCurrentIndex(1)
self.tabbedview.setCurrentIndex(2)

if self.paramview:
if ecu_file == self.paramview.ddtfile:
Expand Down
2 changes: 1 addition & 1 deletion ddtplugins
Submodule ddtplugins updated 1 files
+97 −0 megane3_ab_reset.py
8 changes: 6 additions & 2 deletions displaymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def initXML(self, xmldata):
self.move(rect['left'], rect['top'])
if alignment == '2':
self.setAlignment(core.Qt.AlignHCenter)
elif alignment == '1':
self.setAlignment(core.Qt.AlignRight)
else:
self.setAlignment(core.Qt.AlignLeft)

Expand All @@ -69,6 +71,8 @@ def initJson(self, jsdata):
self.move(rect['left'] / self.uiscale, rect['top'] / self.uiscale)
if alignment == '2':
self.setAlignment(core.Qt.AlignHCenter)
elif alignment == '1':
self.setAlignment(core.Qt.AlignRight)
else:
self.setAlignment(core.Qt.AlignLeft)

Expand Down Expand Up @@ -523,7 +527,7 @@ def initXML(self, input, inputdict):
self.editwidget = gui.QComboBox(self)
items_ref = self.ecurequestsparser.data[text].items

for key in items_ref.keys():
for key in sorted(items_ref.keys()):
self.editwidget.addItem(key)

self.editwidget.resize(rect['width'] - width, rect['height'])
Expand Down Expand Up @@ -585,7 +589,7 @@ def initJson(self, jsoninput, inputdict):
self.editwidget = gui.QComboBox(self)
items_ref = self.ecurequestsparser.data[text].items

for key in items_ref.keys():
for key in sorted(items_ref.keys()):
self.editwidget.addItem(key)


Expand Down
22 changes: 11 additions & 11 deletions ecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,8 @@ def __init__(self, data, isfile=False):
if self.ecu_protocol == "KWP2000":
self.fastinit = ecudict['obd']['fastinit']
self.funcaddr = ecudict['obd']['funcaddr']
self.funcname = ecudict['obd']['funcname']
if 'funcname' in ecudict['obd']:
self.funcname = ecudict['obd']['funcname']
if "kw1" in ecudict['obd']:
self.kw1 = ecudict['obd']['kw1']
self.kw2 = ecudict['obd']['kw2']
Expand Down Expand Up @@ -988,7 +989,7 @@ def __init__(self, data, isfile=False):
ecu_data = Ecu_data(f)
self.data[ecu_data.name] = ecu_data

def connect_to_hardware(self, timeout = 200):
def connect_to_hardware(self):
# Can
ecuname = self.ecuname.encode('ascii', errors='ignore')
if self.ecu_protocol == 'CAN':
Expand All @@ -999,7 +1000,6 @@ def connect_to_hardware(self, timeout = 200):
if self.baudrate == 250000:
ecu_conf['brp'] = 1
options.elm.init_can()
options.elm.set_can_timeout(timeout)
options.elm.set_can_addr(short_addr, ecu_conf)

# KWP 2000 Handling
Expand Down Expand Up @@ -1460,7 +1460,7 @@ def scan(self, progress=None, label=None):
if options.simulation_mode:
# Give scanner something to eat...
if addr == "04":
can_response = "61 80 82 00 30 64 35 48 30 30 31 00 00 32 03 00 03 22 03 60 00 00 2D 32 14 00 60"
can_response = "61 80 30 36 32 36 52 35 37 31 31 35 32 31 36 52 01 99 00 00 00 00 02 00 00 88"
elif addr == "7A":
# Test approximate case
can_response = "61 80 82 00 44 66 27 44 32 31 33 82 00 38 71 38 00 A7 75 00 56 05 02 01 00 00"
Expand Down Expand Up @@ -1505,12 +1505,12 @@ def scan_kwp(self, progress=None, label=None):
can_response = options.elm.request(req='2180', positive='61', cache=False)
else:
# Send some data collected during my tests
if addr == "27":
can_response = "61 80 82 00 26 02 45 09 30 30 31 01 18 52 20 06 05 02 05 00 03 01 04 33 69 91"
elif addr == "01":
can_response = "61 80 82 01 00 28 28 04 41 4D 52 00 03 07 00 07 04 00 04 03 08 2B 00 31 04 00"
elif addr == "2C":
can_response = "61 80 60 01 55 09 13 1C 30 33 37 33 09 31 24 FA EF 9E 01 01 00 00 80 05 84 00"
if addr == "02":
can_response = "61 80 77 00 31 38 31 04 41 42 45 E3 17 03 00 38 00 07 00 00 00 00 09 11 12 00"
elif addr == "7A":
can_response = "61 80 82 00 23 66 18 14 30 33 37 82 00 08 53 86 00 CB A4 00 70 06 3C 02 B1 A4"
elif addr == "26":
can_response = "61 80 82 00 03 27 76 00 32 31 33 11 01 10 30 08 00 66 00 00 00 41 06 01 F1 38"
else:
continue

Expand Down Expand Up @@ -1545,7 +1545,7 @@ def check_ecu2(self, diagversion, supplier, soft, version, label, addr, protocol
label.setText("Found %i ecu" % self.num_ecu_found)
found_exact = True
href = target.href
line = "<font color='green'>Found ECU : %s DIAGVERSION [%s] SUPPLIER [%s] SOFT [%s] VERSION [%s]</font>"\
line = "<font color='green'>Identified ECU : %s DIAGVERSION [%s] SUPPLIER [%s] SOFT [%s] VERSION [%s]</font>"\
% (href, diagversion, supplier, soft, version)

options.main_window.logview.append(line)
Expand Down
18 changes: 10 additions & 8 deletions elm.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@
#v2.1 ;ACH ; ATZ ; Z ; reset all
'''


def get_can_addr(txa):
for d in dnat.keys():
if dnat[d] == txa:
Expand Down Expand Up @@ -722,12 +721,11 @@ def cmd(self, command, serviceDelay="0"):
return cmdrsp

def set_can_timeout(self, value):
if self.currentprotocol == 'can':
val = value / 4
if val > 255:
val = 255
val = hex(val)[2:].upper()
self.cmd("AT ST " + val)
val = value / 4
if val > 255:
val = 255
val = hex(val)[2:].upper()
self.cmd("AT ST %s" % val)

def send_cmd(self, command):
if "AT" in command.upper() or self.currentprotocol != "can":
Expand Down Expand Up @@ -1130,7 +1128,7 @@ def monitor_can_bus(self, callback):

def init_can(self):
self.currentprotocol = "can"
self.currentaddress = "7e0"
self.currentaddress = "7A"
self.startSession = ""
self.lastCMDtime = 0
self.l1_cache = {}
Expand Down Expand Up @@ -1174,6 +1172,7 @@ def set_can_addr(self, addr, ecu):
if 'idTx' in ecu and 'idRx' in ecu:
TXa = ecu['idTx']
RXa = ecu['idRx']
self.currentaddress = get_can_addr(TXa)
else:
TXa = dnat[addr]
RXa = snat[addr]
Expand All @@ -1188,6 +1187,9 @@ def set_can_addr(self, addr, ecu):
else:
self.cmd("AT SP 6")

if options.cantimeout > 0:
self.set_can_timeout(options.cantimeout)

return TXa, RXa

def start_session_iso(self, start_session):
Expand Down
2 changes: 1 addition & 1 deletion options.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
main_window = None
ecu_scanner = None
debug = 'DDTDEBUG' in os.environ
cantimeout = 200
cantimeout = 0
refreshrate = 100
mode_edit = False

Expand Down
25 changes: 18 additions & 7 deletions parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class paramWidget(gui.QWidget):
def __init__(self, parent, ddtfile, ecu_addr, ecu_name, logview, prot_status):
super(paramWidget, self).__init__(parent)
self.defaultdiagsessioncommand = "10C0"
self.setFocusPolicy(core.Qt.ClickFocus)
self.sds = {}
self.currentsession = ""
self.layoutdict = None
Expand Down Expand Up @@ -392,25 +393,35 @@ def mouseMoveEvent(self, event):
def setRefreshTime(self, value):
self.refreshtime = value

def wheelEvent(self, event):
if event.delta() > 0:
def keyPressEvent(self, event):
if event.key() == core.Qt.Key_Plus:
self.zoomin_page()
else:
elif event.key() == core.Qt.Key_Minus:
self.zoomout_page()
self.allow_parameters_update = False
self.init(self.current_screen)
self.allow_parameters_update = True
else:
event.ignore()
return

event.accept()

def zoomin_page(self):
self.uiscale -= 1
if self.uiscale < 4:
self.uiscale = 4

self.allow_parameters_update = False
self.init(self.current_screen)
self.allow_parameters_update = True

def zoomout_page(self):
self.uiscale += 1
if self.uiscale > 20:
self.uiscale = 20

self.allow_parameters_update = False
self.init(self.current_screen)
self.allow_parameters_update = True

def init(self, screen):
if self.panel:
self.layout.removeWidget(self.panel)
Expand Down Expand Up @@ -500,7 +511,7 @@ def send_manual_cmd(self):
self.output.setText(output)

def initELM(self):
connection_status = self.ecurequestsparser.connect_to_hardware(options.cantimeout)
connection_status = self.ecurequestsparser.connect_to_hardware()
if not connection_status:
self.logview.append("<font color='red'>Protocol not supported</font>")
return
Expand Down
Loading

0 comments on commit 3ba56d9

Please sign in to comment.