Skip to content

Commit

Permalink
Merge branch 'python3' of https://github.com/cedricp/ddt4all into pyt…
Browse files Browse the repository at this point in the history
…hon3
  • Loading branch information
cedricp committed Dec 9, 2019
2 parents 7ee8260 + c934fb9 commit 5147f6a
Show file tree
Hide file tree
Showing 30 changed files with 68 additions and 28 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# NEW : Android port
[Wiki](https://github.com/cedricp/ddt4all/wiki/Android-port)

# DDT4All

DDT4All is tool to create your own ECU parameters screens and connect to a CAN network with a cheap ELM327 interface.
Expand Down
10 changes: 5 additions & 5 deletions dataeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@
import options
import copy
import codecs

hex_decoder = codecs.getdecoder("hex_codec")


def decode_hex(string):
return hex_decoder(string)[0]

try:
import PyQt5.QtGui as gui
import PyQt5.QtCore as core
Expand All @@ -38,6 +33,11 @@ def utf8(string):

_ = options.translator('ddt4all')


def decode_hex(string):
return hex_decoder(string)[0]


class Bit_container(widgets.QFrame):
def __init__(self, data, num, parent=None):
super(Bit_container, self).__init__(parent)
Expand Down
11 changes: 11 additions & 0 deletions ddt4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,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 @@ -462,6 +466,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 @@ -552,6 +557,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
5 changes: 4 additions & 1 deletion displaymod.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, parent, uiscale):
self.toggle_selected(False)
self.setWordWrap(True)
self.img = None
self.area = 0

def toggle_selected(self, sel):
if sel:
Expand All @@ -58,7 +59,7 @@ def get_zip_graphic(self, name):
self.buffer = core.QBuffer()
self.buffer.setData(ba)
self.buffer.open(core.QIODevice.ReadOnly)
self.img = gui.QMovie(self.buffer, 'GIF')
self.img = gui.QMovie(self.buffer, b"gif")

def initXML(self, xmldata):
text = xmldata.getAttribute("Text")
Expand All @@ -82,6 +83,7 @@ def initXML(self, xmldata):
rect = getRectangleXML(getChildNodesByName(xmldata, "Rectangle")[0], self.uiscale)
qfnt = getXMLFont(xmldata, self.uiscale)

self.area = rect['width'] * rect['height']
self.setFont(qfnt)
self.resize(rect['width'], rect['height'])
self.setStyleSheet("background: %s; color: %s" % (colorConvert(color), getFontColor(xmldata)))
Expand All @@ -101,6 +103,7 @@ def initJson(self, jsdata):
fontcolor = jsdata['fontcolor']

rect = jsdata['bbox']
self.area = rect['width'] * rect['height']
qfnt = jsonFont(jsdata['font'], self.uiscale)

self.ismovable = True
Expand Down
8 changes: 4 additions & 4 deletions ecu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,14 +1485,14 @@ def identify_new(self, addr, label):
if options.simulation_mode:
# Give scanner something to eat...
if addr == '26':
can_response = "62 F1 8A 43 4F 4E 54 49 4E 45 4E 54 41 4C 20 41 55 54 4F 4D 4F 54 49 56 45 20 20 20 20 " \
"20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 " \
can_response = "62 F1 8A 43 4F 4E 54 49 4E 45 4E 54 41 4C 20 41 55 54 4F 4D 4F 54 49 56 45 20 20 20 20 "\
"20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 "\
"20 20 20 20 20 20 20 20 20"
elif addr == '13':
can_response = "62 F1 8A 43 41 50"
elif addr == '26':
can_response = "62 F1 8A 43 4F 4E 54 49 4E 45 4E 54 41 4C 20 41 55 54 4F 4D 4F 54 49 56 45 20 20 20 20" \
"20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20" \
can_response = "62 F1 8A 43 4F 4E 54 49 4E 45 4E 54 41 4C 20 41 55 54 4F 4D 4F 54 49 56 45 20 20 20 20"\
"20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20"\
"20 20 20 20 20 20 20 20 20 FF FF"
elif addr == '62':
can_response = "62 F1 8A 41 46 4B"
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 modified graphics/checkbox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/down_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/handle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/autorefresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/bt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/command.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/donate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/dtc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/els27.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/expert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
Binary file modified icons/hex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/obdlink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/scan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/usb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/wifi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified locale/it/LC_MESSAGES/ddt4all.mo
Binary file not shown.
5 changes: 4 additions & 1 deletion locale/it/LC_MESSAGES/ddt4all.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: DDT4ALL (22.05.2018)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-21 15:12+0100\n"
"POT-Creation-Date: 2019-03-04 07:06+0100\n"
"PO-Revision-Date: 2019-01-10 21:11+0100\n"
"Last-Translator: bovirus <bovirus@gmail.com>\n"
"Language-Team: bovirus@gmail.com\n"
Expand Down Expand Up @@ -329,6 +329,9 @@ msgstr "Comando manuale"
msgid "Manual request"
msgstr "Richiesta manuale"

