def __init__(self): gr.top_block.__init__(self, "P25 Wav Decode") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=48000, decimation=8000, taps=None, fractional_bw=None, ) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,True,2) self.blocks_wavfile_source_0 = blocks.wavfile_source("p25_raw_unencrypted_edf.wav", True) self.audio_sink_0 = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.blocks_wavfile_source_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "P25 Wav Decode") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=48000, decimation=8000, taps=None, fractional_bw=None, ) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT, dsd.dsd_MOD_AUTO_SELECT, 3, True, 2) self.blocks_wavfile_source_0 = blocks.wavfile_source( "p25_raw_unencrypted_edf.wav", True) self.audio_sink_0 = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.blocks_wavfile_source_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "DSD Chain", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_float*1), ) ################################################## # Blocks ################################################## self.rational_resampler_xxx_3 = filter.rational_resampler_fff( interpolation=48000, decimation=8000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=48000, decimation=2400000, taps=None, fractional_bw=None, ) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_DMR_MOTOTRBO,dsd.dsd_MOD_GFSK,3,True,3) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf(1.6) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_1, 0), (self.dsd_block_ff_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.rational_resampler_xxx_3, 0), (self, 0))
def __init__(self): gr.hier_block2.__init__( self, "DSD Chain", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(1, 1, gr.sizeof_float * 1), ) ################################################## # Blocks ################################################## self.rational_resampler_xxx_3 = filter.rational_resampler_fff( interpolation=48000, decimation=8000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=48000, decimation=2400000, taps=None, fractional_bw=None, ) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_DMR_MOTOTRBO, dsd.dsd_MOD_GFSK, 3, True, 3) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf(1.6) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_1, 0), (self.dsd_block_ff_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.rational_resampler_xxx_3, 0), (self, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Dsd Grc") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self._config_freq_config = ConfigParser.ConfigParser() self._config_freq_config.read(".grc_op25") try: config_freq = self._config_freq_config.getfloat("main", "freq") except: config_freq = 489900000 self.config_freq = config_freq self.freq = freq = config_freq self._config_xlate_offset_config = ConfigParser.ConfigParser() self._config_xlate_offset_config.read(".grc_op25") try: config_xlate_offset = self._config_xlate_offset_config.getfloat("main", "xlate_offset") except: config_xlate_offset = 0 self.config_xlate_offset = config_xlate_offset self.click_freq = click_freq = freq-config_xlate_offset self.xlate_offset_fine = xlate_offset_fine = 0 self.xlate_offset = xlate_offset = freq-click_freq self.samp_rate = samp_rate = 1000000 self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self._config_xlate_bandwidth_config = ConfigParser.ConfigParser() self._config_xlate_bandwidth_config.read(".grc_op25") try: config_xlate_bandwidth = self._config_xlate_bandwidth_config.getfloat("main", "xlate_bandwidth") except: config_xlate_bandwidth = 24000 self.config_xlate_bandwidth = config_xlate_bandwidth self.auto_tune_offset = auto_tune_offset = 0 self.xlate_bandwidth = xlate_bandwidth = config_xlate_bandwidth self.variable_static_text_0 = variable_static_text_0 = freq+xlate_offset+xlate_offset_fine+auto_tune_offset self.squelch = squelch = -65 self.pre_channel_rate = pre_channel_rate = samp_rate/decim self.gain = gain = 25 self.fine_click_freq = fine_click_freq = 0 self.channel_rate = channel_rate = 4800*samp_per_sym self.audio_mul = audio_mul = 0 ################################################## # Blocks ################################################## _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_offset_fine_text_box = forms.text_box( parent=self.GetWin(), sizer=_xlate_offset_fine_sizer, value=self.xlate_offset_fine, callback=self.set_xlate_offset_fine, label="Fine Offset", converter=forms.float_converter(), proportion=0, ) self._xlate_offset_fine_slider = forms.slider( parent=self.GetWin(), sizer=_xlate_offset_fine_sizer, value=self.xlate_offset_fine, callback=self.set_xlate_offset_fine, minimum=-10000, maximum=10000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_xlate_offset_fine_sizer) self._xlate_offset_text_box = forms.text_box( parent=self.GetWin(), value=self.xlate_offset, callback=self.set_xlate_offset, label="Xlate Offset", converter=forms.float_converter(), ) self.Add(self._xlate_offset_text_box) _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_bandwidth_text_box = forms.text_box( parent=self.GetWin(), sizer=_xlate_bandwidth_sizer, value=self.xlate_bandwidth, callback=self.set_xlate_bandwidth, label="Xlate BW", converter=forms.float_converter(), proportion=0, ) self._xlate_bandwidth_slider = forms.slider( parent=self.GetWin(), sizer=_xlate_bandwidth_sizer, value=self.xlate_bandwidth, callback=self.set_xlate_bandwidth, minimum=5000, maximum=50000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_xlate_bandwidth_sizer) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB-1") self.nb.AddPage(grc_wxgui.Panel(self.nb), "BB-2") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Xlate-1") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Xlate-2") self.nb.AddPage(grc_wxgui.Panel(self.nb), "4FSK") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Dibits") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Traffic") self.Add(self.nb) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="Gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), ) self.Add(self._freq_text_box) _audio_mul_sizer = wx.BoxSizer(wx.VERTICAL) self._audio_mul_text_box = forms.text_box( parent=self.GetWin(), sizer=_audio_mul_sizer, value=self.audio_mul, callback=self.set_audio_mul, label="Audio mul", converter=forms.float_converter(), proportion=0, ) self._audio_mul_slider = forms.slider( parent=self.GetWin(), sizer=_audio_mul_sizer, value=self.audio_mul, callback=self.set_audio_mul, minimum=-30, maximum=10, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_audio_mul_sizer) self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(3).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=50, ref_scale=2.0, sample_rate=channel_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(3).Add(self.wxgui_waterfallsink2_0_0.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=freq, dynamic_range=100, ref_level=50, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=channel_rate, v_scale=1.5, v_offset=0, t_scale=0.05, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=gr.gr_TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.nb.GetPage(2).GetWin(), baseband_freq=fine_click_freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=channel_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb.GetPage(2).Add(self.wxgui_fftsink2_0_0.win) def wxgui_fftsink2_0_0_callback(x, y): self.set_fine_click_freq(x) self.wxgui_fftsink2_0_0.set_callback(wxgui_fftsink2_0_0_callback) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=30, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) def wxgui_fftsink2_0_callback(x, y): self.set_click_freq(x) self.wxgui_fftsink2_0.set_callback(wxgui_fftsink2_0_callback) self._variable_static_text_0_static_text = forms.static_text( parent=self.GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="Final freq", converter=forms.float_converter(), ) self.Add(self._variable_static_text_0_static_text) _squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_squelch_sizer, value=self.squelch, callback=self.set_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._squelch_slider = forms.slider( parent=self.GetWin(), sizer=_squelch_sizer, value=self.squelch, callback=self.set_squelch, minimum=-100, maximum=100, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_squelch_sizer) self.osmosdr_source_c_0 = osmosdr.source_c( args="nchan=" + str(1) + " " + "hackrf=0" ) self.osmosdr_source_c_0.set_sample_rate(samp_rate) self.osmosdr_source_c_0.set_center_freq(freq, 0) self.osmosdr_source_c_0.set_freq_corr(0, 0) self.osmosdr_source_c_0.set_dc_offset_mode(0, 0) self.osmosdr_source_c_0.set_iq_balance_mode(0, 0) self.osmosdr_source_c_0.set_gain_mode(0, 0) self.osmosdr_source_c_0.set_gain(14, 0) self.osmosdr_source_c_0.set_if_gain(gain, 0) self.osmosdr_source_c_0.set_bb_gain(gain, 0) self.osmosdr_source_c_0.set_antenna("", 0) self.osmosdr_source_c_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 6000)), xlate_offset+xlate_offset_fine-fine_click_freq, samp_rate) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ((1.0/samp_per_sym,)*samp_per_sym)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_P25_PHASE_1,dsd.dsd_MOD_C4FM,3,3,True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10.**(audio_mul/10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=44100, decimation=8000, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(44100, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.6) ################################################## # Connections ################################################## self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_waterfallsink2_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.osmosdr_source_c_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self,infile, outfile, input_rate, channel_rate, codec_provoice, codec_p25, sslevel, svlevel): gr.top_block.__init__(self, "Top Block") self.input_rate = input_rate self.channel_rate = channel_rate self.source = blocks.file_source(gr.sizeof_gr_complex*1, infile, False) self.lp1_decim = int(input_rate/(channel_rate*1.6)) print self.lp1_decim self.lp1 = filter.fir_filter_ccc(self.lp1_decim,firdes.low_pass( 1.0, self.input_rate, (self.channel_rate/2), ((self.channel_rate/2)*0.6), firdes.WIN_HAMMING)) #self.audiodemod = gr.quadrature_demod_cf(1) audio_pass = (input_rate/self.lp1_decim)*0.25 audio_stop = audio_pass+2000 self.audiodemod = analog.fm_demod_cf(channel_rate=(input_rate/self.lp1_decim), audio_decim=1, deviation=15000, audio_pass=audio_pass, audio_stop=audio_stop, gain=8, tau=75e-6) self.throttle = blocks.throttle(gr.sizeof_gr_complex*1, self.input_rate) self.signal_squelch = analog.pwr_squelch_cc(sslevel,0.01, 0, True) self.vox_squelch = analog.pwr_squelch_ff(svlevel, 0.0005, 0, True) self.audiosink = blocks.wavfile_sink(outfile, 1, 8000) if codec_provoice: self.dsd = dsd.block_ff(dsd.dsd_FRAME_PROVOICE,dsd.dsd_MOD_AUTO_SELECT,1,0,False) channel_rate = input_rate/self.lp1_decim self.resampler_in = filter.rational_resampler_fff(interpolation=48000, decimation=channel_rate, taps=None, fractional_bw=None, ) output_rate = 8000 resampler = filter.rational_resampler_fff( interpolation=(input_rate/self.lp1_decim), decimation=output_rate, taps=None, fractional_bw=None, ) elif codec_p25: symbol_deviation = 600.0 symbol_rate = 4800 channel_rate = input_rate/self.lp1_decim fm_demod_gain = channel_rate / (2.0 * pi * symbol_deviation) fm_demod = analog.quadrature_demod_cf(fm_demod_gain) symbol_decim = 1 samples_per_symbol = channel_rate // symbol_rate symbol_coeffs = (1.0/samples_per_symbol,) * samples_per_symbol symbol_filter = filter.fir_filter_fff(symbol_decim, symbol_coeffs) autotuneq = gr.msg_queue(2) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, symbol_rate) # symbol slicer levels = [ -2.0, 0.0, 2.0, 4.0 ] slicer = op25.fsk4_slicer_fb(levels) imbe = repeater.vocoder(False, True, 0, "", 0, False) self.decodequeue = decodequeue = gr.msg_queue(10000) decoder = repeater.p25_frame_assembler('', 0, 0, True, True, False, decodequeue) float_conversion = blocks.short_to_float(1, 8192) resampler = filter.rational_resampler_fff( interpolation=8000, decimation=8000, taps=None, fractional_bw=None, ) #Tone squelch, custom GRC block that rips off CTCSS squelch to detect 4800 hz tone and latch squelch after that if not codec_provoice and not codec_p25: #self.tone_squelch = gr.tone_squelch_ff(audiorate, 4800.0, 0.05, 300, 0, True) #tone squelch is EDACS ONLY self.high_pass = filter.fir_filter_fff(1, firdes.high_pass(1, (input_rate/self.lp1_decim), 300, 30, firdes.WIN_HAMMING, 6.76)) #output_rate = channel_rate resampler = filter.rational_resampler_fff( interpolation=8000, decimation=(input_rate/self.lp1_decim), taps=None, fractional_bw=None, ) if(codec_provoice): self.connect(self.source, self.throttle, self.lp1, self.audiodemod, self.resampler_in, self.dsd, self.audiosink) elif(codec_p25): self.connect(self.source, self.throttle, self.lp1, fm_demod, symbol_filter, demod_fsk4, slicer, decoder, imbe, float_conversion, resampler, self.audiosink) else: self.connect(self.source, self.throttle, self.lp1, self.signal_squelch, self.audiodemod, self.high_pass, self.vox_squelch, resampler, self.audiosink) self.time_open = time.time() self.time_tone = 0 self.time_activity = 0
def __init__(self, talkgroup, options): gr.hier_block2.__init__( self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature print "Starting log_receiver init()" self.samp_rate = samp_rate = int(options.rate) self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self.xlate_bandwidth = xlate_bandwidth = 24260.0 self.xlate_offset = xlate_offset = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE * samp_per_sym self.audio_mul = audio_mul = 1 self.pre_channel_rate = pre_channel_rate = int(samp_rate / decim) self.squelch = squelch = -55 self.auto_tune_offset = auto_tune_offset = 0 self.audiorate = 44100 #options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 ################################################## # Blocks ################################################## print "Setting up Blocks" self.audiotaps = gr.firdes.low_pass(1, samp_rate, 8000, 2000, gr.firdes.WIN_HANN) self.prefilter_decim = int(self.rate / self.audiorate) #the audio prefilter is a channel selection filter. self.audio_prefilter = gr.freq_xlating_fir_filter_ccf( self.prefilter_decim, #decimation self.audiotaps, #taps 0, #freq offset int(samp_rate)) #sampling rate self.audiodemod = blks2.fm_demod_cf( self.rate / self.prefilter_decim, #rate 1, #audio decimation 4000, #deviation 3000, #audio passband 4000, #audio stopband options.volume, #gain 75e-6) #deemphasis constant #the filtering removes FSK data woobling from the subaudible channel self.audiofilttaps = gr.firdes.high_pass(1, self.audiorate, 300, 50, gr.firdes.WIN_HANN) self.audiofilt = gr.fir_filter_fff(1, self.audiofilttaps) self.gr_quadrature_demod_cf_0 = analog.quadrature_demod_cf( 1.6) #(channel_rate/(2.0 * math.pi * op25.SYMBOL_DEVIATION))) self.gr_freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 2000)), 0, samp_rate) self.gr_fir_filter_xxx_0 = filter.fir_filter_fff( 1, ((1.0 / samp_per_sym, ) * samp_per_sym)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (10.**(audio_mul / 10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=self.audiorate, decimation=8000, taps=None, fractional_bw=None, ) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ( "".join([ random.choice(string.letters + string.digits) for x in range(8) ]) ) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT, dsd.dsd_MOD_AUTO_SELECT, 3, 2, True) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a') self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink( self.filename, 1, self.audiorate, 8 ) #blocks.wavfile_sink(self.filename, 1, self.audiorate, 8) this version allows appending to existing files. self.audio_sink_0 = audio.sink(44100, "", True) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted. print "Connecting blocks" ################################################## # Connections ################################################## self.connect(self.blks2_rational_resampler_xxx_0, self.blocks_multiply_const_vxx_0) self.connect(self.gr_fir_filter_xxx_0, self.valve, self.dsd_block_ff_0) self.connect(self.dsd_block_ff_0, self.blks2_rational_resampler_xxx_0) ## Start self.connect(self, self.gr_freq_xlating_fir_filter_xxx_0, self.blks2_rational_resampler_xxx_1, self.gr_quadrature_demod_cf_0, self.gr_fir_filter_xxx_0) ## End # self.connect(self.blocks_multiply_const_vxx_0, self.audio_sink_0) # Plays the audio self.connect(self.blocks_multiply_const_vxx_0, self.audiosink) # Records the audio
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="CP v0.1a") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.freq = freq = 92.9e6 self.samp_rate = samp_rate = 2.4e6 self.ch2_volume = ch2_volume = 1 self.ch2_squelch = ch2_squelch = -30 self.ch2_mute = ch2_mute = 1 self.ch2_modulation = ch2_modulation = 0 self.ch2_invert = ch2_invert = 1 self.ch2_freq = ch2_freq = freq self.ch1_volume = ch1_volume = 1 self.ch1_squelch = ch1_squelch = -30 self.ch1_mute = ch1_mute = 1 self.ch1_modulation = ch1_modulation = 0 self.ch1_invert = ch1_invert = 1 self.ch1_freq = ch1_freq = freq ################################################## # Blocks ################################################## self.tab = self.tab = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 1") self.tab.AddPage(grc_wxgui.Panel(self.tab), "Ch 2") self.GridAdd(self.tab, 3, 0, 1, 7) self._freq_text_box = forms.text_box( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Radio Center Freq", converter=forms.float_converter(), ) self.GridAdd(self._freq_text_box, 19, 0, 1, 10) _ch2_volume_sizer = wx.BoxSizer(wx.VERTICAL) self._ch2_volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch2_volume_sizer, value=self.ch2_volume, callback=self.set_ch2_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._ch2_volume_slider = forms.slider( parent=self.GetWin(), sizer=_ch2_volume_sizer, value=self.ch2_volume, callback=self.set_ch2_volume, minimum=0, maximum=10, num_steps=20, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch2_volume_sizer, 2, 2, 1, 1) _ch2_squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch2_squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch2_squelch_sizer, value=self.ch2_squelch, callback=self.set_ch2_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._ch2_squelch_slider = forms.slider( parent=self.GetWin(), sizer=_ch2_squelch_sizer, value=self.ch2_squelch, callback=self.set_ch2_squelch, minimum=-70, maximum=0, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch2_squelch_sizer, 2, 3, 1, 1) self._ch2_mute_check_box = forms.check_box( parent=self.GetWin(), value=self.ch2_mute, callback=self.set_ch2_mute, label="Mute", true=0, false=1, ) self.GridAdd(self._ch2_mute_check_box, 2, 5, 1, 1) self._ch2_modulation_chooser = forms.button( parent=self.GetWin(), value=self.ch2_modulation, callback=self.set_ch2_modulation, label="Modulation", choices=[0, 1], labels=["DMR","NBFM"], ) self.GridAdd(self._ch2_modulation_chooser, 2, 1, 1, 1) self._ch2_invert_check_box = forms.check_box( parent=self.GetWin(), value=self.ch2_invert, callback=self.set_ch2_invert, label="Invert", true=-1, false=1, ) self.GridAdd(self._ch2_invert_check_box, 2, 4, 1, 1) self._ch2_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.ch2_freq, callback=self.set_ch2_freq, label="Ch2 Freq", converter=forms.float_converter(), ) self.GridAdd(self._ch2_freq_text_box, 2, 0, 1, 1) _ch1_volume_sizer = wx.BoxSizer(wx.VERTICAL) self._ch1_volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch1_volume_sizer, value=self.ch1_volume, callback=self.set_ch1_volume, label="Volume", converter=forms.float_converter(), proportion=0, ) self._ch1_volume_slider = forms.slider( parent=self.GetWin(), sizer=_ch1_volume_sizer, value=self.ch1_volume, callback=self.set_ch1_volume, minimum=0, maximum=10, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch1_volume_sizer, 0, 2, 1, 1) _ch1_squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch1_squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch1_squelch_sizer, value=self.ch1_squelch, callback=self.set_ch1_squelch, label="Squelch", converter=forms.float_converter(), proportion=0, ) self._ch1_squelch_slider = forms.slider( parent=self.GetWin(), sizer=_ch1_squelch_sizer, value=self.ch1_squelch, callback=self.set_ch1_squelch, minimum=-70, maximum=0, num_steps=14, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_ch1_squelch_sizer, 0, 3, 1, 1) self._ch1_mute_check_box = forms.check_box( parent=self.GetWin(), value=self.ch1_mute, callback=self.set_ch1_mute, label="Mute", true=0, false=1, ) self.GridAdd(self._ch1_mute_check_box, 0, 5, 1, 1) self._ch1_modulation_chooser = forms.button( parent=self.GetWin(), value=self.ch1_modulation, callback=self.set_ch1_modulation, label="Modulation", choices=[0, 1], labels=["DMR","NBFM"], ) self.GridAdd(self._ch1_modulation_chooser, 0, 1, 1, 1) self._ch1_invert_check_box = forms.check_box( parent=self.GetWin(), value=self.ch1_invert, callback=self.set_ch1_invert, label="Invert", true=-1, false=1, ) self.GridAdd(self._ch1_invert_check_box, 0, 4, 1, 1) self._ch1_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.ch1_freq, callback=self.set_ch1_freq, label="Ch1 Freq", converter=forms.float_converter(), ) self.GridAdd(self._ch1_freq_text_box, 0, 0, 1, 1) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.GridAdd(self.wxgui_waterfallsink2_1.win, 4, 0, 15, 10) self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.tab.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=True, avg_alpha=0.1333, title="Channel 2", peak_hold=False, ) self.tab.GetPage(1).GridAdd(self.wxgui_fftsink2_0_0.win, 0, 0, 12, 7) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.tab.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=True, avg_alpha=0.1333, title="Channel 1", peak_hold=False, ) self.tab.GetPage(0).GridAdd(self.wxgui_fftsink2_0.win, 0, 0, 12, 7) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_3_0 = filter.rational_resampler_fff( interpolation=48000, decimation=8000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_3 = filter.rational_resampler_fff( interpolation=48000, decimation=8000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2_0 = filter.rational_resampler_ccc( interpolation=48000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=48000, decimation=2400000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=192000, decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=192000, decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.low_pass_filter_1_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 192000, 5e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, 192000, 5e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fft_filter_ccc_0_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch2_freq - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0_0.declare_sample_delay(0) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc(1, (firdes.low_pass(1,samp_rate,200000,10000)), ch1_freq - freq, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.dsd_block_ff_0_0 = dsd.block_ff(dsd.dsd_FRAME_DMR_MOTOTRBO,dsd.dsd_MOD_GFSK,3,True,3) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_DMR_MOTOTRBO,dsd.dsd_MOD_GFSK,3,True,3) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((ch2_invert * ch2_mute, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((ch1_invert * ch1_mute, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((ch2_volume, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((ch1_volume, )) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=2, input_index=0, output_index=ch2_modulation, ) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=ch2_modulation, output_index=0, ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=ch1_modulation, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=2, input_index=0, output_index=ch1_modulation, ) self.audio_sink_0_0 = audio.sink(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_quadrature_demod_cf_1_0 = analog.quadrature_demod_cf(1.6) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf(1.6) self.analog_pwr_squelch_xx_0_0_0 = analog.pwr_squelch_cc(ch2_squelch, 1e-4, 0, True) self.analog_pwr_squelch_xx_0_0 = analog.pwr_squelch_cc(ch1_squelch, 1e-4, 0, True) self.analog_nbfm_rx_0_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=192000, tau=75e-6, max_dev=2.5e3, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=192000, tau=75e-6, max_dev=2.5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.analog_nbfm_rx_0_0, 0), (self.blks2_selector_0_0_0, 1)) self.connect((self.analog_pwr_squelch_xx_0_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_pwr_squelch_xx_0_0_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.dsd_block_ff_0, 0)) self.connect((self.analog_quadrature_demod_cf_1_0, 0), (self.dsd_block_ff_0_0, 0)) self.connect((self.blks2_selector_0, 1), (self.rational_resampler_xxx_0, 0)) self.connect((self.blks2_selector_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blks2_selector_0_1, 1), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blks2_selector_0_1, 0), (self.rational_resampler_xxx_2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.audio_sink_0_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_3, 0)) self.connect((self.dsd_block_ff_0_0, 0), (self.rational_resampler_xxx_3_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_pwr_squelch_xx_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.analog_pwr_squelch_xx_0_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.low_pass_filter_1_0, 0), (self.analog_nbfm_rx_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_1_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.rational_resampler_xxx_2_0, 0), (self.analog_quadrature_demod_cf_1_0, 0)) self.connect((self.rational_resampler_xxx_3, 0), (self.blks2_selector_0_0, 0)) self.connect((self.rational_resampler_xxx_3_0, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fft_filter_ccc_0_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.wxgui_waterfallsink2_1, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="VA3ODG") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1920000 self.offset = offset = 50000 self.gain = gain = 40 self.fsk_deviation_hz = fsk_deviation_hz = 8000 self.freq = freq = 444850000 self.corr = corr = 0 ################################################## # Blocks ################################################## _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RX gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) _corr_sizer = wx.BoxSizer(wx.VERTICAL) self._corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, label="Freq. correction", converter=forms.float_converter(), proportion=0, ) self._corr_slider = forms.slider( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, minimum=-150, maximum=150, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_corr_sizer) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=48000, fft_size=512, fft_rate=3, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=48000, v_scale=0.25, v_offset=0, t_scale=0.001, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.root_raised_cosine_filter_0 = filter.interp_fir_filter_fff( 10, firdes.root_raised_cosine(1, 48000, 4800, 0.35, 100)) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq - offset, 0) self.osmosdr_source_0.set_freq_corr(corr, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(0, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.fir_filter_fff( 1, firdes.low_pass(1, 48000, 8000, 2000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 40, firdes.low_pass(20, samp_rate, 3500, 2000, firdes.WIN_HAMMING, 6.76)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_DSTAR, dsd.dsd_MOD_AUTO_SELECT, 3, 2, True) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( 10.0, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf( ([-1, 1]), 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.audio_sink_0 = audio.sink(8000, "", True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -offset, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="VA3ODG") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1920000 self.offset = offset = 50000 self.gain = gain = 40 self.fsk_deviation_hz = fsk_deviation_hz = 8000 self.freq = freq = 444850000 self.corr = corr = 0 ################################################## # Blocks ################################################## _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RX gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=49.6, num_steps=124, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) _corr_sizer = wx.BoxSizer(wx.VERTICAL) self._corr_text_box = forms.text_box( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, label="Freq. correction", converter=forms.float_converter(), proportion=0, ) self._corr_slider = forms.slider( parent=self.GetWin(), sizer=_corr_sizer, value=self.corr, callback=self.set_corr, minimum=-150, maximum=150, num_steps=300, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_corr_sizer) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=48000, fft_size=512, fft_rate=3, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=48000, v_scale=0.25, v_offset=0, t_scale=0.001, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.root_raised_cosine_filter_0 = filter.interp_fir_filter_fff(10, firdes.root_raised_cosine( 1, 48000, 4800, 0.35, 100)) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq - offset, 0) self.osmosdr_source_0.set_freq_corr(corr, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(0, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 1, 48000, 8000, 2000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(40, firdes.low_pass( 20, samp_rate, 3500, 2000, firdes.WIN_HAMMING, 6.76)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_DSTAR,dsd.dsd_MOD_AUTO_SELECT,3,2,True) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(10.0, 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([-1,1]), 1) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.audio_sink_0 = audio.sink(8000, "", True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -offset, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Nbfm Dsd") ################################################## # Variables ################################################## self.decim = decim = 2 self.adc_rate = adc_rate = 2000000 self.xlate_offset_fine = xlate_offset_fine = -800 self.xlate_offset = xlate_offset = 0 self.xlate_decim = xlate_decim = 4 self.xlate_bandwidth = xlate_bandwidth = 12500 self.volume = volume = 1 self.squelch = squelch = 50 self.samp_rate = samp_rate = adc_rate/decim self.audio_rate = audio_rate = 48000 self.audio_interp = audio_interp = 4 ################################################## # Blocks ################################################## self.main_notebook = self.main_notebook = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Baseband") self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Scope") self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Watefall") self.main_notebook.AddPage(grc_wxgui.Panel(self.main_notebook), "Quad demod") self.Add(self.main_notebook) _xlate_offset_fine_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_offset_fine_text_box = forms.text_box( parent=self.main_notebook.GetPage(0).GetWin(), sizer=_xlate_offset_fine_sizer, value=self.xlate_offset_fine, callback=self.set_xlate_offset_fine, label="Fine Offset", converter=forms.float_converter(), proportion=0, ) self._xlate_offset_fine_slider = forms.slider( parent=self.main_notebook.GetPage(0).GetWin(), sizer=_xlate_offset_fine_sizer, value=self.xlate_offset_fine, callback=self.set_xlate_offset_fine, minimum=-10000, maximum=10000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.main_notebook.GetPage(0).Add(_xlate_offset_fine_sizer) self._xlate_offset_text_box = forms.text_box( parent=self.main_notebook.GetPage(0).GetWin(), value=self.xlate_offset, callback=self.set_xlate_offset, label="Xlate Offset", converter=forms.float_converter(), ) self.main_notebook.GetPage(0).Add(self._xlate_offset_text_box) _xlate_bandwidth_sizer = wx.BoxSizer(wx.VERTICAL) self._xlate_bandwidth_text_box = forms.text_box( parent=self.main_notebook.GetPage(0).GetWin(), sizer=_xlate_bandwidth_sizer, value=self.xlate_bandwidth, callback=self.set_xlate_bandwidth, label="Xlate Bandwidth", converter=forms.float_converter(), proportion=0, ) self._xlate_bandwidth_slider = forms.slider( parent=self.main_notebook.GetPage(0).GetWin(), sizer=_xlate_bandwidth_sizer, value=self.xlate_bandwidth, callback=self.set_xlate_bandwidth, minimum=2500, maximum=250000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.main_notebook.GetPage(0).Add(_xlate_bandwidth_sizer) _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=10, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) _squelch_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_text_box = forms.text_box( parent=self.GetWin(), sizer=_squelch_sizer, value=self.squelch, callback=self.set_squelch, label='squelch', converter=forms.float_converter(), proportion=0, ) self._squelch_slider = forms.slider( parent=self.GetWin(), sizer=_squelch_sizer, value=self.squelch, callback=self.set_squelch, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_squelch_sizer) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.main_notebook.GetPage(2).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=50, ref_scale=2.0, sample_rate=samp_rate/xlate_decim, fft_size=512, fft_rate=30, average=False, avg_alpha=None, title="Waterfall Plot", ) self.main_notebook.GetPage(2).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( self.main_notebook.GetPage(3).GetWin(), title="Scope Plot", sample_rate=samp_rate/xlate_decim, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.main_notebook.GetPage(3).Add(self.wxgui_scopesink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.main_notebook.GetPage(1).GetWin(), title="Scope Plot", sample_rate=samp_rate/xlate_decim, v_scale=10, v_offset=0, t_scale=10000, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.main_notebook.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.main_notebook.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=50, ref_scale=2.0, sample_rate=samp_rate/xlate_decim, fft_size=1024, fft_rate=30, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.main_notebook.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(442.574e6, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(50, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=48000, decimation=8000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=audio_rate*audio_interp, decimation=samp_rate/xlate_decim, taps=None, fractional_bw=None, ) self.iqbalance_fix_cc_0 = iqbalance.fix_cc(1, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), xlate_offset + xlate_offset_fine, samp_rate) self.dsd_block_ff_1 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,True,2) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch*-1, 1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=audio_rate*audio_interp, tau=75e-6, max_dev=5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.dsd_block_ff_1, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.dsd_block_ff_1, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.iqbalance_fix_cc_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.iqbalance_fix_cc_0, 0))
def configure_blocks(self, protocol): if protocol == 'provoice' or protocol == 'analog_edacs': protocol = 'analog' self.log.debug('configure_blocks(%s)' % protocol) if not (protocol == 'p25' or protocol == 'p25_tdma' or protocol == 'p25_cqpsk' or protocol == 'p25_cqpsk_tdma' or protocol == 'provoice' or protocol == 'dsd_p25' or protocol == 'analog' or protocol == 'none'): raise Exception('Invalid protocol %s' % protocol) if self.protocol == protocol: return True self.lock() if self.protocol == 'analog': self.disconnect(self.source, self.signal_squelch, self.audiodemod, self.high_pass, self.resampler, self.sink) self.signal_squelch = None self.audiodemod = None self.high_pass = None self.resampler = None elif self.protocol == 'p25' or 'p25_tdma': try: self.disconnect(self.source, self.prefilter, self.fm_demod) #, (self.subtract,0)) self.disconnect(self.fm_demod, self.symbol_filter, self.demod_fsk4, self.slicer, self.decoder, self.float_conversion, self.sink) self.disconnect(self.slicer, self.decoder2, self.qsink) self.demod_watcher.keep_running = False except: pass #self.disconnect(self.fm_demod, self.avg, self.mult, (self.subtract,1)) self.prefilter = None self.fm_demod = None #self.avg = None #self.mult = None #self.subtract = None self.symbol_filter = None self.demod_fsk4 = None self.slicer = None self.decoder = None self.decoder2 = None self.qsink = None self.imbe = None self.float_conversion = None self.resampler = None elif self.protocol == 'p25_cqpsk' or self.protocol == 'p25_cqpsk_tdma': self.disconnect(self.source, self.resampler, self.agc, self.symbol_filter_c, self.clock, self.diffdec, self.to_float, self.rescale, self.slicer, self.decoder2, self.qsink) #, (self.subtract,0)) self.disconnect(self.slicer, self.decoder, self.float_conversion, self.sink) self.prefilter = None self.resampler = None self.agc = None self.symbol_filter_c = None self.clock = None self.diffdec = None self.to_float = None self.rescale = None self.slicer = None self.imbe = None self.decodequeue3 = None self.decodequeue2 = None self.decodequeue = None self.demod_watcher = None self.decoder = None self.decoder2 = None self.qsink = None self.float_conversion = None elif self.protocol == 'provoice': self.disconnect(self.source, self.fm_demod, self.resampler_in, self.dsd, self.out_squelch, self.sink) self.fm_demod = None self.resampler_in = None self.dsd = None self.out_squelch = None elif self.protocol == 'dsd_p25': self.disconnect(self.source, self.fm_demod, self.resampler_in, self.dsd, self.sink) self.fm_demod = None self.resampler_in = None self.dsd = None self.protocol = protocol if protocol == 'analog': self.signal_squelch = analog.pwr_squelch_cc(-100, 0.01, 0, True) #self.tone_squelch = gr.tone_squelch_ff(audiorate, 4800.0, 0.05, 300, 0, True) #tone squelch is EDACS ONLY self.audiodemod = analog.fm_demod_cf( channel_rate=self.input_rate, audio_decim=1, deviation=15000, audio_pass=(self.input_rate * 0.25), audio_stop=((self.input_rate * 0.25) + 2000), gain=8, tau=75e-6) self.high_pass = filter.fir_filter_fff( 1, firdes.high_pass(1, self.input_rate, 300, 30, firdes.WIN_HAMMING, 6.76)) self.resampler = filter.rational_resampler_fff( interpolation=8000, decimation=self.input_rate, taps=None, fractional_bw=None, ) self.connect(self.source, self.signal_squelch, self.audiodemod, self.high_pass, self.resampler, self.sink) elif protocol == 'p25' or protocol == 'p25_tdma': self.symbol_deviation = symbol_deviation = 600.0 if protocol == 'p25_tdma': symbol_rate = 6000 else: symbol_rate = 4800 channel_rate = self.input_rate self.prefilter = filter.freq_xlating_fir_filter_ccc( 1, (1, ), 0, self.input_rate) fm_demod_gain = channel_rate / (2.0 * pi * symbol_deviation) self.fm_demod = analog.quadrature_demod_cf(fm_demod_gain) #self.avg = blocks.moving_average_ff(1000, 1, 4000) #self.mult = blocks.multiply_const_vff((0.001, )) #self.subtract = blocks.sub_ff(1) symbol_decim = 1 samples_per_symbol = channel_rate // symbol_rate symbol_coeffs = (1.0 / samples_per_symbol, ) * samples_per_symbol self.symbol_filter = filter.fir_filter_fff(symbol_decim, symbol_coeffs) autotuneq = gr.msg_queue(2) self.demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, symbol_rate) # symbol slicer levels = [-2.0, 0.0, 2.0, 4.0] self.slicer = op25.fsk4_slicer_fb(levels) self.imbe = repeater.vocoder(False, True, 0, "", 0, False) self.decodequeue3 = decodequeue3 = gr.msg_queue(10000) self.decodequeue2 = decodequeue2 = gr.msg_queue(10000) self.decodequeue = decodequeue = gr.msg_queue(10000) self.demod_watcher = None #demod_watcher(decodequeue2, self.adjust_channel_offset) self.decoder = repeater.p25_frame_assembler( '', 0, 0, True, True, False, decodequeue2, True, (True if protocol == 'p25_tdma' else False)) self.decoder2 = repeater.p25_frame_assembler( '', 0, 0, False, True, False, decodequeue3, False, False) self.qsink = blocks.message_sink(gr.sizeof_char, self.decodequeue, False) self.float_conversion = blocks.short_to_float(1, 8192) self.connect(self.source, self.prefilter, self.fm_demod) #, (self.subtract,0)) #self.connect(self.fm_demod, self.symbol_filter, self.demod_fsk4, self.slicer, self.decoder, self.imbe, self.float_conversion, self.sink) self.connect(self.fm_demod, self.symbol_filter, self.demod_fsk4, self.slicer, self.decoder, self.float_conversion, self.sink) self.connect(self.slicer, self.decoder2, self.qsink) #self.connect(self.fm_demod, self.avg, self.mult, (self.subtract,1)) elif protocol == 'p25_cqpsk' or protocol == 'p25_cqpsk_tdma': self.symbol_deviation = symbol_deviation = 600.0 self.resampler = blocks.multiply_const_cc(1.0) self.agc = analog.feedforward_agc_cc(1024, 1.0) self.symbol_filter_c = blocks.multiply_const_cc(1.0) gain_mu = 0.025 if protocol == 'p25_cqpsk_tdma': symbol_rate = 6000 else: symbol_rate = 4800 omega = float(self.input_rate) / float(symbol_rate) gain_omega = 0.1 * gain_mu * gain_mu alpha = 0.04 beta = 0.125 * alpha * alpha fmax = 1200 # Hz fmax = 2 * pi * fmax / float(self.input_rate) self.clock = repeater.gardner_costas_cc(omega, gain_mu, gain_omega, alpha, beta, fmax, -fmax) self.diffdec = digital.diff_phasor_cc() self.to_float = blocks.complex_to_arg() self.rescale = blocks.multiply_const_ff((1 / (pi / 4))) # symbol slicer levels = [-2.0, 0.0, 2.0, 4.0] self.slicer = op25.fsk4_slicer_fb(levels) #self.imbe = repeater.vocoder(False, True, 0, "", 0, False) self.decodequeue3 = decodequeue3 = gr.msg_queue(2) self.decodequeue2 = decodequeue2 = gr.msg_queue(2) self.decodequeue = decodequeue = gr.msg_queue(10000) #self.demod_watcher = demod_watcher(decodequeue2, self.adjust_channel_offset) self.decoder = repeater.p25_frame_assembler( '', 0, 0, True, True, False, decodequeue2, True, (False if protocol == 'p25_cqpsk' else True)) self.decoder2 = repeater.p25_frame_assembler( '', 0, 0, False, True, True, decodequeue3, False, False) #temp for debug #self.debug_sink = blocks.file_sink(1, '/dev/null') #self.connect(self.slicer, self.debug_sink) self.qsink = blocks.message_sink(gr.sizeof_char, self.decodequeue, False) self.float_conversion = blocks.short_to_float(1, 8192) self.connect(self.source, self.resampler, self.agc, self.symbol_filter_c, self.clock, self.diffdec, self.to_float, self.rescale, self.slicer, self.decoder2, self.qsink) #, (self.subtract,0)) self.connect(self.slicer, self.decoder, self.float_conversion, self.sink) elif protocol == 'provoice': fm_demod_gain = 0.6 self.fm_demod = analog.quadrature_demod_cf(fm_demod_gain) self.resampler_in = filter.rational_resampler_fff( interpolation=48000, decimation=self.input_rate, taps=None, fractional_bw=None, ) self.dsd = dsd.block_ff(dsd.dsd_FRAME_PROVOICE, dsd.dsd_MOD_AUTO_SELECT, 3, 0, False) self.out_squelch = analog.pwr_squelch_ff(-100, 0.01, 0, True) self.connect(self.source, self.fm_demod, self.resampler_in, self.dsd, self.out_squelch, self.sink) elif protocol == 'dsd_p25': symbol_deviation = 600.0 fm_demod_gain = 0.4 #self.input_rate / (2.0 * pi * symbol_deviation) self.fm_demod = analog.quadrature_demod_cf(fm_demod_gain) self.resampler_in = filter.rational_resampler_fff( interpolation=48000, decimation=self.input_rate, taps=None, fractional_bw=None, ) self.dsd = dsd.block_ff(dsd.dsd_FRAME_P25_PHASE_1, dsd.dsd_MOD_AUTO_SELECT, 3, 3, False) self.connect(self.source, self.fm_demod, self.resampler_in, self.dsd, self.sink) self.unlock()
def __init__(self): gr.top_block.__init__(self, "Nbfm Dsd No Gui") ################################################## # Variables ################################################## self.decim = decim = 2 self.adc_rate = adc_rate = 2000000 self.xlate_offset_fine = xlate_offset_fine = -800 self.xlate_offset = xlate_offset = 0 self.xlate_decim = xlate_decim = 4 self.xlate_bandwidth = xlate_bandwidth = 12500 self.volume = volume = 2 self.squelch = squelch = 50 self.samp_rate = samp_rate = adc_rate/decim self.audio_rate = audio_rate = 48000 self.audio_interp = audio_interp = 4 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(442.574e6, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(50, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff( interpolation=48000, decimation=8000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=audio_rate*audio_interp, decimation=samp_rate/xlate_decim, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(xlate_decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 1000)), xlate_offset + xlate_offset_fine, samp_rate) self.dsd_block_ff_1 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,True,2) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, )) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch*-1, 1) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=audio_rate, quad_rate=audio_rate*audio_interp, tau=75e-6, max_dev=5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.dsd_block_ff_1, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.dsd_block_ff_1, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self, options): gr.top_block.__init__(self) self.rate = options.rate print "Samples per second is %i" % self.rate self._syms_per_sec = 3600; options.audiorate = 44100 options.rate = self.rate options.samples_per_second = self.rate #yeah i know it's on the list options.syms_per_sec = self._syms_per_sec options.gain_mu = 0.01 options.mu=0.5 options.omega_relative_limit = 0.3 options.syms_per_sec = self._syms_per_sec options.offset = options.centerfreq - options.freq print "Tuning channel offset: %f" % options.offset self.freq = options.freq self.samp_rate = samp_rate = self.rate self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self.xlate_bandwidth = 14000 self.pre_channel_rate = pre_channel_rate = int(samp_rate/decim) self.channel_rate = channel_rate = 4800*samp_per_sym self.rtl = osmosdr.source_c( args="nchan=" + str(1) + " " + "" ) self.rtl.set_sample_rate(options.rate) self.rtl.set_center_freq(options.centerfreq, 0) self.rtl.set_freq_corr(options.ppm, 0) #self.rtl.set_gain_mode(1, 0) print "Channel Rate: %d Pre Channel Rate: %d" % (channel_rate, pre_channel_rate) self.centerfreq = options.centerfreq print "Setting center to (With Error): %fMHz" % (self.centerfreq - options.error) if not(self.tune(options.centerfreq - options.error)): print "Failed to set initial frequency" if options.gain is None: options.gain = 14 if options.bbgain is None: options.bbgain = 25 if options.ifgain is None: options.ifgain = 25 print "Setting RF gain to %i" % options.gain print "Setting BB gain to %i" % options.bbgain print "Setting IF gain to %i" % options.ifgain self.rtl.set_gain(options.gain, 0) self.rtl.set_if_gain(options.ifgain,0) self.rtl.set_bb_gain(options.bbgain,0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, self.xlate_bandwidth/2, 6000)), -options.offset, samp_rate) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ((1.0/self.samp_per_sym,)*self.samp_per_sym)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,3,True) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=44100, decimation=8000, taps=None, fractional_bw=None, ) self.audio_sink_0 = audio.sink(44100, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.6) #self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) #self.connect((self.analog_quadrature_demod_cf_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.rtl, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self, center_freq=867.4105, find_chan_nums=False, freq_list=[ 866.0375, 866.2875, 866.5375, 866.7875, 867.0375, 867.2875, 867.5375, 867.7875, 868.0375, 868.2875, 868.5375, 868.7875, 866.0625, 866.3125, 866.5625, 866.8125, 867.0625, 867.3125, 867.5625, 867.8125 ], noise_threshold=5, sink_rate=48000, source_rate=4000000, talkgroup=1796, tone_threshold=0.1, track_analog=True, track_digital=False, voice_threshold=0.4): gr.hier_block2.__init__( self, "Trunked Radio", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_char * 1]), ) ################################################## # Parameters ################################################## self.center_freq = center_freq self.find_chan_nums = find_chan_nums self.freq_list = freq_list self.noise_threshold = noise_threshold self.sink_rate = sink_rate self.source_rate = source_rate self.talkgroup = talkgroup self.tone_threshold = tone_threshold self.track_analog = track_analog self.track_digital = track_digital self.voice_threshold = voice_threshold ################################################## # Variables ################################################## self.baud_rate = baud_rate = 9600 self.samp_per_sym = samp_per_sym = sink_rate / baud_rate self.fp_sel_index = fp_sel_index = 0 ################################################## # Blocks ################################################## self.edacs_handle_eot_0 = edacs.handle_eot(sink_rate, 4800, tone_threshold, noise_threshold) def _fp_sel_index_probe(): while True: val = self.edacs_handle_eot_0.get_sel_index() try: self.set_fp_sel_index(val) except AttributeError: pass time.sleep(1.0 / (100)) _fp_sel_index_thread = threading.Thread(target=_fp_sel_index_probe) _fp_sel_index_thread.daemon = True _fp_sel_index_thread.start() self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=sink_rate / 8000, decimation=1, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=int(sink_rate / 1000), decimation=int(source_rate / 100000), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(sink_rate / 1000), decimation=int(source_rate / 100000), taps=None, fractional_bw=None, ) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 100, firdes.low_pass(1, source_rate, .00625e6, .002e6, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 100, firdes.low_pass(1, source_rate, .00625e6, .002e6, firdes.WIN_HAMMING, 6.76)) self.edacs_proc_msg_0 = edacs.proc_msg(talkgroup, (freq_list), center_freq, find_chan_nums, track_analog, track_digital) self.edacs_find_chan_nums_0 = edacs.find_chan_nums( (freq_list), center_freq, source_rate, voice_threshold) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_PROVOICE, dsd.dsd_MOD_AUTO_SELECT, 3, False, 0, True, 0) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=samp_per_sym, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.digital_correlate_access_code_bb_0 = digital.correlate_access_code_bb( '010101010101010101010111000100100101010101010101', 0) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_not_xx_0 = blocks.not_bb() self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1024) self.blks2_selector_1 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=2, num_outputs=1, input_index=fp_sel_index, output_index=0, ) self.analog_sig_source_x_1 = analog.sig_source_c( source_rate, analog.GR_COS_WAVE, 0, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( source_rate, analog.GR_COS_WAVE, 0, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.msg_connect((self.edacs_find_chan_nums_0, 'status_out'), (self.edacs_proc_msg_0, 'chan_status_in')) self.msg_connect((self.edacs_handle_eot_0, 'status_out'), (self.edacs_proc_msg_0, 'eot_status_in')) self.msg_connect((self.edacs_proc_msg_0, 'ctrl_freq'), (self.analog_sig_source_x_0, 'freq')) self.msg_connect((self.edacs_proc_msg_0, 'voice_freq'), (self.analog_sig_source_x_1, 'freq')) self.msg_connect((self.edacs_proc_msg_0, 'chan_status_out'), (self.edacs_find_chan_nums_0, 'status_in')) self.msg_connect((self.edacs_proc_msg_0, 'eot_status_out'), (self.edacs_handle_eot_0, 'status_in')) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.edacs_handle_eot_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blks2_selector_1, 0), (self, 0)) self.connect((self.blocks_delay_0, 0), (self.edacs_find_chan_nums_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_not_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_not_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_correlate_access_code_bb_0, 0)) self.connect((self.digital_correlate_access_code_bb_0, 0), (self.edacs_proc_msg_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.dsd_block_ff_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.edacs_handle_eot_0, 0), (self.blks2_selector_1, 0)) self.connect((self.edacs_handle_eot_0, 0), (self.dsd_block_ff_0, 0)) self.connect((self.edacs_proc_msg_0, 0), (self, 1)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self, 0), (self.blocks_delay_0, 0)) self.connect((self, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.digital_gfsk_demod_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blks2_selector_1, 1))
def __init__(self, talkgroup, options): gr.hier_block2.__init__(self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature print "Starting log_receiver init()" self.samp_rate = samp_rate = int(options.rate) self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self.xlate_bandwidth = xlate_bandwidth = 24260.0 self.xlate_offset = xlate_offset = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE*samp_per_sym self.audio_mul = audio_mul = 1 self.pre_channel_rate = pre_channel_rate = int(samp_rate/decim) self.squelch = squelch = -55 self.auto_tune_offset = auto_tune_offset = 0 self.audiorate = 44100 #options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 ################################################## # Blocks ################################################## print "Setting up Blocks" self.audiotaps = gr.firdes.low_pass(1, samp_rate, 8000, 2000, gr.firdes.WIN_HANN) self.prefilter_decim = int(self.rate / self.audiorate) #the audio prefilter is a channel selection filter. self.audio_prefilter = gr.freq_xlating_fir_filter_ccf(self.prefilter_decim, #decimation self.audiotaps, #taps 0, #freq offset int(samp_rate)) #sampling rate self.audiodemod = blks2.fm_demod_cf(self.rate/self.prefilter_decim, #rate 1, #audio decimation 4000, #deviation 3000, #audio passband 4000, #audio stopband options.volume, #gain 75e-6) #deemphasis constant #the filtering removes FSK data woobling from the subaudible channel self.audiofilttaps = gr.firdes.high_pass(1, self.audiorate, 300, 50, gr.firdes.WIN_HANN) self.audiofilt = gr.fir_filter_fff(1, self.audiofilttaps) self.gr_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.6) #(channel_rate/(2.0 * math.pi * op25.SYMBOL_DEVIATION))) self.gr_freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 2000)), 0, samp_rate) self.gr_fir_filter_xxx_0 = filter.fir_filter_fff(1, ((1.0/samp_per_sym,)*samp_per_sym)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10.**(audio_mul/10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=self.audiorate, decimation=8000, taps=None, fractional_bw=None, ) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ("".join([random.choice(string.letters+string.digits) for x in range(8)])) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,2,True) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a'); self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink(self.filename, 1, self.audiorate, 8) #blocks.wavfile_sink(self.filename, 1, self.audiorate, 8) this version allows appending to existing files. self.audio_sink_0 = audio.sink(44100, "", True) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted. print "Connecting blocks" ################################################## # Connections ################################################## self.connect(self.blks2_rational_resampler_xxx_0, self.blocks_multiply_const_vxx_0) self.connect(self.gr_fir_filter_xxx_0 , self.valve, self.dsd_block_ff_0) self.connect(self.dsd_block_ff_0, self.blks2_rational_resampler_xxx_0) ## Start self.connect(self, self.gr_freq_xlating_fir_filter_xxx_0, self.blks2_rational_resampler_xxx_1, self.gr_quadrature_demod_cf_0, self.gr_fir_filter_xxx_0) ## End # self.connect(self.blocks_multiply_const_vxx_0, self.audio_sink_0) # Plays the audio self.connect(self.blocks_multiply_const_vxx_0, self.audiosink) # Records the audio