def __init__(self, frame, panel, vbox, argv): stdgui.gui_flow_graph.__init__(self) self.frame = frame self.panel = panel parser = OptionParser(option_class=eng_option) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, help="select USRP Rx side A or B (default=first one with a daughterboard)") parser.add_option("-d", "--decim", type="int", default=128, help="set fgpa decimation rate to DECIM [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default=None, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") #align interval is default not yet enabled in gr.align_on_samplenumbers_ss #parser.add_option("-a", "--align_interval", type="int", default=-1, # help="Align master and slave every so much samples.") # width 8 does not work yet with multi_usrp because it interferes with the 32 bit samplecounter #parser.add_option("-8", "--width-8", action="store_true", default=False, # help="Enable 8-bit samples across USB") parser.add_option("-m", "--mux", type="intx", default=None, help="set fpga FR_RX_MUX register to MUX") parser.add_option("-n", "--frame-decim", type="int", default=1, help="set oscope frame decimation factor to n [default=1]") parser.add_option("-N", "--nchan", type="int", default=2, help="set nchannels to NCHAN") parser.add_option("-q", "--show-q", action="store_true", default=False, help="show the q value of the complex samples") parser.add_option("-s", "--show-counters", action="store_true", default=False, help="show the counters") parser.add_option("-v", "--v-scale", type="eng_float", default=1000, help="set oscope initial V/div to SCALE [default=%default]") parser.add_option("-t", "--t-scale", type="eng_float", default=49e-6, help="set oscope initial s/div to SCALE [default=50us]") parser.add_option("-x", "--master-serialno", type="string", default=None, help="Serial_no of the usrp which should be the MASTER (default= select any)") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.show_debug_info = True # build the graph #self.u = usrp.source_c(which=options.which_usrp,decim_rate=options.decim) if (options.mux is None) | (4==options.nchan): init_mux=None #use default mux which is 0x10321032 else: init_mux=options.mux init_gain=0.0 init_freq=0.0 init_align_interval=-1 self.multi=usrp_multi.multi_source_align( self, options.master_serialno, options.decim, options.nchan, init_gain, init_freq, init_mux, init_align_interval) self.um=self.multi.get_master_usrp() self.us=self.multi.get_slave_usrp() if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(self.um) if (options.mux==None) and (options.nchan!=4): mux=usrp.determine_rx_mux_value(self.um, options.rx_subdev_spec) mux= (mux<<8 & 0xffffffff) | (mux & 0xff) self.um.set_mux(mux) self.us.set_mux(mux) # width 8 does not work yet with multi_usrp because it interferes with the 32 bit samplecounter #if options.width_8: # width = 8 # shift = 8 # format = self.um.make_format(width, shift) # r = self.um.set_format(format) # r = self.us.set_format(format) # determine the daughterboard subdevice of the first channel we're using self.subdevm = usrp.selected_subdev(self.um, options.rx_subdev_spec) self.subdevs = usrp.selected_subdev(self.us, options.rx_subdev_spec) input_rate = self.um.adc_freq() / self.um.decim_rate() self.scope = scopesink.scope_sink_f(self, panel, sample_rate=input_rate, frame_decim=options.frame_decim, v_scale=options.v_scale, t_scale=options.t_scale) self.sink_count=0 self.add_to_scope((self.multi.get_master_source_c(),1),options.show_q) self.add_to_scope((self.multi.get_slave_source_c(),1),options.show_q) if 4==options.nchan: self.add_to_scope((self.multi.get_master_source_c(),2),options.show_q) self.add_to_scope((self.multi.get_slave_source_c(),2),options.show_q) if options.show_counters: self.add_to_scope((self.multi.get_master_source_c(),0),options.show_q) self.add_to_scope((self.multi.get_slave_source_c(),0),options.show_q) self._build_gui(vbox) # set initial values if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdevm.gain_range() options.gain = float(g[0]+g[1])/2 if options.freq is None: # if no freq was specified, use the mid-point r = self.subdevm.freq_range() options.freq = float(r[0]+r[1])/2 self.set_gain(options.gain) if self.show_debug_info: self.myform['decim'].set_value(self.um.decim_rate()) self.myform['fs@usb'].set_value(self.um.adc_freq() / self.um.decim_rate()) self.myform['dbname'].set_value(self.subdevm.name()) self.myform['baseband'].set_value(0) self.myform['ddc'].set_value(0) if not(self.set_freq(options.freq)): self._set_status_msg("Failed to set initial frequency") self.multi.print_db_info() self.unsynced=True frame.Bind(wx.EVT_IDLE, self.onIdle)
def __init__(self): gr.top_block.__init__(self) usage="%prog: [options] output_filename" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=(0, 0), help="select USRP Rx side A or B (default=A)") parser.add_option("-d", "--decim", type="int", default=128, help="set selfpa decimation rate to DECIM [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default=0.0, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") parser.add_option("-n", "--nchan", type="intx", default=2, help="set nchannels to NCHAN") parser.add_option("-N", "--nsamples", type="eng_float", default=None, help="number of samples to collect [default=+inf]") parser.add_option ("-o", "--output-file-m", default="usrp_rx_m.dat", help="write master data to FILE", metavar="FILE") parser.add_option ("--output-file-m2", default="usrp_rx_m2.dat", help="write master data from second channel to FILE", metavar="FILE") parser.add_option ("-p", "--output-file-s", default="usrp_rx_s.dat", help="write slave data to FILE", metavar="FILE") parser.add_option ("--output-file-s2", default="usrp_rx_s2.dat", help="write slave data from second channel to FILE", metavar="FILE") parser.add_option("-x", "--master-serialno", type="string", default=None, help="Serial_no of the usrp which should be the MASTER (default= select any)") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 if options.freq is None: parser.print_help() sys.stderr.write('You must specify the frequency with -f FREQ\n'); raise SystemExit, 1 # build the graph self.multi=usrp_multi.multi_source_align( fg=self, master_serialno=options.master_serialno, decim=options.decim, nchan=options.nchan ) self.um=self.multi.get_master_usrp() self.us=self.multi.get_slave_usrp() dst_m=gr.file_sink (gr.sizeof_gr_complex, options.output_file_m) dst_s=gr.file_sink (gr.sizeof_gr_complex, options.output_file_s) if options.nsamples is None: self.connect((self.multi.get_master_source_c(),1),dst_m) self.connect((self.multi.get_slave_source_c(),1),dst_s) else: head_m = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) head_s = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) self.connect((self.multi.get_master_source_c(),1),head_m,dst_m) self.connect((self.multi.get_slave_source_c(),1),head_s,dst_s) if(4==options.nchan): dst_m2=gr.file_sink (gr.sizeof_gr_complex, options.output_file_m2) dst_s2=gr.file_sink (gr.sizeof_gr_complex, options.output_file_s2) if options.nsamples is None: self.connect((self.multi.get_master_source_c(),2),dst_m2) self.connect((self.multi.get_slave_source_c(),2),dst_s2) else: head_m2 = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) head_s2 = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) self.connect((self.multi.get_master_source_c(),2),head_m2,dst_m2) self.connect((self.multi.get_slave_source_c(),2),head_s2,dst_s2) if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_subdevice(self.um) if (options.nchan!=4): mux=usrp.determine_rx_mux_value(self.um, options.rx_subdev_spec) mux= (mux<<8 & 0xffffffff) | (mux & 0xff) self.um.set_mux(mux) self.us.set_mux(mux) # determine the daughterboard subdevice we're using self.subdevm = usrp.selected_subdev(self.um, options.rx_subdev_spec) self.subdevs = usrp.selected_subdev(self.us, options.rx_subdev_spec) print "Using MASTER RX d'board %s" % (self.subdevm.side_and_name(),) print "Using SLAVE RX d'board %s" % (self.subdevs.side_and_name(),) input_rate = self.um.adc_freq() / self.um.decim_rate() print "USB sample rate %s" % (eng_notation.num_to_str(input_rate)) if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdevm.gain_range() options.gain = float(g[0]+g[1])/2 self.multi.set_gain_all_rx(options.gain) result,r1,r2,r3,r4 = self.multi.tune_all_rx(options.freq) if not result: sys.stderr.write('Failed to set frequency\n') raise SystemExit, 1
def __init__(self): gr.flow_graph.__init__(self) usage="%prog: [options] output_filename" parser = OptionParser(option_class=eng_option, usage=usage) parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=(0, 0), help="select USRP Rx side A or B (default=A)") parser.add_option("-d", "--decim", type="int", default=128, help="set selfpa decimation rate to DECIM [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default=0.0, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") parser.add_option("-n", "--nchan", type="intx", default=2, help="set nchannels to NCHAN") parser.add_option("-N", "--nsamples", type="eng_float", default=None, help="number of samples to collect [default=+inf]") parser.add_option ("-o", "--output-file-m", default="usrp_rx_m.dat", help="write master data to FILE", metavar="FILE") parser.add_option ("--output-file-m2", default="usrp_rx_m2.dat", help="write master data from second channel to FILE", metavar="FILE") parser.add_option ("-p", "--output-file-s", default="usrp_rx_s.dat", help="write slave data to FILE", metavar="FILE") parser.add_option ("--output-file-s2", default="usrp_rx_s2.dat", help="write slave data from second channel to FILE", metavar="FILE") parser.add_option("-x", "--master-serialno", type="string", default=None, help="Serial_no of the usrp which should be the MASTER (default= select any)") (options, args) = parser.parse_args () if len(args) != 0: parser.print_help() raise SystemExit, 1 if options.freq is None: parser.print_help() sys.stderr.write('You must specify the frequency with -f FREQ\n'); raise SystemExit, 1 # build the graph self.multi=usrp_multi.multi_source_align( fg=self, master_serialno=options.master_serialno, decim=options.decim, nchan=options.nchan ) self.um=self.multi.get_master_usrp() self.us=self.multi.get_slave_usrp() dst_m=gr.file_sink (gr.sizeof_gr_complex, options.output_file_m) dst_s=gr.file_sink (gr.sizeof_gr_complex, options.output_file_s) if options.nsamples is None: self.connect((self.multi.get_master_source_c(),1),dst_m) self.connect((self.multi.get_slave_source_c(),1),dst_s) else: head_m = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) head_s = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) self.connect((self.multi.get_master_source_c(),1),head_m,dst_m) self.connect((self.multi.get_slave_source_c(),1),head_s,dst_s) if(4==options.nchan): dst_m2=gr.file_sink (gr.sizeof_gr_complex, options.output_file_m2) dst_s2=gr.file_sink (gr.sizeof_gr_complex, options.output_file_s2) if options.nsamples is None: self.connect((self.multi.get_master_source_c(),2),dst_m2) self.connect((self.multi.get_slave_source_c(),2),dst_s2) else: head_m2 = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) head_s2 = gr.head(gr.sizeof_gr_complex, int(options.nsamples)) self.connect((self.multi.get_master_source_c(),2),head_m2,dst_m2) self.connect((self.multi.get_slave_source_c(),2),head_s2,dst_s2) if options.rx_subdev_spec is None: options.rx_subdev_spec = usrp.pick_rx_subdevice(self.um) if (options.nchan!=4): mux=usrp.determine_rx_mux_value(self.um, options.rx_subdev_spec) mux= (mux<<8 & 0xffffffff) | (mux & 0xff) self.um.set_mux(mux) self.us.set_mux(mux) # determine the daughterboard subdevice we're using self.subdevm = usrp.selected_subdev(self.um, options.rx_subdev_spec) self.subdevs = usrp.selected_subdev(self.us, options.rx_subdev_spec) print "Using MASTER RX d'board %s" % (self.subdevm.side_and_name(),) print "Using SLAVE RX d'board %s" % (self.subdevs.side_and_name(),) input_rate = self.um.adc_freq() / self.um.decim_rate() print "USB sample rate %s" % (eng_notation.num_to_str(input_rate)) if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.subdevm.gain_range() options.gain = float(g[0]+g[1])/2 self.multi.set_gain_all_rx(options.gain) result,r1,r2,r3,r4 = self.multi.tune_all_rx(options.freq) if not result: sys.stderr.write('Failed to set frequency\n') raise SystemExit, 1