Added extra error reporting

This commit is contained in:
Kovid Goyal 2007-01-23 17:31:13 +00:00
parent 64771613b6
commit af7605a075
2 changed files with 8 additions and 4 deletions

View File

@ -379,6 +379,9 @@ class PRS500Device(Device):
data = data_type(self.handle.bulk_read(self.BULK_IN_EP, rsize))
if self.log_packets:
self.log_packet(data, "Answer d->h")
if len(data) != size:
raise ProtocolError("Unable to read " + str(size) + " bytes from "\
"device. Read: " + str(len(data)) + " bytes")
return data
bytes_left = bytes
@ -452,6 +455,7 @@ class PRS500Device(Device):
" for reading. Response code: " + hex(res.code))
_id = self._bulk_read(20, data_type=IdAnswer, \
command_number=FileOpen.NUMBER)[0].id
# The first 16 bytes from the device are meta information on the packet stream
bytes_left, chunk_size = bytes, 512 * self.bulk_read_max_packet_size -16
packet_size, pos = 64 * self.bulk_read_max_packet_size, 0
while bytes_left > 0:
@ -465,7 +469,6 @@ class PRS500Device(Device):
packets = self._bulk_read(chunk_size+16, \
command_number=FileIO.RNUMBER, packet_size=packet_size)
try:
# The first 16 bytes are meta information on the packet stream
outfile.write("".join(map(chr, packets[0][16:])))
for i in range(1, len(packets)):
outfile.write("".join(map(chr, packets[i])))

View File

@ -525,7 +525,8 @@ class Main(QObject, Ui_MainWindow):
self.status("Device is in use by another application")
self.window.setCursor(Qt.ArrowCursor)
return
except DeviceError:
except DeviceError, err:
traceback.print_exc(err)
self.dev.reconnect()
self.thread().msleep(100)
return self.establish_connection()