def read(self, size):
    recv_chunk = self.RECV_CHUNK
    if ((size > 0) and (size < recv_chunk)):
        recv_chunk = size
    header_size = 12
    max_padding = 511
    eom = False
    raw_read = super(USBTMC, self).read
    raw_write = super(USBTMC, self).write
    received = bytearray()
    while (not eom):
        self._btag = ((self._btag % 255) + 1)
        req = BulkInMessage.build_array(self._btag, recv_chunk, None)
        raw_write(req)
        try:
            resp = raw_read(((recv_chunk + header_size) + max_padding))
            response = BulkInMessage.from_bytes(resp)
        except (usb.core.USBError, ValueError):
            self._abort_bulk_in(self._btag)
            raise
        received.extend(response.data)
        if (len(response.data) >= response.transfer_size):
            eom = (response.transfer_attributes & 1)
    return bytes(received)
def read(self, size):
    recv_chunk = self.RECV_CHUNK
    if ((size > 0) and (size < recv_chunk)):
        recv_chunk = size
    header_size = 12
    max_padding = 511
    eom = False
    raw_read = super(USBTMC, self).read
    raw_write = super(USBTMC, self).write
    received = bytearray()
    while (not eom):
        self._btag = ((self._btag % 255) + 1)
        req = BulkInMessage.build_array(self._btag, recv_chunk, None)
        raw_write(req)
        try:
            resp = raw_read(((recv_chunk + header_size) + max_padding))
            response = BulkInMessage.from_bytes(resp)
        except (usb.core.USBError, ValueError):
            self._abort_bulk_in(self._btag)
            raise
        received.extend(response.data)
        if (len(response.data) >= response.transfer_size):
            eom = (response.transfer_attributes & 1)
    return bytes(received)