Skip to content

Commit f6b66b5

Browse files
committed
Improve support for generating config telemetry dictionary
1 parent d90c7fc commit f6b66b5

5 files changed

Lines changed: 26 additions & 6 deletions

File tree

poly-xdrgen

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ from polyxdr.parser import *
99
def main():
1010
parser = argparse.ArgumentParser(description='XDR compiler')
1111
parser.add_argument("input", metavar="FILE", type=argparse.FileType('r'), help="Input file")
12-
parser.add_argument("--target", "-t", required=True, choices=["python", "xp","libproc", "telem-dict"], help="Target language")
12+
parser.add_argument("--target", "-t", required=True, choices=["python", "xp","libproc", "telem-dict", "datalogger"], help="Target language")
1313
parser.add_argument("--output", "-o", metavar="PATH", help="Output directory")
1414

1515
args = parser.parse_args()
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<SENSOR>
22
KEY=${key}
3-
UNIT=${unit}
4-
NAME=${name}
3+
UNITS=${doc.unit}
4+
NAME=${doc.name}
55
DESCRIPTION=${doc.description}
6+
LOCATION=${doc.location}
7+
SUBSYSTEM=${doc.subsystem}
8+
DIVISOR=${doc.divisor}
9+
OFFSET=${doc.offset}
610
</SENSOR>

polyxdr/ir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
XDRUnion = namedtuple("XDRUnion", ["name", "discriminant", "members"])
1717
XDRUnionMember = namedtuple("XDRUnionMember", ["case", "declaration"])
1818
XDRNamespace = namedtuple("XDRNamespace", ["name"])
19-
XDRFieldDocumentation = namedtuple("XDRFieldDocs", ["key", "name", "description", "offset", "divisor", "conversion", "inverse", "unit", "computed_by", "true_label", "false_label"])
19+
XDRFieldDocumentation = namedtuple("XDRFieldDocs", ["key", "name", "description", "offset", "divisor", "conversion", "inverse", "unit", "computed_by", "true_label", "false_label", "location", "subsystem", "group"])
2020
XDRCommand = namedtuple("XDRCommand", ["name", "id", "summary", "param", "response", "types", "autoname"])
2121
XDRError = namedtuple("XDRError", ["id", "name", "description"])
2222

polyxdr/parser.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ def __init__(self, filename, parentParser):
185185
P.Optional(g(kw("divisor") + decimal_literal + s(";"))) & \
186186
P.Optional(g(kw("offset") + decimal_literal + s(";"))) & \
187187
P.Optional(g(kw("description") + P.QuotedString('"') + s(";"))) & \
188+
P.Optional(g(kw("location") + P.QuotedString('"') + s(";"))) & \
189+
P.Optional(g(kw("subsystem") + P.QuotedString('"') + s(";"))) & \
190+
P.Optional(g(kw("group") + P.QuotedString('"') + s(";"))) & \
188191
P.Optional(g(kw("true_label") + P.QuotedString('"') + s(";"))) & \
189192
P.Optional(g(kw("false_label") + P.QuotedString('"') + s(";"))) \
190193
) + s("}")
@@ -282,6 +285,9 @@ def xdr_parse_fielddoc(self, x):
282285
offset = 0
283286
true_label = ''
284287
false_label = ''
288+
location = ''
289+
subsystem = ''
290+
group = ''
285291
for field in x:
286292
if field[0] == 'key':
287293
key = field[1]
@@ -303,15 +309,23 @@ def xdr_parse_fielddoc(self, x):
303309
inv = self.stringify_conversion(field[1])
304310
if field[0] == 'computed_by':
305311
computed = self.stringify_conversion(field[1])
312+
if field[0] == 'location':
313+
location = field[1]
314+
if field[0] == 'subsystem':
315+
subsystem = field[1]
306316
if field[0] == 'true_label':
307317
true_label = field[1]
308318
if field[0] == 'false_label':
309319
false_label = field[1]
310-
return XDRFieldDocumentation(key, name, desc, offset, divisor, conv, inv, unit, computed, true_label, false_label)
320+
if subsystem == '' and group != '':
321+
subsystem = group
322+
if group == '' and subsystem != '':
323+
group = subsystem
324+
return XDRFieldDocumentation(key, name, desc, offset, divisor, conv, inv, unit, computed, true_label, false_label, location, subsystem, group)
311325

312326
def xdr_parse_declaration(self, x):
313327
if x[0] == 'void':
314-
return XDRDeclaration(None, 'basic', 'void', None, None, True, XDRFieldDocumentation('', '', '', 0, 1, '', '', '', '', '', ''), 0, 'void')
328+
return XDRDeclaration(None, 'basic', 'void', None, None, True, XDRFieldDocumentation('', '', '', 0, 1, '', '', '', '', '', '', '', '', ''), 0, 'void')
315329
elif x[0] == 'opaque' or x[0] == 'string':
316330
type = x[0]
317331
name = x[1]

tests/xp_schema.xp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ struct Status {
8989
key mag_y;
9090
unit "rad/s";
9191
description "y value of mag reading";
92+
location "systemboard";
93+
subsystem "adcs";
9294
};
9395
int mag_z {
9496
name "Magnetometer Z value";

0 commit comments

Comments
 (0)