Skip to content

Commit

Permalink
Add command line argument --message, minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmechnich committed Oct 13, 2022
1 parent 3fbc5e3 commit 9b5ddb1
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions p600_syxdump
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ if __name__ == "__main__":
"-d", "--debug", action="store_true", help="turn on debug output"
)
argparser.add_argument(
"-p", "--program", type=int, default=-1, help="filter for program number"
"-m",
"--message",
type=int,
default=-1,
help="select message number (default: all messages)",
)
argparser.add_argument(
"-p",
"--program",
type=int,
default=-1,
help="select program number (default: all programs)",
)
argparser.add_argument(
"infile",
Expand All @@ -28,7 +39,7 @@ if __name__ == "__main__":
print(f"File {args.infile} not found, exiting")
sys.exit(1)
if args.debug:
print("Reading from file {args.infile}", file=sys.stderr)
print(f"Reading from file {args.infile}", file=sys.stderr)
with open(args.infile, "rb") as f:
raw_data = f.read()
else:
Expand All @@ -42,9 +53,14 @@ if __name__ == "__main__":
print(f"Found {len(msgs)} messages")

for i, m in enumerate(msgs):
if args.message > -1 and i != args.message:
continue
parser = p600syx.factory.get_parser(m)
if not parser:
print(f"No suitable parser found for message {i}")
if args.debug:
print(repr(m), file=sys.stderr)
print()
continue
if args.debug:
print(f"Using {parser.name} for message {i}", file=sys.stderr)
Expand Down

0 comments on commit 9b5ddb1

Please sign in to comment.