sedbgmux-dump.py: allow limiting number of records to parse/convert
This commit is contained in:
parent
168ace9da5
commit
877015cf57
|
@ -20,6 +20,7 @@
|
|||
|
||||
import logging as log
|
||||
import argparse
|
||||
import math
|
||||
import sys
|
||||
|
||||
from sedbgmux.io import *
|
||||
|
@ -55,7 +56,7 @@ class SEDbgMuxDumpApp:
|
|||
def do_parse(self, argv):
|
||||
dump = self.FORMATS[argv.format][0](argv.input, readonly=True)
|
||||
num_records: int = 0
|
||||
while True:
|
||||
while num_records < argv.num_records:
|
||||
try:
|
||||
record: dict = dump.read()
|
||||
record['nr'] = num_records
|
||||
|
@ -68,7 +69,7 @@ class SEDbgMuxDumpApp:
|
|||
di = self.FORMATS[argv.input_format][0](argv.input, readonly=True)
|
||||
do = self.FORMATS[argv.output_format][0](argv.output, readonly=False)
|
||||
num_records: int = 0
|
||||
while True:
|
||||
while num_records < argv.num_records:
|
||||
try:
|
||||
record: dict = di.read()
|
||||
do.write(record)
|
||||
|
@ -115,6 +116,8 @@ parse.add_argument('-f', '--format', type=str, default='auto',
|
|||
help='input file format (default: %(default)s)')
|
||||
parse.add_argument('-dp', '--decode-payload', action='store_true',
|
||||
help='decode DebugMux frame contents')
|
||||
parse.add_argument('-nr', '--num-records', type=int, default=math.inf,
|
||||
help='number of records to parse (default: all)')
|
||||
parse.add_argument('--ignore-bad-fcs', action='store_true',
|
||||
help='do not abort parsing on FCS mismatch')
|
||||
|
||||
|
@ -129,6 +132,8 @@ convert.add_argument('-if', '--input-format', type=str, required=True,
|
|||
convert.add_argument('-of', '--output-format', type=str, required=True,
|
||||
choices=SEDbgMuxDumpApp.FORMATS.keys(),
|
||||
help='output file format')
|
||||
convert.add_argument('-nr', '--num-records', type=int, default=math.inf,
|
||||
help='number of records to convert (default: all)')
|
||||
|
||||
sp.add_parser('list-formats', help='list all supported formats')
|
||||
|
||||
|
|
Loading…
Reference in New Issue