aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples/rx_samples_to_file.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-10-05 11:59:27 -0700
committerJosh Blum <josh@joshknows.com>2011-11-03 20:37:10 -0700
commita629bbe7e3c39a10bdc3a981f6badb85a436b443 (patch)
tree58036a96d8fa045ce8900821b073f9f5a441f683 /host/examples/rx_samples_to_file.cpp
parente89b20da1511f02d887435d093d8efef3e4df261 (diff)
downloaduhd-a629bbe7e3c39a10bdc3a981f6badb85a436b443.tar.gz
uhd-a629bbe7e3c39a10bdc3a981f6badb85a436b443.tar.bz2
uhd-a629bbe7e3c39a10bdc3a981f6badb85a436b443.zip
uhd: updated examples to use new streamer interface
Diffstat (limited to 'host/examples/rx_samples_to_file.cpp')
-rw-r--r--host/examples/rx_samples_to_file.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp
index 1e213c83a..58bd158a5 100644
--- a/host/examples/rx_samples_to_file.cpp
+++ b/host/examples/rx_samples_to_file.cpp
@@ -34,20 +34,21 @@ void sig_int_handler(int){stop_signal_called = true;}
template<typename samp_type> void recv_to_file(
uhd::usrp::multi_usrp::sptr usrp,
- const uhd::io_type_t &io_type,
+ const std::string &cpu_format,
const std::string &file,
size_t samps_per_buff
){
+ //create a receive streamer
+ uhd::streamer_args stream_args(cpu_format);
+ uhd::rx_streamer::sptr rx_stream = usrp->get_rx_streamer(stream_args);
+
uhd::rx_metadata_t md;
std::vector<samp_type> buff(samps_per_buff);
std::ofstream outfile(file.c_str(), std::ofstream::binary);
bool overflow_message = true;
while(not stop_signal_called){
- size_t num_rx_samps = usrp->get_device()->recv(
- &buff.front(), buff.size(), md, io_type,
- uhd::device::RECV_MODE_FULL_BUFF
- );
+ size_t num_rx_samps = rx_stream->recv(&buff.front(), buff.size(), md);
if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break;
if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_OVERFLOW){
@@ -205,9 +206,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
}
//recv to file
- if (type == "double") recv_to_file<std::complex<double> >(usrp, uhd::io_type_t::COMPLEX_FLOAT64, file, spb);
- else if (type == "float") recv_to_file<std::complex<float> >(usrp, uhd::io_type_t::COMPLEX_FLOAT32, file, spb);
- else if (type == "short") recv_to_file<std::complex<short> >(usrp, uhd::io_type_t::COMPLEX_INT16, file, spb);
+ if (type == "double") recv_to_file<std::complex<double> >(usrp, "fc64", file, spb);
+ else if (type == "float") recv_to_file<std::complex<float> >(usrp, "fc32", file, spb);
+ else if (type == "short") recv_to_file<std::complex<short> >(usrp, "sc16", file, spb);
else throw std::runtime_error("Unknown type " + type);
//finished