From 5192df2d2b9e6b2d2d612f62390d4689b418d37d Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Fri, 23 Aug 2024 16:47:26 +0200 Subject: [PATCH] [reassembler] libacars: finish json mode --- iridiumtk/reassembler/sbd.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/iridiumtk/reassembler/sbd.py b/iridiumtk/reassembler/sbd.py index 41389b9..3633be0 100755 --- a/iridiumtk/reassembler/sbd.py +++ b/iridiumtk/reassembler/sbd.py @@ -437,6 +437,9 @@ class ReassembleIDASBDlibACARS(ReassembleIDASBD): def __init__(self): global libacars, la_msg_dir from libacars import libacars, la_msg_dir + if 'json' in config.args: + global json + import json super().__init__() def consume_l2(self, q): @@ -459,11 +462,21 @@ def consume_l2(self, q): if o.is_ping() and 'nopings' in config.args: return + q.timestamp = dt.epoch(q.time).isoformat(timespec='seconds') + if 'json' in config.args: - print(o.json()) + out = {} + + out['app'] = { 'name': 'iridium-toolkit', 'version': '0.0.2' } + out['source'] = { 'transport': 'iridium', 'parser': 'libacars', 'version': libacars.version } + out['timestamp'] = q.timestamp + out['link_direction'] = 'uplink' if q.ul else 'downlink' + if config.station: + out['source']['station_id'] = config.station + out['acars']=json.loads(o.json())['acars'] + print(json.dumps(out), file=outfile) return - q.timestamp = dt.epoch(q.time).isoformat(timespec='seconds') print(q.timestamp, end=" ") if q.ul: