forked from mutability/mlat-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfa-mlat-client
executable file
·54 lines (40 loc) · 1.77 KB
/
fa-mlat-client
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
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
# -*- mode: python; indent-tabs-mode: nil -*-
# FlightAware multilateration client
import argparse
import mlat.client.version
from flightaware.client.adeptclient import AdeptConnection, UdpServerConnection
from mlat.client.coordinator import Coordinator
from mlat.client.util import log, log_exc
from mlat.client import options
def main():
# piaware will timestamp our log messages itself, suppress the normal logging timestamps
mlat.client.util.suppress_log_timestamps = True
parser = argparse.ArgumentParser(description="Client for multilateration.")
options.make_inputs_group(parser)
options.make_results_group(parser)
parser.add_argument('--udp-transport',
help="Provide UDP transport information. Expects a host:port:key argument.",
required=True)
args = parser.parse_args()
log("fa-mlat-client {version} starting up", version=mlat.client.version.CLIENT_VERSION)
udp_host, udp_port, udp_key = args.udp_transport.split(':')
udp_port = int(udp_port)
udp_key = int(udp_key)
udp_transport = UdpServerConnection(udp_host, udp_port, udp_key)
log("Using UDP transport to {host}:{port}", host=udp_host, port=udp_port)
receiver = options.build_receiver_connection(args)
adept = AdeptConnection(udp_transport)
outputs = options.build_outputs(args)
coordinator = Coordinator(receiver=receiver, server=adept, outputs=outputs, freq=options.clock_frequency(args))
adept.start(coordinator)
coordinator.run_until(lambda: adept.closed)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
log("Exiting on SIGINT")
except Exception:
log_exc("Exiting on exception")
else:
log("Exiting on connection loss")