Ejemplo n.º 1
0
def add_subparser(subparsers):
    subparser = subparsers.add_parser('publish',
                                      description='Publish given topic.')
    subparser.add_argument('--host',
                           default='localhost',
                           help='Broker host (default: %(default)s).')
    subparser.add_argument('--port',
                           type=Integer(0),
                           default=1883,
                           help='Broker port (default: %(default)s).')
    subparser.add_argument('--client-id',
                           help='Client id (default: mqttools-<UUID[0..14]>).')
    subparser.add_argument(
        '--count',
        type=Integer(0),
        default=1,
        help='Number of times to publish the message (default: %(default)s).')
    subparser.add_argument(
        '--size',
        type=Integer(0),
        default=10,
        help='Generated message size (default: %(default)s).')
    subparser.add_argument('--retain',
                           action='store_true',
                           help='Retain the message.')
    subparser.add_argument('--will-topic', help='Will topic.')
    subparser.add_argument('--will-message', help='Will message.')
    subparser.add_argument('--will-retain',
                           action='store_true',
                           help='Retain the will message.')
    subparser.add_argument(
        '--session-expiry-interval',
        type=Integer(0, 0xffffffff),
        default=0,
        help=
        'Session expiry interval in the range 0..0xffffffff (default: %(default)s).'
    )
    subparser.add_argument('--message-format',
                           choices=('auto', 'binary', 'text'),
                           default='auto',
                           help='Message format (default: %(default)s).')
    subparser.add_argument('--cafile', default='', help='CA file.')
    subparser.add_argument('--no-check-hostname',
                           action='store_true',
                           help='Do not check certificate hostname.')
    subparser.add_argument('topic', help='Topic to publish.')
    subparser.add_argument(
        'message',
        nargs='?',
        help='Message to publish (default: <counter>\xa5...')
    subparser.set_defaults(func=_do_publish)
Ejemplo n.º 2
0
def add_subparser(subparsers):
    decode_parser = subparsers.add_parser(
        'decode',
        description=('Decode "candump" CAN frames read from standard input '
                     'and print them in a human readable format.'))
    decode_parser.add_argument(
        '-c',
        '--no-decode-choices',
        action='store_true',
        help='Do not convert scaled values to choice strings.')
    decode_parser.add_argument(
        '-s',
        '--single-line',
        action='store_true',
        help='Print the decoded message on a single line.')
    decode_parser.add_argument('-e', '--encoding', help='File encoding.')
    decode_parser.add_argument('--no-strict',
                               action='store_true',
                               help='Skip database consistency checks.')
    decode_parser.add_argument(
        '-m',
        '--frame-id-mask',
        type=Integer(0),
        help=('Only compare selected frame id bits to find the message in the '
              'database. By default the candump and database frame ids must '
              'be equal for a match.'))
    decode_parser.add_argument('database', help='Database file.')
    decode_parser.set_defaults(func=_do_decode)
Ejemplo n.º 3
0
def add_subparser(subparsers):
    monitor_parser = subparsers.add_parser(
        'monitor',
        description='Monitor CAN bus traffic in a text based user interface.')
    monitor_parser.add_argument(
        '-s',
        '--single-line',
        action='store_true',
        help='Print the decoded message on a single line.')
    monitor_parser.add_argument('-e', '--encoding', help='File encoding.')
    monitor_parser.add_argument('--no-strict',
                                action='store_true',
                                help='Skip database consistency checks.')
    monitor_parser.add_argument(
        '-m',
        '--frame-id-mask',
        type=Integer(0),
        help=('Only compare selected frame id bits to find the message in the '
              'database. By default the received and database frame ids must '
              'be equal for a match.'))
    monitor_parser.add_argument(
        '-b',
        '--bus-type',
        default='socketcan',
        help='Python CAN bus type (default: socketcan).')
    monitor_parser.add_argument(
        '-c',
        '--channel',
        default='vcan0',
        help='Python CAN bus channel (default: vcan0).')
    monitor_parser.add_argument('-B',
                                '--bit-rate',
                                help='Python CAN bus bit rate.')
    monitor_parser.add_argument('database', help='Database file.')
    monitor_parser.set_defaults(func=_do_monitor)
