Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACARS JSON in libacars mode #125

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions iridiumtk/reassembler/sbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,38 @@ def consume_l2(self, q):

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']
out['acars']['timestamp'] = q.timestamp
out['acars']['link_direction'] = 'uplink' if q.ul else 'downlink'
out['acars']['errors'] = int(out["acars"]["err"] == 'true')

for key in ('reg:tail', 'label', 'blk_id:block_id', 'msg_num_seq:message_number', 'ack', 'msg_text:text', 'more:block_end'):
old, _, new = key.partition(':')
if new == '': new = old
if old in out['acars'].keys():
val = out['acars'][old]
if isinstance(val, bytes):
val = val.decode('ascii')
if old == 'label':
val = val.replace('_\u007f', '_d')
if old == 'ack':
val = val.replace('\u0015', '!')
if old == 'reg':
while len(val)>0 and val[0:1]=='.':
val = val[1:]
if old == 'more':
val = not val
out['acars'][new] = val

out['freq'] = self.ofreq
out['level'] = self.olevel
if q.data[1] == 0x3:
out['header'] = q.data[1:9].hex()
else:
out['header'] = ""

print(json.dumps(out), file=self.outfile)
return

Expand Down
Empty file modified iridiumtk/reassembler/tdoa.py
100755 → 100644
Empty file.