diff options
Diffstat (limited to 'gr-uhd')
-rw-r--r-- | gr-uhd/apps/uhd_app.py | 7 | ||||
-rwxr-xr-x | gr-uhd/examples/python/fm_tx4.py | 3 | ||||
-rw-r--r-- | gr-uhd/include/gnuradio/uhd/usrp_source.h | 5 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_source_impl.cc | 35 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_source_impl.h | 4 |
5 files changed, 35 insertions, 19 deletions
diff --git a/gr-uhd/apps/uhd_app.py b/gr-uhd/apps/uhd_app.py index 59bebe24ec..ff4412a140 100644 --- a/gr-uhd/apps/uhd_app.py +++ b/gr-uhd/apps/uhd_app.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2015 Free Software Foundation, Inc. +# Copyright 2015-2016 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -141,6 +141,9 @@ class UHDApp(object): if args.spec: for mb_idx in xrange(self.usrp.get_num_mboards()): self.usrp.set_subdev_spec(args.spec, mb_idx) + # Set the clock source: + if args.clock_source is not None: + self.usrp.set_clock_source(args.clock_source) # Sampling rate: self.usrp.set_samp_rate(args.samp_rate) self.samp_rate = self.usrp.get_samp_rate() @@ -305,5 +308,7 @@ class UHDApp(object): help="Show asynchronous message notifications from UHD") group.add_argument("--sync", choices=('default', 'pps', 'auto'), default='auto', help="Set to 'pps' to sync devices to PPS") + group.add_argument("--clock-source", + help="Set the clock source; typically 'internal', 'external' or 'gpsdo'") return parser diff --git a/gr-uhd/examples/python/fm_tx4.py b/gr-uhd/examples/python/fm_tx4.py index fefa67861b..516033dae1 100755 --- a/gr-uhd/examples/python/fm_tx4.py +++ b/gr-uhd/examples/python/fm_tx4.py @@ -63,7 +63,8 @@ class pipeline(gr.hier_block2): sys.exit(1) print audio_rate, if_rate - fmtx = analog.nbfm_tx(audio_rate, if_rate, max_dev=5e3, tau=75e-6) + fmtx = analog.nbfm_tx(audio_rate, if_rate, max_dev=5e3, + tau=75e-6, fh=0.925*if_rate/2.0) # Local oscillator lo = analog.sig_source_c(if_rate, # sample rate diff --git a/gr-uhd/include/gnuradio/uhd/usrp_source.h b/gr-uhd/include/gnuradio/uhd/usrp_source.h index 19b3feb61f..19201c031c 100644 --- a/gr-uhd/include/gnuradio/uhd/usrp_source.h +++ b/gr-uhd/include/gnuradio/uhd/usrp_source.h @@ -96,10 +96,13 @@ namespace gr { /*! * \param device_addr the address to identify the hardware * \param stream_args the IO format and channel specification + * \param issue_stream_cmd_on_start enable or disable continuous streaming when flowgraph + * starts (default true) * \return a new USRP source block object */ static sptr make(const ::uhd::device_addr_t &device_addr, - const ::uhd::stream_args_t &stream_args); + const ::uhd::stream_args_t &stream_args, + const bool issue_stream_cmd_on_start = true); /*! * Set the start time for incoming samples. diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc index eeb9521a5a..7ad2280955 100644 --- a/gr-uhd/lib/usrp_source_impl.cc +++ b/gr-uhd/lib/usrp_source_impl.cc @@ -53,20 +53,23 @@ namespace gr { usrp_source::sptr usrp_source::make(const ::uhd::device_addr_t &device_addr, - const ::uhd::stream_args_t &stream_args) + const ::uhd::stream_args_t &stream_args, + const bool issue_stream_cmd_on_start) { check_abi(); return usrp_source::sptr - (new usrp_source_impl(device_addr, stream_args_ensure(stream_args))); + (new usrp_source_impl(device_addr, stream_args_ensure(stream_args), issue_stream_cmd_on_start)); } usrp_source_impl::usrp_source_impl(const ::uhd::device_addr_t &device_addr, - const ::uhd::stream_args_t &stream_args): + const ::uhd::stream_args_t &stream_args, + const bool issue_stream_cmd_on_start): usrp_block("gr uhd usrp source", io_signature::make(0, 0, 0), args_to_io_sig(stream_args)), usrp_block_impl(device_addr, stream_args, ""), - _tag_now(false) + _tag_now(false), + _issue_stream_cmd_on_start(issue_stream_cmd_on_start) { std::stringstream str; str << name() << unique_id(); @@ -382,18 +385,20 @@ namespace gr { _samps_per_packet = _rx_stream->get_max_num_samps(); } #endif - //setup a stream command that starts streaming slightly in the future - static const double reasonable_delay = 0.1; //order of magnitude over RTT - ::uhd::stream_cmd_t stream_cmd(::uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); - stream_cmd.stream_now = _stream_now; - if(_start_time_set) { - _start_time_set = false; //cleared for next run - stream_cmd.time_spec = _start_time; - } - else { - stream_cmd.time_spec = get_time_now() + ::uhd::time_spec_t(reasonable_delay); + if(_issue_stream_cmd_on_start){ + //setup a stream command that starts streaming slightly in the future + static const double reasonable_delay = 0.1; //order of magnitude over RTT + ::uhd::stream_cmd_t stream_cmd(::uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS); + stream_cmd.stream_now = _stream_now; + if(_start_time_set) { + _start_time_set = false; //cleared for next run + stream_cmd.time_spec = _start_time; + } + else { + stream_cmd.time_spec = get_time_now() + ::uhd::time_spec_t(reasonable_delay); + } + this->issue_stream_cmd(stream_cmd); } - this->issue_stream_cmd(stream_cmd); _tag_now = true; return true; } diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h index 98af816c02..b43df4dab3 100644 --- a/gr-uhd/lib/usrp_source_impl.h +++ b/gr-uhd/lib/usrp_source_impl.h @@ -55,7 +55,8 @@ namespace gr { { public: usrp_source_impl(const ::uhd::device_addr_t &device_addr, - const ::uhd::stream_args_t &stream_args); + const ::uhd::stream_args_t &stream_args, + const bool issue_stream_cmd_on_start = true); ~usrp_source_impl(); // Get Commands @@ -119,6 +120,7 @@ namespace gr { bool _tag_now; ::uhd::rx_metadata_t _metadata; pmt::pmt_t _id; + bool _issue_stream_cmd_on_start; //tag shadows double _samp_rate; |