def __init__(self, options, args): gr.top_block.__init__(self) pubsub.__init__(self) self._verbose = options.verbose #initialize values from options self._setup_usrpx(options) self[SAMP_RATE_KEY] = options.samp_rate self[TX_FREQ_KEY] = options.tx_freq self[AMPLITUDE_KEY] = options.amplitude self[WAVEFORM_FREQ_KEY] = options.waveform_freq self[WAVEFORM_OFFSET_KEY] = options.offset self[WAVEFORM2_FREQ_KEY] = options.waveform2_freq self[DSP_FREQ_KEY] = 0 self[RF_FREQ_KEY] = 0 #subscribe set methods self.subscribe(SAMP_RATE_KEY, self.set_samp_rate) self.subscribe(GAIN_KEY, self.set_gain) self.subscribe(TX_FREQ_KEY, self.set_freq) self.subscribe(AMPLITUDE_KEY, self.set_amplitude) self.subscribe(WAVEFORM_FREQ_KEY, self.set_waveform_freq) self.subscribe(WAVEFORM2_FREQ_KEY, self.set_waveform2_freq) self.subscribe(TYPE_KEY, self.set_waveform) #force update on pubsub keys for key in (SAMP_RATE_KEY, GAIN_KEY, TX_FREQ_KEY, AMPLITUDE_KEY, WAVEFORM_FREQ_KEY, WAVEFORM_OFFSET_KEY, WAVEFORM2_FREQ_KEY): self[key] = self[key] self[TYPE_KEY] = options.type #set type last
def __init__(self, parent=None, sizer=None, proportion=0, flag=wx.EXPAND, ps=None, key='', value=None, callback=None, converter=converters.identity_converter()): pubsub.__init__(self) wx.BoxSizer.__init__(self, wx.HORIZONTAL) self._parent = parent self._key = key self._converter = converter self._callback = callback self._widgets = list() #add to the sizer if provided if sizer: sizer.Add(self, proportion, flag) #proxy the pubsub and key into this form if ps is not None: assert key self.proxy(EXT_KEY, ps, key) #no pubsub passed, must set initial value else: self.set_value(value)
def __init__(self, options, args): gr.top_block.__init__(self) pubsub.__init__(self) self._verbose = options.verbose #initialize values from options self._setup_usrpx(options) self.subscribe(INTERP_KEY, lambda i: setter(self, SAMP_RATE_KEY, self[DAC_RATE_KEY]/i)) self.subscribe(SAMP_RATE_KEY, lambda e: setter(self, LINK_RATE_KEY, e*32)) self[INTERP_KEY] = options.interp or 16 self[TX_FREQ_KEY] = options.tx_freq self[AMPLITUDE_KEY] = options.amplitude self[WAVEFORM_FREQ_KEY] = options.waveform_freq self[WAVEFORM_OFFSET_KEY] = options.offset self[WAVEFORM2_FREQ_KEY] = options.waveform2_freq self[BB_FREQ_KEY] = 0 self[DDC_FREQ_KEY] = 0 #subscribe set methods self.subscribe(INTERP_KEY, self.set_interp) self.subscribe(GAIN_KEY, self.set_gain) self.subscribe(TX_FREQ_KEY, self.set_freq) self.subscribe(AMPLITUDE_KEY, self.set_amplitude) self.subscribe(WAVEFORM_FREQ_KEY, self.set_waveform_freq) self.subscribe(WAVEFORM2_FREQ_KEY, self.set_waveform2_freq) self.subscribe(TYPE_KEY, self.set_waveform) #force update on pubsub keys for key in (INTERP_KEY, GAIN_KEY, TX_FREQ_KEY, AMPLITUDE_KEY, WAVEFORM_FREQ_KEY, WAVEFORM_OFFSET_KEY, WAVEFORM2_FREQ_KEY): self[key] = self[key] self[TYPE_KEY] = options.type #set type last
def __init__(self, options, args): gr.top_block.__init__(self) pubsub.__init__(self) self._verbose = options.verbose #initialize values from options self._setup_usrpx(options) self.subscribe( INTERP_KEY, lambda i: setter(self, SAMP_RATE_KEY, self[DAC_RATE_KEY] / i)) self.subscribe(SAMP_RATE_KEY, lambda e: setter(self, LINK_RATE_KEY, e * 32)) self[INTERP_KEY] = options.interp or 16 self[TX_FREQ_KEY] = options.tx_freq self[AMPLITUDE_KEY] = options.amplitude self[WAVEFORM_FREQ_KEY] = options.waveform_freq self[WAVEFORM_OFFSET_KEY] = options.offset self[WAVEFORM2_FREQ_KEY] = options.waveform2_freq self[BB_FREQ_KEY] = 0 self[DDC_FREQ_KEY] = 0 #subscribe set methods self.subscribe(INTERP_KEY, self.set_interp) self.subscribe(GAIN_KEY, self.set_gain) self.subscribe(TX_FREQ_KEY, self.set_freq) self.subscribe(AMPLITUDE_KEY, self.set_amplitude) self.subscribe(WAVEFORM_FREQ_KEY, self.set_waveform_freq) self.subscribe(WAVEFORM2_FREQ_KEY, self.set_waveform2_freq) self.subscribe(TYPE_KEY, self.set_waveform) #force update on pubsub keys for key in (INTERP_KEY, GAIN_KEY, TX_FREQ_KEY, AMPLITUDE_KEY, WAVEFORM_FREQ_KEY, WAVEFORM_OFFSET_KEY, WAVEFORM2_FREQ_KEY): self[key] = self[key] self[TYPE_KEY] = options.type #set type last
def __init__(self, frame, panel, vbox, top_block, options, args): pubsub.__init__(self) self.frame = frame # Use for top-level application window frame self.panel = panel # Use as parent class for created windows self.vbox = vbox # Use as sizer for created windows self.tb = top_block # GUI-unaware flowgraph class self.options = options # Supplied command-line options self.args = args # Supplied command-line arguments self.build_gui()
def __init__(self, args): gr.top_block.__init__(self) pubsub.__init__(self) UHDApp.__init__(self, args=args, prefix="UHD-SIGGEN") self.extra_sink = None # Allocate some attributes self._src1 = None self._src2 = None self._src = None # Initialize device: self.setup_usrp( ctor=uhd.usrp_sink, args=args, ) print("[UHD-SIGGEN] UHD Signal Generator") print("[UHD-SIGGEN] UHD Version: {ver}".format( ver=uhd.get_version_string())) print("[UHD-SIGGEN] Using USRP configuration:") print(self.get_usrp_info_string(tx_or_rx="tx")) self.usrp_description = self.get_usrp_info_string(tx_or_rx="tx", compact=True) ### Set subscribers and publishers: self.publish(SAMP_RATE_KEY, lambda: self.usrp.get_samp_rate()) self.publish(DESC_KEY, lambda: self.usrp_description) self.publish(FREQ_RANGE_KEY, lambda: self.usrp.get_freq_range(self.channels[0])) self.publish(GAIN_RANGE_KEY, lambda: self.usrp.get_gain_range(self.channels[0])) self.publish(GAIN_KEY, lambda: self.usrp.get_gain(self.channels[0])) self[SAMP_RATE_KEY] = args.samp_rate self[TX_FREQ_KEY] = args.freq self[AMPLITUDE_KEY] = args.amplitude self[WAVEFORM_FREQ_KEY] = args.waveform_freq self[WAVEFORM_OFFSET_KEY] = args.offset self[WAVEFORM2_FREQ_KEY] = args.waveform2_freq self[DSP_FREQ_KEY] = 0 self[RF_FREQ_KEY] = 0 #subscribe set methods self.subscribe(SAMP_RATE_KEY, self.set_samp_rate) self.subscribe(GAIN_KEY, self.set_gain) self.subscribe(TX_FREQ_KEY, self.set_freq) self.subscribe(AMPLITUDE_KEY, self.set_amplitude) self.subscribe(WAVEFORM_FREQ_KEY, self.set_waveform_freq) self.subscribe(WAVEFORM2_FREQ_KEY, self.set_waveform2_freq) self.subscribe(TYPE_KEY, self.set_waveform) #force update on pubsub keys for key in (SAMP_RATE_KEY, GAIN_KEY, TX_FREQ_KEY, AMPLITUDE_KEY, WAVEFORM_FREQ_KEY, WAVEFORM_OFFSET_KEY, WAVEFORM2_FREQ_KEY): self[key] = self[key] self[TYPE_KEY] = args.type #set type last
def __init__(self, args): gr.top_block.__init__(self) pubsub.__init__(self) UHDApp.__init__(self, args=args, prefix="UHD-SIGGEN") self.extra_sink = None # Allocate some attributes self._src1 = None self._src2 = None self._src = None # Initialize device: self.setup_usrp( ctor=uhd.usrp_sink, args=args, ) print("[UHD-SIGGEN] UHD Signal Generator") print("[UHD-SIGGEN] UHD Version: {ver}".format(ver=uhd.get_version_string())) print("[UHD-SIGGEN] Using USRP configuration:") print(self.get_usrp_info_string(tx_or_rx="tx")) self.usrp_description = self.get_usrp_info_string(tx_or_rx="tx", compact=True) ### Set subscribers and publishers: self.publish(SAMP_RATE_KEY, lambda: self.usrp.get_samp_rate()) self.publish(DESC_KEY, lambda: self.usrp_description) self.publish(FREQ_RANGE_KEY, lambda: self.usrp.get_freq_range(self.channels[0])) self.publish(GAIN_RANGE_KEY, lambda: self.usrp.get_gain_range(self.channels[0])) self.publish(GAIN_KEY, lambda: self.usrp.get_gain(self.channels[0])) self[SAMP_RATE_KEY] = args.samp_rate self[TX_FREQ_KEY] = args.freq self[AMPLITUDE_KEY] = args.amplitude self[WAVEFORM_FREQ_KEY] = args.waveform_freq self[WAVEFORM_OFFSET_KEY] = args.offset self[WAVEFORM2_FREQ_KEY] = args.waveform2_freq self[DSP_FREQ_KEY] = 0 self[RF_FREQ_KEY] = 0 #subscribe set methods self.subscribe(SAMP_RATE_KEY, self.set_samp_rate) self.subscribe(GAIN_KEY, self.set_gain) self.subscribe(TX_FREQ_KEY, self.set_freq) self.subscribe(AMPLITUDE_KEY, self.set_amplitude) self.subscribe(WAVEFORM_FREQ_KEY, self.set_waveform_freq) self.subscribe(WAVEFORM2_FREQ_KEY, self.set_waveform2_freq) self.subscribe(TYPE_KEY, self.set_waveform) #force update on pubsub keys for key in (SAMP_RATE_KEY, GAIN_KEY, TX_FREQ_KEY, AMPLITUDE_KEY, WAVEFORM_FREQ_KEY, WAVEFORM_OFFSET_KEY, WAVEFORM2_FREQ_KEY): self[key] = self[key] self[TYPE_KEY] = args.type #set type last
def __init__(self, options): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._source = osmosdr.source(options.source) wat = self._source.get_sample_rates() rate = wat.stop() # Maximum available sample rate print "Using sample rate of %d" % rate self._source.set_sample_rate(rate) self._source.set_gain(34) self._source.set_center_freq(options.center_freq) channel_spacing = 25e3 channel_decimation = int(rate / channel_spacing) print "Using channel decimation of %d" % channel_decimation taps = firdes.low_pass(1.0, rate, channel_spacing*0.4, channel_spacing*0.1, firdes.WIN_HANN) #taps = optfir.low_pass(1.0, # rate, # 11000, # 12500, # 0.1, # 60) self._ctrl_chan = freq_xlating_fir_filter_ccf(channel_decimation, taps, options.ctrl_freq - options.center_freq, rate) data_sample_rate = float(rate) / channel_decimation print "Using data sample rate of %f" % data_sample_rate self._data_path = smartnet_all_rx(data_sample_rate) self.connect(self._source, self._ctrl_chan, self._data_path) if options.fft: pass
def __init__(self, options, args): gr.top_block.__init__(self) pubsub.__init__(self) self._verbose = options.verbose #initialize values from options self._setup_osmosdr(options) self[SAMP_RATE_KEY] = options.samp_rate self[TX_FREQ_KEY] = options.tx_freq self[FREQ_CORR_KEY] = options.freq_corr self[AMPLITUDE_KEY] = options.amplitude self[WAVEFORM_FREQ_KEY] = options.waveform_freq self[WAVEFORM_OFFSET_KEY] = options.offset self[WAVEFORM2_FREQ_KEY] = options.waveform2_freq # initialize reasonable defaults for DC / IQ correction self[DC_OFFSET_REAL] = 0 self[DC_OFFSET_IMAG] = 0 self[IQ_BALANCE_MAG] = 0 self[IQ_BALANCE_PHA] = 0 #subscribe set methods self.subscribe(SAMP_RATE_KEY, self.set_samp_rate) for name in self.get_gain_names(): self.subscribe(GAIN_KEY(name), (lambda gain, self=self, name=name: self.set_named_gain(gain, name))) self.subscribe(BWIDTH_KEY, self.set_bandwidth) self.subscribe(TX_FREQ_KEY, self.set_freq) self.subscribe(FREQ_CORR_KEY, self.set_freq_corr) self.subscribe(AMPLITUDE_KEY, self.set_amplitude) self.subscribe(WAVEFORM_FREQ_KEY, self.set_waveform_freq) self.subscribe(WAVEFORM2_FREQ_KEY, self.set_waveform2_freq) self.subscribe(TYPE_KEY, self.set_waveform) self.subscribe(DC_OFFSET_REAL, self.set_dc_offset) self.subscribe(DC_OFFSET_IMAG, self.set_dc_offset) self.subscribe(IQ_BALANCE_MAG, self.set_iq_balance) self.subscribe(IQ_BALANCE_PHA, self.set_iq_balance) #force update on pubsub keys for key in (SAMP_RATE_KEY, GAIN_KEY, BWIDTH_KEY, TX_FREQ_KEY, FREQ_CORR_KEY, AMPLITUDE_KEY, WAVEFORM_FREQ_KEY, WAVEFORM_OFFSET_KEY, WAVEFORM2_FREQ_KEY): #print key, "=", self[key] self[key] = self[key] self[TYPE_KEY] = options.type #set type last
def __init__(self, options, context): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._queue = gr.msg_queue() self._rate = int(options.rate) self._resample = None self._setup_source(options) if self._rate < 4e6: self._resample = pfb.arb_resampler_ccf(4.e6 / self._rate) self._rx_rate = 4e6 else: self._rx_rate = self._rate self._rx_path = air_modes.rx_path(self._rx_rate, options.threshold, self._queue, options.pmf, options.dcblock) #now subscribe to set various options via pubsub self.subscribe("freq", self.set_freq) self.subscribe("gain", self.set_gain) self.subscribe("rate", self.set_rate) self.subscribe("rate", self._rx_path.set_rate) self.subscribe("threshold", self._rx_path.set_threshold) self.subscribe("pmf", self._rx_path.set_pmf) self.publish("freq", self.get_freq) self.publish("gain", self.get_gain) self.publish("rate", self.get_rate) self.publish("threshold", self._rx_path.get_threshold) self.publish("pmf", self._rx_path.get_pmf) if self._resample is not None: self.connect(self._u, self._resample, self._rx_path) else: self.connect(self._u, self._rx_path) #Publish messages when they come back off the queue server_addr = ["inproc://modes-radio-pub"] if options.tcp is not None: server_addr += ["tcp://*:%i" % options.tcp] self._sender = air_modes.zmq_pubsub_iface(context, subaddr=None, pubaddr=server_addr) self._async_sender = gru.msgq_runner(self._queue, self.send)
def __init__(self, options, args): gr.top_block.__init__(self) pubsub.__init__(self) self._verbose = options.verbose #initialize values from options self._setup_osmosdr(options) self[SAMP_RATE_KEY] = options.samp_rate self[TX_FREQ_KEY] = options.tx_freq self[FREQ_CORR_KEY] = options.freq_corr self[AMPLITUDE_KEY] = options.amplitude self[WAVEFORM_FREQ_KEY] = options.waveform_freq self[WAVEFORM_OFFSET_KEY] = options.offset self[WAVEFORM2_FREQ_KEY] = options.waveform2_freq # initialize reasonable defaults for DC / IQ correction self[DC_OFFSET_REAL] = 0 self[DC_OFFSET_IMAG] = 0 self[IQ_BALANCE_MAG] = 0 self[IQ_BALANCE_PHA] = 0 #subscribe set methods self.subscribe(SAMP_RATE_KEY, self.set_samp_rate) for name in self.get_gain_names(): self.subscribe(GAIN_KEY(name), (lambda gain,self=self,name=name: self.set_named_gain(gain, name))) self.subscribe(BWIDTH_KEY, self.set_bandwidth) self.subscribe(TX_FREQ_KEY, self.set_freq) self.subscribe(FREQ_CORR_KEY, self.set_freq_corr) self.subscribe(AMPLITUDE_KEY, self.set_amplitude) self.subscribe(WAVEFORM_FREQ_KEY, self.set_waveform_freq) self.subscribe(WAVEFORM2_FREQ_KEY, self.set_waveform2_freq) self.subscribe(TYPE_KEY, self.set_waveform) self.subscribe(DC_OFFSET_REAL, self.set_dc_offset) self.subscribe(DC_OFFSET_IMAG, self.set_dc_offset) self.subscribe(IQ_BALANCE_MAG, self.set_iq_balance) self.subscribe(IQ_BALANCE_PHA, self.set_iq_balance) #force update on pubsub keys for key in (SAMP_RATE_KEY, GAIN_KEY, BWIDTH_KEY, TX_FREQ_KEY, FREQ_CORR_KEY, AMPLITUDE_KEY, WAVEFORM_FREQ_KEY, WAVEFORM_OFFSET_KEY, WAVEFORM2_FREQ_KEY): #print key, "=", self[key] self[key] = self[key] self[TYPE_KEY] = options.type #set type last
def __init__(self, options, context): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._queue = gr.msg_queue() self._rate = int(options.rate) self._resample = None self._setup_source(options) if self._rate < 4e6: self._resample = pfb.arb_resampler_ccf(4.e6/self._rate) self._rx_rate = 4e6 else: self._rx_rate = self._rate self._rx_path = air_modes.rx_path(self._rx_rate, options.threshold, self._queue, options.pmf, options.dcblock) #now subscribe to set various options via pubsub self.subscribe("freq", self.set_freq) self.subscribe("gain", self.set_gain) self.subscribe("rate", self.set_rate) self.subscribe("rate", self._rx_path.set_rate) self.subscribe("threshold", self._rx_path.set_threshold) self.subscribe("pmf", self._rx_path.set_pmf) self.publish("freq", self.get_freq) self.publish("gain", self.get_gain) self.publish("rate", self.get_rate) self.publish("threshold", self._rx_path.get_threshold) self.publish("pmf", self._rx_path.get_pmf) if self._resample is not None: self.connect(self._u, self._resample, self._rx_path) else: self.connect(self._u, self._rx_path) #Publish messages when they come back off the queue server_addr = ["inproc://modes-radio-pub"] if options.tcp is not None: server_addr += ["tcp://*:%i" % options.tcp] self._sender = air_modes.zmq_pubsub_iface(context, subaddr=None, pubaddr=server_addr) self._async_sender = gru.msgq_runner(self._queue, self.send)
def __init__(self, options): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._feed = scanner.trunked_feed(options, nchans=2) self._monitor = [int(i) for i in options.monitor.split(",")] self._tg_assignments = {} if options.type == 'smartnet': self._data_path = scanner.smartnet_ctrl_rx(self._feed.get_rate("ctrl")) elif options.type == 'edacs': self._data_path = scanner.edacs_ctrl_rx(self._feed.get_rate("ctrl")) else: raise Exception("Invalid network type (must be edacs or smartnet)") self.connect((self._feed,0), self._data_path) options.rate = self._feed.get_rate("audio") self._audio_path = scanner.audio_path(options) self.connect((self._feed,1), self._audio_path) #setup a callback to retune the audio feed freq self._data_path.set_assign_callback(self.handle_assignment)
def __init__(self, options): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._queue = gr.msg_queue() self._u = self._setup_source(options) self._rate = self.get_rate() print "Rate is %i" % (self._rate,) self._rx_path1 = ais_rx(161.975e6 - 162.0e6, options.rate, "A", self._queue, options.viterbi) self._rx_path2 = ais_rx(162.025e6 - 162.0e6, options.rate, "B", self._queue, options.viterbi) self.connect(self._u, self._rx_path1) self.connect(self._u, self._rx_path2) #now subscribe to set various options via pubsub self.subscribe("gain", self.set_gain) self.subscribe("rate", self.set_rate) self.publish("gain", self.get_gain) self.publish("rate", self.get_rate) self._async_sender = gru.msgq_runner(self._queue, self.send)
def __init__(self, options): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._u = self._setup_source(options) self._rate = self.get_rate() print "Rate is %i" % (self._rate,) if options.singlechannel is True: self._rx_paths = (ais_rx(0, options.rate, "A"),) else: self._rx_paths = (ais_rx(161.975e6 - 162.0e6, options.rate, "A"), ais_rx(162.025e6 - 162.0e6, options.rate, "B")) for rx_path in self._rx_paths: self.connect(self._u, rx_path) #now subscribe to set various options via pubsub self.subscribe("gain", self.set_gain) self.subscribe("rate", self.set_rate) self.publish("gain", self.get_gain) self.publish("rate", self.get_rate)
def __init__(self, options): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._u = self._setup_source(options) self._rate = self.get_rate() print("Rate is %i" % (self._rate,)) if options.singlechannel is True: self._rx_paths = (ais_rx(0, options.rate, "A"),) else: self._rx_paths = (ais_rx(161.975e6 - 162.0e6, options.rate, "A"), ais_rx(162.025e6 - 162.0e6, options.rate, "B")) for rx_path in self._rx_paths: self.connect(self._u, rx_path) #now subscribe to set various options via pubsub self.subscribe("gain", self.set_gain) self.subscribe("rate", self.set_rate) self.publish("gain", self.get_gain) self.publish("rate", self.get_rate)
def __init__(self, options): gr.top_block.__init__(self) pubsub.__init__(self) self._options = options self._feed = scanner.trunked_feed(options, nchans=2) self._monitor = [int(i) for i in options.monitor.split(",")] self._tg_assignments = {} if options.type == 'smartnet': self._data_path = scanner.smartnet_ctrl_rx( self._feed.get_rate("ctrl")) elif options.type == 'edacs': self._data_path = scanner.edacs_ctrl_rx( self._feed.get_rate("ctrl")) else: raise Exception("Invalid network type (must be edacs or smartnet)") self.connect((self._feed, 0), self._data_path) options.rate = self._feed.get_rate("audio") self._audio_path = scanner.audio_path(options) self.connect((self._feed, 1), self._audio_path) #setup a callback to retune the audio feed freq self._data_path.set_assign_callback(self.handle_assignment)
def __init__(self, options, args): gr.top_block.__init__(self, "RDS Tropo Detector") pubsub.__init__(self) # Retrieve the selected options self.options = options self._verbose = options.verbose # Variables self.freq = 99.5e6 self.samp_rate = 1000000 # TODO FIX : sampling rate self.bb_decim = 4 self.freq_offset = baseband_rate = self.samp_rate/self.bb_decim self.audio_decim = 5 self.xlate_bandwidth = 100000 self.gain = 20 self.freq_tune = self.freq - self.freq_offset # Initialize the device using OsmoSDR library self.src = osmosdr.source(options.args) try: self.src.get_sample_rates().start() except RuntimeError: print "Source has no sample rates (wrong device arguments?)." sys.exit(1) # Set the antenna if(options.antenna): self.src.set_antenna(options.antenna) # Apply the selected settings self.src.set_sample_rate(options.samp_rate) #self.src.set_sample_rate(self.samp_rate) self.src.set_center_freq(self.freq_tune, 0) self.src.set_freq_corr(0, 0) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) self.src.set_gain_mode(False, 0) self.src.set_gain(self.gain, 0) self.src.set_if_gain(20, 0) self.src.set_bb_gain(20, 0) self.src.set_antenna("", 0) self.src.set_bandwidth(0, 0) # Blocks self.fir_in = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1, self.samp_rate, self.xlate_bandwidth, 100000)), self.freq_offset, self.samp_rate) self.fm_demod = analog.wfm_rcv( quad_rate=self.samp_rate, audio_decimation=self.bb_decim, ) self.fir_bb = filter.freq_xlating_fir_filter_fcf( self.audio_decim, (firdes.low_pass(2500.0,baseband_rate,2.4e3,2e3,firdes.WIN_HAMMING)), 57e3, baseband_rate) self.rrc = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, self.samp_rate/self.bb_decim/self.audio_decim, 2375, 1, 100)) self.mpsk_demod = digital.mpsk_receiver_cc(2, 0, 1*cmath.pi/100.0, -0.06, 0.06, 0.5, 0.05, self.samp_rate/self.bb_decim/self.audio_decim/ 2375.0, 0.001, 0.005) self.complex_to_real = blocks.complex_to_real(1) self.slicer = digital.binary_slicer_fb() self.skip = blocks.keep_one_in_n(1, 2) self.diff = digital.diff_decoder_bb(2) self.rds_decoder = rds.decoder(False, False) self.rds_parser = rds.parser(False, False, 1) self.rds_pi_extract = rds_pi() # Connections self.connect((self.src, 0), (self.fir_in, 0)) self.connect((self.fir_in, 0), (self.fm_demod, 0)) self.connect((self.fm_demod, 0), (self.fir_bb, 0)) self.connect((self.fir_bb, 0), (self.rrc, 0)) self.connect((self.rrc, 0), (self.mpsk_demod, 0)) self.connect((self.mpsk_demod, 0), (self.complex_to_real, 0)) self.connect((self.complex_to_real, 0), (self.slicer, 0)) self.connect((self.slicer, 0), (self.skip, 0)) self.connect((self.skip, 0), (self.diff, 0)) self.connect((self.diff, 0), (self.rds_decoder, 0)) self.msg_connect((self.rds_decoder, 'out'), (self.rds_parser, 'in')) self.msg_connect((self.rds_parser, 'out'), (self.rds_pi_extract, 'in'))
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) pubsub.__init__(self) self.frame = frame self.panel = panel parser = OptionParser(option_class=eng_option) parser.add_option('-a', '--args', type='string', default='bladerf=0', help='Device args, [default=%default]') parser.add_option('-s', '--sample-rate', type='eng_float', default=DEFAULT_SAMPLE_RATE, help='Sample rate [default=%default]') parser.add_option('-f', '--rx-freq', type='eng_float', default=DEFAULT_RX_FREQ, help='RX frequency [default=%default]') parser.add_option('-o', '--tx-freq-off', type='eng_float', default=DEFAULT_TX_FREQ_OFFSET, help='TX frequency offset [default=%default]') parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1, help="Set fftsink averaging factor, default=[%default]") parser.add_option("", "--averaging", action="store_true", default=False, help="Enable fftsink averaging, default=[%default]") parser.add_option("", "--ref-scale", type="eng_float", default=1.0, help="Set dBFS=0dB input value, default=[%default]") parser.add_option("", "--fft-size", type="int", default=DEFAULT_FFT_SIZE, help="Set number of FFT bins [default=%default]") parser.add_option("", "--fft-rate", type="int", default=30, help="Set FFT update rate, [default=%default]") parser.add_option("-v", "--verbose", action="store_true", default=False, help="Use verbose console output [default=%default]") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.options = options if options.rx_freq >= 1.5e6: options.args += ',loopback=rf_lna1' else: options.args += ',loopback=rf_lna2' self._verbose = options.verbose self.src = osmosdr.source(options.args) self.sink = osmosdr.sink(options.args) self.src.set_sample_rate(options.sample_rate) self.sink.set_sample_rate(options.sample_rate) self.src.set_bandwidth(0.90 * options.sample_rate) self.sink.set_bandwidth(0.90 * options.sample_rate) self[KEY_RX_FREQ] = options.rx_freq self[KEY_TX_FREQ_OFF] = options.tx_freq_off self[KEY_DC_OFF_I] = 0 self[KEY_DC_OFF_Q] = 0 self[KEY_IQ_BAL_I] = 0 self[KEY_IQ_BAL_Q] = 0 self.subscribe(KEY_RX_FREQ, self.set_freq) self.subscribe(KEY_DC_OFF_I, self.set_dc_offset) self.subscribe(KEY_DC_OFF_Q, self.set_dc_offset) self.subscribe(KEY_IQ_BAL_I, self.set_iq_balance) self.subscribe(KEY_IQ_BAL_Q, self.set_iq_balance) self.fft = fftsink2.fft_sink_c(panel, fft_size=options.fft_size, sample_rate=options.sample_rate, ref_scale=options.ref_scale, ref_level=0, y_divs=10, average=options.averaging, avg_alpha=options.avg_alpha, fft_rate=options.fft_rate) self.fft.set_callback(self.wxsink_callback) self.connect(self.src, self.fft) self.scope = scopesink2.scope_sink_c(panel, sample_rate = options.sample_rate, v_scale = 0, v_offest = 0, t_scale = 0, ac_couple = False, xy_mode = True, num_inputs = 1) self.connect(self.src, self.scope) self.constant_source = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, 1) self.connect(self.constant_source, self.sink) self.set_freq(options.rx_freq) self.frame.SetMinSize((800, 420)) self._build_gui(vbox)
def __init__(self, args): gr.top_block.__init__(self) pubsub.__init__(self) if not 0.0 <= args.amplitude <= 1.0: raise ValueError( "Invalid value for amplitude: {}. Must be in [0.0, 1.0]". format(args.amplitude)) # If the power argument is given, we need to turn that into a power # *reference* level. This is a bit of a hack because we're assuming # knowledge of UHDApp (i.e. we're leaking abstractions). But it's simple # and harmless enough. if args.power: if args.amplitude < self.MIN_AMP_POWER_MODE: raise RuntimeError( "[ERROR] Invalid amplitude: In power mode, amplitude must be " "larger than {}!".format(self.MIN_AMP_POWER_MODE)) args.power -= 20 * math.log10(args.amplitude) UHDApp.__init__(self, args=args, prefix="UHD-SIGGEN") self.extra_sink = None # Allocate some attributes self._src1 = None self._src2 = None self._src = None # Initialize device: self.setup_usrp( ctor=uhd.usrp_sink, args=args, ) print("[UHD-SIGGEN] UHD Signal Generator") print("[UHD-SIGGEN] UHD Version: {ver}".format( ver=uhd.get_version_string())) print("[UHD-SIGGEN] Using USRP configuration:") print(self.get_usrp_info_string(tx_or_rx="tx")) self.usrp_description = self.get_usrp_info_string(tx_or_rx="tx", compact=True) ### Set subscribers and publishers: self.publish(SAMP_RATE_KEY, lambda: self.usrp.get_samp_rate()) self.publish(DESC_KEY, lambda: self.usrp_description) self.publish(FREQ_RANGE_KEY, lambda: self.usrp.get_freq_range(self.channels[0])) self.publish(GAIN_KEY, lambda: self.get_gain_or_power()) self[SAMP_RATE_KEY] = args.samp_rate self[TX_FREQ_KEY] = args.freq self[AMPLITUDE_KEY] = args.amplitude self[WAVEFORM_FREQ_KEY] = args.waveform_freq self[WAVEFORM_OFFSET_KEY] = args.offset self[WAVEFORM2_FREQ_KEY] = args.waveform2_freq self[DSP_FREQ_KEY] = 0 self[RF_FREQ_KEY] = 0 #subscribe set methods self.subscribe(SAMP_RATE_KEY, self.set_samp_rate) self.subscribe(GAIN_KEY, self.set_gain_or_power) self.subscribe(TX_FREQ_KEY, self.set_freq) self.subscribe(AMPLITUDE_KEY, self.set_amplitude) self.subscribe(WAVEFORM_FREQ_KEY, self.set_waveform_freq) self.subscribe(WAVEFORM2_FREQ_KEY, self.set_waveform2_freq) self.subscribe(TYPE_KEY, self.set_waveform) self.subscribe(RF_FREQ_KEY, self.update_gain_range) #force update on pubsub keys for key in (SAMP_RATE_KEY, GAIN_KEY, TX_FREQ_KEY, AMPLITUDE_KEY, WAVEFORM_FREQ_KEY, WAVEFORM_OFFSET_KEY, WAVEFORM2_FREQ_KEY): self[key] = self[key] self[TYPE_KEY] = args.type #set type last
def __init__(self, options, nchans=16): gr.hier_block2.__init__(self, "trunked_feed", gr.io_signature(0,0,gr.sizeof_gr_complex), gr.io_signature(nchans,nchans,gr.sizeof_gr_complex)) pubsub.__init__(self) self._options = options self._freqs = {"center": options.center_freq, "ctrl": options.ctrl_freq, "audio": options.ctrl_freq } self._nchans = nchans if options.source == "uhd": #UHD source by default from gnuradio import uhd src = uhd.usrp_source(options.args, uhd.io_type_t.COMPLEX_FLOAT32, 1) if options.subdev is not None: src.set_subdev_spec(options.subdev) if options.antenna is not None: src.set_antenna(options.antenna) #pick a reasonable sample rate master_clock_rate = src.get_clock_rate() acceptable_rates = [i.start() for i in src.get_samp_rates() if i.start() > 8e6 and (master_clock_rate / i.start()) % 4 == 0] src.set_samp_rate(min(acceptable_rates)) self._channel_decimation = 1 print "Using sample rate: %i" % min(acceptable_rates) if options.gain is None: #set to halfway g = src.get_gain_range() options.gain = (g.start()+g.stop()) / 2.0 src.set_gain(options.gain) print "Gain is %i" % src.get_gain() #TODO: detect if you're using an RTLSDR or Jawbreaker #and set up accordingly. elif options.source == "hackrf" or options.source == "rtlsdr": #RTLSDR dongle or HackRF Jawbreaker import osmosdr src = osmosdr.source(options.source) wat = src.get_sample_rates() rates = range(int(wat.start()), int(wat.stop()+1), int(wat.step())) acceptable_rates = [i for i in rates if i >= 8e6] if len(acceptable_rates) < 1: #we're in single-channel-only mode acceptable_rates = (max(rates)) src.set_sample_rate(min(acceptable_rates)) src.get_samp_rate = src.get_sample_rate #alias for UHD compatibility in get_rate if options.gain is None: options.gain = 34 src.set_gain(options.gain) print "Gain is %i" % src.get_gain() else: #semantically detect whether it's ip.ip.ip.ip:port or filename self._rate = options.rate if ':' in options.source: try: ip, port = re.search("(.*)\:(\d{1,5})", options.source).groups() except: raise Exception("Please input UDP source e.g. 192.168.10.1:12345") src = blocks.udp_source(gr.sizeof_gr_complex, ip, int(port)) print "Using UDP source %s:%s" % (ip, port) else: src = blocks.file_source(gr.sizeof_gr_complex, options.source, repeat=False) print "Using file source %s" % options.source channel_spacing = 25e3 self._channel_decimation = int(options.rate / channel_spacing) self._filter_bank = filterbank(rate=options.rate, channel_spacing=channel_spacing) #TODO parameterize self.connect(src, self._filter_bank) for i in xrange(self._nchans): self.connect((self._filter_bank,i), (self, i)) self._data_src = src self._source_name = options.source self.set_center_freq(options.center_freq) self.set_ctrl_freq(options.ctrl_freq) self.set_audio_freq(options.ctrl_freq) #wooboobooboboobobbo print "Using master rate: %f" % self.get_rate("master") print "Using ctrl rate: %f" % self.get_rate("ctrl") print "Using audio rate: %f" % self.get_rate("audio")
def __init__(self, options, nchans=16): gr.hier_block2.__init__( self, "trunked_feed", gr.io_signature(0, 0, gr.sizeof_gr_complex), gr.io_signature(nchans, nchans, gr.sizeof_gr_complex)) pubsub.__init__(self) self._options = options self._freqs = { "center": options.center_freq, "ctrl": options.ctrl_freq, "audio": options.ctrl_freq } self._nchans = nchans if options.source == "uhd": #UHD source by default from gnuradio import uhd src = uhd.usrp_source(options.args, uhd.io_type_t.COMPLEX_FLOAT32, 1) if options.subdev is not None: src.set_subdev_spec(options.subdev) if options.antenna is not None: src.set_antenna(options.antenna) #pick a reasonable sample rate master_clock_rate = src.get_clock_rate() acceptable_rates = [ i.start() for i in src.get_samp_rates() if i.start() > 8e6 and (master_clock_rate / i.start()) % 4 == 0 ] src.set_samp_rate(min(acceptable_rates)) self._channel_decimation = 1 print "Using sample rate: %i" % min(acceptable_rates) if options.gain is None: #set to halfway g = src.get_gain_range() options.gain = (g.start() + g.stop()) / 2.0 src.set_gain(options.gain) print "Gain is %i" % src.get_gain() #TODO: detect if you're using an RTLSDR or Jawbreaker #and set up accordingly. elif options.source == "hackrf" or options.source == "rtlsdr": #RTLSDR dongle or HackRF Jawbreaker import osmosdr src = osmosdr.source(options.source) wat = src.get_sample_rates() rates = range(int(wat.start()), int(wat.stop() + 1), int(wat.step())) acceptable_rates = [i for i in rates if i >= 8e6] if len(acceptable_rates) < 1: #we're in single-channel-only mode acceptable_rates = (max(rates), ) src.set_sample_rate(min(acceptable_rates)) src.get_samp_rate = src.get_sample_rate #alias for UHD compatibility in get_rate if options.gain is None: options.gain = 34 src.set_gain(options.gain) print "Gain is %i" % src.get_gain() else: #semantically detect whether it's ip.ip.ip.ip:port or filename self._rate = options.rate if ':' in options.source: try: ip, port = re.search("(.*)\:(\d{1,5})", options.source).groups() except: raise Exception( "Please input UDP source e.g. 192.168.10.1:12345") src = blocks.udp_source(gr.sizeof_gr_complex, ip, int(port)) print "Using UDP source %s:%s" % (ip, port) else: src = blocks.file_source(gr.sizeof_gr_complex, options.source, repeat=False) print "Using file source %s" % options.source channel_spacing = 25e3 self._channel_decimation = int(options.rate / channel_spacing) self._filter_bank = filterbank( rate=options.rate, channel_spacing=channel_spacing) #TODO parameterize self.connect(src, self._filter_bank) for i in xrange(self._nchans): self.connect((self._filter_bank, i), (self, i)) self._data_src = src self._source_name = options.source self.set_center_freq(options.center_freq) self.set_ctrl_freq(options.ctrl_freq) self.set_audio_freq(options.ctrl_freq) #wooboobooboboobobbo print "Using master rate: %f" % self.get_rate("master") print "Using ctrl rate: %f" % self.get_rate("ctrl") print "Using audio rate: %f" % self.get_rate("audio")