diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2017-03-16 22:27:04 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2017-03-16 22:27:04 -0700 |
commit | ffa0822abf7a30f9b44b3fb046cb6d723c4d8c37 (patch) | |
tree | 0e2d7be7824e91cf037f275098e1f90561fdafec /gr-uhd | |
parent | 00e775ff3e78f9e0fd216e683c958ed820363fac (diff) | |
parent | b675ccc2fd08574c3169659003290327b63aa16b (diff) |
Merge branch 'next' into python3
Conflicts:
gr-blocks/swig/blocks_swig.py.in
gr-uhd/apps/uhd_app.py
Diffstat (limited to 'gr-uhd')
-rw-r--r-- | gr-uhd/apps/uhd_app.py | 74 | ||||
-rwxr-xr-x | gr-uhd/apps/uhd_fft | 5 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_source_impl.cc | 10 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_source_impl.h | 1 |
4 files changed, 42 insertions, 48 deletions
diff --git a/gr-uhd/apps/uhd_app.py b/gr-uhd/apps/uhd_app.py index 893919337f..1a22eb1570 100644 --- a/gr-uhd/apps/uhd_app.py +++ b/gr-uhd/apps/uhd_app.py @@ -108,43 +108,22 @@ class UHDApp(object): except: return "Can't establish USRP info." - def normalize_antenna_sel(self, args): + def normalize_sel(self, num_name, arg_name, num, arg): """ - Make sure the --antenna option matches the --channels option. + num_name: meaningful name why we need num arguments + arg_name: name of current argument + num: required number of arguments + arg: actual argument """ - if args.antenna is None: - return None - antennas = [x.strip() for x in args.antenna.split(",")] - if len(antennas) != 1 and len(antennas) != len(args.channels): - raise ValueError("Invalid antenna setting for {n} channels: {a}".format( - n=len(self.channels), a=args.antenna, - )) - if len(antennas) == 1: - antennas = [antennas[0],] * len(args.channels) - return antennas - def normalize_subdev_sel(self, spec): - """ - """ - if spec is None: + if arg is None: return None - specs = [x.strip() for x in spec.split(",")] - if len(specs) == 1: - return spec - elif len(specs) != self.usrp.get_num_mboards(): - raise ValueError("Invalid subdev setting for {n} mboards: {a}".format( - n=len(self.usrp.get_num_mboards()), a=spec + args = [x.strip() for x in arg.split(",")] + if len(args) != num: + raise ValueError("Invalid {m} setting for {n} {b}: {a}".format( + m=arg_name, n=num, a=arg, b=num_name )) - return specs - - def normalize_lo_source_export_sel(self, args): - lo_source = [x.strip() for x in args.lo_source.split(",")] - lo_export = [x.strip() for x in args.lo_export.split(",")] - if len(lo_source) != len(self.channels): - raise ValueError("Invalid number of lo-source settings {n} for {c} channels. Must be one argument per channel.".format(n=len(lo_source), c=len(args.channels))) - if len(lo_export) != len(self.channels): - raise ValueError("Invalid number of lo-export settings {n} for {c} channels. Must be one argument per channel.".format(n=len(lo_source), c=len(args.channels))) - return (lo_source, lo_export) + return args def async_callback(self, msg): """ @@ -176,27 +155,40 @@ class UHDApp(object): ) ) # Set the subdevice spec: - args.spec = self.normalize_subdev_sel(args.spec) + args.spec = self.normalize_sel("mboards", "subdev", + self.usrp.get_num_mboards(), args.spec) if args.spec: for mb_idx in range(self.usrp.get_num_mboards()): - if isinstance(args.spec, list): - self.usrp.set_subdev_spec(args.spec[mb_idx], mb_idx) - else: + if len(args.spec) == 1: self.usrp.set_subdev_spec(args.spec, mb_idx) + else: + self.usrp.set_subdev_spec(args.spec[mb_idx], mb_idx) # Set the clock and/or time source: if args.clock_source is not None: + args.clock_source = self.normalize_sel("mboards", "clock-source", + self.usrp.get_num_mboards(), args.clock_source) for mb_idx in range(self.usrp.get_num_mboards()): - self.usrp.set_clock_source(args.clock_source, mb_idx) + if len(args.time_source) == 1: + self.usrp.set_clock_source(args.clock_source[0], mb_idx) + else: + self.usrp.set_clock_source(args.clock_source[mb_idx], mb_idx) if args.time_source is not None: + args.time_source = self.normalize_sel("mboards", "time-source", + self.usrp.get_num_mboards(), args.time_source) for mb_idx in range(self.usrp.get_num_mboards()): - self.usrp.set_time_source(args.time_source, mb_idx) + if len(args.time_source) == 1: + self.usrp.set_time_source(args.time_source[0], mb_idx) + else: + self.usrp.set_time_source(args.time_source[mb_idx], mb_idx) # Sampling rate: self.usrp.set_samp_rate(args.samp_rate) self.samp_rate = self.usrp.get_samp_rate() self.vprint("Using sampling rate: {rate}".format(rate=self.samp_rate)) # Set the antenna: - self.antenna = self.normalize_antenna_sel(args) + self.antenna = self.normalize_sel("channels", "antenna", len(args.channels), args.antenna) if self.antenna is not None: + if len(self.antenna) == 1: + self.antenna = [self.antenna, ] * len(args.channels) for i, chan in enumerate(self.channels): if not self.antenna[i] in self.usrp.get_antennas(i): self.vprint("[ERROR] {} is not a valid antenna name for this USRP device!".format(self.antenna[i])) @@ -217,7 +209,8 @@ class UHDApp(object): self.has_lo_sensor = 'lo_locked' in self.usrp.get_sensor_names() # Set LO export and LO source operation if (args.lo_export is not None) and (args.lo_source is not None): - (args.lo_source,args.lo_export) = self.normalize_lo_source_export_sel(args) + args.lo_source = self.normalize_sel("channels", "lo-source", len(args.channels), args.lo_source) + args.lo_export = self.normalize_sel("channels", "lo-export", len(args.channels), args.lo_export) for chan,lo_source,lo_export in zip(self.channels,args.lo_source,args.lo_export): if (lo_source == "None") or (lo_export == "None"): continue @@ -403,4 +396,3 @@ class UHDApp(object): group.add_argument("--time-source", help="Set the time source") return parser - diff --git a/gr-uhd/apps/uhd_fft b/gr-uhd/apps/uhd_fft index b65bb7a062..1f0cf1cda5 100755 --- a/gr-uhd/apps/uhd_fft +++ b/gr-uhd/apps/uhd_fft @@ -98,6 +98,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp): self.stream_args = args.stream_args self.update_rate = args.update_rate self.wire_format = args.otw_format + self.lo_offset = args.lo_offset ################################################## # Variables @@ -128,7 +129,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp): self.setup_usrp(uhd.usrp_source, args) self._ant_options = self.usrp.get_antennas(0) for c in range(len(self.channels)): - self.usrp.set_bandwidth(self.samp_rate, c) + self.usrp.set_bandwidth(self.samp_rate + abs(self.lo_offset), c) self.usrp_device_info = self.get_usrp_info_string(compact=True, tx_or_rx='rx') ### Now set up the GUI widgets: ##################################### @@ -431,7 +432,7 @@ class uhd_fft(gr.top_block, Qt.QWidget, UHDApp): self.qtgui_waterfall_sink_x_0.set_frequency_range(self.freq, self.samp_rate) self.usrp.set_samp_rate(self.samp_rate) for c in range(len(self.channels)): - self.usrp.set_bandwidth(self.samp_rate, c) + self.usrp.set_bandwidth(self.samp_rate + abs(self.lo_offset), c) def set_lo_locked_probe(self, lo_locked_probe): self.lo_locked_probe = lo_locked_probe diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc index 8cdaebc4ca..52e67baccf 100644 --- a/gr-uhd/lib/usrp_source_impl.cc +++ b/gr-uhd/lib/usrp_source_impl.cc @@ -59,7 +59,6 @@ namespace gr { _id = pmt::string_to_symbol(str.str()); _samp_rate = this->get_samp_rate(); - _center_freq = this->get_center_freq(0); _samps_per_packet = 1; register_msg_cmd_handler(CMD_TAG_KEY, boost::bind(&usrp_source_impl::_cmd_handler_tag, this, _1)); } @@ -114,10 +113,8 @@ namespace gr { usrp_source_impl::set_center_freq(const ::uhd::tune_request_t tune_request, size_t chan) { - const size_t user_chan = chan; chan = _stream_args.channels[chan]; const ::uhd::tune_result_t res = _dev->set_rx_freq(tune_request, chan); - _center_freq = this->get_center_freq(user_chan); _tag_now = true; return res; } @@ -440,10 +437,15 @@ namespace gr { void usrp_source_impl::issue_stream_cmd(const ::uhd::stream_cmd_t &cmd) { +// This is a new define in UHD 3.6 which is used to separate 3.6 and pre 3.6 +#ifdef INCLUDED_UHD_UTILS_MSG_TASK_HPP + _rx_stream->issue_stream_cmd(cmd); +#else for (size_t i = 0; i < _stream_args.channels.size(); i++) { _dev->issue_stream_cmd(cmd, _stream_args.channels[i]); } +#endif _tag_now = true; } @@ -589,7 +591,7 @@ namespace gr { this->add_item_tag(i, nitems_written(0), RATE_KEY, pmt::from_double(_samp_rate), _id); this->add_item_tag(i, nitems_written(0), FREQ_KEY, - pmt::from_double(_center_freq), _id); + pmt::from_double(this->get_center_freq(i)), _id); } } break; diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h index c1566e18d0..2e5c1d31de 100644 --- a/gr-uhd/lib/usrp_source_impl.h +++ b/gr-uhd/lib/usrp_source_impl.h @@ -125,7 +125,6 @@ namespace gr { //tag shadows double _samp_rate; - double _center_freq; boost::recursive_mutex d_mutex; }; |