@staticmethod
    def chooseBoard(dap_class=DAPAccess, blocking=True, return_first=False,
                    board_id=None, target_override=None, frequency=1000000,
                    init_board=True):
        """
        Allow you to select a board among all boards connected
        """
        all_mbeds = MbedBoard.getAllConnectedBoards(dap_class, False, blocking,
                                                    target_override, frequency)

        # If a board ID is specified close all other boards
        if board_id != None:
            new_mbed_list = []
            for mbed in all_mbeds:
                if mbed.unique_id == (board_id):
                    new_mbed_list.append(mbed)
                else:
                    mbed.link.close()
            assert len(new_mbed_list) <= 1
            all_mbeds = new_mbed_list

        # Return if no boards are connected
        if all_mbeds == None or len(all_mbeds) <= 0:
            if board_id is None:
                print("No connected boards")
            else:
                print("Board %s is not connected" % board_id)
            return None # No boards to close so it is safe to return

        # Select first board and close others if True
        if return_first:
            for i in range(1, len(all_mbeds)):
                all_mbeds[i].link.close()
            all_mbeds = all_mbeds[0:1]

        # Ask use to select boards if there is more than 1 left
        if len(all_mbeds) > 1:
            index = 0
            print "id => usbinfo | boardname"
            for mbed in all_mbeds:
                print "%d => %s" % (index, mbed.getInfo().encode('ascii', 'ignore'))
                index += 1
            while True:
                print "input id num to choice your board want to connect"
                line = sys.stdin.readline()
                valid = False
                try:
                    ch = int(line)
                    valid = 0 <= ch < len(all_mbeds)
                except __HOLE__:
                    pass
                if not valid:
                    logging.info("BAD CHOICE: %s", line)
                    index = 0
                    for mbed in all_mbeds:
                        print "%d => %s" % (index, mbed.getInfo())
                        index += 1
                else:
                    break
            # close all others mbed connected
            for mbed in all_mbeds:
                if mbed != all_mbeds[ch]:
                    mbed.link.close()
            all_mbeds = all_mbeds[ch:ch + 1]

        assert len(all_mbeds) == 1
        mbed = all_mbeds[0]
        if init_board:
            try:
                mbed.init()
            except:
                mbed.link.close()
                raise
        return mbed
dataset/ETHPy150Open mbedmicro/pyOCD/pyOCD/board/mbed_board.py/MbedBoard.chooseBoard