-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadsb-decoder.py
More file actions
executable file
·42 lines (26 loc) · 849 Bytes
/
adsb-decoder.py
File metadata and controls
executable file
·42 lines (26 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python2
__author__ = 'Oliver Maskery'
import logging
import signal
import adsb
import json
def main():
logging.basicConfig()
client = AdsbDecoderClient()
client.enable_tx_channel('adsb_decoded', 'fanout')
client.enable_rx_channel('adsb_raw', 'fanout')
signal.signal(signal.SIGINT, client.handle_sigint)
client.consume_in_worker()
print("exiting")
class AdsbDecoderClient(adsb.Client):
def __init__(self):
adsb.Client.__init__(self)
def handle_received(self, message):
raw_message = json.loads(message)
decoded = adsb.Message.from_encoded(raw_message)
print("DF: {} CA: {} ICAO: {:06X}".format(
decoded.type_description(), decoded.ca, decoded.icao
))
self.send_blob(decoded.to_json())
if __name__ == "__main__":
main()