From 1fc5128e4ca5a98c04fe2b8be2dd2739c5938aa5 Mon Sep 17 00:00:00 2001 From: Peter Antypas Date: Sun, 13 Feb 2022 21:24:03 -0800 Subject: [PATCH] GUI client validating HW revision --- latest/Apps/maiana-update/maiana-update.fbp | 250 +++++++++++++++++++- latest/Apps/maiana-update/maianaclient.py | 6 +- latest/Apps/maiana-update/mainframe.py | 26 +- latest/Apps/maiana-update/mainwindow.py | 35 ++- 4 files changed, 308 insertions(+), 9 deletions(-) diff --git a/latest/Apps/maiana-update/maiana-update.fbp b/latest/Apps/maiana-update/maiana-update.fbp index d9fa3f4..a5f65b0 100644 --- a/latest/Apps/maiana-update/maiana-update.fbp +++ b/latest/Apps/maiana-update/maiana-update.fbp @@ -50,7 +50,7 @@ 605,300 wxCAPTION|wxCLOSE_BOX|wxMINIMIZE_BOX ; ; forward_declare - MAIANA Transponder Manager ver 0.1 + MAIANA Transponder Manager ver 0.2 0 @@ -180,7 +180,7 @@ gSizer1 none - 5 + 6 0 5 @@ -395,7 +395,7 @@ 5 - wxALL|wxALIGN_CENTER_VERTICAL + wxALIGN_CENTER_VERTICAL|wxALL 0 1 @@ -759,6 +759,250 @@ -1 + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Breakout Board Generation + 0 + + 0 + + + 0 + + 1 + m_staticText21 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + (unknown) + 0 + + 0 + + + 0 + + 1 + m_breakoutLbl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Bootloader Present + 0 + + 0 + + + 0 + + 1 + m_staticText23 + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + (unknown) + 0 + + 0 + + + 0 + + 1 + m_bootloaderLbl + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + diff --git a/latest/Apps/maiana-update/maianaclient.py b/latest/Apps/maiana-update/maianaclient.py index 208b3fe..8b58390 100644 --- a/latest/Apps/maiana-update/maianaclient.py +++ b/latest/Apps/maiana-update/maianaclient.py @@ -84,7 +84,11 @@ class MaianaClient: return {} systokens = re.split(',|\\*', sysline.decode('utf-8')) - sysd = {'fw': systokens[2], 'hw': systokens[1], 'cpu': systokens[4]} + sysd = {'fw': systokens[2], + 'hw': systokens[1], + 'cpu': systokens[4], + 'newbrkout': int(systokens[5]), + 'bootloader': int(systokens[6])} return sysd except: pass diff --git a/latest/Apps/maiana-update/mainframe.py b/latest/Apps/maiana-update/mainframe.py index 37f2f7c..983c203 100644 --- a/latest/Apps/maiana-update/mainframe.py +++ b/latest/Apps/maiana-update/mainframe.py @@ -17,7 +17,7 @@ import wx.xrc class MainFrame ( wx.Frame ): def __init__( self, parent ): - wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"MAIANA Transponder Manager ver 0.1", pos = wx.DefaultPosition, size = wx.Size( 605,300 ), style = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.TAB_TRAVERSAL ) + wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"MAIANA Transponder Manager ver 0.2", pos = wx.DefaultPosition, size = wx.Size( 605,300 ), style = wx.CAPTION|wx.CLOSE_BOX|wx.MINIMIZE_BOX|wx.TAB_TRAVERSAL ) self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) @@ -25,7 +25,7 @@ class MainFrame ( wx.Frame ): self.m_notebook2 = wx.Notebook( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_StatusPnl = wx.Panel( self.m_notebook2, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) - gSizer1 = wx.GridSizer( 5, 2, 0, 0 ) + gSizer1 = wx.GridSizer( 6, 2, 0, 0 ) self.m_staticText1 = wx.StaticText( self.m_StatusPnl, wx.ID_ANY, u"Serial Port", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText1.Wrap( -1 ) @@ -52,7 +52,7 @@ class MainFrame ( wx.Frame ): self.m_staticText7 = wx.StaticText( self.m_StatusPnl, wx.ID_ANY, u"CPU", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText7.Wrap( -1 ) - gSizer1.Add( self.m_staticText7, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + gSizer1.Add( self.m_staticText7, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 ) self.m_CPULbl = wx.StaticText( self.m_StatusPnl, wx.ID_ANY, u"(unknown)", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_CPULbl.Wrap( -1 ) @@ -85,6 +85,26 @@ class MainFrame ( wx.Frame ): gSizer1.Add( self.m_FWRevLbl, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) + self.m_staticText21 = wx.StaticText( self.m_StatusPnl, wx.ID_ANY, u"Breakout Board Generation", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText21.Wrap( -1 ) + + gSizer1.Add( self.m_staticText21, 0, wx.ALL, 5 ) + + self.m_breakoutLbl = wx.StaticText( self.m_StatusPnl, wx.ID_ANY, u"(unknown)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_breakoutLbl.Wrap( -1 ) + + gSizer1.Add( self.m_breakoutLbl, 0, wx.ALL, 5 ) + + self.m_staticText23 = wx.StaticText( self.m_StatusPnl, wx.ID_ANY, u"Bootloader Present", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_staticText23.Wrap( -1 ) + + gSizer1.Add( self.m_staticText23, 0, wx.ALL, 5 ) + + self.m_bootloaderLbl = wx.StaticText( self.m_StatusPnl, wx.ID_ANY, u"(unknown)", wx.DefaultPosition, wx.DefaultSize, 0 ) + self.m_bootloaderLbl.Wrap( -1 ) + + gSizer1.Add( self.m_bootloaderLbl, 0, wx.ALL, 5 ) + self.m_StatusPnl.SetSizer( gSizer1 ) self.m_StatusPnl.Layout() diff --git a/latest/Apps/maiana-update/mainwindow.py b/latest/Apps/maiana-update/mainwindow.py index 77a6d9d..836ecb4 100644 --- a/latest/Apps/maiana-update/mainwindow.py +++ b/latest/Apps/maiana-update/mainwindow.py @@ -4,6 +4,8 @@ import serial import wx from fwUpdateThread import * +MIN_HW_REV = [b'11', b'0', b'0'] + class MainWindow(MainFrame): def __init__(self): MainFrame.__init__(self, None) @@ -37,8 +39,8 @@ class MainWindow(MainFrame): else: #Assuming status is RUNNING self.m_SerialBtn.SetLabel(b'Disconnect') - self.enableUI() if self.refreshSys(): + self.enableUI() self.refreshStation() self.m_StationSaveBtn.Disable() else: @@ -94,7 +96,8 @@ class MainWindow(MainFrame): def enableUI(self): self.m_StationPnl.Enable() - self.m_FWUpdatePnl.Enable() + if self.sysdata['bootloader']: + self.m_FWUpdatePnl.Enable() def disableUI(self): self.m_StationPnl.Disable() @@ -108,15 +111,43 @@ class MainWindow(MainFrame): self.stationdata = MaianaClient.loadStation(self.port) return self.renderStation() + def validateRev(self, rev): + tokens = rev.split('.') + if len(tokens) < 3: + return False + + for i in range(3): + if int(tokens[i]) < int(MIN_HW_REV[i]): + return False + + return True + + + def renderSys(self): if not 'hw' in self.sysdata: wx.MessageDialog(self, b'There was no response from MAIANA. Please check connections and try again.', 'Timeout', wx.OK | wx.STAY_ON_TOP|wx.CENTRE).ShowModal() return False + if not self.validateRev(self.sysdata['hw']): + wx.MessageDialog(self, b'This version of MAIANA is too old for this software to manage.', + 'Unrecognized', wx.OK | wx.STAY_ON_TOP|wx.CENTRE).ShowModal() + return False + self.m_HWRevLbl.SetLabel(self.sysdata['hw']) self.m_FWRevLbl.SetLabel(self.sysdata['fw']) self.m_CPULbl.SetLabel(self.sysdata['cpu']) + if self.sysdata['newbrkout']: + self.m_breakoutLbl.SetLabel(b'New') + else: + self.m_breakoutLbl.SetLabel(b'Legacy') + + if self.sysdata['bootloader']: + self.m_bootloaderLbl.SetLabel('Yes') + else: + self.m_bootloaderLbl.SetLabel('No') + return True def renderStation(self):