msgid "Software flow control"
msgstr "Flusso controllo software"

msgid "Zoom In"
msgstr "Zoom +"

Expand Down
15 changes: 13 additions & 2 deletions parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ def __init__(self, parent, ddtfile, ecu_addr, ecu_name, logview, prot_status, ca
self.movingwidgets = []
self.allow_parameters_update = True

def set_soft_fc(self, b):
if options.elm is not None:
options.elm.ATCFC0 = b

def tester_send(self):
if self.tester_presend_command == "":
return
Expand Down Expand Up @@ -1060,17 +1064,24 @@ def drawButtons(self, screen):
qbutton.clicked.connect(lambda state, btn=qbutton.uniquename: self.buttonClicked(btn))

def drawLabels(self, screen):
labeldict = {}
if self.parser == 'xml':
labels = self.getChildNodesByName(screen, "Label")
for label in labels:
qlabel = displaymod.labelWidget(self.panel, self.uiscale)
qlabel.initXML(label)

labeldict[qlabel] = qlabel.area
else:
for label in screen['labels']:
qlabel = displaymod.labelWidget(self.panel, self.uiscale)
qlabel.initJson(label)

labeldict[qlabel] = qlabel.area

# Raise the small labels so they're not hidden by bigger ones
for key, value in [(k, labeldict[k]) for k in sorted(labeldict, key=labeldict.get, reverse=True)]:
key.setParent(self.panel)
key.raise_()

def drawInputs(self,screen):
self.inputdict = {}
if self.parser == 'xml':
Expand Down
8 changes: 4 additions & 4 deletions uiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def getXMLFont(xml, scale = 1):
if font_italic == '1':
fnt_flags |= gui.QFont.StyleItalic

font_size = font_size / float(scale) * 12.
font_size = font_size / float(scale) * 14.
qfnt = gui.QFont(font_name, font_size, fnt_flags)

qfnt.setPixelSize(font_size)
return qfnt


Expand Down Expand Up @@ -132,8 +132,8 @@ def jsonFont(fnt, scale):
if font_italic == '1':
fnt_flags |= gui.QFont.StyleItalic

font_size = font_size / float(scale) * 12.
font_size = font_size / float(scale) * 14.

qfnt = gui.QFont(font_name, font_size, fnt_flags);

qfnt.setPixelSize(font_size)
return qfnt
8 changes: 4 additions & 4 deletions usbdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def init(self):
self.device = usb.core.find(idVendor=0x16c0, idProduct=0x05df)
if self.device:
self.descriptor = self.get_string_descriptor()
print "Found USB adapter : %s" % self.descriptor
print("Found USB adapter : %s" % self.descriptor)
return True

self.device = None
Expand Down Expand Up @@ -95,11 +95,11 @@ def get_buffer(self, timeout = 500):
while 1:
leng = self.get_read_buffer_length()
if leng == -1:
return "WRONG RESPONSE"
return("WRONG RESPONSE")
if leng > 0:
break
if time.time() - start > timeout / 1000:
return "TIMEOUT"
return("TIMEOUT")
return self.get_data(leng)


Expand Down Expand Up @@ -138,7 +138,7 @@ def request(self, req, positive='', cache=True, serviceDelay="0"):
self.device.set_data(req_as_bytes)
return self.device.get_buffer(500)

def close_protocol(self):
def close_protocol(self):
pass

def start_session_can(self, start_session):
Expand Down

0 comments on commit 5147f6a

Please sign in to comment.