Ejemplo n.º 4
0
def add_subparser(subparsers):
    subparser = subparsers.add_parser('monitor',
                                      description='Monitor given topics.')
    subparser.add_argument('--host',
                           default='localhost',
                           help='Broker host (default: %(default)s).')
    subparser.add_argument('--port',
                           type=Integer(0),
                           default=1883,
                           help='Broker port (default: %(default)s).')
    subparser.add_argument('--client-id',
                           help='Client id (default: mqttools-<UUID[0..14]>).')
    subparser.add_argument('--keep-alive',
                           type=Integer(0),
                           default=0,
                           help=('Keep alive time in seconds (default: '
                                 '%(default)s). Give as 0 to disable keep '
                                 'alive.'))
    subparser.add_argument(
        '--session-expiry-interval',
        default=0,
        type=Integer(0, 0xffffffff),
        help='Session expiry interval in the range 0..0xffffffff (default: %(default)s).')
    subparser.add_argument(
        '--cafile',
        default='',
        help='CA file.')
    subparser.add_argument(
        '--no-check-hostname',
        action='store_true',
        help='Do not check certificate hostname.')
    subparser.add_argument(
        '--retain-handling',
        type=Integer(0, 2),
        default=[],
        action='append',
        help=('Retain handling for the subscriptions. May be given once for each '
              'subscription. Last known value is used for remaining topics '
              '(default: 0).'))
    subparser.add_argument(
        'subscribe',
        nargs='+',
        help='Subscribe to given topic(s) <topic>.')
    subparser.set_defaults(func=_do_monitor)
Ejemplo n.º 5
0
def add_subparser(subparsers):
    subparser = subparsers.add_parser('subscribe',
                                      description='Subscribe for given topic.')
    subparser.add_argument('--host',
                           default='localhost',
                           help='Broker host (default: %(default)s).')
    subparser.add_argument('--port',
                           type=Integer(0),
                           default=1883,
                           help='Broker port (default: %(default)s).')
    subparser.add_argument('--client-id',
                           help='Client id (default: mqttools-<UUID[0..14]>).')
    subparser.add_argument(
        '--keep-alive',
        type=Integer(0),
        default=0,
        help=(
            'Keep alive time in seconds (default: %(default)s). Give as 0 to '
            'disable keep alive.'))
    subparser.add_argument(
        '--session-expiry-interval',
        default=0,
        type=Integer(0, 0xffffffff),
        help=
        'Session expiry interval in the range 0..0xffffffff (default: %(default)s).'
    )
    subparser.add_argument(
        '--retain-handling',
        type=Integer(0, 2),
        default=0,
        help='Retain handling for the subscriptions (default: %(default)s).')
    subparser.add_argument('--message-format',
                           choices=('auto', 'binary', 'text'),
                           default='auto',
                           help='Message format (default: %(default)s).')
    subparser.add_argument('--cafile', default='', help='CA file.')
    subparser.add_argument('--no-check-hostname',
                           action='store_true',
                           help='Do not check certificate hostname.')
    subparser.add_argument('topic', help='Topic to subscribe for.')
    subparser.set_defaults(func=_do_subscribe)
Ejemplo n.º 6
0
def add_subparser(subparsers):
    subparser = subparsers.add_parser('broker', description='A simple broker.')
    subparser.add_argument('--host',
                           default='localhost',
                           help="Broker host (default: %(default)s).")
    subparser.add_argument('--port',
                           type=Integer(0),
                           default=1883,
                           help='Broker port (default: %(default)s).')
    subparser.add_argument('--secure-port',
                           type=Integer(0),
                           default=8883,
                           help='Secure broker port (default: %(default)s).')
    subparser.add_argument('--cafile', default='', help='CA file.')
    subparser.add_argument('--certfile',
                           default='',
                           help='MQTT broker certificate file.')
    subparser.add_argument('--keyfile',
                           default='',
                           help='MQTT broker key file.')
    subparser.add_argument('--no-check-hostname',
                           action='store_true',
                           help='Do not check certificate hostname.')
    subparser.set_defaults(func=_do_broker)
