mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
CURA-2079: Rework on adding detailed error messages to firmware updater
This commit is contained in:
parent
e72a10c97a
commit
c174ce4396
3 changed files with 67 additions and 66 deletions
|
@ -35,47 +35,45 @@ UM.Dialog
|
||||||
if (manager.errorCode == 0)
|
if (manager.errorCode == 0)
|
||||||
{
|
{
|
||||||
if (manager.firmwareUpdateCompleteStatus)
|
if (manager.firmwareUpdateCompleteStatus)
|
||||||
{
|
{
|
||||||
//: Firmware update status label
|
//: Firmware update status label
|
||||||
return catalog.i18nc("@label","Firmware update completed.")
|
return catalog.i18nc("@label","Firmware update completed.")
|
||||||
}
|
|
||||||
if (manager.progress == 0)
|
|
||||||
{
|
|
||||||
//: Firmware update status label
|
|
||||||
return catalog.i18nc("@label","Starting firmware update, this may take a while.")
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//: Firmware update status label
|
|
||||||
return catalog.i18nc("@label","Updating firmware.")
|
|
||||||
}
|
}
|
||||||
}
|
else if (manager.progress == 0)
|
||||||
|
{
|
||||||
|
//: Firmware update status label
|
||||||
|
return catalog.i18nc("@label","Starting firmware update, this may take a while.")
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//: Firmware update status label
|
||||||
|
return catalog.i18nc("@label","Updating firmware.")
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (manager.errorCode == 1)
|
switch (manager.errorCode)
|
||||||
{
|
{
|
||||||
//: Firmware update status label
|
case 1:
|
||||||
return catalog.i18nc("@label","Firmware update failed due to an unknown error.")
|
//: Firmware update status label
|
||||||
}
|
return catalog.i18nc("@label","Firmware update failed due to an unknown error.")
|
||||||
else if (manager.errorCode == 2)
|
|
||||||
{
|
case 2:
|
||||||
//: Firmware update status label
|
//: Firmware update status label
|
||||||
return catalog.i18nc("@label","Firmware update failed due to an communication error.")
|
return catalog.i18nc("@label","Firmware update failed due to an communication error.")
|
||||||
}
|
|
||||||
else if (manager.errorCode == 3)
|
|
||||||
{
|
case 3:
|
||||||
//: Firmware update status label
|
//: Firmware update status label
|
||||||
return catalog.i18nc("@label","Firmware update failed due to an input/output error.")
|
return catalog.i18nc("@label","Firmware update failed due to an input/output error.")
|
||||||
}
|
|
||||||
else if (manager.errorCode == 4)
|
case 4:
|
||||||
{
|
//: Firmware update status label
|
||||||
//: Firmware update status label
|
return catalog.i18nc("@label","Firmware update failed due to missing firmware.")
|
||||||
return catalog.i18nc("@label","Firmware update failed due to missing firmware.")
|
|
||||||
}
|
default:
|
||||||
else
|
//: Firmware update status label
|
||||||
{
|
return catalog.i18nc("@label", "Unknown error code: %1").arg(manager.errorCode)
|
||||||
//: Firmware update status label
|
|
||||||
return catalog.i18nc("@label", "Unknown error code: %1").arg(manager.errorCode)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,8 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
self._firmware_update_finished = False
|
self._firmware_update_finished = False
|
||||||
|
|
||||||
self._error_message = None
|
self._error_message = None
|
||||||
|
|
||||||
|
self._error_code = 0
|
||||||
|
|
||||||
onError = pyqtSignal()
|
onError = pyqtSignal()
|
||||||
|
|
||||||
|
@ -173,7 +175,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
|
|
||||||
## Private function (threaded) that actually uploads the firmware.
|
## Private function (threaded) that actually uploads the firmware.
|
||||||
def _updateFirmware(self):
|
def _updateFirmware(self):
|
||||||
self._errorCode = 0
|
self._error_code = 0
|
||||||
self.setProgress(0, 100)
|
self.setProgress(0, 100)
|
||||||
self._firmware_update_finished = False
|
self._firmware_update_finished = False
|
||||||
|
|
||||||
|
@ -183,7 +185,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
|
|
||||||
if len(hex_file) == 0:
|
if len(hex_file) == 0:
|
||||||
Logger.log("e", "Unable to read provided hex file. Could not update firmware")
|
Logger.log("e", "Unable to read provided hex file. Could not update firmware")
|
||||||
self._updateFirmware_completed_missing_firmware()
|
self._updateFirmwareFailedMissingFirmware()
|
||||||
return
|
return
|
||||||
|
|
||||||
programmer = stk500v2.Stk500v2()
|
programmer = stk500v2.Stk500v2()
|
||||||
|
@ -199,7 +201,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
|
|
||||||
if not programmer.isConnected():
|
if not programmer.isConnected():
|
||||||
Logger.log("e", "Unable to connect with serial. Could not update firmware")
|
Logger.log("e", "Unable to connect with serial. Could not update firmware")
|
||||||
self._updateFirmware_failed_communication_error()
|
self._updateFirmwareFailedCommunicationError()
|
||||||
return
|
return
|
||||||
|
|
||||||
self._updating_firmware = True
|
self._updating_firmware = True
|
||||||
|
@ -209,48 +211,39 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
self._updating_firmware = False
|
self._updating_firmware = False
|
||||||
except serial.SerialException as e:
|
except serial.SerialException as e:
|
||||||
Logger.log("e", "SerialException while trying to update firmware: <%s>" %(repr(e)))
|
Logger.log("e", "SerialException while trying to update firmware: <%s>" %(repr(e)))
|
||||||
self._updateFirmware_failed_io_error()
|
self._updateFirmwareFailedIOError()
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Logger.log("e", "Exception while trying to update firmware: <%s>" %(repr(e)))
|
Logger.log("e", "Exception while trying to update firmware: <%s>" %(repr(e)))
|
||||||
self._updateFirmware_failed_unknown()
|
self._updateFirmwareFailedUnknown()
|
||||||
return
|
return
|
||||||
programmer.close()
|
programmer.close()
|
||||||
|
|
||||||
self._updateFirmware_completed_sucessfully()
|
self._updateFirmwareCompletedSucessfully()
|
||||||
return
|
return
|
||||||
|
|
||||||
## Private function which makes sure that firmware update process has failed by missing firmware
|
## Private function which makes sure that firmware update process has failed by missing firmware
|
||||||
def _updateFirmware_failed_missing_firmware(self):
|
def _updateFirmwareFailedMissingFirmware(self):
|
||||||
return self._updateFirmware_failed_common(4)
|
return self._updateFirmwareFailedCommon(4)
|
||||||
|
|
||||||
## Private function which makes sure that firmware update process has failed by an IO error
|
## Private function which makes sure that firmware update process has failed by an IO error
|
||||||
def _updateFirmware_failed_io_error(self):
|
def _updateFirmwareFailedIOError(self):
|
||||||
return self._updateFirmware_failed_common(3)
|
return self._updateFirmwareFailedCommon(3)
|
||||||
|
|
||||||
## Private function which makes sure that firmware update process has failed by a communication problem
|
## Private function which makes sure that firmware update process has failed by a communication problem
|
||||||
def _updateFirmware_failed_communication_error(self):
|
def _updateFirmwareFailedCommunicationError(self):
|
||||||
return self._updateFirmware_failed_common(2)
|
return self._updateFirmwareFailedCommon(2)
|
||||||
|
|
||||||
## Private function which makes sure that firmware update process has failed by an unknown error
|
## Private function which makes sure that firmware update process has failed by an unknown error
|
||||||
def _updateFirmware_failed_unknown(self):
|
def _updateFirmwareFailedUnknown(self):
|
||||||
return self._updateFirmware_failed_common(1)
|
return self._updateFirmwareFailedCommon(1)
|
||||||
|
|
||||||
## Private function which makes sure that firmware update process has successfully completed
|
|
||||||
def _updateFirmware_completed_sucessfully(self):
|
|
||||||
self.setProgress(100, 100)
|
|
||||||
self._firmware_update_finished = True
|
|
||||||
self.resetFirmwareUpdate(update_has_finished = True)
|
|
||||||
self.firmwareUpdateComplete.emit()
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
## Private common function which makes sure that firmware update process has completed/ended with a set progress state
|
## Private common function which makes sure that firmware update process has completed/ended with a set progress state
|
||||||
def _updateFirmware_failed_common(self, code):
|
def _updateFirmwareFailedCommon(self, code):
|
||||||
if not code:
|
if not code:
|
||||||
raise Exception("Error code not set!")
|
raise Exception("Error code not set!")
|
||||||
|
|
||||||
self._errorCode = code
|
self._error_code = code
|
||||||
|
|
||||||
self._firmware_update_finished = True
|
self._firmware_update_finished = True
|
||||||
self.resetFirmwareUpdate(update_has_finished = True)
|
self.resetFirmwareUpdate(update_has_finished = True)
|
||||||
|
@ -259,6 +252,15 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
## Private function which makes sure that firmware update process has successfully completed
|
||||||
|
def _updateFirmwareCompletedSucessfully(self):
|
||||||
|
self.setProgress(100, 100)
|
||||||
|
self._firmware_update_finished = True
|
||||||
|
self.resetFirmwareUpdate(update_has_finished = True)
|
||||||
|
self.firmwareUpdateComplete.emit()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
## Upload new firmware to machine
|
## Upload new firmware to machine
|
||||||
# \param filename full path of firmware file to be uploaded
|
# \param filename full path of firmware file to be uploaded
|
||||||
def updateFirmware(self, file_name):
|
def updateFirmware(self, file_name):
|
||||||
|
|
|
@ -38,8 +38,6 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
|
||||||
self._update_thread = threading.Thread(target = self._updateThread)
|
self._update_thread = threading.Thread(target = self._updateThread)
|
||||||
self._update_thread.setDaemon(True)
|
self._update_thread.setDaemon(True)
|
||||||
|
|
||||||
self._errorCode = 0
|
|
||||||
|
|
||||||
self._check_updates = True
|
self._check_updates = True
|
||||||
self._firmware_view = None
|
self._firmware_view = None
|
||||||
|
|
||||||
|
@ -61,7 +59,10 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
|
||||||
|
|
||||||
@pyqtProperty(int, notify = progressChanged)
|
@pyqtProperty(int, notify = progressChanged)
|
||||||
def errorCode(self):
|
def errorCode(self):
|
||||||
return self._errorCode
|
for printer_name, device in self._usb_output_devices.items(): # TODO: @UnusedVariable "printer_name"
|
||||||
|
if device._error_code:
|
||||||
|
return device._error_code
|
||||||
|
return 0
|
||||||
|
|
||||||
## Return True if all printers finished firmware update
|
## Return True if all printers finished firmware update
|
||||||
@pyqtProperty(float, notify = firmwareUpdateChange)
|
@pyqtProperty(float, notify = firmwareUpdateChange)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue