summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-uhd/include/gr_uhd_usrp_source.h9
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_source.cc19
2 files changed, 28 insertions, 0 deletions
diff --git a/gr-uhd/include/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h
index e9fc41b93..8a799b397 100644
--- a/gr-uhd/include/gr_uhd_usrp_source.h
+++ b/gr-uhd/include/gr_uhd_usrp_source.h
@@ -455,6 +455,15 @@ public:
* \return the multi usrp device object
*/
virtual uhd::usrp::multi_usrp::sptr get_device(void) = 0;
+
+ /*!
+ * Convenience function for finite data acquisition.
+ * This is not to be used with the scheduler; rather,
+ * one can request samples from the USRP in python.
+ * //TODO multi-channel
+ * //TODO assumes fc32
+ */
+ virtual std::vector<std::complex<float> > finite_acquisition(const size_t nsamps) = 0;
};
#endif /* INCLUDED_GR_UHD_USRP_SOURCE_H */
diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc
index 51a756908..2244238bd 100644
--- a/gr-uhd/lib/gr_uhd_usrp_source.cc
+++ b/gr-uhd/lib/gr_uhd_usrp_source.cc
@@ -409,6 +409,25 @@ public:
return true;
}
+ std::vector<std::complex<float> > finite_acquisition(const size_t nsamps){
+ #ifdef GR_UHD_USE_STREAM_API
+ uhd::stream_cmd_t cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
+ cmd.num_samps = nsamps;
+ cmd.stream_now = true;
+ _dev->issue_stream_cmd(cmd);
+
+ std::vector<std::complex<float> > samps(nsamps);
+ const size_t actual_num_samps = _rx_stream->recv(
+ &samps.front(), nsamps, _metadata, 0.1
+ );
+ samps.resize(actual_num_samps);
+
+ return samps;
+ #else
+ throw std::runtime_error("not implemented in this version");
+ #endif
+ }
+
private:
uhd::usrp::multi_usrp::sptr _dev;
const uhd::stream_args_t _stream_args;