lpcmanager

Parents 7c1c9a104bb3
Children 1d5087e72ac0
Add FW update methods using ExtendedCall and fix py3 and wxPython4 problems for FW update code
--- a/HostFirmwareUpdater.py Mon Nov 11 16:03:30 2024 +0100
+++ b/HostFirmwareUpdater.py Wed Nov 20 12:04:45 2024 +0100
@@ -87,7 +87,8 @@
def _CreateFirmwareImageFileSizeMD5File(self):
# Note Pyro exceptions are already caught by catcher_func and PyroCatcher in PyroProxyProxy
- self.firmwareImageFileMD5Size = hashlib.md5("%s\n"%self.firmwareImageFileSize).hexdigest()
+ self.firmwareImageFileMD5Size = hashlib.md5(
+ ("%s\n"%self.firmwareImageFileSize).encode()).hexdigest()
self.controller.logger.write(_("Firmware image size md5: %s\n")%(self.firmwareImageFileMD5Size))
status, textError = self.controller._connector.CreateFirmwareImageFileSizeMD5File(self.firmwareImageFileMD5Size)
if not status :
@@ -120,7 +121,7 @@
# User feedback as percentage
keepGoing, _skip = self.dialog.Update(
- transferedBytes * 100 / self.firmwareImageFileSize)
+ int(transferedBytes * 100 / self.firmwareImageFileSize))
if not keepGoing:
status = False
@@ -128,7 +129,8 @@
raise Exception(textError)
chunkData = self.imageData[transferedBytes:transferedBytes + chunksSize]
- status, textError = self.controller._connector.RunFeedPipe(chunkData, isLastChunk, chunksSize)
+ transferedData = bytes([isLastChunk])+chunkData
+ status, textError = self.controller._connector.RunFeedPipe(transferedData)
if not status :
break
transferedBytes = transferedBytes + chunksSize
--- a/LPCExtension.py Mon Nov 11 16:03:30 2024 +0100
+++ b/LPCExtension.py Wed Nov 20 12:04:45 2024 +0100
@@ -81,9 +81,34 @@
raise Exception("Invalid input for " + ExtendedCallName)
return JsonMethodProxy
-LPCManagerExtendedCalls = ["CheckProductID", "GetVersions"]
-for ExtendedCall in LPCManagerExtendedCalls:
- setattr(BeremizPLCObjectServiceClient, ExtendedCall, JsonMethodProxyFactory(ExtendedCall))
+def JsonOutputMethodProxyFactory(ExtendedCallName):
+ def JsonMethodProxy(self, inputbin):
+ outputbin = self.ExtendedCall(ExtendedCallName, inputbin)
+ jsonoutput = json.loads(outputbin)
+ if type(jsonoutput) == list and len(jsonoutput) == 2:
+ result, error = jsonoutput
+ if type(error) == str:
+ raise UserAddressedException(error)
+ else:
+ return result
+ raise Exception("Invalid input for " + ExtendedCallName)
+ return JsonMethodProxy
+
+LPCManagerExtendedCalls = [
+ "CheckProductID",
+ "GetFWVersions",
+ "RunUpdateScript",
+ "CreateFirmwareImageFileSizeFile",
+ "CreateFirmwareImageFileSizeMD5File",
+ "CreateFirmwareImageFileMD5File",
+ "RebootTarget"
+]
+
+for ExtendedCallName in LPCManagerExtendedCalls:
+ setattr(BeremizPLCObjectServiceClient, ExtendedCallName, JsonMethodProxyFactory(ExtendedCallName))
+
+# RunFeedPipe uses no JSON encoding for performance
+setattr(BeremizPLCObjectServiceClient, "RunFeedPipe", JsonOutputMethodProxyFactory("RunFeedPipe"))
# TODO
# from LPCconnector import LPC_connector_factory
--- a/LPCProjectController.py Mon Nov 11 16:03:30 2024 +0100
+++ b/LPCProjectController.py Wed Nov 20 12:04:45 2024 +0100
@@ -199,7 +199,7 @@
self.firmwareUpadateIsRunning = True
self.logger.write(_("Firmware update started\n"))
- version_string = self._connector.GetVersions()
+ version_string = self._connector.GetFWVersions()
# Launch the firmware selection dialog
dialog = FirmwareUpdateDialog(self.AppFrame, version_string)