コード例 #1
0
ファイル: controlpanel.py プロジェクト: ekomook/Poon2
 def kline_worker_handler(self, info, value):
     if info in ["ecmid", "flashcount", "dtc", "dtccount", "state"]:
         self.ecuinfo[info] = value
         if info == "state":
             self.securebutton.Enable(False)
             self.statusicon.SetToolTip(
                 wx.ToolTip("state: %s" % (str(value).split(".")[-1])))
             if value in [ECUSTATE.OFF, ECUSTATE.UNKNOWN]:  # BLACK
                 self.__clear_widgets()
                 self.statusicon.SetBitmap(self.statusicons[0])
             elif value in [ECUSTATE.RECOVER_NEW,
                            ECUSTATE.RECOVER_OLD]:  # YELLOW
                 self.statusicon.SetBitmap(self.statusicons[1])
             elif value in [ECUSTATE.OK]:  # GREEN
                 self.securebutton.Enable(True)
                 self.statusicon.SetBitmap(self.statusicons[2])
             elif value in [ECUSTATE.FLASH]:  # BLUE
                 self.statusicon.SetBitmap(self.statusicons[3])
             elif value in [ECUSTATE.SECURE]:  # PURPLE
                 self.statusicon.SetBitmap(self.statusicons[4])
                 self.modell.SetLabel("Unknown Model")
                 self.ecupnl.SetLabel("~ Security Access Mode ~")
                 self.Layout()
         elif info == "ecmid":
             if len(value) > 0:
                 ecmid = " ".join(["%02x" % i for i in value])
                 self.ecmidl.SetLabel("   ECM ID: %s" % ecmid)
                 if value in ECM_IDs:
                     model = "%s (%s)" % (ECM_IDs[value]["model"],
                                          ECM_IDs[value]["year"])
                     pn = ECM_IDs[value]["pn"]
                 else:
                     model = "Unknown Model"
                     pn = "-"
                     for m in ECM_IDs.keys():
                         if m[:3] == value[:3]:
                             model = "%s (%s)" % (ECM_IDs[m]["model"],
                                                  ECM_IDs[m]["year"])
                             break
                 self.modell.SetLabel(model)
                 self.ecupnl.SetLabel(pn)
                 self.Layout()
         elif info == "flashcount":
             if value >= 0:
                 self.flashcountl.SetLabel("   Flash Count: %d" % value)
         elif info == "dtccount":
             if value >= 0:
                 self.dtccountl.SetLabel("   DTC Count: %d" % value)
         self.statusbar.OnSize(None)
     elif info == "data":
         if info not in self.ecuinfo:
             self.ecuinfo[info] = {}
         self.ecuinfo[info][value[0]] = value[1:]
コード例 #2
0
ファイル: controlpanel.py プロジェクト: parliak/HondaECU
	def OnDetectMap(self, event):
		with wx.FileDialog(self, "Open ECU dump file", wildcard="ECU dump (*.bin)|*.bin", style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) as fileDialog:
			if fileDialog.ShowModal() == wx.ID_CANCEL:
				return
			pathname = fileDialog.GetPath()
			ecupn = os.path.splitext(os.path.split(pathname)[-1])[0]
			for i in ECM_IDs.values():
				if ecupn == i["pn"] and "keihinaddr" in i:
					fbin = open(pathname, "rb")
					nbyts = os.path.getsize(pathname)
					byts = bytearray(fbin.read(nbyts))
					fbin.close()
					idadr = int(i["keihinaddr"],16)
					self.statusbar.SetStatusText("Map ID: " + byts[idadr:(idadr+7)].decode("ascii"), 0)
					return
			self.statusbar.SetStatusText("Map ID: unknown", 0)
コード例 #3
0
ファイル: tunehelper.py プロジェクト: ekomook/Poon2
 def gen_model_tree(self):
     modeltree = {}
     for ecmid, info in ECM_IDs.items():
         if self.parent.force_restrictions and not info[
                 "model"] in self.parent.restrictions[1]:
             continue
         if not info["model"] in modeltree:
             modeltree[info["model"]] = {}
         if not info["year"] in modeltree[info["model"]]:
             modeltree[info["model"]][info["year"]] = {}
         if not info["pn"] in modeltree[info["model"]][info["year"]]:
             blcode = info["pn"].split("-")[1]
             modelstring = "%s_%s_%s" % (info["model"], blcode,
                                         info["year"])
             base = self.parent.basepath
             if not getattr(sys, 'frozen', False):
                 base = os.path.join(base, os.pardir)
             xdfdir = os.path.join(base, "xdfs", modelstring)
             bindir = os.path.join(base, "bins", modelstring)
             if os.path.exists(xdfdir) and os.path.exists(bindir):
                 xdf1 = os.path.join(xdfdir, "38770-%s.xdf" % (blcode))
                 xdf2 = os.path.join(xdfdir, "%s.xdf" % (info["pn"]))
                 bin = os.path.join(bindir, "%s.bin" % (info["pn"]))
                 checksum = info["checksum"] if "checksum" in info else None
                 offset = info["offset"] if "offset" in info else None
                 ecmidaddr = info[
                     "ecmidaddr"] if "ecmidaddr" in info else None
                 keihinaddr = info[
                     "keihinaddr"] if "keihinaddr" in info else None
                 if os.path.isfile(bin):
                     _xdf = None
                     if os.path.isfile(xdf2):
                         _xdf = xdf2
                     elif os.path.isfile(xdf1):
                         _xdf = xdf1
                     modeltree[info["model"]][info["year"]][info["pn"]] = (
                         ecmid, _xdf, bin, checksum, offset, ecmidaddr,
                         keihinaddr)
     models = list(modeltree.keys())
     for m in models:
         years = list(modeltree[m].keys())
         for y in years:
             if len(modeltree[m][y].keys()) == 0:
                 del modeltree[m][y]
         if len(modeltree[m].keys()) == 0:
             del modeltree[m]
     return modeltree