From 339987be9d3a7cf80d7932c49cd418009e9182df Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 2 Aug 2018 11:50:28 +0200 Subject: [PATCH] Move hardcoded firmware-file table to definitions --- .../USBPrinterOutputDeviceManager.py | 44 ++++--------------- resources/definitions/bq_hephestos.def.json | 3 +- resources/definitions/bq_witbox.def.json | 3 +- resources/definitions/ultimaker2.def.json | 3 +- .../definitions/ultimaker2_extended.def.json | 3 +- .../ultimaker2_extended_plus.def.json | 3 +- resources/definitions/ultimaker2_go.def.json | 3 +- .../definitions/ultimaker2_plus.def.json | 3 +- .../definitions/ultimaker_original.def.json | 4 +- .../ultimaker_original_dual.def.json | 2 + .../ultimaker_original_plus.def.json | 3 +- 11 files changed, 30 insertions(+), 44 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py index 2ee85187ee..f444e72908 100644 --- a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py +++ b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py @@ -93,57 +93,31 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin): global_container_stack = self._application.getGlobalContainerStack() if not global_container_stack: Logger.log("e", "There is no global container stack. Can not update firmware.") - self._firmware_view.close() return "" # The bottom of the containerstack is the machine definition machine_id = global_container_stack.getBottom().id - machine_has_heated_bed = global_container_stack.getProperty("machine_heated_bed", "value") + baudrate = 250000 if platform.system() == "Linux": + # Linux prefers a baudrate of 115200 here because older versions of + # pySerial did not support a baudrate of 250000 baudrate = 115200 - else: - baudrate = 250000 - # NOTE: The keyword used here is the id of the machine. You can find the id of your machine in the *.json file, eg. - # https://github.com/Ultimaker/Cura/blob/master/resources/machines/ultimaker_original.json#L2 - # The *.hex files are stored at a seperate repository: - # https://github.com/Ultimaker/cura-binary-data/tree/master/cura/resources/firmware - machine_without_extras = {"bq_witbox" : "MarlinWitbox.hex", - "bq_hephestos_2" : "MarlinHephestos2.hex", - "ultimaker_original" : "MarlinUltimaker-{baudrate}.hex", - "ultimaker_original_plus" : "MarlinUltimaker-UMOP-{baudrate}.hex", - "ultimaker_original_dual" : "MarlinUltimaker-{baudrate}-dual.hex", - "ultimaker2" : "MarlinUltimaker2.hex", - "ultimaker2_go" : "MarlinUltimaker2go.hex", - "ultimaker2_plus" : "MarlinUltimaker2plus.hex", - "ultimaker2_extended" : "MarlinUltimaker2extended.hex", - "ultimaker2_extended_plus" : "MarlinUltimaker2extended-plus.hex", - } - machine_with_heated_bed = {"ultimaker_original" : "MarlinUltimaker-HBK-{baudrate}.hex", - "ultimaker_original_dual" : "MarlinUltimaker-HBK-{baudrate}-dual.hex", - } - ##TODO: Add check for multiple extruders - hex_file = None - if machine_id in machine_without_extras.keys(): # The machine needs to be defined here! - if machine_id in machine_with_heated_bed.keys() and machine_has_heated_bed: - Logger.log("d", "Choosing firmware with heated bed enabled for machine %s.", machine_id) - hex_file = machine_with_heated_bed[machine_id] # Return firmware with heated bed enabled - else: - Logger.log("d", "Choosing basic firmware for machine %s.", machine_id) - hex_file = machine_without_extras[machine_id] # Return "basic" firmware - else: - Logger.log("w", "There is no firmware for machine %s.", machine_id) + # If a firmware file is available, it should be specified in the definition for the printer + hex_file = global_container_stack.getMetaDataEntry("firmware_file", None) + if machine_has_heated_bed: + hex_file = global_container_stack.getMetaDataEntry("firmware_hbk_file", hex_file) if hex_file: try: return Resources.getPath(CuraApplication.ResourceTypes.Firmware, hex_file.format(baudrate=baudrate)) except FileNotFoundError: - Logger.log("w", "Could not find any firmware for machine %s.", machine_id) + Logger.log("w", "Firmware file %s not found.", hex_file) return "" else: - Logger.log("w", "Could not find any firmware for machine %s.", machine_id) + Logger.log("w", "There is no firmware for machine %s.", machine_id) return "" ## Helper to identify serial ports (and scan for them) diff --git a/resources/definitions/bq_hephestos.def.json b/resources/definitions/bq_hephestos.def.json index 8dc67a8cad..be024cd6fa 100644 --- a/resources/definitions/bq_hephestos.def.json +++ b/resources/definitions/bq_hephestos.def.json @@ -12,7 +12,8 @@ "machine_extruder_trains": { "0": "bq_hephestos_extruder_0" - } + }, + "firmware_file": "MarlinHephestos2.hex" }, "overrides": { diff --git a/resources/definitions/bq_witbox.def.json b/resources/definitions/bq_witbox.def.json index 0ae1c5e339..b96da6179c 100644 --- a/resources/definitions/bq_witbox.def.json +++ b/resources/definitions/bq_witbox.def.json @@ -12,7 +12,8 @@ "machine_extruder_trains": { "0": "bq_witbox_extruder_0" - } + }, + "firmware_file": "MarlinWitbox.hex" }, "overrides": { diff --git a/resources/definitions/ultimaker2.def.json b/resources/definitions/ultimaker2.def.json index aa684946c2..ca7a784bfc 100644 --- a/resources/definitions/ultimaker2.def.json +++ b/resources/definitions/ultimaker2.def.json @@ -20,7 +20,8 @@ "machine_extruder_trains": { "0": "ultimaker2_extruder_0" - } + }, + "firmware_file": "MarlinUltimaker2.hex" }, "overrides": { "machine_name": { "default_value": "Ultimaker 2" }, diff --git a/resources/definitions/ultimaker2_extended.def.json b/resources/definitions/ultimaker2_extended.def.json index af169c94fb..39a1ca37b3 100644 --- a/resources/definitions/ultimaker2_extended.def.json +++ b/resources/definitions/ultimaker2_extended.def.json @@ -14,7 +14,8 @@ "machine_extruder_trains": { "0": "ultimaker2_extended_extruder_0" - } + }, + "firmware_file": "MarlinUltimaker2extended.hex" }, "overrides": { diff --git a/resources/definitions/ultimaker2_extended_plus.def.json b/resources/definitions/ultimaker2_extended_plus.def.json index f3a8bfcf9f..c296ecd43e 100644 --- a/resources/definitions/ultimaker2_extended_plus.def.json +++ b/resources/definitions/ultimaker2_extended_plus.def.json @@ -14,7 +14,8 @@ "machine_extruder_trains": { "0": "ultimaker2_extended_plus_extruder_0" - } + }, + "firmware_file": "MarlinUltimaker2extended-plus.hex" }, "overrides": { diff --git a/resources/definitions/ultimaker2_go.def.json b/resources/definitions/ultimaker2_go.def.json index c66fb38fc0..5301fd7db9 100644 --- a/resources/definitions/ultimaker2_go.def.json +++ b/resources/definitions/ultimaker2_go.def.json @@ -17,7 +17,8 @@ "machine_extruder_trains": { "0": "ultimaker2_go_extruder_0" - } + }, + "firmware_file": "MarlinUltimaker2go.hex" }, "overrides": { diff --git a/resources/definitions/ultimaker2_plus.def.json b/resources/definitions/ultimaker2_plus.def.json index bc4d3a6230..45019789bf 100644 --- a/resources/definitions/ultimaker2_plus.def.json +++ b/resources/definitions/ultimaker2_plus.def.json @@ -19,7 +19,8 @@ "machine_extruder_trains": { "0": "ultimaker2_plus_extruder_0" - } + }, + "firmware_file": "MarlinUltimaker2plus.hex" }, "overrides": { diff --git a/resources/definitions/ultimaker_original.def.json b/resources/definitions/ultimaker_original.def.json index c961423504..bb6a64d8dc 100644 --- a/resources/definitions/ultimaker_original.def.json +++ b/resources/definitions/ultimaker_original.def.json @@ -18,7 +18,9 @@ "machine_extruder_trains": { "0": "ultimaker_original_extruder_0" - } + }, + "firmware_file": "MarlinUltimaker-{baudrate}.hex", + "firmware_hbk_file": "MarlinUltimaker-HKB-{baudrate}.hex" }, "overrides": { diff --git a/resources/definitions/ultimaker_original_dual.def.json b/resources/definitions/ultimaker_original_dual.def.json index 55eddba85f..c6002ef396 100644 --- a/resources/definitions/ultimaker_original_dual.def.json +++ b/resources/definitions/ultimaker_original_dual.def.json @@ -19,6 +19,8 @@ "0": "ultimaker_original_dual_1st", "1": "ultimaker_original_dual_2nd" }, + "firmware_file": "MarlinUltimaker-{baudrate}-dual.hex", + "firmware_hbk_file": "MarlinUltimaker-HKB-{baudrate}-dual.hex", "first_start_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel"], "supported_actions": ["UMOUpgradeSelection", "UMOCheckup", "BedLevel", "UpgradeFirmware"] }, diff --git a/resources/definitions/ultimaker_original_plus.def.json b/resources/definitions/ultimaker_original_plus.def.json index 71aa53b2bf..46d95f8028 100644 --- a/resources/definitions/ultimaker_original_plus.def.json +++ b/resources/definitions/ultimaker_original_plus.def.json @@ -16,7 +16,8 @@ "machine_extruder_trains": { "0": "ultimaker_original_plus_extruder_0" - } + }, + "firmware_file": "MarlinUltimaker-UMOP-{baudrate}.hex" }, "overrides": {