--- a/LPCManager.py Fri Jun 19 20:18:11 2015 +0200
+++ b/LPCManager.py Thu Jul 30 15:04:59 2015 +0200
@@ -104,14 +104,14 @@
from controls import TextCtrlAutoComplete
-from canfestival import RootClass as CanOpenRootClass
-from canfestival.canfestival import _SlaveCTN, _NodeListCTN, NodeManager
-from canfestival.NetworkEditor import NetworkEditor
-from canfestival.SlaveEditor import SlaveEditor
-# havecanfestival = False
+ from canfestival import RootClass as CanOpenRootClass + from canfestival.canfestival import _SlaveCTN, _NodeListCTN, NodeManager + from canfestival.NetworkEditor import NetworkEditor + from canfestival.SlaveEditor import SlaveEditor + havecanfestival = False WINDOW_COLOUR = wx.Colour(240,240,240)
@@ -360,6 +360,11 @@
"tooltip" : _("Disconnect from PLC"),
"method" : "_Disconnect"},
+ {"bitmap" : "UpdateFw", + "name" : _("UpdateFw"), + "tooltip" : _("Update the PLC firmware"), + "method" : "_UpdateFw"}, _MethodFromPLCState["Disconnected"] += [("_Connect", True),
@@ -394,6 +399,9 @@
self.SimulationBuildPath = None
self.AbortTransferTimer = None
+ # Firmware update running status + self.firmawreUpadateIsRunning = False def GetProjectInfos(self):
infos = PLCControler.GetProjectInfos(self)
@@ -974,6 +982,132 @@
self.logger.write_error(_("Couldn't start PLC !\n"))
self.UpdateMethodsFromPLCStatus()
+ Method called by user to flash the firmware of the PLC + from dialogs import FirmwareUpdateDialog + from dialogs import DiscoveryDialog + from HostFirmwareUpdater import HostFirmwareUpdater + if self.firmawreUpadateIsRunning == True: + self.logger.write_error(_("Firmware update is already running!\n")) + self.firmawreUpadateIsRunning = True + self.logger.write(_("Firmware update started\n")) + # Launch the firmware selection dialog + dialog = FirmwareUpdateDialog(self.AppFrame) + answer = dialog.ShowModal() + imageFilePath = dialog.GetFirmwareImageFile() + updateType = dialog.GetFirmwareUpdateType() + chunksSize = dialog.GetChunksSize() + reboot = dialog.GetReboot() + if answer == wx.ID_CANCEL: + self.logger.write_error(_("Firmware update canceled!\n")) + self.firmawreUpadateIsRunning = False + if imageFilePath == None or imageFilePath == "": + self.logger.write_error(_("No firmware image file selected!\n")) + self.logger.write_error(_("Firmware update canceled!\n")) + self.firmawreUpadateIsRunning = False + self.logger.write(_("Firmware image file: %s\n")%imageFilePath) + self.logger.write(_("Firmware update type: Linux kernel image\n")) + self.logger.write(_("Firmware update type: Linux DTB image\n")) + self.logger.write(_("Firmware update type: Root file system image\n")) + self.logger.write_error(_("Unknown firmware update type!\n")) + self.logger.write_error(_("Firmware update canceled!\n")) + self.firmawreUpadateIsRunning = False + if chunksSize < 1024 or chunksSize > 1024*1024: + self.logger.write_error(_("Bad chunks size : %d KiB!\n")%chunksSize) + self.logger.write_error(_("Firmware update canceled!\n")) + self.firmawreUpadateIsRunning = False + self.logger.write(_("Chunks size : %d KiB\n")%chunksSize) + self.logger.write(_("Reboot after update : %s\n")%("Yes" if reboot else "No")) + # Get the target PLC URI + # Check if an uri is already configured in the Beremiz project + uri = self.BeremizRoot.getURI_location() + if uri is not None and uri != "": + self.logger.write(_("PLC URI configured in the Beremiz project will be used: %s\n")%uri) + # PLC URI is not configured in the Beremiz project + # Launch Service Discovery dialog + self.logger.write(_("PLC URI is not configured in the Beremiz project. Launching the Discover dialog\n")) + dialog = DiscoveryDialog(self.AppFrame) + answer = dialog.ShowModal() + # Nothing choosed or cancel button + if uri is None or answer == wx.ID_CANCEL: + self.logger.write_error(_("Connection canceled!\n")) + self.logger.write_error(_("Firmware update canceled!\n")) + self.firmawreUpadateIsRunning = False + # Get connector from uri + self._SetConnector(connectors.ConnectorFactory(uri, self)) + self.logger.write_error(_("Exception while connecting %s!\n")%uri) + self.logger.write_error(traceback.format_exc()) + self.logger.write_error(_("Firmware update canceled!\n")) + self.firmawreUpadateIsRunning = False + # Did connection success ? + if self._connector is None: + self.logger.write_error(_("Connection failed to %s!\n")%uri) + self.logger.write_error(_("Firmware update canceled!\n")) + self.firmawreUpadateIsRunning = False + self.logger.write(_("Connected.\n")) + # Last confirmation before firmware update + answer = wx.MessageBox(_('Are you sure to launch the firmware update for the selected PLC?'), + _('Firmware Update'), wx.YES_NO | wx.CENTRE |wx.NO_DEFAULT, + self.logger.write_error(_("Firmware update canceled!\n")) + self.firmawreUpadateIsRunning = False + self.AppFrame.Refresh() + # Lauch the firmaware update on the remote PLC + updater = HostFirmwareUpdater(self._connector, imageFilePath, updateType, chunksSize, reboot, self.logger) + self.logger.write_error(str(e) + "\n") + self.logger.write_error(_("Firmware update canceled!\n")) + self.firmawreUpadateIsRunning = False + self.firmawreUpadateIsRunning = False #-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------