diff --git a/FirmwareUpdateWindow.qml b/FirmwareUpdateWindow.qml index 2ae6ed40d5..e3777e853f 100644 --- a/FirmwareUpdateWindow.qml +++ b/FirmwareUpdateWindow.qml @@ -9,7 +9,7 @@ Rectangle Text { - text: "Updating firmware + text: "Updating firmware" } ProgressBar { diff --git a/PrinterConnection.py b/PrinterConnection.py index d5fb1e1690..d94beea6c5 100644 --- a/PrinterConnection.py +++ b/PrinterConnection.py @@ -117,9 +117,9 @@ class PrinterConnection(SignalEmitter): self._connect_thread.start() def updateFirmware(self, file_name): + print("Update firmware; " , self._is_connecting, " ", self._is_connected ) if self._is_connecting or self._is_connected: - return False - + self.close() hex_file = intelHex.readHex(file_name) if len(hex_file) == 0: Logger.log('e', "Unable to read provided hex file. Could not update firmware") @@ -136,7 +136,7 @@ class PrinterConnection(SignalEmitter): programmer.programChip(hex_file) self._updating_firmware = False except Exception as e: - Logger.log("e", "Exception while trying to update firmware" , e) + Logger.log("e", "Exception while trying to update firmware %s" %e) self._updating_firmware = False return False programmer.close() @@ -173,6 +173,9 @@ class PrinterConnection(SignalEmitter): self._sendCommand("M105") #Request temperature, as this should (if baudrate is correct) result in a command with 'T:' in it while timeout_time > time.time(): line = self._readline() + if line is None: + self.setIsConnected(False) # something went wrong with reading, could be that close was called. + return if b"T:" in line: self._serial.timeout = 0.5 self._serial.write(b"\n") diff --git a/avr_isp/intelHex.py b/avr_isp/intelHex.py index 75c7d3a5b2..822936ef1b 100644 --- a/avr_isp/intelHex.py +++ b/avr_isp/intelHex.py @@ -34,7 +34,7 @@ def readHex(filename): if recType == 0:#Data record while len(data) < addr + recLen: data.append(0) - for i in xrange(0, recLen): + for i in range(0, recLen): data[addr + i] = int(line[i*2+9:i*2+11], 16) elif recType == 1: #End Of File record pass diff --git a/avr_isp/stk500v2.py b/avr_isp/stk500v2.py index b2d2449727..778adc7da3 100644 --- a/avr_isp/stk500v2.py +++ b/avr_isp/stk500v2.py @@ -86,7 +86,7 @@ class Stk500v2(ispBase.IspBase): self.sendMessage([0x06, 0x00, 0x00, 0x00, 0x00]) loadCount = (len(flashData) + pageSize - 1) / pageSize - for i in xrange(0, loadCount): + for i in range(0, loadCount): recv = self.sendMessage([0x13, pageSize >> 8, pageSize & 0xFF, 0xc1, 0x0a, 0x40, 0x4c, 0x20, 0x00, 0x00] + flashData[(i * pageSize):(i * pageSize + pageSize)]) if self.progressCallback is not None: if self._has_checksum: @@ -114,11 +114,11 @@ class Stk500v2(ispBase.IspBase): self.sendMessage([0x06, 0x00, 0x00, 0x00, 0x00]) loadCount = (len(flashData) + 0xFF) / 0x100 - for i in xrange(0, loadCount): + for i in range(0, loadCount): recv = self.sendMessage([0x14, 0x01, 0x00, 0x20])[2:0x102] if self.progressCallback is not None: self.progressCallback(loadCount + i + 1, loadCount*2) - for j in xrange(0, 0x100): + for j in range(0, 0x100): if i * 0x100 + j < len(flashData) and flashData[i * 0x100 + j] != recv[j]: raise ispBase.IspError('Verify error at: 0x%x' % (i * 0x100 + j))