More cleanups. Minor GUI bug fixed when deleting books from device list. Version bump.

This commit is contained in:
Kovid Goyal 2007-01-25 05:30:33 +00:00
parent af7605a075
commit b81fe715b1
5 changed files with 21 additions and 8 deletions

View File

@ -37,7 +37,7 @@ You may have to adjust the GROUP and the location of the rules file to
suit your distribution. suit your distribution.
""" """
__version__ = "0.3.5" __version__ = "0.3.6"
__docformat__ = "epytext" __docformat__ = "epytext"
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>" __author__ = "Kovid Goyal <kovid@kovidgoyal.net>"

View File

@ -260,7 +260,9 @@ class PRS500Device(Device):
if version not in KNOWN_USB_PROTOCOL_VERSIONS: if version not in KNOWN_USB_PROTOCOL_VERSIONS:
print >> sys.stderr, "WARNING: Usb protocol version " + \ print >> sys.stderr, "WARNING: Usb protocol version " + \
hex(version) + " is unknown" hex(version) + " is unknown"
res = self.send_validated_command(SetBulkSize(size=0x028000)) res = self.send_validated_command(SetBulkSize(\
chunk_size = 512*self.bulk_read_max_packet_size, \
unknown = 2))
if res.code != 0: if res.code != 0:
raise ProtocolError("Unable to set bulk size.") raise ProtocolError("Unable to set bulk size.")
self.send_validated_command(UnlockDevice(key=0x312d)) self.send_validated_command(UnlockDevice(key=0x312d))

View File

@ -177,6 +177,7 @@ class Main(QObject, Ui_MainWindow):
self.status("Syncing media list to card") self.status("Syncing media list to card")
self.dev.upload_book_list(self.card_model.booklist) self.dev.upload_book_list(self.card_model.booklist)
self.update_availabe_space() self.update_availabe_space()
self.model_modified()
self.show_book(self.current_view.currentIndex(), QModelIndex()) self.show_book(self.current_view.currentIndex(), QModelIndex())
self.window.setCursor(Qt.ArrowCursor) self.window.setCursor(Qt.ArrowCursor)
@ -479,7 +480,8 @@ class Main(QObject, Ui_MainWindow):
self.detector = DeviceConnectDetector(self.dev) self.detector = DeviceConnectDetector(self.dev)
self.connect(self.detector, SIGNAL("device_connected()"), \ self.connect(self.detector, SIGNAL("device_connected()"), \
self.establish_connection) self.establish_connection)
self.connect(self.detector, SIGNAL("device_removed()"), self.device_removed) self.connect(self.detector, SIGNAL("device_removed()"), \
self.device_removed)
self.search.setFocus(Qt.OtherFocusReason) self.search.setFocus(Qt.OtherFocusReason)
self.show_device(False) self.show_device(False)
self.df_template = self.df.text() self.df_template = self.df.text()

View File

@ -253,6 +253,8 @@ class DeviceHandle(Structure):
if rsize < 0: if rsize < 0:
raise Error('Could not read ' + str(size) + ' bytes on the '\ raise Error('Could not read ' + str(size) + ' bytes on the '\
'bulk bus. Error code: ' + str(rsize)) 'bulk bus. Error code: ' + str(rsize))
if rsize == 0:
raise Error('Device sent zero bytes')
if rsize < size: if rsize < size:
arr = arr[:rsize] arr = arr[:rsize]
return arr return arr

View File

@ -46,6 +46,7 @@ import time
from libprs500.errors import PacketError from libprs500.errors import PacketError
WORD = "<H" #: Unsigned integer little endian encoded in 2 bytes
DWORD = "<I" #: Unsigned integer little endian encoded in 4 bytes DWORD = "<I" #: Unsigned integer little endian encoded in 4 bytes
DDWORD = "<Q" #: Unsigned long long little endian encoded in 8 bytes DDWORD = "<Q" #: Unsigned long long little endian encoded in 8 bytes
@ -402,12 +403,17 @@ class GetUSBProtocolVersion(ShortCommand):
number=GetUSBProtocolVersion.NUMBER, \ number=GetUSBProtocolVersion.NUMBER, \
type=0x01, command=0x00) type=0x01, command=0x00)
class SetBulkSize(ShortCommand): class SetBulkSize(Command):
""" Set size for bulk transfers in this session """ """ Set size for bulk transfers in this session """
NUMBER = 0x107 #: Command number NUMBER = 0x107 #: Command number
def __init__(self, size=0x028000): chunk_size = field(fmt=WORD, start=0x10)
ShortCommand.__init__(self, \ unknown = field(fmt=WORD, start=0x12)
number=SetBulkSize.NUMBER, type=0x01, command=size) def __init__(self, chunk_size=0x8000, unknown=0x2):
Command.__init__(self, [0 for i in range(24)])
self.number = SetBulkSize.NUMBER
self.type = 0x01
self.chunk_size = chunk_size
self.unknown = unknown
class UnlockDevice(ShortCommand): class UnlockDevice(ShortCommand):
""" Unlock the device """ """ Unlock the device """
@ -714,7 +720,8 @@ class Answer(TransferBuffer):
if "__len__" in dir(packet): if "__len__" in dir(packet):
if len(packet) < 16 : if len(packet) < 16 :
raise PacketError(str(self.__class__)[7:-2] + \ raise PacketError(str(self.__class__)[7:-2] + \
" packets must have a length of atleast 16 bytes") " packets must have a length of atleast 16 bytes. "\
"Got initializer of " + str(len(packet)) + " bytes.")
elif packet < 16: elif packet < 16:
raise PacketError(str(self.__class__)[7:-2] + \ raise PacketError(str(self.__class__)[7:-2] + \
" packets must have a length of atleast 16 bytes") " packets must have a length of atleast 16 bytes")