forked from daniestevez/gr-satellites
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathao73.py
executable file
·217 lines (173 loc) · 8.79 KB
/
ao73.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: AO-73 decoder
# Author: Daniel Estevez
# Description: AO-73 decoder
# Generated: Sun Feb 12 13:36:08 2017
##################################################
import os
import sys
sys.path.append(os.environ.get('GRC_HIER_PATH', os.path.expanduser('~/.grc_gnuradio')))
from ao40_fec_decoder import ao40_fec_decoder # grc-generated hier_block
from gnuradio import analog
from gnuradio import blocks
from gnuradio import digital
from gnuradio import eng_notation
from gnuradio import filter
from gnuradio import gr
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from optparse import OptionParser
import ao40
import sids
class ao73(gr.top_block):
def __init__(self, bfo=1500, callsign='', ip='::', latitude=0, longitude=0, port=7355, recstart=''):
gr.top_block.__init__(self, "AO-73 decoder")
##################################################
# Parameters
##################################################
self.bfo = bfo
self.callsign = callsign
self.ip = ip
self.latitude = latitude
self.longitude = longitude
self.port = port
self.recstart = recstart
##################################################
# Variables
##################################################
self.sps = sps = 8
self.nfilts = nfilts = 16
self.alpha = alpha = 0.35
self.variable_constellation_0_0 = variable_constellation_0_0 = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 2, 1).base()
self.samp_rate = samp_rate = 48000
self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), alpha, 11*sps*nfilts)
##################################################
# Blocks
##################################################
self.sids_submit_0 = sids.submit('http://tlm.pe0sat.nl/tlmdb/frame_db.php', 39444, callsign, longitude, latitude, recstart)
self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S')
self.funcube_telemetry_parser_0 = ao40.funcube_telemetry_parser()
self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf(5, (firdes.low_pass(1, samp_rate, 1300, 500)), bfo, samp_rate)
self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 0.1, (rrc_taps), nfilts, nfilts/2, 0.05, 1)
self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, 0.350, 100, 0.01)
self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short*1, ip, port, 1472, False)
self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767)
self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, ))
self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1)
self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
self.ao40_fec_decoder_0 = ao40_fec_decoder()
self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 2)
##################################################
# Connections
##################################################
self.msg_connect((self.ao40_fec_decoder_0, 'out'), (self.sids_print_timestamp_0, 'in'))
self.msg_connect((self.ao40_fec_decoder_0, 'out'), (self.sids_submit_0, 'in'))
self.msg_connect((self.sids_print_timestamp_0, 'out'), (self.funcube_telemetry_parser_0, 'in'))
self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_fll_band_edge_cc_0, 0))
self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_0, 0))
self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_real_0, 0))
self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0))
self.connect((self.blocks_short_to_float_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
self.connect((self.blocks_udp_source_0, 0), (self.blocks_short_to_float_0, 0))
self.connect((self.digital_binary_slicer_fb_0, 0), (self.ao40_fec_decoder_0, 0))
self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0))
self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_delay_0, 0))
self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_feedforward_agc_cc_0, 0))
def get_bfo(self):
return self.bfo
def set_bfo(self, bfo):
self.bfo = bfo
self.freq_xlating_fir_filter_xxx_0.set_center_freq(self.bfo)
def get_callsign(self):
return self.callsign
def set_callsign(self, callsign):
self.callsign = callsign
def get_ip(self):
return self.ip
def set_ip(self, ip):
self.ip = ip
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_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 get_sps(self):
return self.sps
def set_sps(self, sps):
self.sps = sps
self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0/float(self.sps), self.alpha, 11*self.sps*self.nfilts))
def get_nfilts(self):
return self.nfilts
def set_nfilts(self, nfilts):
self.nfilts = nfilts
self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0/float(self.sps), self.alpha, 11*self.sps*self.nfilts))
def get_alpha(self):
return self.alpha
def set_alpha(self, alpha):
self.alpha = alpha
self.set_rrc_taps(firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0/float(self.sps), self.alpha, 11*self.sps*self.nfilts))
def get_variable_constellation_0_0(self):
return self.variable_constellation_0_0
def set_variable_constellation_0_0(self, variable_constellation_0_0):
self.variable_constellation_0_0 = variable_constellation_0_0
def get_samp_rate(self):
return self.samp_rate
def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.freq_xlating_fir_filter_xxx_0.set_taps((firdes.low_pass(1, self.samp_rate, 1300, 500)))
def get_rrc_taps(self):
return self.rrc_taps
def set_rrc_taps(self, rrc_taps):
self.rrc_taps = rrc_taps
self.digital_pfb_clock_sync_xxx_0.update_taps((self.rrc_taps))
def argument_parser():
description = 'AO-73 decoder'
parser = OptionParser(usage="%prog: [options]", option_class=eng_option, description=description)
parser.add_option(
"", "--bfo", dest="bfo", type="eng_float", default=eng_notation.num_to_str(1500),
help="Set carrier frequency of the BPSK signal [default=%default]")
parser.add_option(
"", "--callsign", dest="callsign", type="string", default='',
help="Set your callsign [default=%default]")
parser.add_option(
"", "--ip", dest="ip", type="string", default='::',
help="Set UDP listen IP [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(
"", "--port", dest="port", type="intx", default=7355,
help="Set UDP 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=ao73, options=None):
if options is None:
options, _ = argument_parser().parse_args()
tb = top_block_cls(bfo=options.bfo, callsign=options.callsign, ip=options.ip, latitude=options.latitude, longitude=options.longitude, port=options.port, recstart=options.recstart)
tb.start()
tb.wait()
if __name__ == '__main__':
main()