Beispiel #1
0
def get_connected_devices() -> ConnectedDevices:
    """Returns Mbed Devices connected to host computer.

    Connected devices which have been identified as Mbed Boards and also connected devices which are potentially
    Mbed Boards (but not could not be identified in the database) are returned.

    Raises:
        DeviceLookupFailed: If there is a problem with the process of identifying Mbed Boards from connected devices.
    """
    connected_devices = ConnectedDevices()

    board: Optional["Board"]
    for candidate_device in detect_candidate_devices():
        try:
            board = resolve_board(candidate_device)
        except NoBoardForCandidate:
            board = None
        except MbedTargetsError as err:
            raise DeviceLookupFailed(
                "A problem occurred when looking up board data for connected devices."
            ) from err

        connected_devices.add_device(candidate_device, board)

    return connected_devices
Beispiel #2
0
def get_connected_devices() -> ConnectedDevices:
    """Returns Mbed Devices connected to host computer.

    Connected devices which have been identified as Mbed Boards and also connected devices which are potentially
    Mbed Boards (but not could not be identified in the database) are returned.

    Raises:
        DeviceLookupFailed: If there is a problem with the process of identifying Mbed Boards from connected devices.
    """
    connected_devices = ConnectedDevices()

    board: Optional["Board"]
    for candidate_device in detect_candidate_devices():
        try:
            board = resolve_board(candidate_device)
        except NoBoardForCandidate:
            board = None
        except MbedTargetsError as err:
            raise DeviceLookupFailed(
                f"We found a potential connected device ({candidate_device!r}) but could not identify it as being "
                "Mbed enabled. This is because we couldn't find a known product code from the available data on your "
                "device. Check your device contains a valid HTM file with a product code, and that it is added as an "
                "Mbed enabled device on os.mbed.com.") from err

        connected_devices.add_device(candidate_device, board)

    return connected_devices
Beispiel #3
0
def get_connected_devices() -> ConnectedDevices:
    """Returns Mbed Devices connected to host computer.

    Connected devices which have been identified as Mbed Boards and also connected devices which are potentially
    Mbed Boards (but not could not be identified in the database) are returned.
    """
    connected_devices = ConnectedDevices()

    for candidate_device in detect_candidate_devices():
        device = Device.from_candidate(candidate_device)
        connected_devices.add_device(device)

    return connected_devices