当前位置: 首页>>代码示例>>Python>>正文


Python MbedBoard.getAllConnectedBoards方法代码示例

本文整理汇总了Python中pyOCD.board.MbedBoard.getAllConnectedBoards方法的典型用法代码示例。如果您正苦于以下问题:Python MbedBoard.getAllConnectedBoards方法的具体用法?Python MbedBoard.getAllConnectedBoards怎么用?Python MbedBoard.getAllConnectedBoards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyOCD.board.MbedBoard的用法示例。


在下文中一共展示了MbedBoard.getAllConnectedBoards方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list_boards

# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import getAllConnectedBoards [as 别名]
    def list_boards(self):
        self.disable_logging()

        try:
            all_mbeds = MbedBoard.getAllConnectedBoards(close=True, blocking=False)
            status = 0
            error = ""
        except Exception as e:
            all_mbeds = []
            status = 1
            error = str(e)
            if not self.args.output_json:
                raise

        if self.args.output_json:
            boards = []
            obj = {
                'pyocd_version' : __version__,
                'version' : { 'major' : 1, 'minor' : 0 },
                'status' : status,
                'boards' : boards,
                }

            if status != 0:
                obj['error'] = error

            for mbed in all_mbeds:
                d = {
                    'unique_id' : mbed.unique_id,
                    'info' : mbed.getInfo(),
                    'board_name' : mbed.getBoardName(),
                    'target' : mbed.getTargetType(),
                    'vendor_name' : '',
                    'product_name' : '',
                    }

                # Reopen the link so we can access the USB vendor and product names from the inteface.
                # If it's not a USB based link, then we don't attempt this.
                if isinstance(mbed.link, DAPAccessUSB):
                    try:
                        mbed.link.open()
                        d['vendor_name'] = mbed.link._interface.vendor_name
                        d['product_name'] = mbed.link._interface.product_name
                        mbed.link.close()
                    except Exception:
                        pass
                boards.append(d)

            print json.dumps(obj, indent=4) #, sys.stdout)
        else:
            index = 0
            if len(all_mbeds) > 0:
                for mbed in all_mbeds:
                    print("%d => %s boardId => %s" % (index, mbed.getInfo().encode('ascii', 'ignore'), mbed.unique_id))
                    index += 1
            else:
                print("No available boards are connected")
开发者ID:CobooGuo,项目名称:pyOCD,代码行数:59,代码来源:gdb_server.py

示例2: main

# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import getAllConnectedBoards [as 别名]
def main():
    log_file = "automated_test_result.txt"
    summary_file = "automated_test_summary.txt"

    parser = argparse.ArgumentParser(description='pyOCD automated testing')
    parser.add_argument('-d', '--debug',
                        action="store_true", help='Enable debug logging')
    args = parser.parse_args()

    # Setup logging
    if os.path.exists(log_file):
        os.remove(log_file)
    level = logging.DEBUG if args.debug else logging.INFO
    logging.basicConfig(level=level)
    logger = Logger(log_file)
    sys.stdout = logger
    sys.stderr = logger

    test_list = []
    board_list = []
    result_list = []

    # Put together list of tests
    test = Test("Basic Test", lambda board: basic_test(board, None))
    test_list.append(test)
    test_list.append(GdbServerJsonTest())
    test_list.append(SpeedTest())
    test_list.append(CortexTest())
    test_list.append(FlashTest())
    test_list.append(GdbTest())

    # Put together list of boards to test
    board_list = MbedBoard.getAllConnectedBoards(close=True, blocking=False)

    start = time()
    for board in board_list:
        print("--------------------------")
        print("TESTING BOARD %s" % board.getUniqueID())
        print("--------------------------")
        for test in test_list:
            test_start = time()
            result = test.run(board)
            test_stop = time()
            result.time = test_stop - test_start
            result_list.append(result)
    stop = time()
    test_time = (stop - start)

    print_summary(test_list, result_list, test_time)
    with open(summary_file, "wb") as output_file:
        print_summary(test_list, result_list, test_time, output_file)

    exit_val = 0 if Test.all_tests_pass(result_list) else -1
    exit(exit_val)
开发者ID:0xc0170,项目名称:pyOCD,代码行数:56,代码来源:automated_test.py

示例3: list_boards

# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import getAllConnectedBoards [as 别名]
    def list_boards(self):
        self.disable_logging()

        try:
            all_mbeds = MbedBoard.getAllConnectedBoards(close=True, blocking=False)
            status = 0
            error = ""
        except Exception as e:
            all_mbeds = []
            status = 1
            error = str(e)
            if not self.args.output_json:
                raise

        if self.args.output_json:
            boards = []
            obj = {
                'pyocd_version' : __version__,
                'version' : { 'major' : 1, 'minor' : 0 },
                'status' : status,
                'boards' : boards,
                }

            if status != 0:
                obj['error'] = error

            for mbed in all_mbeds:
                d = {
                    'unique_id' : mbed.unique_id,
                    'info' : mbed.getInfo(),
                    'board_name' : mbed.getBoardName(),
                    'target' : mbed.getTargetType(),
                    'vendor_name' : mbed.interface.vendor_name,
                    'product_name' : mbed.interface.product_name,
                    }
                boards.append(d)

            print json.dumps(obj, indent=4) #, sys.stdout)
        else:
            index = 0
            if len(all_mbeds) > 0:
                for mbed in all_mbeds:
                    print("%d => %s boardId => %s" % (index, mbed.getInfo().encode('ascii', 'ignore'), mbed.unique_id))
                    index += 1
            else:
                print("No available boards are connected")
开发者ID:oliviermartin,项目名称:pyOCD,代码行数:48,代码来源:gdb_server.py

示例4: validate_boards

# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import getAllConnectedBoards [as 别名]
    def validate_boards(data):
        did_pass = True

        print 'boards',
        p = data.has_key('boards') and type(data['boards']) is list
        if p:
            b = data['boards']
        if p:
            print "PASSED"
        else:
            did_pass = False
            print"FAILED"

        try:
            all_mbeds = MbedBoard.getAllConnectedBoards(close=True, blocking=False)
            p = len(all_mbeds) == len(b)
            matching_boards = 0
            if p:
                for mbed in all_mbeds:
                    for brd in b:
                        if mbed.unique_id == brd['unique_id']:
                            matching_boards += 1
                            p = brd.has_key('info') and brd.has_key('target') and brd.has_key('board_name')
                            if not p:
                                break
                    if not p:
                        break
                p = matching_boards == len(all_mbeds)
            if p:
                print "PASSED"
            else:
                did_pass = False
                print"FAILED"
        except Exception:
            print "FAILED"
            did_pass = False

        return did_pass
开发者ID:0xc0170,项目名称:pyOCD,代码行数:40,代码来源:gdb_server_json_test.py

示例5: Test

# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import getAllConnectedBoards [as 别名]
    sys.stderr = logger

    test_list = []
    board_list = []
    result_list = []

    # Put together list of tests
    test = Test("Basic Test", lambda board: basic_test(board, None))
    test_list.append(test)
    test_list.append(SpeedTest())
    test_list.append(CortexTest())
    test_list.append(FlashTest())
    test_list.append(GdbTest())

    # Put together list of boards to test
    board_list = MbedBoard.getAllConnectedBoards(close=True, blocking=False)

    start = time()
    for board in board_list:
        print("--------------------------")
        print("TESTING BOARD %s" % board.getUniqueID())
        print("--------------------------")
        for test in test_list:
            test_start = time()
            result = test.run(board)
            test_stop = time()
            result.time = test_stop - test_start
            result_list.append(result)
    stop = time()

    for test in test_list:
开发者ID:oliviermartin,项目名称:pyOCD,代码行数:33,代码来源:automated_test.py

示例6: FIRMWARE

# 需要导入模块: from pyOCD.board import MbedBoard [as 别名]
# 或者: from pyOCD.board.MbedBoard import getAllConnectedBoards [as 别名]
if __name__ == '__main__' :
    parser = argparse.ArgumentParser(description = "flash a board with sender or reciever code")
    parser.add_argument('firmware', type=str, nargs='*', metavar='FIRMWARE'
                        , help='flash FIRMWARE to marked BOARDS')
    parser.add_argument('-m', '--mark', type=str,  metavar='BOARD'
                        , help='mark BOARD to be flashed by only the FIRMWARE (fails if more than one FIRMWARE is provided)')
    parser.add_argument('-c', '--config', type=createWriteableFile
                        , metavar='CONFIG', help='CONFIG file to use'
                        , default='.board-config.json')
    parser.add_argument('-l', '--list', action='store_true'
                        , help='list all connected boards')
    parser.add_argument
    args = parser.parse_args()
    if args.list :
        for board in MbedBoard.getAllConnectedBoards() :
            print("{} ID: {}".format(board.getTargetType(),board.getUniqueID()))
        exit(0)

    if args.mark is not None and len(args.firmware) != 1:
        print("ERROR: you must provide exactly one FIRMWARE when marking a BOARD")
        exit(1)

    try:
        config = json.load(args.config)
    except ValueError:
        print("WARNING: configuration file corrupted; creating a new empty one")
        config = {}
    except IOError:
        print("INFO: board configuration file not found; creating a new empty one")
        config = {}
开发者ID:ut-ras,项目名称:magi,代码行数:32,代码来源:flash-boards.py


注:本文中的pyOCD.board.MbedBoard.getAllConnectedBoards方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。