From 30eaa1d54046b34b0f741dee602fa64caaa03c19 Mon Sep 17 00:00:00 2001 From: sailoog Date: Mon, 25 Apr 2022 22:08:00 +0200 Subject: [PATCH] parse firmware files --- openplotterMaiana/data/download.png | Bin 0 -> 974 bytes openplotterMaiana/openplotterMaiana.py | 41 +++++++++++++++++++++---- 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 openplotterMaiana/data/download.png diff --git a/openplotterMaiana/data/download.png b/openplotterMaiana/data/download.png new file mode 100644 index 0000000000000000000000000000000000000000..ce8903515c38a8e364c58d508ae165b2480932bd GIT binary patch literal 974 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM3?#3wJbMaAv7|ftIx;Y9?C1WI$O_~uBzpw; zGB8xBF)%c=FfjZA3N^f7U???UV0e|lz+g3lfkC`r&aOZk1_nl#0G|+7ke=no<(3_n zUw%w>=~1a=XH=G)kXv>Pf@GH-XIQmLVg7!3kjPPn|NrHHikBaiS$aZ#*-`nWK#fq9 zK!(DqQy}irV{#x9KnBV!Jq%@KSNuPba_?xN{PM#P z+3xLg|DQ|&qNhj7X%3KzC<*clW>APP zi4fsi`1gA=GslS~jP)U^y+P0Re)}l#X}VTepwd1$l~+?%{kVGOO`1!AThit`md8)2 zFaKkI|DlNF^NsDjqBGy6U%&U^$JM*d-Tb$OWDXorFwMy|XYBM-@&?+$nB?v5!qCAg z>jC6&7I;J!GcfQS0b$0e+I-SLLG}_)Usv|WoYMS8@_RM%Zvll~db&7he%1si08oBS(q?qww@8 zT@I|5j08Aua+E0Ou?tNP?>I0eFeM=%sP6z%h=fGQ#iLiQT(wj-k&rM6Y@NDwOKC~T z*DsP1Dgj4$d3u!=FH-LHm5}h6c=YTUT_xq@BxPmYwGwM`C#dASRZG5$uaC{o z;K3WF$px<5$>uX!tY@{jr^M9wWko)T2#l@(RB#C%pue}0NvT3FSRR{1KH z-|Q}GOWoPn5nC}Q!>*kack&yTeJqKK@wy`aDG}zd16s2 kLwR|*US?i)adKios$PCk`s{Z$Qb0uvp00i_>zopr05A!nK>z>% literal 0 HcmV?d00001 diff --git a/openplotterMaiana/openplotterMaiana.py b/openplotterMaiana/openplotterMaiana.py index 9d059f7..b7bbe7c 100644 --- a/openplotterMaiana/openplotterMaiana.py +++ b/openplotterMaiana/openplotterMaiana.py @@ -15,9 +15,6 @@ # You should have received a copy of the GNU General Public License # along with Openplotter. If not, see . -#TODO add tx action -#TODO parse bin file - import wx, os, webbrowser, subprocess, time, datetime, ujson, serial, requests, re, sys import wx.richtext as rt from openplotterSettings import conf @@ -287,13 +284,18 @@ class MyFrame(wx.Frame): self.logger.BeginFontSize(10) self.logger.WriteText(_('Hardware revision')) - if 'hardwareRevision' in data: self.logger.WriteText(': '+data['hardwareRevision']['value']) + if 'hardwareRevision' in data: + self.logger.WriteText(': '+data['hardwareRevision']['value']) + self.hardwareRevision = data['hardwareRevision']['value'] self.logger.Newline() self.logger.WriteText(_('Firmware revision')) - if 'firmwareRevision' in data: self.logger.WriteText(': '+data['firmwareRevision']['value']) + if 'firmwareRevision' in data: + self.logger.WriteText(': '+data['firmwareRevision']['value']) self.logger.Newline() self.logger.WriteText(_('Type of MCU')) - if 'MCUtype' in data: self.logger.WriteText(': '+data['MCUtype']['value']) + if 'MCUtype' in data: + self.logger.WriteText(': '+data['MCUtype']['value']) + self.MCUtype = data['MCUtype']['value'] self.logger.Newline() self.logger.WriteText(_('Serial number')) if 'serialNumber' in data: self.logger.WriteText(': '+data['serialNumber']['value']) @@ -585,6 +587,10 @@ class MyFrame(wx.Frame): toolRefresh = self.toolbar2.AddTool(201, _('Refresh'), wx.Bitmap(self.currentdir+"/data/refresh.png")) self.Bind(wx.EVT_TOOL, self.OnToolRefresh, toolRefresh) self.toolbar2.AddSeparator() + + toolDownload= self.toolbar2.AddTool(203, _('Download firmware'), wx.Bitmap(self.currentdir+"/data/download.png")) + self.Bind(wx.EVT_TOOL, self.OnToolDownload, toolDownload) + toolFile= self.toolbar2.AddTool(202, _('Update firmware'), wx.Bitmap(self.currentdir+"/data/file.png")) self.Bind(wx.EVT_TOOL, self.OnToolFile, toolFile) self.logger = rt.RichTextCtrl(self.firmware, style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_DONTWRAP|wx.LC_SORT_ASCENDING) @@ -596,6 +602,10 @@ class MyFrame(wx.Frame): self.firmware.SetSizer(vbox) + def OnToolDownload(self,e): + url = "https://github.com/peterantypas/maiana/tree/master/latest/Firmware/Transponder/Binaries" + webbrowser.open(url, new=2) + def OnToolFile(self,e): file_path = False dlg = wx.FileDialog(self, message=_('Choose a file'), defaultDir='~', defaultFile='', wildcard=_('bin files') + ' (*.bin)|*.bin|' + _('All files') + ' (*.*)|*.*', style=wx.FD_OPEN | wx.FD_CHANGE_DIR) @@ -603,6 +613,25 @@ class MyFrame(wx.Frame): file_path = dlg.GetPath() dlg.Destroy() if file_path: + try: + fileName = file_path.split('/') + fileName = fileName[-1] + fileName = fileName.split('-') + MCUtype = fileName[1].upper() + if MCUtype != self.MCUtype: + self.ShowStatusBarRED(_('MCU type mismatch: ')+MCUtype) + return + hardwareRevision = fileName[2].replace('hw','') + hardwareRevision2 = self.hardwareRevision.split('.') + del hardwareRevision2[-1] + hardwareRevision2 = '.'.join(hardwareRevision2) + if hardwareRevision != hardwareRevision2: + self.ShowStatusBarRED(_('Hardware revision mismatch: ')+hardwareRevision) + return + except Exception as e: + self.ShowStatusBarRED(_('Error processing file: ')+str(e)) + return + self.SetStatusText('') dlg = wx.MessageDialog(None, _( 'Your MAIANA device firmware will be updated, please do not disconnect or tamper with it during the update.\n\nDo you want to go ahead?'), _('Question'), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)