forked from daniestevez/gr-satellites
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkiss_submitter.py
executable file
·132 lines (104 loc) · 4.57 KB
/
kiss_submitter.py
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
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: KISS client telemetry submitter
# Author: Daniel Estevez
# Description: KISS client telemetry submitter
# Generated: Fri Jan 20 11:22:32 2017
##################################################
from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser
import kiss
import sids
class kiss_submitter(gr.top_block):
def __init__(self, callsign='', host='localhost', latitude=0, longitude=0, norad=0, port='8001', recstart=''):
gr.top_block.__init__(self, "KISS client telemetry submitter")
##################################################
# Parameters
##################################################
self.callsign = callsign
self.host = host
self.latitude = latitude
self.longitude = longitude
self.norad = norad
self.port = port
self.recstart = recstart
##################################################
# Blocks
##################################################
self.sids_submit_0 = sids.submit('http://tlm.pe0sat.nl/tlmdb/frame_db.php', norad, callsign, longitude, latitude, recstart)
self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True)
self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_CLIENT", host, port, 10000, False)
self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
##################################################
# Connections
##################################################
self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.sids_submit_0, 'in'))
self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.kiss_kiss_to_pdu_0, 0))
def get_callsign(self):
return self.callsign
def set_callsign(self, callsign):
self.callsign = callsign
def get_host(self):
return self.host
def set_host(self, host):
self.host = host
def get_latitude(self):
return self.latitude
def set_latitude(self, latitude):
self.latitude = latitude
def get_longitude(self):
return self.longitude
def set_longitude(self, longitude):
self.longitude = longitude
def get_norad(self):
return self.norad
def set_norad(self, norad):
self.norad = norad
def get_port(self):
return self.port
def set_port(self, port):
self.port = port
def get_recstart(self):
return self.recstart
def set_recstart(self, recstart):
self.recstart = recstart
def argument_parser():
description = 'KISS client telemetry submitter'
parser = OptionParser(usage="%prog: [options]", option_class=eng_option, description=description)
parser.add_option(
"", "--callsign", dest="callsign", type="string", default='',
help="Set your callsign [default=%default]")
parser.add_option(
"", "--host", dest="host", type="string", default='localhost',
help="Set Host [default=%default]")
parser.add_option(
"", "--latitude", dest="latitude", type="eng_float", default=eng_notation.num_to_str(0),
help="Set latitude (format 00.000 or -00.000) [default=%default]")
parser.add_option(
"", "--longitude", dest="longitude", type="eng_float", default=eng_notation.num_to_str(0),
help="Set longitude (format 00.000 or -00.000) [default=%default]")
parser.add_option(
"", "--norad", dest="norad", type="intx", default=0,
help="Set NORAD ID [default=%default]")
parser.add_option(
"-p", "--port", dest="port", type="string", default='8001',
help="Set Port [default=%default]")
parser.add_option(
"", "--recstart", dest="recstart", type="string", default='',
help="Set start of recording, if processing a recording (format YYYY-MM-DD HH:MM:SS) [default=%default]")
return parser
def main(top_block_cls=kiss_submitter, options=None):
if options is None:
options, _ = argument_parser().parse_args()
tb = top_block_cls(callsign=options.callsign, host=options.host, latitude=options.latitude, longitude=options.longitude, norad=options.norad, port=options.port, recstart=options.recstart)
tb.start()
tb.wait()
if __name__ == '__main__':
main()