-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python3 | ||
# YAML sniffer log TDOA2 decoder, generates a stream of YAML documents | ||
# containing the decoded packet | ||
# out of simplicity (and lazyness), reads from STDIN and write to STDOUT, | ||
# just use your shell piping functionalities! | ||
|
||
import sys | ||
import yaml | ||
import struct | ||
|
||
# Packet format: | ||
# NSLOTS = 8 | ||
# typedef struct rangePacket_s { | ||
# uint8_t type; | ||
# uint8_t seqs[NSLOTS]; // Packet sequence number of the timestamps | ||
# uint32_t timestamps[NSLOTS]; // Relevant time for anchors | ||
# uint16_t distances[NSLOTS]; | ||
# } __attribute__((packed)) rangePacket_t; | ||
|
||
for packet in yaml.load_all(sys.stdin, Loader=yaml.CLoader): | ||
if not packet: | ||
continue | ||
|
||
# Its alost free so we keel the raw data and just add the decoded fields | ||
packetType = packet["data"][0] | ||
|
||
if packetType == 34: | ||
decoded = struct.unpack("<BBBBBBBBBLLLLLLLLHHHHHHHH", packet["data"]) | ||
packet["type"] = decoded[0] | ||
if packet["type"] == 34: | ||
packet["seqs"] = list(decoded[1:9]) | ||
packet["timestamps"] = list(decoded[9:17]) | ||
packet["distances"] = list(decoded[17:25]) | ||
|
||
print("---") | ||
print(yaml.dump(packet, Dumper=yaml.CDumper)) |