mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 10:47:49 -06:00
Added check to prevent printing when firmware is being updated
This commit is contained in:
parent
f5e8e7df80
commit
6e9a07d73c
2 changed files with 44 additions and 4 deletions
|
@ -77,6 +77,8 @@ class PrinterConnection(SignalEmitter):
|
||||||
# This index is the extruder we requested data from the last time.
|
# This index is the extruder we requested data from the last time.
|
||||||
self._temperature_requested_extruder_index = 0
|
self._temperature_requested_extruder_index = 0
|
||||||
|
|
||||||
|
self._updating_firmware = False
|
||||||
|
|
||||||
#TODO: Might need to add check that extruders can not be changed when it started printing or loading these settings from settings object
|
#TODO: Might need to add check that extruders can not be changed when it started printing or loading these settings from settings object
|
||||||
def setNumExtuders(self, num):
|
def setNumExtuders(self, num):
|
||||||
self._extruder_count = num
|
self._extruder_count = num
|
||||||
|
@ -111,10 +113,9 @@ class PrinterConnection(SignalEmitter):
|
||||||
|
|
||||||
## Try to connect the serial. This simply starts the thread, which runs _connect.
|
## Try to connect the serial. This simply starts the thread, which runs _connect.
|
||||||
def connect(self):
|
def connect(self):
|
||||||
if not self._connect_thread.isAlive():
|
if not self._updating_firmware and not self._connect_thread.isAlive():
|
||||||
self._connect_thread.start()
|
self._connect_thread.start()
|
||||||
|
|
||||||
|
|
||||||
def updateFirmware(self, file_name):
|
def updateFirmware(self, file_name):
|
||||||
if self._is_connecting or self._is_connected:
|
if self._is_connecting or self._is_connected:
|
||||||
return False
|
return False
|
||||||
|
@ -124,15 +125,19 @@ class PrinterConnection(SignalEmitter):
|
||||||
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")
|
||||||
return False
|
return False
|
||||||
programmer = stk500v2.Stk500v2()
|
programmer = stk500v2.Stk500v2()
|
||||||
|
programmer.progressCallback = self.setProgress
|
||||||
programmer.connect(self._serial_port)
|
programmer.connect(self._serial_port)
|
||||||
time.sleep(1) #Give programmer some time to connect
|
time.sleep(1) #Give programmer some time to connect
|
||||||
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 False
|
return False
|
||||||
|
self._updating_firmware = True
|
||||||
try:
|
try:
|
||||||
programmer.programChip(hex_file)
|
programmer.programChip(hex_file)
|
||||||
|
self._updating_firmware = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Logger.log("e", "Exception while trying to update firmware" , e)
|
Logger.log("e", "Exception while trying to update firmware" , e)
|
||||||
|
self._updating_firmware = False
|
||||||
return False
|
return False
|
||||||
programmer.close()
|
programmer.close()
|
||||||
return True
|
return True
|
||||||
|
@ -383,7 +388,7 @@ class PrinterConnection(SignalEmitter):
|
||||||
|
|
||||||
progressChanged = Signal()
|
progressChanged = Signal()
|
||||||
|
|
||||||
def setProgress(self, progress):
|
def setProgress(self, progress,max_progress = 100):
|
||||||
self._progress = progress
|
self._progress = progress
|
||||||
self.progressChanged.emit(self._progress, self._serial_port)
|
self.progressChanged.emit(self._progress, self._serial_port)
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import platform
|
||||||
import glob
|
import glob
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from PyQt5.QtQuick import QQuickView
|
from PyQt5.QtQuick import QQuickView
|
||||||
from PyQt5.QtCore import QUrl, QObject,pyqtSlot , pyqtProperty,pyqtSignal
|
from PyQt5.QtCore import QUrl, QObject,pyqtSlot , pyqtProperty,pyqtSignal
|
||||||
|
@ -29,6 +30,7 @@ class USBPrinterManager(QObject, SignalEmitter,PluginObject):
|
||||||
self._extruder_temp = 0
|
self._extruder_temp = 0
|
||||||
self._bed_temp = 0
|
self._bed_temp = 0
|
||||||
self._error_message = ""
|
self._error_message = ""
|
||||||
|
|
||||||
#time.sleep(1)
|
#time.sleep(1)
|
||||||
#self.connectAllConnections()
|
#self.connectAllConnections()
|
||||||
#time.sleep(5)
|
#time.sleep(5)
|
||||||
|
@ -103,6 +105,39 @@ class USBPrinterManager(QObject, SignalEmitter,PluginObject):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def updateFirmwareBySerial(self, serial_port):
|
||||||
|
printer_connection = self.getConnectionByPort(serial_port)
|
||||||
|
if printer_connection is not None:
|
||||||
|
printer_connection.updateFirmware(Resources.getPath(Resources.FirmwareLocation, self._getDefaultFirmwareName()))
|
||||||
|
|
||||||
|
def _getDefaultFirmwareName(self):
|
||||||
|
machine_type = Application.getInstance().getActiveMachine().getTypeID()
|
||||||
|
firmware_name = ""
|
||||||
|
baudrate = 250000
|
||||||
|
if sys.platform.startswith('linux'):
|
||||||
|
baudrate = 115200
|
||||||
|
if machine_type == "ultimaker_original":
|
||||||
|
firmware_name = 'MarlinUltimaker'
|
||||||
|
firmware_name += '-%d' % (baudrate)
|
||||||
|
elif machine_type == "ultimaker_original_plus":
|
||||||
|
firmware_name = 'MarlinUltimaker-UMOP-%d' % (baudrate)
|
||||||
|
elif machine_type == "Witbox":
|
||||||
|
return "MarlinWitbox.hex"
|
||||||
|
elif machine_type == "ultimaker2go":
|
||||||
|
return "MarlinUltimaker2go.hex"
|
||||||
|
elif machine_type == "ultimaker2extended":
|
||||||
|
return "MarlinUltimaker2extended.hex"
|
||||||
|
elif machine_type == "ultimaker2":
|
||||||
|
return "MarlinUltimaker2.hex"
|
||||||
|
|
||||||
|
|
||||||
|
##TODO: Add check for multiple extruders
|
||||||
|
|
||||||
|
if firmware_name != "":
|
||||||
|
firmware_name += ".hex"
|
||||||
|
return firmware_name
|
||||||
|
|
||||||
def onBedTemperature(self, serial_port,temperature):
|
def onBedTemperature(self, serial_port,temperature):
|
||||||
self._bed_temperature = temperature
|
self._bed_temperature = temperature
|
||||||
self.pyqtBedTemperature.emit(temperature)
|
self.pyqtBedTemperature.emit(temperature)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue