Logo Search packages:      
Sourcecode: calibre version File versions

def calibre::devices::prs500::driver::PRS500::_bulk_read (   self,
  bytes,
  command_number = 0x00,
  packet_size = 0x1000,
  data_type = Answer 
) [private]

Read in C{bytes} bytes via a bulk transfer in
packets of size S{<=} C{packet_size}
@param data_type: an object of type type.
The data packet is returned as an object of type C{data_type}.
@return: A list of packets read from the device.
Each packet is of type data_type

Definition at line 387 of file driver.py.

                                    :
        """
        Read in C{bytes} bytes via a bulk transfer in
        packets of size S{<=} C{packet_size}
        @param data_type: an object of type type.
        The data packet is returned as an object of type C{data_type}.
        @return: A list of packets read from the device.
        Each packet is of type data_type
        """
        msize = self.bulk_read_max_packet_size
        def bulk_read_packet(data_type=Answer, size=0x1000):
            rsize = size
            if size % msize:
                rsize = size - size % msize + msize
            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
        packets = []
        while bytes_left > 0:
            if packet_size > bytes_left:
                packet_size = bytes_left
            packet = bulk_read_packet(data_type=data_type, size=packet_size)
            bytes_left -= len(packet)
            packets.append(packet)
        self.send_validated_command(\
            AcknowledgeBulkRead(packets[0].number), \
            cnumber=command_number)
        return packets

    @safe
    def get_device_information(self, end_session=True):


Generated by  Doxygen 1.6.0   Back to index