Commit 00888d45 authored by Andreas Schmidt's avatar Andreas Schmidt

Add a method to automatically generate the capturing header for xlap.

parent 83a33a6f
......@@ -61,6 +61,9 @@ durations:
Start: StampC
Stop: StampD
Source: receiver
packet_types:
Data: 0
Ack: 1
```
* You can run a jitter analysis via `xlap jitter`. The parameter `-e` exports the diagrams as `pdf`.
......
......@@ -129,3 +129,6 @@ durations:
Start: DecodeStart
Stop: DecodeEnd
Source: receiver
packet_types:
Data: 0
Redundancy: 1
......@@ -4,7 +4,8 @@ from xlap.parse import evaluate, parse_config
import xlap.analyse.jitter as jitter
tasks = {
"jitter": None
"jitter": None,
"capture": None
}
......@@ -22,16 +23,33 @@ def main():
print("{} is not a known analysis task.".format(command))
continue
df_data = evaluate(data_files["sender"], data_files["receiver"], config=config, kind=0)
if command == "capture":
types = ",\n".join([" ts_{}_packet = {}".format(k.lower(),v) for k,v in config["packet_types"].items()])
params = {"export": args.export}
typedef = "typedef enum XlapTimestampPacketKind {{\n{}\n}} XlapTimestampPacketKind".format(types)
if command == "jitter":
params1 = dict(params)
params1.update({"file_name": "TraceJitter.pdf"})
params2 = dict(params)
params2.update({"file_name": "JitterCauses.pdf"})
timestamp = "#define TIMESTAMP_ID_LIST \\\n"
timestamp += ", \\\n".join([" " * 8 + x for x in config["stamps"].keys()])
df = jitter.prep(df_data, config)
jitter.trace_jitter(df, **params1)
jitter.jitter_causes(df, config["durations"], **params2)
output = "#ifndef {0}\n#define {0}\n\n{1}\n\n{2}\n\n#endif // {0}".format("XLAP_CAPTURE_H", typedef, timestamp)
if args.export:
with open("xlap_capture.h", "w") as f:
f.write(output)
f.write("\n")
else:
print(output)
else:
df_data = evaluate(data_files["sender"], data_files["receiver"], config=config, kind=0)
params = {"export": args.export}
if command == "jitter":
params1 = dict(params)
params1.update({"file_name": "TraceJitter.pdf"})
params2 = dict(params)
params2.update({"file_name": "JitterCauses.pdf"})
df = jitter.prep(df_data, config)
jitter.trace_jitter(df, **params1)
jitter.jitter_causes(df, config["durations"], **params2)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment