How to use the pyocd.probe.pydapaccess.dap_access_api.DAPAccessIntf function in pyocd

To help you get started, we’ve selected a few pyocd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github XIVN1987 / DAPCmdr / pyocd / probe / pydapaccess / interface / pyusb_backend.py View on Github external
def open(self):
        assert self.closed is True

        # Get device handle
        dev = usb.core.find(custom_match=FindDap(self.serial_number))
        if dev is None:
            raise DAPAccessIntf.DeviceError("Device %s not found" %
                                            self.serial_number)

        # get active config
        config = dev.get_active_configuration()

        # Get hid interface
        interface = None
        interface_number = None
        for interface in config:
            if interface.bInterfaceClass == 0x03:
                interface_number = interface.bInterfaceNumber
                break
        if interface_number is None or interface is None:
            raise DAPAccessIntf.DeviceError("Device %s has no hid interface" %
                                            self.serial_number)
github mbedmicro / pyOCD / pyocd / probe / pydapaccess / interface / __init__.py View on Github external
# Check validity of backend env var.
if USB_BACKEND and ((USB_BACKEND not in INTERFACE) or (not INTERFACE[USB_BACKEND].isAvailable)):
    LOG.error("Invalid USB backend specified in PYOCD_USB_BACKEND: " + USB_BACKEND)
    USB_BACKEND = ""

# Select backend based on OS and availability.
if not USB_BACKEND:
    if os.name == "nt":
        # Prefer hidapi over pyWinUSB for Windows, since pyWinUSB has known bug(s)
        if HidApiUSB.isAvailable:
            USB_BACKEND = "hidapiusb"
        elif PyWinUSB.isAvailable:
            USB_BACKEND = "pywinusb"
        else:
            raise DAPAccessIntf.DeviceError("No USB backend found")
    elif os.name == "posix":
        # Select hidapi for OS X and pyUSB for Linux.
        if os.uname()[0] == 'Darwin':
            USB_BACKEND = "hidapiusb"
        else:
            USB_BACKEND = "pyusb"
    else:
        raise DAPAccessIntf.DeviceError("No USB backend found")

USB_BACKEND_V2 = "pyusb_v2"
github mbedmicro / pyOCD / pyocd / probe / pydapaccess / interface / pyusb_backend.py View on Github external
def open(self):
        assert self.closed is True

        # Get device handle
        dev = usb.core.find(custom_match=FindDap(self.serial_number))
        if dev is None:
            raise DAPAccessIntf.DeviceError("Device %s not found" % self.serial_number)

        # get active config
        config = dev.get_active_configuration()

        # Get CMSIS-DAPv1 interface
        interface = usb.util.find_descriptor(config, custom_match=_match_cmsis_dap_v1_interface)
        if interface is None:
            raise DAPAccessIntf.DeviceError("Device %s has no CMSIS-DAPv1 interface" %
                                            self.serial_number)
        interface_number = interface.bInterfaceNumber

        # Find endpoints
        ep_in, ep_out = None, None
        for endpoint in interface:
            if endpoint.bEndpointAddress & usb.util.ENDPOINT_IN:
                ep_in = endpoint
github XIVN1987 / DAPCmdr / pyocd / probe / pydapaccess / dap_access_api.py View on Github external
def __init__(self, faultAddress=None):
            super(DAPAccessIntf.TransferFaultError, self).__init__(faultAddress)
            self._address = faultAddress
github mbedmicro / pyOCD / pyocd / probe / pydapaccess / cmsis_dap_core.py View on Github external
def jtag_id_code(self, index=0):
        cmd = []
        cmd.append(Command.DAP_JTAG_IDCODE)
        cmd.append(index)
        self.interface.write(cmd)

        resp = self.interface.read()
        if resp[0] != Command.DAP_JTAG_IDCODE:
            # Response is to a different command
            raise DAPAccessIntf.DeviceError()

        if resp[1] != DAP_OK:
            # Operation failed
            raise DAPAccessIntf.CommandError()

        return  (resp[2] << 0) | \
                (resp[3] << 8) | \
                (resp[4] << 16) | \
                (resp[5] << 24)
github mbedmicro / pyOCD / pyocd / probe / pydapaccess / dap_access_cmsis_dap.py View on Github external
def _abort_all_transfers(self, exception):
        """! @brief Abort any ongoing transfers and clear all buffers
        """
        pending_reads = len(self._commands_to_read)
        # invalidate _transfer_list
        for transfer in self._transfer_list:
            transfer.add_error(exception)
        # clear all deferred buffers
        self._init_deferred_buffers()
        # finish all pending reads and ignore the data
        # Only do this if the error is a tranfer error.
        # Otherwise this could cause another exception
        if isinstance(exception, DAPAccessIntf.TransferError):
            for _ in range(pending_reads):
                self._interface.read()