def __init__(self, channel_rate, auto_tune_msgq=None): gr.hier_block2.__init__(self, "op25_fsk4", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(1, 1, gr.sizeof_float)) self.symbol_rate = SYMBOL_RATE #print "Channel rate:", channel_rate self.channel_rate = channel_rate self.auto_tune_msgq = auto_tune_msgq if self.auto_tune_msgq is None: self.auto_tune_msgq = gr.msg_queue(2) # C4FM demodulator #print "Symbol rate:", self.symbol_rate try: self.demod_fsk4 = _op25.fsk4_demod_ff(self.auto_tune_msgq, self.channel_rate, self.symbol_rate) if _verbose: print "Using new fsk4_demod_ff" except: try: self.demod_fsk4 = fsk4.demod_ff(self.auto_tune_msgq, self.channel_rate, self.symbol_rate) # LEGACY if _verbose: print "Using legacy fsk4.demod_ff" except: raise Exception("Could not find a FSK4 demodulator to use") self.connect(self, self.demod_fsk4, self)
def __init__(self, sps, channel_decim, channel_taps, options, usrp_rate, channel_rate, lo_freq): gr.hier_block2.__init__(self, "rx_channel_fm", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float)) chan = gr.freq_xlating_fir_filter_ccf(int(channel_decim), channel_taps, lo_freq, usrp_rate) symbol_decim = 1 symbol_rate = 4800 self.symbol_deviation = 600.0 fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) symbol_coeffs = gr.firdes_root_raised_cosine(1.0, channel_rate, symbol_rate, 1.0, 51) symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) # C4FM demodulator autotuneq = gr.msg_queue(2) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, symbol_rate) self.connect(self, chan, fm_demod, symbol_filter, demod_fsk4, self)
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-a", "--audio-input", type="string", default="") parser.add_option("-A", "--audio-output", type="string", default="") parser.add_option("-f", "--factor", type="eng_float", default=1) parser.add_option("-i", "--do-interp", action="store_true", default=False, help="enable output interpolator") parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate") parser.add_option("-S", "--stretch", type="int", default=0, help="flex amt") parser.add_option("-y", "--symbol-rate", type="int", default=4800, help="input symbol rate") parser.add_option("-v", "--verbose", action="store_true", default=False, help="dump demodulation data") (options, args) = parser.parse_args() sample_rate = options.sample_rate symbol_rate = options.symbol_rate IN = audio.source(sample_rate, options.audio_input) audio_output_rate = 8000 if options.do_interp: audio_output_rate = 48000 OUT = audio.sink(audio_output_rate, options.audio_output) symbol_decim = 1 symbol_coeffs = gr.firdes.root_raised_cosine(1.0, # gain sample_rate , # sampling rate symbol_rate, # symbol rate 0.2, # width of trans. band 500) # filter type SYMBOL_FILTER = gr.fir_filter_fff (symbol_decim, symbol_coeffs) AMP = gr.multiply_const_ff(options.factor) msgq = gr.msg_queue(2) FSK4 = op25.fsk4_demod_ff(msgq, sample_rate, symbol_rate) levels = levels = [-2.0, 0.0, 2.0, 4.0] SLICER = repeater.fsk4_slicer_fb(levels) framer_msgq = gr.msg_queue(2) DECODE = repeater.p25_frame_assembler('', # udp hostname 0, # udp port no. options.verbose, #debug True, # do_imbe True, # do_output False, # do_msgq framer_msgq) IMBE = repeater.vocoder(False, # 0=Decode,True=Encode options.verbose, # Verbose flag options.stretch, # flex amount "", # udp ip address 0, # udp port False) # dump raw u vectors CVT = gr.short_to_float() if options.do_interp: interp_taps = gr.firdes.low_pass(1.0, 48000, 4000, 4000 * 0.1, gr.firdes.WIN_HANN) INTERP = gr.interp_fir_filter_fff(48000 // 8000, interp_taps) AMP2 = gr.multiply_const_ff(1.0 / 32767.0) self.connect(IN, AMP, SYMBOL_FILTER, FSK4, SLICER, DECODE, IMBE, CVT, AMP2) if options.do_interp: self.connect(AMP2, INTERP, OUT) else: self.connect(AMP2, OUT)
def __build_graph(self, source, capture_rate): # tell the scope the source rate self.spectrum.set_sample_rate(capture_rate) # channel filter self.channel_offset = 0.0 channel_decim = capture_rate // self.channel_rate channel_rate = capture_rate // channel_decim trans_width = 12.5e3 / 2 trans_centre = trans_width + (trans_width / 2) # discriminator tap doesn't do freq. xlation, FM demodulation, etc. if not self.baseband_input: coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) self.channel_filter = gr.freq_xlating_fir_filter_ccf( channel_decim, coeffs, 0.0, capture_rate) self.set_channel_offset(0.0, 0, self.spectrum.win._units) # power squelch squelch_db = 0 self.squelch = gr.pwr_squelch_cc(squelch_db, 1e-3, 0, True) self.set_squelch_threshold(squelch_db) # FM demodulator fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) # symbol filter symbol_decim = 1 #symbol_coeffs = gr.firdes.root_raised_cosine(1.0, channel_rate, self.symbol_rate, 0.2, 500) # boxcar coefficients for "integrate and dump" filter samples_per_symbol = channel_rate // self.symbol_rate symbol_coeffs = (1.0 / samples_per_symbol, ) * samples_per_symbol self.symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) # C4FM demodulator autotuneq = gr.msg_queue(2) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, self.symbol_rate) # for now no audio output sink = gr.null_sink(gr.sizeof_float) # connect it all up if self.baseband_input: self.rescaler = gr.multiply_const_ff(1) sinkx = gr.file_sink(gr.sizeof_float, "rx.dat") self.__connect([[ source, self.rescaler, self.symbol_filter, demod_fsk4, self.slicer, self.p25_decoder, sink ], [self.symbol_filter, self.signal_scope], [demod_fsk4, sinkx], [demod_fsk4, self.symbol_scope]]) self.connect_data_scope(not self.datascope_raw_input) else: self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) self.__connect([[ source, self.channel_filter, self.squelch, fm_demod, self.symbol_filter, demod_fsk4, self.slicer, self.p25_decoder, sink ], [source, self.spectrum], [self.symbol_filter, self.signal_scope], [demod_fsk4, self.symbol_scope]])
def __build_graph(self, source, capture_rate): # tell the scope the source rate self.spectrum.set_sample_rate(capture_rate) # channel filter self.channel_offset = 0.0 channel_decim = capture_rate // self.channel_rate channel_rate = capture_rate // channel_decim trans_width = 12.5e3 / 2 trans_centre = trans_width + (trans_width / 2) coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) self.channel_filter = gr.freq_xlating_fir_filter_ccf( channel_decim, coeffs, 0.0, capture_rate) self.set_channel_offset(0.0, 0, self.spectrum.win._units) # power squelch squelch_db = 0 self.squelch = gr.pwr_squelch_cc(squelch_db, 1e-3, 0, True) self.set_squelch_threshold(squelch_db) # FM demodulator fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) # symbol filter symbol_decim = 1 # symbol_coeffs = gr.firdes.root_raised_cosine(1.0, channel_rate, self.symbol_rate, 0.2, 500) # boxcar coefficients for "integrate and dump" filter samples_per_symbol = channel_rate // self.symbol_rate symbol_coeffs = (1.0 / samples_per_symbol, ) * samples_per_symbol symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) # C4FM demodulator autotuneq = gr.msg_queue(2) self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, self.symbol_rate) # symbol slicer levels = [-2.0, 0.0, 2.0, 4.0] slicer = op25.fsk4_slicer_fb(levels) # ALSA output device (if not locked) try: sink = audio.sink(8000, "plughw:0,0", True) # ToDo: get actual device from prefs except Exception: sink = gr.null_sink(gr.sizeof_float) # connect it all up self.__connect([[ source, self.channel_filter, self.squelch, fm_demod, symbol_filter, demod_fsk4, slicer, self.p25_decoder, sink ], [source, self.spectrum], [symbol_filter, self.signal_scope], [demod_fsk4, self.symbol_scope]])
def __build_graph(self, source, capture_rate): # tell the scope the source rate self.spectrum.set_sample_rate(capture_rate) # channel filter self.channel_offset = 0.0 channel_decim = capture_rate // self.channel_rate channel_rate = capture_rate // channel_decim trans_width = 12.5e3 / 2; trans_centre = trans_width + (trans_width / 2) coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) self.channel_filter = gr.freq_xlating_fir_filter_ccf(channel_decim, coeffs, 0.0, capture_rate) self.set_channel_offset(0.0) # power squelch squelch_db = 0 self.squelch = gr.pwr_squelch_cc(squelch_db, 1e-3, 0, True) self.set_squelch_threshold(squelch_db) # FM demodulator fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) # symbol filter symbol_decim = 1 # symbol_coeffs = gr.firdes.root_raised_cosine(1.0, channel_rate, self.symbol_rate, 0.2, 500) # boxcar coefficients for "integrate and dump" filter samples_per_symbol = channel_rate // self.symbol_rate symbol_coeffs = (1.0/samples_per_symbol,)*samples_per_symbol symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) # C4FM demodulator autotuneq = gr.msg_queue(2) self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, self.symbol_rate) # symbol slicer levels = [ -2.0, 0.0, 2.0, 4.0 ] slicer = op25.fsk4_slicer_fb(levels) # ALSA output device (if not locked) try: sink = audio.sink(8000, "plughw:0,0", True) # ToDo: get actual device from prefs except Exception: sink = gr.null_sink(gr.sizeof_float) # connect it all up self.__connect([[source, self.channel_filter, self.squelch, fm_demod, symbol_filter, demod_fsk4, slicer, self.p25_decoder, sink], [source, self.spectrum], [symbol_filter, self.signal_scope], [demod_fsk4, self.symbol_scope]])
def __build_graph(self, source, capture_rate): # tell the scope the source rate self.spectrum.set_sample_rate(capture_rate) # channel filter self.channel_offset = 0.0 channel_decim = capture_rate // self.channel_rate channel_rate = capture_rate // channel_decim trans_width = 12.5e3 / 2; trans_centre = trans_width + (trans_width / 2) coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) self.channel_filter = gr.freq_xlating_fir_filter_ccf(channel_decim, coeffs, -9500.0, capture_rate) self.set_channel_offset(0.0, 0, self.spectrum.win._units) # power squelch squelch_db = -60 self.squelch = gr.pwr_squelch_cc(squelch_db, 1e-3, 0, True) self.set_squelch_threshold(squelch_db) # FM demodulator fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) # symbol filter symbol_decim = 1 #symbol_coeffs = gr.firdes.root_raised_cosine(1.0, channel_rate, self.symbol_rate, 0.2, 500) # boxcar coefficients for "integrate and dump" filter samples_per_symbol = channel_rate // self.symbol_rate symbol_coeffs = (1.0/samples_per_symbol,)*samples_per_symbol symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) # C4FM demodulator autotuneq = gr.msg_queue(2) self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, self.symbol_rate) reverser = gr.multiply_const_ff(-1.0) # for now no audio output sink = gr.null_sink(gr.sizeof_float) # connect it all up self.__connect([[source, self.channel_filter, self.squelch, fm_demod, symbol_filter, demod_fsk4, reverser, self.slicer, self.p25_decoder, sink], [source, self.spectrum], [symbol_filter, self.signal_scope], [demod_fsk4, self.symbol_scope]])
def create(self): self.op25_msgq = gr.msg_queue(2) self.slicer = None try: levels = [ -2.0, 0.0, 2.0, 4.0 ] self.slicer = _op25.fsk4_slicer_fb(levels) self.p25_decoder = _op25.decoder_bf() # FIXME: Message queue? if _verbose: print "Using new decoder_bf" except: try: self.p25_decoder = _op25.decoder_ff(self.op25_msgq) # LEGACY if _verbose: print "Using legacy decoder_ff" except: raise Exception("Could not find a decoder to use") # Reference code #self.decode_watcher = decode_watcher(self.op25_msgq, self.traffic) if (self.key is not None) and (len(self.key) > 0): # Relates to key string passed in from GRC block self.set_key(self.key) # Reference code #trans_width = 12.5e3 / 2; #trans_centre = trans_width + (trans_width / 2) # discriminator tap doesn't do freq. xlation, FM demodulation, etc. # coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) # self.channel_filter = gr.freq_xlating_fir_filter_ccf(channel_decim, coeffs, 0.0, capture_rate) # self.set_channel_offset(0.0, 0, self.spectrum.win._units) # # power squelch # squelch_db = 0 # self.squelch = gr.pwr_squelch_cc(squelch_db, 1e-3, 0, True) # self.set_squelch_threshold(squelch_db) # # FM demodulator # fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) # fm_demod = gr.quadrature_demod_cf(fm_demod_gain) # symbol filter #symbol_decim = 1 #symbol_coeffs = gr.firdes.root_raised_cosine(1.0, channel_rate, self.symbol_rate, 0.2, 500) # boxcar coefficients for "integrate and dump" filter #samples_per_symbol = channel_rate // self.symbol_rate #symbol_duration = float(self.symbol_rate) / channel_rate #print "Symbol duration:", symbol_duration #print "Samples per symbol:", samples_per_symbol #symbol_coeffs = (1.0/samples_per_symbol,)*samples_per_symbol #self.symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) # C4FM demodulator #print "Symbol rate:", self.symbol_rate if self.auto_tune_msgq is None: self.auto_tune_msgq = gr.msg_queue(2) try: self.demod_fsk4 = _op25.fsk4_demod_ff(self.auto_tune_msgq, self.channel_rate, self.symbol_rate) if _verbose: print "Using new fsk4_demod_ff" except: try: self.demod_fsk4 = fsk4.demod_ff(self.auto_tune_msgq, self.channel_rate, self.symbol_rate) # LEGACY if _verbose: print "Using legacy fsk4.demod_ff" except: raise Exception("Could not find a FSK4 demodulator to use") # Reference code #self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) #list = [[self, self.channel_filter, self.squelch, fm_demod, self.symbol_filter, demod_fsk4, self.p25_decoder, self.sink]] self.connect(self, self.demod_fsk4) if self.slicer: self.connect(self.demod_fsk4, self.slicer) self.connect(self.slicer, self.p25_decoder) else: self.connect(self.demod_fsk4, self.p25_decoder) self.connect(self.p25_decoder, (self, 0)) if self.output_dibits: self.connect(self.demod_fsk4, (self, 1))
def __init__(self, subdev_spec, center_freq, offset_freq, decim, squelch, gain): gr.top_block.__init__(self) # configure USRP u = usrp.source_c() u.set_decim_rate(decim) capture_rate = u.adc_freq() / u.decim_rate() if subdev_spec is None: subdev_spec = usrp.pick_rx_subdevice(u) subdev = usrp.selected_subdev(u, subdev_spec) u.set_mux(usrp.determine_rx_mux_value(u, subdev_spec)) print "Using RX d'board %s" % (subdev.side_and_name(), ) if gain is None: g = subdev.gain_range() gain = float(g[0] + g[1]) / 2 subdev.set_gain(gain) u.tune(0, subdev, center_freq) # setup receiver attributes channel_rate = 125000 symbol_rate = 4800 # channel filter self.channel_offset = offset_freq channel_decim = capture_rate // channel_rate channel_rate = capture_rate // channel_decim trans_width = 12.5e3 / 2 trans_centre = trans_width + (trans_width / 2) coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) self.channel_filter = gr.freq_xlating_fir_filter_ccf( channel_decim, coeffs, self.channel_offset, capture_rate) self.connect(u, self.channel_filter) # power squelch power_squelch = gr.pwr_squelch_cc(squelch, 1e-3, 0, True) self.connect(self.channel_filter, power_squelch) # FM demodulator self.symbol_deviation = 600.0 fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) self.connect(power_squelch, fm_demod) # symbol filter symbol_decim = 1 samples_per_symbol = channel_rate // symbol_rate symbol_coeffs = (1.0 / samples_per_symbol, ) * samples_per_symbol symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) self.connect(fm_demod, symbol_filter) # C4FM demodulator autotuneq = gr.msg_queue(2) self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, symbol_rate) self.connect(symbol_filter, demod_fsk4) # symbol slicer levels = [-2.0, 0.0, 2.0, 4.0] slicer = op25.fsk4_slicer_fb(levels) self.connect(demod_fsk4, slicer) # frame decoder decoder = op25.decoder_bf() self.connect(slicer, decoder) # try to connect audio output device try: audio_sink = audio.sink(8000, "plughw:0,0", True) self.connect(decoder, audio_sink) except Exception: sink = gr.null_sink(gr.sizeof_float) self.connect(decoder, sink)
def __init__(self, interface, address, center_freq, offset_freq, decim, squelch, gain): gr.top_block.__init__(self) # setup USRP2 u = usrp2.source_32fc(interface, address) u.set_decim(decim) capture_rate = u.adc_rate() / decim u.set_center_freq(center_freq) if gain is None: g = u.gain_range() gain = float(g[0] + g[1]) / 2 u.set_gain(gain) # Setup receiver attributes channel_rate = 125000 symbol_rate = 4800 # channel filter self.channel_offset = offset_freq channel_decim = capture_rate // channel_rate channel_rate = capture_rate // channel_decim trans_width = 12.5e3 / 2 trans_centre = trans_width + (trans_width / 2) coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) self.channel_filter = gr.freq_xlating_fir_filter_ccf( channel_decim, coeffs, self.channel_offset, capture_rate) self.connect(u, self.channel_filter) # power squelch power_squelch = gr.pwr_squelch_cc(squelch, 1e-3, 0, True) self.connect(self.channel_filter, power_squelch) # FM demodulator self.symbol_deviation = 600.0 fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) self.connect(power_squelch, fm_demod) # symbol filter symbol_decim = 1 samples_per_symbol = channel_rate // symbol_rate symbol_coeffs = (1.0 / samples_per_symbol, ) * samples_per_symbol symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) self.connect(fm_demod, symbol_filter) # C4FM demodulator autotuneq = gr.msg_queue(2) self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, symbol_rate) self.connect(symbol_filter, demod_fsk4) # symbol slicer levels = [-2.0, 0.0, 2.0, 4.0] slicer = op25.fsk4_slicer_fb(levels) self.connect(demod_fsk4, slicer) # frame decoder decoder = op25.decoder_bf() self.connect(slicer, decoder) # try to connect audio output device try: audio_sink = audio.sink(8000, "plughw:0,0", True) self.connect(decoder, audio_sink) except Exception: sink = gr.null_sink(gr.sizeof_float) self.connect(decoder, null)
def create(self): self.op25_msgq = gr.msg_queue(2) self.slicer = None try: levels = [-2.0, 0.0, 2.0, 4.0] self.slicer = _op25.fsk4_slicer_fb(levels) self.p25_decoder = _op25.decoder_bf() # FIXME: Message queue? if _verbose: print "Using new decoder_bf" except: try: self.p25_decoder = _op25.decoder_ff(self.op25_msgq) # LEGACY if _verbose: print "Using legacy decoder_ff" except: raise Exception("Could not find a decoder to use") # Reference code #self.decode_watcher = decode_watcher(self.op25_msgq, self.traffic) if (self.key is not None) and ( len(self.key) > 0): # Relates to key string passed in from GRC block self.set_key(self.key) # Reference code #trans_width = 12.5e3 / 2; #trans_centre = trans_width + (trans_width / 2) # discriminator tap doesn't do freq. xlation, FM demodulation, etc. # coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) # self.channel_filter = gr.freq_xlating_fir_filter_ccf(channel_decim, coeffs, 0.0, capture_rate) # self.set_channel_offset(0.0, 0, self.spectrum.win._units) # # power squelch # squelch_db = 0 # self.squelch = gr.pwr_squelch_cc(squelch_db, 1e-3, 0, True) # self.set_squelch_threshold(squelch_db) # # FM demodulator # fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) # fm_demod = gr.quadrature_demod_cf(fm_demod_gain) # symbol filter #symbol_decim = 1 #symbol_coeffs = gr.firdes.root_raised_cosine(1.0, channel_rate, self.symbol_rate, 0.2, 500) # boxcar coefficients for "integrate and dump" filter #samples_per_symbol = channel_rate // self.symbol_rate #symbol_duration = float(self.symbol_rate) / channel_rate #print "Symbol duration:", symbol_duration #print "Samples per symbol:", samples_per_symbol #symbol_coeffs = (1.0/samples_per_symbol,)*samples_per_symbol #self.symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) # C4FM demodulator #print "Symbol rate:", self.symbol_rate if self.auto_tune_msgq is None: self.auto_tune_msgq = gr.msg_queue(2) try: self.demod_fsk4 = _op25.fsk4_demod_ff(self.auto_tune_msgq, self.channel_rate, self.symbol_rate) if _verbose: print "Using new fsk4_demod_ff" except: try: self.demod_fsk4 = fsk4.demod_ff(self.auto_tune_msgq, self.channel_rate, self.symbol_rate) # LEGACY if _verbose: print "Using legacy fsk4.demod_ff" except: raise Exception("Could not find a FSK4 demodulator to use") # Reference code #self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) #list = [[self, self.channel_filter, self.squelch, fm_demod, self.symbol_filter, demod_fsk4, self.p25_decoder, self.sink]] self.connect(self, self.demod_fsk4) if self.slicer: self.connect(self.demod_fsk4, self.slicer) self.connect(self.slicer, self.p25_decoder) else: self.connect(self.demod_fsk4, self.p25_decoder) self.connect(self.p25_decoder, (self, 0)) if self.output_dibits: self.connect(self.demod_fsk4, (self, 1))
def __init__(self, filename, offset_freq, squelch): gr.top_block.__init__(self) # open file and info f = open(filename + ".info", "r") info = cPickle.load(f) capture_rate = info["capture-rate"] f.close() file = gr.file_source(gr.sizeof_gr_complex, filename, True) throttle = gr.throttle(gr.sizeof_gr_complex, capture_rate) self.connect(file, throttle) # setup receiver attributes channel_rate = 125000 symbol_rate = 4800 # channel filter self.channel_offset = offset_freq channel_decim = capture_rate // channel_rate channel_rate = capture_rate // channel_decim trans_width = 12.5e3 / 2 trans_centre = trans_width + (trans_width / 2) coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) self.channel_filter = gr.freq_xlating_fir_filter_ccf( channel_decim, coeffs, self.channel_offset, capture_rate) self.connect(throttle, self.channel_filter) # power squelch power_squelch = gr.pwr_squelch_cc(squelch, 1e-3, 0, True) self.connect(self.channel_filter, power_squelch) # FM demodulator self.symbol_deviation = 600.0 fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) self.connect(power_squelch, fm_demod) # symbol filter symbol_decim = 1 samples_per_symbol = channel_rate // symbol_rate symbol_coeffs = (1.0 / samples_per_symbol, ) * samples_per_symbol symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) self.connect(fm_demod, symbol_filter) # C4FM demodulator autotuneq = gr.msg_queue(2) self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, symbol_rate) self.connect(symbol_filter, demod_fsk4) # symbol slicer levels = [-2.0, 0.0, 2.0, 4.0] slicer = op25.fsk4_slicer_fb(levels) self.connect(demod_fsk4, slicer) # frame decoder decoder = op25.decoder_bf() self.connect(slicer, decoder) # try to connect default output device try: audio_sink = audio.sink(8000, "plughw:0,0", True) self.connect(decoder, audio_sink) except Exception: sink = gr.null_sink(gr.sizeof_float) self.connect(decoder, sink)
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-a", "--audio-input", type="string", default="") parser.add_option("-A", "--audio-output", type="string", default="") parser.add_option("-f", "--factor", type="eng_float", default=1) parser.add_option("-i", "--do-interp", action="store_true", default=False, help="enable output interpolator") parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate") parser.add_option("-S", "--stretch", type="int", default=0, help="flex amt") parser.add_option("-y", "--symbol-rate", type="int", default=4800, help="input symbol rate") parser.add_option("-v", "--verbose", action="store_true", default=False, help="dump demodulation data") (options, args) = parser.parse_args() sample_rate = options.sample_rate symbol_rate = options.symbol_rate IN = audio.source(sample_rate, options.audio_input) audio_output_rate = 8000 if options.do_interp: audio_output_rate = 48000 OUT = audio.sink(audio_output_rate, options.audio_output) symbol_decim = 1 symbol_coeffs = gr.firdes.root_raised_cosine( 1.0, # gain sample_rate, # sampling rate symbol_rate, # symbol rate 0.2, # width of trans. band 500) # filter type SYMBOL_FILTER = gr.fir_filter_fff(symbol_decim, symbol_coeffs) AMP = gr.multiply_const_ff(options.factor) msgq = gr.msg_queue(2) FSK4 = op25.fsk4_demod_ff(msgq, sample_rate, symbol_rate) levels = levels = [-2.0, 0.0, 2.0, 4.0] SLICER = repeater.fsk4_slicer_fb(levels) framer_msgq = gr.msg_queue(2) DECODE = repeater.p25_frame_assembler( '', # udp hostname 0, # udp port no. options.verbose, #debug True, # do_imbe True, # do_output False, # do_msgq framer_msgq) IMBE = repeater.vocoder( False, # 0=Decode,True=Encode options.verbose, # Verbose flag options.stretch, # flex amount "", # udp ip address 0, # udp port False) # dump raw u vectors CVT = gr.short_to_float() if options.do_interp: interp_taps = gr.firdes.low_pass(1.0, 48000, 4000, 4000 * 0.1, gr.firdes.WIN_HANN) INTERP = gr.interp_fir_filter_fff(48000 // 8000, interp_taps) AMP2 = gr.multiply_const_ff(1.0 / 32767.0) self.connect(IN, AMP, SYMBOL_FILTER, FSK4, SLICER, DECODE, IMBE, CVT, AMP2) if options.do_interp: self.connect(AMP2, INTERP, OUT) else: self.connect(AMP2, OUT)
def __init__(self, interface, address, center_freq, offset_freq, decim, squelch, gain): gr.top_block.__init__(self) # setup USRP2 u = usrp2.source_32fc(interface, address) u.set_decim(decim) capture_rate = u.adc_rate() / decim u.set_center_freq(center_freq) if gain is None: g = u.gain_range() gain = float(g[0] + g[1]) / 2 u.set_gain(gain) # Setup receiver attributes channel_rate = 125000 symbol_rate = 4800 # channel filter self.channel_offset = offset_freq channel_decim = capture_rate // channel_rate channel_rate = capture_rate // channel_decim trans_width = 12.5e3 / 2; trans_centre = trans_width + (trans_width / 2) coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) self.channel_filter = gr.freq_xlating_fir_filter_ccf(channel_decim, coeffs, self.channel_offset, capture_rate) self.connect(u, self.channel_filter) # power squelch power_squelch = gr.pwr_squelch_cc(squelch, 1e-3, 0, True) self.connect(self.channel_filter, power_squelch) # FM demodulator self.symbol_deviation = 600.0 fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) self.connect(power_squelch, fm_demod) # symbol filter symbol_decim = 1 samples_per_symbol = channel_rate // symbol_rate symbol_coeffs = (1.0/samples_per_symbol,) * samples_per_symbol symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) self.connect(fm_demod, symbol_filter) # C4FM demodulator autotuneq = gr.msg_queue(2) self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, symbol_rate) self.connect(symbol_filter, demod_fsk4) # symbol slicer levels = [ -2.0, 0.0, 2.0, 4.0 ] slicer = op25.fsk4_slicer_fb(levels) self.connect(demod_fsk4, slicer) # frame decoder decoder = op25.decoder_bf() self.connect(slicer, decoder) # try to connect audio output device try: audio_sink = audio.sink(8000, "plughw:0,0", True) self.connect(decoder, audio_sink) except Exception: sink = gr.null_sink(gr.sizeof_float) self.connect(decoder, null);
def __init__(self): gr.top_block.__init__(self) parser = OptionParser(option_class=eng_option) parser.add_option("-a", "--audio-input", type="string", default="") parser.add_option("-A", "--analog-gain", type="float", default=1.0, help="output gain for analog channel") parser.add_option("-c", "--ctcss-freq", type="float", default=0.0, help="CTCSS tone frequency") parser.add_option("-d", "--debug", type="int", default=0, help="debug level") parser.add_option("-g", "--gain", type="eng_float", default=1, help="adjusts input level for standard data levels") parser.add_option("-H", "--hostname", type="string", default="127.0.0.1", help="asterisk host IP") parser.add_option("-p", "--port", type="int", default=32001, help="chan_usrp UDP port") parser.add_option("-s", "--sample-rate", type="int", default=48000, help="input sample rate") parser.add_option("-S", "--stretch", type="int", default=0) (options, args) = parser.parse_args() sample_rate = options.sample_rate symbol_rate = 4800 symbol_decim = 1 IN = audio.source(sample_rate, options.audio_input) symbol_coeffs = gr.firdes.root_raised_cosine( 1.0, # gain sample_rate, # sampling rate symbol_rate, # symbol rate 0.2, # width of trans. band 500) # filter type SYMBOL_FILTER = gr.fir_filter_fff(symbol_decim, symbol_coeffs) AMP = gr.multiply_const_ff(options.gain) msgq = gr.msg_queue(2) FSK4 = op25.fsk4_demod_ff(msgq, sample_rate, symbol_rate) levels = levels = [-2.0, 0.0, 2.0, 4.0] SLICER = repeater.fsk4_slicer_fb(levels) framer_msgq = gr.msg_queue(2) DECODE = repeater.p25_frame_assembler( '', # udp hostname 0, # udp port no. options.debug, #debug True, # do_imbe True, # do_output False, # do_msgq framer_msgq) IMBE = repeater.vocoder( False, # 0=Decode,True=Encode options.debug, # Verbose flag options.stretch, # flex amount "", # udp ip address 0, # udp port False) # dump raw u vectors CHAN_RPT = repeater.chan_usrp_rx(options.hostname, options.port, options.debug) self.connect(IN, AMP, SYMBOL_FILTER, FSK4, SLICER, DECODE, IMBE, CHAN_RPT) # blocks for second channel (fm rx) output_sample_rate = 8000 decim_amt = sample_rate / output_sample_rate RESAMP = blks2.rational_resampler_fff(1, decim_amt) if options.ctcss_freq > 0: level = 5.0 len = 0 ramp = 0 gate = True CTCSS = repeater.ctcss_squelch_ff(output_sample_rate, options.ctcss_freq, level, len, ramp, gate) AMP2 = gr.multiply_const_ff(32767.0 * options.analog_gain) CVT = gr.float_to_short() CHAN_RPT2 = repeater.chan_usrp_rx(options.hostname, options.port + 1, options.debug) if options.ctcss_freq > 0: self.connect(IN, RESAMP, CTCSS, AMP2, CVT, CHAN_RPT2) else: self.connect(IN, RESAMP, AMP2, CVT, CHAN_RPT2)
def __init__(self, subdev_spec, center_freq, offset_freq, decim, squelch, gain): gr.top_block.__init__(self) # configure USRP u = usrp.source_c() u.set_decim_rate(decim) capture_rate = u.adc_freq() / u.decim_rate() if subdev_spec is None: subdev_spec = usrp.pick_rx_subdevice(u) subdev = usrp.selected_subdev(u, subdev_spec) u.set_mux(usrp.determine_rx_mux_value(u, subdev_spec)) print "Using RX d'board %s" % (subdev.side_and_name(),) if gain is None: g = subdev.gain_range() gain = float(g[0] + g[1]) / 2 subdev.set_gain(gain) u.tune(0, subdev, center_freq) # setup receiver attributes channel_rate = 125000 symbol_rate = 4800 # channel filter self.channel_offset = offset_freq channel_decim = capture_rate // channel_rate channel_rate = capture_rate // channel_decim trans_width = 12.5e3 / 2; trans_centre = trans_width + (trans_width / 2) coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) self.channel_filter = gr.freq_xlating_fir_filter_ccf(channel_decim, coeffs, self.channel_offset, capture_rate) self.connect(u, self.channel_filter) # power squelch power_squelch = gr.pwr_squelch_cc(squelch, 1e-3, 0, True) self.connect(self.channel_filter, power_squelch) # FM demodulator self.symbol_deviation = 600.0 fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) self.connect(power_squelch, fm_demod) # symbol filter symbol_decim = 1 samples_per_symbol = channel_rate // symbol_rate symbol_coeffs = (1.0/samples_per_symbol,) * samples_per_symbol symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) self.connect(fm_demod, symbol_filter) # C4FM demodulator autotuneq = gr.msg_queue(2) self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, symbol_rate) self.connect(symbol_filter, demod_fsk4) # symbol slicer levels = [ -2.0, 0.0, 2.0, 4.0 ] slicer = op25.fsk4_slicer_fb(levels) self.connect(demod_fsk4, slicer) # frame decoder decoder = op25.decoder_bf() self.connect(slicer, decoder) # try to connect audio output device try: audio_sink = audio.sink(8000, "plughw:0,0", True) self.connect(decoder, audio_sink) except Exception: sink = gr.null_sink(gr.sizeof_float) self.connect(decoder, sink)
def __init__(self, filename, offset_freq, squelch): gr.top_block.__init__(self) # open file and info f = open(filename + ".info", "r") info = cPickle.load(f) capture_rate = info["capture-rate"] f.close() file = gr.file_source(gr.sizeof_gr_complex, filename, True) throttle = gr.throttle(gr.sizeof_gr_complex, capture_rate) self.connect(file, throttle) # setup receiver attributes channel_rate = 125000 symbol_rate = 4800 # channel filter self.channel_offset = offset_freq channel_decim = capture_rate // channel_rate channel_rate = capture_rate // channel_decim trans_width = 12.5e3 / 2; trans_centre = trans_width + (trans_width / 2) coeffs = gr.firdes.low_pass(1.0, capture_rate, trans_centre, trans_width, gr.firdes.WIN_HANN) self.channel_filter = gr.freq_xlating_fir_filter_ccf(channel_decim, coeffs, self.channel_offset, capture_rate) self.connect(throttle, self.channel_filter) # power squelch power_squelch = gr.pwr_squelch_cc(squelch, 1e-3, 0, True) self.connect(self.channel_filter, power_squelch) # FM demodulator self.symbol_deviation = 600.0 fm_demod_gain = channel_rate / (2.0 * pi * self.symbol_deviation) fm_demod = gr.quadrature_demod_cf(fm_demod_gain) self.connect(power_squelch, fm_demod) # symbol filter symbol_decim = 1 samples_per_symbol = channel_rate // symbol_rate symbol_coeffs = (1.0/samples_per_symbol,) * samples_per_symbol symbol_filter = gr.fir_filter_fff(symbol_decim, symbol_coeffs) self.connect(fm_demod, symbol_filter) # C4FM demodulator autotuneq = gr.msg_queue(2) self.demod_watcher = demod_watcher(autotuneq, self.adjust_channel_offset) demod_fsk4 = op25.fsk4_demod_ff(autotuneq, channel_rate, symbol_rate) self.connect(symbol_filter, demod_fsk4) # symbol slicer levels = [ -2.0, 0.0, 2.0, 4.0 ] slicer = op25.fsk4_slicer_fb(levels) self.connect(demod_fsk4, slicer) # frame decoder decoder = op25.decoder_bf() self.connect(slicer, decoder) # try to connect default output device try: audio_sink = audio.sink(8000, "plughw:0,0", True) self.connect(decoder, audio_sink) except Exception: sink = gr.null_sink(gr.sizeof_float) self.connect(decoder, sink)