# Path: pyDAPLink/errors.py
# class TransferError(ValueError):
#     pass


import logging
import array
from ..errors import TransferError
        if resp[0] != COMMAND_ID['DAP_TRANSFER_CONFIGURE']:
            raise ValueError('DAP_TRANSFER_CONFIGURE response error')

        if resp[1] != DAP_OK:
            raise ValueError('DAP Transfer Configure failed')

        return resp[1]

    def transfer(self, count, request, data = [0], dap_index = 0):
        cmd = []
        cmd.append(COMMAND_ID['DAP_TRANSFER'])
        cmd.append(dap_index)
        cmd.append(count)
        count_write = count
        for i in range(count):
            cmd.append(request[i])
            if not ( request[i] & ((1 << 1) | (1 << 4))):
                cmd.append(data[i] & 0xff)
                cmd.append((data[i] >> 8) & 0xff)
                cmd.append((data[i] >> 16) & 0xff)
                cmd.append((data[i] >> 24) & 0xff)
                count_write -= 1
        self.interface.write(cmd)

        resp = self.interface.read()
        if resp[0] != COMMAND_ID['DAP_TRANSFER']:
            raise ValueError('DAP_TRANSFER response error')

        if resp[2] != DAP_TRANSFER_OK:
            if resp[2] == DAP_TRANSFER_FAULT:

# Path: pyDAPLink/errors.py
# class TransferError(ValueError):
#     pass


# Path: pyDAPLink/daplink/protocol.py
import logging
import array
from ..errors import TransferError

        if resp[0] != COMMAND_ID['DAP_TRANSFER_CONFIGURE']:
            raise ValueError('DAP_TRANSFER_CONFIGURE response error')

        if resp[1] != DAP_OK:
            raise ValueError('DAP Transfer Configure failed')

        return resp[1]

    def transfer(self, count, request, data = [0], dap_index = 0):
        cmd = []
        cmd.append(COMMAND_ID['DAP_TRANSFER'])
        cmd.append(dap_index)
        cmd.append(count)
        count_write = count
        for i in range(count):
            cmd.append(request[i])
            if not ( request[i] & ((1 << 1) | (1 << 4))):
                cmd.append(data[i] & 0xff)
                cmd.append((data[i] >> 8) & 0xff)
                cmd.append((data[i] >> 16) & 0xff)
                cmd.append((data[i] >> 24) & 0xff)
                count_write -= 1
        self.interface.write(cmd)

        resp = self.interface.read()
        if resp[0] != COMMAND_ID['DAP_TRANSFER']:
            raise ValueError('DAP_TRANSFER response error')

        if resp[2] != DAP_TRANSFER_OK:
            if resp[2] == DAP_TRANSFER_FAULT:

                raise TransferError()