From 8bbbb480a4573898beffe322f60d79d19a21dc18 Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Mon, 14 Mar 2016 09:38:55 +0100 Subject: [PATCH 01/13] USBPrinting: Moving baudrate and correcting indent Moves the baudrate into the if clause, which looks at least for me better and just found a wrong indent --- plugins/USBPrinting/USBPrinterManager.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index 3a2beab0c8..d8b93c6cc5 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -135,9 +135,10 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): def _getDefaultFirmwareName(self): machine_instance = Application.getInstance().getMachineManager().getActiveMachineInstance() machine_type = machine_instance.getMachineDefinition().getId() - baudrate = 250000 if sys.platform.startswith("linux"): - baudrate = 115200 + baudrate = 115200 + else: + baudrate = 250000 if machine_type == "ultimaker_original": firmware_name = "MarlinUltimaker" if machine_instance.getMachineSettingValue("machine_heated_bed"): #Has heated bed upgrade kit? From 97a7cee3e25f070287ebaf0223716eabffdd0fd3 Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Mon, 14 Mar 2016 09:42:57 +0100 Subject: [PATCH 02/13] USBPrinting: Using platform.system() for platform check As platform is already imported here, usig platform for the check is much easier. --- plugins/USBPrinting/USBPrinterManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index d8b93c6cc5..1a2570be7f 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -135,7 +135,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): def _getDefaultFirmwareName(self): machine_instance = Application.getInstance().getMachineManager().getActiveMachineInstance() machine_type = machine_instance.getMachineDefinition().getId() - if sys.platform.startswith("linux"): + if platform.system() == "Linux": baudrate = 115200 else: baudrate = 250000 From 29ea25d0b3f1815331ad34d55d93f060242c663f Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Mon, 14 Mar 2016 10:04:30 +0100 Subject: [PATCH 03/13] USBPrinting: Huge clean up in _getDefaultFirmwareName * Moving TODO on top of if clauses * Moving all machine types and hex-file names into dictionaries * Adding error messages for unknown printers --- plugins/USBPrinting/USBPrinterManager.py | 55 +++++++++++++----------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index 1a2570be7f..ccbf8bafd6 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -139,33 +139,40 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): baudrate = 115200 else: baudrate = 250000 - if machine_type == "ultimaker_original": - firmware_name = "MarlinUltimaker" - if machine_instance.getMachineSettingValue("machine_heated_bed"): #Has heated bed upgrade kit? - firmware_name += "-HBK" - firmware_name += "-%d" % (baudrate) - return firmware_name + ".hex" - elif machine_type == "ultimaker_original_plus": - firmware_name = "MarlinUltimaker-UMOP-%d" % (baudrate) - return firmware_name + ".hex" - elif machine_type == "bq_witbox": - return "MarlinWitbox.hex" - elif machine_type == "ultimaker2_go": - return "MarlinUltimaker2go.hex" - elif machine_type == "ultimaker2_extended": - return "MarlinUltimaker2extended.hex" - elif machine_type == "ultimaker2": - return "MarlinUltimaker2.hex" - elif machine_type == "ultimaker2plus": - return "MarlinUltimaker2plus.hex" - elif machine_type == "ultimaker2_extended_plus": - return "MarlinUltimaker2extended-plus.hex" - else: - Logger.log("e", "I don't know of any firmware for machine %s.", machine_type) - raise FileNotFoundError() + + machine_without_heated_bed = {"ultimaker_original" : "MarlinUltimaker-{baudrate}.hex", + "ultimaker_original_plus" : "MarlinUltimaker-UMOP-{baudrate}.hex", + "bq_witbox" : "MarlinWitbox.hex", + "ultimaker2_go" : "MarlinUltimaker2go.hex", + "ultimaker2_extended" : "MarlinUltimaker2extended.hex", + "ultimaker2" : "MarlinUltimaker2.hex", + "ultimaker2plus" : "MarlinUltimaker2plus.hex", + "ultimaker2_extended_plus" : "MarlinUltimaker2extended-plus.hex", + } + machine_with_heated_bed = {"ultimaker_original-HBK-{baudrate}.hex", + } ##TODO: Add check for multiple extruders + hex_file = None + if not machine_instance.getMachineSettingValue("machine_heated_bed"): + if machine_type in machine_without_heated_bed.keys(): + hex_file = machine_without_heated_bed[machine_type] + else: + Logger.log("e", "There is no firmware for machine %s.", machine_type) + else: + if machine_type in machine_with_heated_bed.keys(): + hex_file = machine_without_heated_bed[machine_type] + else: + Logger.log("e", "There is no firmware for machine %s with heated bed.", machine_type) + + if hex_file: + return hex_file.format(baudrate=baudrate) + else: + Logger.log("e", "Could not find any firmware for machine %s.", machine_type) + raise FileNotFoundError() + + def _addRemovePorts(self, serial_ports): # First, find and add all new or changed keys for serial_port in list(serial_ports): From d968d3e2b2739e2ac99f40e7c411e2e857eb9ec0 Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Mon, 14 Mar 2016 10:14:12 +0100 Subject: [PATCH 04/13] USBPrinting: Correcting machine_with_heated_bed dictionary --- plugins/USBPrinting/USBPrinterManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index ccbf8bafd6..41f715ba22 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -149,7 +149,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): "ultimaker2plus" : "MarlinUltimaker2plus.hex", "ultimaker2_extended_plus" : "MarlinUltimaker2extended-plus.hex", } - machine_with_heated_bed = {"ultimaker_original-HBK-{baudrate}.hex", + machine_with_heated_bed = {"ultimaker_original" : "ultimaker_original-HBK-{baudrate}.hex", } ##TODO: Add check for multiple extruders From a2915ddc80a224ee0ff57d75fcb8160c01942ea2 Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Mon, 14 Mar 2016 10:16:53 +0100 Subject: [PATCH 05/13] USBPrinting: Correcting machine_with_heated_bed dictionary again (oops) --- plugins/USBPrinting/USBPrinterManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index 41f715ba22..75433cae5c 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -149,7 +149,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): "ultimaker2plus" : "MarlinUltimaker2plus.hex", "ultimaker2_extended_plus" : "MarlinUltimaker2extended-plus.hex", } - machine_with_heated_bed = {"ultimaker_original" : "ultimaker_original-HBK-{baudrate}.hex", + machine_with_heated_bed = {"ultimaker_original" : "MarlinUltimaker-HBK-{baudrate}.hex", } ##TODO: Add check for multiple extruders From a1e673dc64dbd92eb8b7dac175e459d7a2683e62 Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Mon, 14 Mar 2016 13:34:49 +0100 Subject: [PATCH 06/13] USBPrinting: Correcting indents --- plugins/USBPrinting/USBPrinterManager.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index 75433cae5c..f74ce38958 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -156,15 +156,15 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): hex_file = None if not machine_instance.getMachineSettingValue("machine_heated_bed"): - if machine_type in machine_without_heated_bed.keys(): - hex_file = machine_without_heated_bed[machine_type] - else: - Logger.log("e", "There is no firmware for machine %s.", machine_type) + if machine_type in machine_without_heated_bed.keys(): + hex_file = machine_without_heated_bed[machine_type] + else: + Logger.log("e", "There is no firmware for machine %s.", machine_type) else: if machine_type in machine_with_heated_bed.keys(): - hex_file = machine_without_heated_bed[machine_type] - else: - Logger.log("e", "There is no firmware for machine %s with heated bed.", machine_type) + hex_file = machine_without_heated_bed[machine_type] + else: + Logger.log("e", "There is no firmware for machine %s with heated bed.", machine_type) if hex_file: return hex_file.format(baudrate=baudrate) From eed5f88b1316a267e5c4d2ea0a4953cce636925d Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Mon, 14 Mar 2016 13:56:27 +0100 Subject: [PATCH 07/13] USBPrinting: Adding a short instruction Just added a short instruction where to find the id of the machine, just to make it easier for the vendor to fill in the correct values. --- plugins/USBPrinting/USBPrinterManager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index f74ce38958..c532f92542 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -140,6 +140,8 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): else: baudrate = 250000 + # Note the keyword 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 machine_without_heated_bed = {"ultimaker_original" : "MarlinUltimaker-{baudrate}.hex", "ultimaker_original_plus" : "MarlinUltimaker-UMOP-{baudrate}.hex", "bq_witbox" : "MarlinWitbox.hex", From 8422356dc9684830681a047e8fdc63b44d44538f Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Mon, 14 Mar 2016 13:57:27 +0100 Subject: [PATCH 08/13] USBPrinting: Correcting typo --- plugins/USBPrinting/USBPrinterManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index c532f92542..567cd5e177 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -140,7 +140,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): else: baudrate = 250000 - # Note the keyword here is the id of the machine. You can find the id of your machine in the *.json file, eg. + # 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 machine_without_heated_bed = {"ultimaker_original" : "MarlinUltimaker-{baudrate}.hex", "ultimaker_original_plus" : "MarlinUltimaker-UMOP-{baudrate}.hex", From b3f721cfa0eee26d2f61472b2d0a9073d3fe3476 Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Mon, 14 Mar 2016 14:02:56 +0100 Subject: [PATCH 09/13] USBPrinting: Using the correct dictionary (Dirty coding does not make any sense..) --- plugins/USBPrinting/USBPrinterManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index f74ce38958..c1b6533aec 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -162,7 +162,7 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): Logger.log("e", "There is no firmware for machine %s.", machine_type) else: if machine_type in machine_with_heated_bed.keys(): - hex_file = machine_without_heated_bed[machine_type] + hex_file = machine_with_heated_bed[machine_type] else: Logger.log("e", "There is no firmware for machine %s with heated bed.", machine_type) From 4d0a2094a1d05d58994c0ad5823559c577a3d817 Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Mon, 14 Mar 2016 14:13:26 +0100 Subject: [PATCH 10/13] USBPrinting: Reordering printers in dictionaries --- plugins/USBPrinting/USBPrinterManager.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index c1b6533aec..1869d3d3ea 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -140,16 +140,16 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): else: baudrate = 250000 - machine_without_heated_bed = {"ultimaker_original" : "MarlinUltimaker-{baudrate}.hex", - "ultimaker_original_plus" : "MarlinUltimaker-UMOP-{baudrate}.hex", - "bq_witbox" : "MarlinWitbox.hex", + machine_without_heated_bed = {"bq_witbox" : "MarlinWitbox.hex", + "ultimaker_original" : "MarlinUltimaker-{baudrate}.hex", "ultimaker2_go" : "MarlinUltimaker2go.hex", - "ultimaker2_extended" : "MarlinUltimaker2extended.hex", - "ultimaker2" : "MarlinUltimaker2.hex", - "ultimaker2plus" : "MarlinUltimaker2plus.hex", - "ultimaker2_extended_plus" : "MarlinUltimaker2extended-plus.hex", } machine_with_heated_bed = {"ultimaker_original" : "MarlinUltimaker-HBK-{baudrate}.hex", + "ultimaker_original_plus" : "MarlinUltimaker-UMOP-{baudrate}.hex", + "ultimaker2" : "MarlinUltimaker2.hex", + "ultimaker2_extended_plus" : "MarlinUltimaker2extended-plus.hex", + "ultimaker2plus" : "MarlinUltimaker2plus.hex", + "ultimaker2_extended" : "MarlinUltimaker2extended.hex", } ##TODO: Add check for multiple extruders From 6775d337f5d4500961250e5e67c4b04559eb5147 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Mon, 14 Mar 2016 14:23:26 +0100 Subject: [PATCH 11/13] USBPrinting: Complete the note with a link to the hex files --- plugins/USBPrinting/USBPrinterManager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index 77919e332e..909a79c476 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -142,6 +142,8 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): # 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_heated_bed = {"bq_witbox" : "MarlinWitbox.hex", "ultimaker_original" : "MarlinUltimaker-{baudrate}.hex", "ultimaker2_go" : "MarlinUltimaker2go.hex", From e7bd07740e3d3f01d225dde7f2ea4f1050fa3e15 Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Mon, 14 Mar 2016 14:43:14 +0100 Subject: [PATCH 12/13] USBPrinting: Reordering and rethinking machine detection * Moved all machines again to a basic dictionary ** The idea is to collect all machines at one place, which are unmodified. In case there is a printer, which is modified, it goes to a seperate dictionary. * The if-clauses now respect this idea (hopefully) --- plugins/USBPrinting/USBPrinterManager.py | 39 +++++++++++------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index 77919e332e..4d0625ceb0 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -142,31 +142,29 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): # 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 - machine_without_heated_bed = {"bq_witbox" : "MarlinWitbox.hex", - "ultimaker_original" : "MarlinUltimaker-{baudrate}.hex", - "ultimaker2_go" : "MarlinUltimaker2go.hex", - } - machine_with_heated_bed = {"ultimaker_original" : "MarlinUltimaker-HBK-{baudrate}.hex", - "ultimaker_original_plus" : "MarlinUltimaker-UMOP-{baudrate}.hex", - "ultimaker2" : "MarlinUltimaker2.hex", - "ultimaker2_extended_plus" : "MarlinUltimaker2extended-plus.hex", - "ultimaker2plus" : "MarlinUltimaker2plus.hex", - "ultimaker2_extended" : "MarlinUltimaker2extended.hex", - } + machine_without_extras = {"bq_witbox" : "MarlinWitbox.hex", + "ultimaker_original" : "MarlinUltimaker-{baudrate}.hex", + "ultimaker_original_plus" : "MarlinUltimaker-UMOP-{baudrate}.hex", + "ultimaker2" : "MarlinUltimaker2.hex", + "ultimaker2_go" : "MarlinUltimaker2go.hex", + "ultimaker2plus" : "MarlinUltimaker2plus.hex", + "ultimaker2_extended" : "MarlinUltimaker2extended.hex", + "ultimaker2_extended_plus" : "MarlinUltimaker2extended-plus.hex", + } + machine_with_heated_bed = {"ultimaker_original" : "MarlinUltimaker-HBK-{baudrate}.hex", + } ##TODO: Add check for multiple extruders - hex_file = None - if not machine_instance.getMachineSettingValue("machine_heated_bed"): - if machine_type in machine_without_heated_bed.keys(): - hex_file = machine_without_heated_bed[machine_type] - else: - Logger.log("e", "There is no firmware for machine %s.", machine_type) - else: - if machine_type in machine_with_heated_bed.keys(): + if machine_type in machine_without_extras.keys(): # The machine needs to be defined here! + if machine_type in machine_with_heated_bed.keys(): # Return firmware with heated bed enabled + Logger.log("d", "Choosing firmware with heated bed enabled for machine %s.", machine_type) hex_file = machine_with_heated_bed[machine_type] else: - Logger.log("e", "There is no firmware for machine %s with heated bed.", machine_type) + Logger.log("d", "Choosing basic firmware for machine %s.", machine_type) + hex_file = machine_without_extras[machine_type] # Return "basic" firmware + else: + Logger.log("e", "There is no firmware for machine %s.", machine_type) if hex_file: return hex_file.format(baudrate=baudrate) @@ -174,7 +172,6 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): Logger.log("e", "Could not find any firmware for machine %s.", machine_type) raise FileNotFoundError() - def _addRemovePorts(self, serial_ports): # First, find and add all new or changed keys for serial_port in list(serial_ports): From bad862e72f92c464ed65daa8031463ce8d332cfa Mon Sep 17 00:00:00 2001 From: Thomas-Karl Pietrowski Date: Mon, 14 Mar 2016 15:09:10 +0100 Subject: [PATCH 13/13] USBPrinting: Adding lost check for "machine_heated_bed" --- plugins/USBPrinting/USBPrinterManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/USBPrinting/USBPrinterManager.py b/plugins/USBPrinting/USBPrinterManager.py index 4cadef7cad..fcb61c3365 100644 --- a/plugins/USBPrinting/USBPrinterManager.py +++ b/plugins/USBPrinting/USBPrinterManager.py @@ -159,9 +159,9 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension): ##TODO: Add check for multiple extruders hex_file = None if machine_type in machine_without_extras.keys(): # The machine needs to be defined here! - if machine_type in machine_with_heated_bed.keys(): # Return firmware with heated bed enabled + if machine_type in machine_with_heated_bed.keys() and machine_instance.getMachineSettingValue("machine_heated_bed"): Logger.log("d", "Choosing firmware with heated bed enabled for machine %s.", machine_type) - hex_file = machine_with_heated_bed[machine_type] + hex_file = machine_with_heated_bed[machine_type] # Return firmware with heated bed enabled else: Logger.log("d", "Choosing basic firmware for machine %s.", machine_type) hex_file = machine_without_extras[machine_type] # Return "basic" firmware