forked from daniestevez/gr-frontends
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fcdpp_usb.py
executable file
·192 lines (154 loc) · 7.47 KB
/
fcdpp_usb.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
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##################################################
# GNU Radio Python Flow Graph
# Title: SSB receiver for a FUNcube Dongle Pro+ device
# Author: Daniel Estevez
# Description: Receives with an FUNcube Dongle Pro+ and streams the USB audio (3kHz filter)
# Generated: Sun Aug 28 12:59:47 2016
##################################################
from gnuradio import analog
from gnuradio import blocks
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 fcdproplus
import gpredict
class fcdpp_usb(gr.top_block):
def __init__(self, bb_gain=20, destination="localhost", freq=145e6, freq_corr=0, gpredict_port=4532, if_gain=20, offset=30e3, port=7355, rf_gain=40):
gr.top_block.__init__(self, "SSB receiver for a FUNcube Dongle Pro+ device")
##################################################
# Parameters
##################################################
self.bb_gain = bb_gain
self.destination = destination
self.freq = freq
self.freq_corr = freq_corr
self.gpredict_port = gpredict_port
self.if_gain = if_gain
self.offset = offset
self.port = port
self.rf_gain = rf_gain
##################################################
# Variables
##################################################
self.samp_rate = samp_rate = 192e3
self.doppler_freq = doppler_freq = freq
##################################################
# Blocks
##################################################
self.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq, "localhost", 4532, False)
self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(4, (firdes.low_pass(1, samp_rate, 1500, 500)), doppler_freq-freq+offset, samp_rate)
self.fcdproplus_fcdproplus_0 = fcdproplus.fcdproplus("",1)
self.fcdproplus_fcdproplus_0.set_lna(0)
self.fcdproplus_fcdproplus_0.set_mixer_gain(0)
self.fcdproplus_fcdproplus_0.set_if_gain(0)
self.fcdproplus_fcdproplus_0.set_freq_corr(0)
self.fcdproplus_fcdproplus_0.set_freq(freq-offset)
self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_short*1, destination, port, 1472, True)
self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
self.blocks_float_to_short_0 = blocks.float_to_short(1, 32767)
self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
self.analog_sig_source_x_0 = analog.sig_source_c(48000, analog.GR_COS_WAVE, 1500, 1, 0)
##################################################
# Connections
##################################################
self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0))
self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_float_to_short_0, 0))
self.connect((self.blocks_float_to_short_0, 0), (self.blocks_udp_sink_0, 0))
self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0))
self.connect((self.fcdproplus_fcdproplus_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_multiply_xx_0, 1))
def get_bb_gain(self):
return self.bb_gain
def set_bb_gain(self, bb_gain):
self.bb_gain = bb_gain
def get_destination(self):
return self.destination
def set_destination(self, destination):
self.destination = destination
def get_freq(self):
return self.freq
def set_freq(self, freq):
self.freq = freq
self.set_doppler_freq(self.freq)
self.freq_xlating_fir_filter_xxx_0.set_center_freq(self.doppler_freq-self.freq+self.offset)
self.fcdproplus_fcdproplus_0.set_freq(self.freq-self.offset)
def get_freq_corr(self):
return self.freq_corr
def set_freq_corr(self, freq_corr):
self.freq_corr = freq_corr
def get_gpredict_port(self):
return self.gpredict_port
def set_gpredict_port(self, gpredict_port):
self.gpredict_port = gpredict_port
def get_if_gain(self):
return self.if_gain
def set_if_gain(self, if_gain):
self.if_gain = if_gain
def get_offset(self):
return self.offset
def set_offset(self, offset):
self.offset = offset
self.freq_xlating_fir_filter_xxx_0.set_center_freq(self.doppler_freq-self.freq+self.offset)
self.fcdproplus_fcdproplus_0.set_freq(self.freq-self.offset)
def get_port(self):
return self.port
def set_port(self, port):
self.port = port
def get_rf_gain(self):
return self.rf_gain
def set_rf_gain(self, rf_gain):
self.rf_gain = rf_gain
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, 1500, 500)))
def get_doppler_freq(self):
return self.doppler_freq
def set_doppler_freq(self, doppler_freq):
self.doppler_freq = doppler_freq
self.freq_xlating_fir_filter_xxx_0.set_center_freq(self.doppler_freq-self.freq+self.offset)
def argument_parser():
description = 'Receives with an FUNcube Dongle Pro+ and streams the USB audio (3kHz filter)'
parser = OptionParser(usage="%prog: [options]", option_class=eng_option, description=description)
parser.add_option(
"", "--bb-gain", dest="bb_gain", type="eng_float", default=eng_notation.num_to_str(20),
help="Set baseband gain [default=%default]")
parser.add_option(
"", "--destination", dest="destination", type="string", default="localhost",
help="Set localhost [default=%default]")
parser.add_option(
"-f", "--freq", dest="freq", type="eng_float", default=eng_notation.num_to_str(145e6),
help="Set frequency [default=%default]")
parser.add_option(
"", "--freq-corr", dest="freq_corr", type="eng_float", default=eng_notation.num_to_str(0),
help="Set frequency correction (ppm) [default=%default]")
parser.add_option(
"", "--gpredict-port", dest="gpredict_port", type="intx", default=4532,
help="Set GPredict port [default=%default]")
parser.add_option(
"", "--if-gain", dest="if_gain", type="eng_float", default=eng_notation.num_to_str(20),
help="Set IF gain [default=%default]")
parser.add_option(
"", "--offset", dest="offset", type="eng_float", default=eng_notation.num_to_str(30e3),
help="Set centre frequency offset [default=%default]")
parser.add_option(
"", "--port", dest="port", type="intx", default=7355,
help="Set port [default=%default]")
parser.add_option(
"", "--rf-gain", dest="rf_gain", type="eng_float", default=eng_notation.num_to_str(40),
help="Set RF gain [default=%default]")
return parser
def main(top_block_cls=fcdpp_usb, options=None):
if options is None:
options, _ = argument_parser().parse_args()
tb = top_block_cls(bb_gain=options.bb_gain, destination=options.destination, freq=options.freq, freq_corr=options.freq_corr, gpredict_port=options.gpredict_port, if_gain=options.if_gain, offset=options.offset, port=options.port, rf_gain=options.rf_gain)
tb.start()
tb.wait()
if __name__ == '__main__':
main()