1
0
mirror of synced 2024-11-26 03:04:29 +01:00

Allow using the -f cmdline option to also extend the builtin library of existing protocol names

This commit is contained in:
David Mirabito 2018-07-04 14:25:10 +10:00
parent 1c1894d37d
commit df343dc373
2 changed files with 24 additions and 2 deletions

View File

@ -288,6 +288,13 @@
Multiple invocations of -f are allowed. Multiple invocations of -f are allowed.
Additionally, if a line contains a ';' character, the word to the left is
treated as a protocol name and text to the right is the corresponding
specification string. This allows users to build up a custom library of
protocol specifications, extending the list of built-in existing names.
Both forms may be intermixed in a single file.
0x05 - EXAMPLES 0x05 - EXAMPLES
@ -481,6 +488,16 @@
| uint32_t | | uint32_t |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bash-3.2$ cat mylib.txt
float;sign:1,exponent:8,significand:23
double;sign:1,exponent:11,significand:52?bits=64
$ protocol -f mylib.txt double
0 1 2 3 4 5 6
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|s| exponent | significand |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0x06 - CONTACT, SUPPORT AND BUG REPORTING 0x06 - CONTACT, SUPPORT AND BUG REPORTING

View File

@ -531,8 +531,13 @@ class Main():
continue continue
# If we have something else, treat it as a protocol spec # If we have something else, treat it as a protocol spec
proto=Protocol(line) if ';' in line:
self.protocols.append(proto) name = line.split(';')[0]
p = line.split(';')[1]
specs.protocols[name]=p
else:
proto=Protocol(line)
self.protocols.append(proto)
i+=1 i+=1
return i return i