Bugfixes to usb printing

This commit is contained in:
Jaime van Kessel 2015-04-17 10:40:44 +02:00
parent 34aac653b4
commit a07781fa26
4 changed files with 11 additions and 8 deletions

View file

@ -9,7 +9,7 @@ Rectangle
Text
{
text: "Updating firmware
text: "Updating firmware"
}
ProgressBar
{

View file

@ -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")

View file

@ -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

View file

@ -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))