Пример #1
0
def get_args():
    parser = get_argument_parser(description=__doc__)

    options_grp = parser.add_argument_group('Command options')
    options_grp.add_argument(
        '-i', '--id',
        dest='id',
        type=dmxl_id,
        help='the servo id',
        default=1
    )
    options_grp.add_argument(
        '-I', '--interface',
        dest='intf',
        action='store_true',
        help='''if used, command targets the interface instead of a servo
                       (-i ignored in this case)'''
    )
    action_grp = parser.add_mutually_exclusive_group(required=True)
    action_grp.add_argument(
        '-l', '--list',
        dest='list',
        action='store_true',
        help='list all registers names and ids'
    )
    action_grp.add_argument(
        '-a', '--all',
        dest='readall',
        action='store_true',
        help='display all registers'
    )
    action_grp.add_argument(
        '-r', '--read', dest='read',
        type=dmxl_regnum,
        help='the register to read',
    )
    action_grp.add_argument(
        '-w', '--write',
        dest='write',
        type=WriteStatement.check,
        help='register write statement (syntax: %s)' % WriteStatement.SYNTAX
    )

    args = parser.parse_args()

    # unify target identification
    if args.id == DynamixelBusInterface.INTERFACE_ID:
        args.intf = True
    elif args.intf:
        args.id = DynamixelBusInterface.INTERFACE_ID

    return args
Пример #2
0
def get_args():
    parser = get_argument_parser(description=__doc__)
    parser.add_argument(
        '-f', '--fromid',
        dest='from_id',
        type=int,
        help='start scan at this id',
        default=1
    )
    parser.add_argument(
        '-t', '--toid',
        dest='to_id',
        type=int,
        help='stop scan at this id',
        default=253
    )

    return parser.parse_args()