forked from csyangbinbin/mlat-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmlat-client
More file actions
executable file
·120 lines (100 loc) · 5.12 KB
/
Copy pathmlat-client
File metadata and controls
executable file
·120 lines (100 loc) · 5.12 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env python3
# -*- mode: python; indent-tabs-mode: nil -*-
# Part of mlat-client - an ADS-B multilateration client.
# Copyright 2015, Oliver Jowett <oliver@mutability.co.uk>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import argparse
import mlat.client.version
from mlat.client.util import log
from mlat.client.receiver import ReceiverConnection
from mlat.client.jsonclient import JsonServerConnection
from mlat.client.coordinator import Coordinator
from mlat.client import options
import threading
def main():
parser = argparse.ArgumentParser(description="Client for multilateration.")
options.make_inputs_group(parser)
options.make_results_group(parser)
location = parser.add_argument_group('Receiver location')
location.add_argument('--lat',
type=options.latitude,
help="Latitude of the receiver, in decimal degrees. Required.",
required=True)
location.add_argument('--lon',
type=options.longitude,
help="Longitude of the receiver, in decimal degrees. Required.",
required=True)
location.add_argument('--alt',
type=options.altitude,
help="""
Altitude of the receiver (height above ellipsoid). Required. Defaults to metres, but units may
specified with a 'ft' or 'm' suffix. (Except if they're negative due to option
parser weirdness. Sorry!)""",
required=True)
location.add_argument('--privacy',
help="""
Sets the privacy flag for this receiver. Currently, this removes the receiver
location pin from the coverage maps.""",
action='store_true',
default=False)
server = parser.add_argument_group('Multilateration server connection')
server.add_argument('--user',
help="User information to give to the server. Used to get in touch if there are problems.",
required=True)
server.add_argument('--server',
help="host:port of the multilateration server to connect to",
type=options.hostport,
default=('mlat.mutability.co.uk', 40147))
server.add_argument('--no-udp',
dest='udp',
help="Don't offer to use UDP transport for sync/mlat messages",
action='store_false',
default=True)
args = parser.parse_args()
log("mlat-client {version} starting up", version=mlat.client.version.CLIENT_VERSION)
outputs = options.build_outputs(args)
receiver = ReceiverConnection(host=args.input_connect[0], port=args.input_connect[1],
mode=options.connection_mode(args))
server = JsonServerConnection(host=args.server[0], port=args.server[1],
handshake_data={'lat': args.lat,
'lon': args.lon,
'alt': args.alt,
'user': args.user,
'clock_type': options.clock_type(args),
'clock_frequency': options.clock_frequency(args),
'clock_epoch': options.clock_epoch(args),
'privacy': args.privacy},
offer_zlib=True,
offer_udp=args.udp,
return_results=(len(outputs) > 0))
coordinator = Coordinator(receiver=receiver, server=server, outputs=outputs, freq=options.clock_frequency(args),
allow_anon=args.allow_anon_results, allow_modeac=args.allow_modeac_results)
server.start()
if(args.allow_gps):
try:
from mlat.client.serialgps import MSerialPort
GPSDevName =args.gpsdev ;
if(len(GPSDevName) ==0):
GPSDevName = "/dev/ttyACM0"
print("INFO:Open GPS Dev:%s ." % GPSDevName)
serialGPS = MSerialPort(GPSDevName, 9600, coordinator)
GPSThread=threading.Thread(target=serialGPS.read_data)
GPSThread.setDaemon(True)
GPSThread.start()
except Exception as e:
print("ERROR:Open GPS Dev Failed! => " ,e)
coordinator.run_forever()
if __name__ == '__main__':
main()