Skip to content

Commit 5192df2

Browse files
committed
[reassembler] libacars: finish json mode
1 parent ab8cd55 commit 5192df2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

iridiumtk/reassembler/sbd.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ class ReassembleIDASBDlibACARS(ReassembleIDASBD):
437437
def __init__(self):
438438
global libacars, la_msg_dir
439439
from libacars import libacars, la_msg_dir
440+
if 'json' in config.args:
441+
global json
442+
import json
440443
super().__init__()
441444

442445
def consume_l2(self, q):
@@ -459,11 +462,21 @@ def consume_l2(self, q):
459462
if o.is_ping() and 'nopings' in config.args:
460463
return
461464

465+
q.timestamp = dt.epoch(q.time).isoformat(timespec='seconds')
466+
462467
if 'json' in config.args:
463-
print(o.json())
468+
out = {}
469+
470+
out['app'] = { 'name': 'iridium-toolkit', 'version': '0.0.2' }
471+
out['source'] = { 'transport': 'iridium', 'parser': 'libacars', 'version': libacars.version }
472+
out['timestamp'] = q.timestamp
473+
out['link_direction'] = 'uplink' if q.ul else 'downlink'
474+
if config.station:
475+
out['source']['station_id'] = config.station
476+
out['acars']=json.loads(o.json())['acars']
477+
print(json.dumps(out), file=outfile)
464478
return
465479

466-
q.timestamp = dt.epoch(q.time).isoformat(timespec='seconds')
467480
print(q.timestamp, end=" ")
468481

469482
if q.ul:

0 commit comments

Comments
 (0)