Ejemplo n.º 7
0
def add_subparser(subparsers):
    '''
    Is called from ../__init__.py.
    It adds the options for this subprogram to the argparse parser.
    It sets the entry point for this subprogram by setting a default values for func.
    '''
    decode_parser = subparsers.add_parser(
        'plot',
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)
    decode_parser.add_argument(
        '-c',
        '--no-decode-choices',
        action='store_true',
        help='Do not convert scaled values to choice strings.')
    decode_parser.add_argument('-e',
                               '--encoding',
                               help='File encoding of dbc file.')
    decode_parser.add_argument('--no-strict',
                               action='store_true',
                               help='Skip database consistency checks.')
    decode_parser.add_argument(
        '-m',
        '--frame-id-mask',
        type=Integer(0),
        help=('Only compare selected frame id bits to find the message in the '
              'database. By default the candump and database frame ids must '
              'be equal for a match.'))
    decode_parser.add_argument('-I',
                               '--case-sensitive',
                               action='store_true',
                               help='Match the signal names case sensitive.')
    decode_parser.add_argument(
        '-l',
        '--line-numbers',
        action='store_true',
        help=
        'Use line numbers instead of time stamps on the horizontal axis (useful with `candump -td`).'
    )
    decode_parser.add_argument(
        '-t',
        '--break-time',
        default=100,
        type=float,
        help=
        ('If the time distance between two consecutive signals is longer than this value '
         'the line in the plot will be interrupted. The value is given in seconds '
         '(if timestamps are used) or input lines (if line numbers are used). '
         '-1 means infinite. '))

    decode_parser.add_argument(
        '--show-invalid-syntax',
        action='store_true',
        help=
        'Show a marker for lines which could not be parsed. This implies -l.')
    decode_parser.add_argument(
        '--show-unknown-frames',
        action='store_true',
        help=
        'Show a marker for messages which are not contained in the database file.'
    )
    decode_parser.add_argument(
        '--show-invalid-data',
        action='store_true',
        help='Show a marker for messages with data which could not be parsed.')
    decode_parser.add_argument(
        '-s',
        '--show-errors',
        action='store_true',
        help=
        'Show all error messages in the plot. This is an abbreviation for all --show-* options. This implies -l.'
    )

    decode_parser.add_argument(
        '--ignore-invalid-syntax',
        action='store_true',
        help=
        'Don\'t print an error message for lines which could not be parsed.')
    decode_parser.add_argument(
        '--ignore-unknown-frames',
        action='store_true',
        help=
        'Don\'t print an error message for messages which are not contained in the database file.'
    )
    decode_parser.add_argument(
        '--ignore-invalid-data',
        action='store_true',
        help=
        'Don\'t print an error message for messages with data which could not be parsed.'
    )
    decode_parser.add_argument(
        '-q',
        '--quiet',
        action='store_true',
        help=
        'Don\'t print any error messages. This is an abbreviation for all --ignore-* options.'
    )

    decode_parser.add_argument(
        '-o',
        '--output-file',
        help='A file to write the plot to instead of displaying it in a window.'
    )

    decode_parser.add_argument('database', help='Database file.')
    decode_parser.add_argument('signals',
                               nargs='*',
                               help='The signals to be plotted.')
    decode_parser.set_defaults(func=_do_decode)
