mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 19:59:12 +08:00
Merge pull request #922 from thopiekar/master-CURA-2079
CURA-2079: Finish firmware upload process on errors
This commit is contained in:
commit
db4a198a1c
@ -182,6 +182,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()
|
||||||
return
|
return
|
||||||
|
|
||||||
programmer = stk500v2.Stk500v2()
|
programmer = stk500v2.Stk500v2()
|
||||||
@ -197,7 +198,8 @@ 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")
|
||||||
return
|
self._updateFirmware_completed()
|
||||||
|
return
|
||||||
|
|
||||||
self._updating_firmware = True
|
self._updating_firmware = True
|
||||||
|
|
||||||
@ -206,15 +208,21 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
self._updating_firmware = False
|
self._updating_firmware = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Logger.log("e", "Exception while trying to update firmware %s" %e)
|
Logger.log("e", "Exception while trying to update firmware %s" %e)
|
||||||
self._updating_firmware = False
|
self._updateFirmware_completed()
|
||||||
return
|
return
|
||||||
programmer.close()
|
programmer.close()
|
||||||
|
|
||||||
|
self._updateFirmware_completed()
|
||||||
|
return
|
||||||
|
|
||||||
|
## Private function which makes sure that firmware update process has completed/ended
|
||||||
|
def _updateFirmware_completed(self):
|
||||||
self.setProgress(100, 100)
|
self.setProgress(100, 100)
|
||||||
self._firmware_update_finished = True
|
self._firmware_update_finished = True
|
||||||
|
self.resetFirmwareUpdate(update_has_finished=True)
|
||||||
self.firmwareUpdateComplete.emit()
|
self.firmwareUpdateComplete.emit()
|
||||||
self.firmwareUpdateChange.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
|
||||||
@ -227,8 +235,8 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
|
|||||||
def firmwareUpdateFinished(self):
|
def firmwareUpdateFinished(self):
|
||||||
return self._firmware_update_finished
|
return self._firmware_update_finished
|
||||||
|
|
||||||
def resetFirmwareUpdateFinished(self):
|
def resetFirmwareUpdate(self, update_has_finished = False):
|
||||||
self._firmware_update_finished = False
|
self._firmware_update_finished = update_has_finished
|
||||||
self.firmwareUpdateChange.emit()
|
self.firmwareUpdateChange.emit()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
@ -103,7 +103,7 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
|
|||||||
return
|
return
|
||||||
|
|
||||||
for printer_connection in self._usb_output_devices:
|
for printer_connection in self._usb_output_devices:
|
||||||
self._usb_output_devices[printer_connection].resetFirmwareUpdateFinished()
|
self._usb_output_devices[printer_connection].resetFirmwareUpdate()
|
||||||
self.spawnFirmwareInterface("")
|
self.spawnFirmwareInterface("")
|
||||||
for printer_connection in self._usb_output_devices:
|
for printer_connection in self._usb_output_devices:
|
||||||
try:
|
try:
|
||||||
@ -111,7 +111,7 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
|
|||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
# Should only happen in dev environments where the resources/firmware folder is absent.
|
# Should only happen in dev environments where the resources/firmware folder is absent.
|
||||||
self._usb_output_devices[printer_connection].setProgress(100, 100)
|
self._usb_output_devices[printer_connection].setProgress(100, 100)
|
||||||
Logger.log("w", "No firmware found for printer %s", printer_connection)
|
Logger.log("w", "No firmware found for printer %s called '%s'" %(printer_connection, self._getDefaultFirmwareName()))
|
||||||
Message(i18n_catalog.i18nc("@info",
|
Message(i18n_catalog.i18nc("@info",
|
||||||
"Could not find firmware required for the printer at %s.") % printer_connection).show()
|
"Could not find firmware required for the printer at %s.") % printer_connection).show()
|
||||||
self._firmware_view.close()
|
self._firmware_view.close()
|
||||||
@ -126,7 +126,7 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
|
|||||||
self._usb_output_devices[serial_port].updateFirmware(Resources.getPath(CuraApplication.ResourceTypes.Firmware, self._getDefaultFirmwareName()))
|
self._usb_output_devices[serial_port].updateFirmware(Resources.getPath(CuraApplication.ResourceTypes.Firmware, self._getDefaultFirmwareName()))
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self._firmware_view.close()
|
self._firmware_view.close()
|
||||||
Logger.log("e", "Could not find firmware required for this machine")
|
Logger.log("e", "Could not find firmware required for this machine called '%s'" %(self._getDefaultFirmwareName()))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user