>From 424ee8d2d96df2e5538eb39388e3432bf1302b17 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Stefan=20Br=C3=BCns?=
Date: Thu, 10 Dec 2009 17:09:18 +0100
Subject: [PATCH] add possibility to save interleaved shorts (as comming from USRP)
---
gr-usrp/apps/usrp_rx_cfile.cc | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/gr-usrp/apps/usrp_rx_cfile.cc b/gr-usrp/apps/usrp_rx_cfile.cc
index d40ca58..e9ced6d 100644
--- a/gr-usrp/apps/usrp_rx_cfile.cc
+++ b/gr-usrp/apps/usrp_rx_cfile.cc
@@ -82,7 +82,9 @@ usrp_rx_cfile::usrp_rx_cfile(int which, usrp_subdev_spec spec,
d_gain(gain), d_width8(width8), d_nohb(nohb), d_nsamples(nsamples),
d_filename(filename)
{
- usrp_source_c_sptr usrp;
+ usrp_source_s_sptr usrp_s;
+ usrp_source_c_sptr usrp_c;
+ boost::shared_ptr usrp;
if(d_nohb || (d_decim<8)) {
// Min decimation of this firmware is 4.
@@ -90,15 +92,29 @@ usrp_rx_cfile::usrp_rx_cfile(int which, usrp_subdev_spec spec,
std::string fpga_filename="std_4rx_0tx.rbf";
// use default values and add fpga_filename
- usrp = usrp_make_source_c(d_which, d_decim,
- 1, -1, 0, 0, 0,
- fpga_filename.c_str());
+ if(output_shorts) {
+ usrp_s = usrp_make_source_s(d_which, d_decim,
+ 1, -1, 0, 0, 0,
+ fpga_filename.c_str());
+ usrp = usrp_s;
+ } else {
+ usrp_c = usrp_make_source_c(d_which, d_decim,
+ 1, -1, 0, 0, 0,
+ fpga_filename.c_str());
+ usrp = usrp_c;
+ }
}
else {
// standard fpga firmware "std_2rxhb_2tx.rbf" contains
// 2 Rx paths with halfband filters and 2 tx paths
//(the default) min decimation 8
- usrp = usrp_make_source_c(d_which, d_decim);
+ if(output_shorts) {
+ usrp_s = usrp_make_source_s(d_which, d_decim);
+ usrp = usrp_s;
+ } else {
+ usrp_c = usrp_make_source_c(d_which, d_decim);
+ usrp = usrp_c;
+ }
}
if(d_width8) {
@@ -138,13 +154,14 @@ usrp_rx_cfile::usrp_rx_cfile(int which, usrp_subdev_spec spec,
}
/* The rest */
- d_dst = gr_make_file_sink(sizeof(gr_complex), d_filename.c_str());
+ size_t samplesize = output_shorts?sizeof(short):sizeof(gr_complex);
+ d_dst = gr_make_file_sink(samplesize, d_filename.c_str());
if(d_nsamples == -1) {
connect(usrp, 0, d_dst, 0);
}
else {
- d_head = gr_make_head(sizeof(gr_complex), d_nsamples*2);
+ d_head = gr_make_head(samplesize, d_nsamples*2);
connect(usrp, 0, d_head, 0);
connect(d_head, 0, d_dst, 0);
}
@@ -174,7 +191,7 @@ int main(int argc, char *argv[])
("gain,g", po::value(), "set gain in dB (default is midpoint)")
("width-8,8", "Enable 8-bit samples across USB")
("no-hb", "don't use halfband filter in usrp")
- //("output-shorts,s", "output interleaved shorts in stead of complex floats")
+ ("output-shorts,s", "output interleaved shorts instead of complex floats")
("nsamples,N", po::value(&nsamples), "number of samples to collect")
;
--
1.5.6