Ejemplo n.º 8
0
def add_subparser(subparsers):
    '''
    Is called from ../__init__.py.
    It adds the options for this subprogram to the argparse parser.
    It sets the entry point for this subprogram by setting a default values for func.
    '''
    decode_parser = subparsers.add_parser(
        'plot',
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)
    decode_parser.add_argument(
        '-c',
        '--no-decode-choices',
        action='store_true',
        help='Do not convert scaled values to choice strings.')
    decode_parser.add_argument('-e',
                               '--encoding',
                               help='File encoding of dbc file.')
    decode_parser.add_argument('--no-strict',
                               action='store_true',
                               help='Skip database consistency checks.')
    decode_parser.add_argument(
        '-m',
        '--frame-id-mask',
        type=Integer(0),
        help=('Only compare selected frame id bits to find the message in the '
              'database. By default the candump and database frame ids must '
              'be equal for a match.'))
    decode_parser.add_argument('-I',
                               '--case-sensitive',
                               action='store_true',
                               help='Match the signal names case sensitive.')
    decode_parser.add_argument(
        '-l',
        '--line-numbers',
        action='store_true',
        help=
        'Use line numbers instead of time stamps on the horizontal axis (useful with `candump -td`).'
    )
    decode_parser.add_argument(
        '-t',
        '--break-time',
        default=100,
        type=float,
        help=
        ('If the time distance between two consecutive signals is longer than this value '
         'the line in the plot will be interrupted. The value is given in seconds '
         '(if timestamps are used) or input lines (if line numbers are used). '
         '-1 means infinite. '))

    decode_parser.add_argument(
        '--show-invalid-syntax',
        action='store_true',
        help=
        'Show a marker for lines which could not be parsed. This implies -l.')
    decode_parser.add_argument(
        '--show-unknown-frames',
        action='store_true',
        help=
        'Show a marker for messages which are not contained in the database file.'
    )
    decode_parser.add_argument(
        '--show-invalid-data',
        action='store_true',
        help='Show a marker for messages with data which could not be parsed.')
    decode_parser.add_argument(
        '-s',
        '--show-errors',
        action='store_true',
        help=
        'Show all error messages in the plot. This is an abbreviation for all --show-* options. This implies -l.'
    )

    decode_parser.add_argument(
        '--ignore-invalid-syntax',
        action='store_true',
        help=
        'Don\'t print an error message for lines which could not be parsed.')
    decode_parser.add_argument(
        '--ignore-unknown-frames',
        action='store_true',
        help=
        'Don\'t print an error message for messages which are not contained in the database file.'
    )
    decode_parser.add_argument(
        '--ignore-invalid-data',
        action='store_true',
        help=
        'Don\'t print an error message for messages with data which could not be parsed.'
    )
    decode_parser.add_argument(
        '-q',
        '--quiet',
        action='store_true',
        help=
        'Don\'t print any error messages. This is an abbreviation for all --ignore-* options.'
    )

    decode_parser.add_argument(
        '-o',
        '--output-file',
        help='A file to write the plot to instead of displaying it in a window.'
    )

    decode_parser.add_argument(
        '-ss',
        '--start',
        help='A start time or line number. Everything before is ignored. '
        'This filters the lines/messages to be processed. It does *not* set the minimum value of the x-axis.'
    )
    decode_parser.add_argument(
        '-to',
        '--stop',
        help='An end time or line number. Everything after is ignored. '
        'This filters the lines/messages to be processed. It does *not* set the maximum value of the x-axis.'
    )

    decode_parser.add_argument('--style',
                               help='The matplotlib style to be used.')
    decode_parser.add_argument(
        '--list-styles',
        action='store_true',
        help='Print all available matplotlib styles without drawing a plot.')
    decode_parser.add_argument(
        '-ac',
        '--auto-color-ylabels',
        action='store_true',
        help=
        'This is equivalent to applying --color C0 to the first y-axis, --color C1 to the second and so on.'
    )

    decode_parser.add_argument('database', help='Database file.')
    decode_parser.add_argument('signals',
                               nargs='*',
                               help='The signals to be plotted.')
    decode_parser.set_defaults(func=_do_decode)

    subplot_arggroup = decode_parser.add_argument_group(
        'subplot arguments', '''\
The following options can be used to configure the subplots/axes.
If they shall apply to a specific subplot/axis they must be placed among the signals for that subplot/axis and a -- must mark the end of the global optional arguments.
Otherwise they are used as default value for each subplot/axis.
''')
    add_subplot_options(subplot_arggroup)