[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9981 - gnuradio/branches/features/cppdb/gnuradio-exam
From: |
trondeau |
Subject: |
[Commit-gnuradio] r9981 - gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test |
Date: |
Wed, 12 Nov 2008 17:52:26 -0700 (MST) |
Author: trondeau
Date: 2008-11-12 17:52:26 -0700 (Wed, 12 Nov 2008)
New Revision: 9981
Added:
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_tx.cc
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_tx.h
Modified:
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/Makefile.am
Log:
adding a c++-based usrp transmit example
Property changes on:
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test
___________________________________________________________________
Name: svn:ignore
- Makefile
Makefile.in
.libs
.deps
usrp_test
+ Makefile
Makefile.in
.libs
.deps
usrp_test_tx
usrp_test_rx
Modified:
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/Makefile.am
===================================================================
---
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/Makefile.am
2008-11-13 00:31:15 UTC (rev 9980)
+++
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/Makefile.am
2008-11-13 00:52:26 UTC (rev 9981)
@@ -36,10 +36,12 @@
# For compiling outside the tree, these will get fished out by pkgconfig
noinst_PROGRAMS = \
- usrp_test_rx
+ usrp_test_rx \
+ usrp_test_tx
noinst_HEADERS = \
- usrp_test_rx.h
+ usrp_test_rx.h \
+ usrp_test_tx.h
usrp_test_rx_SOURCES = \
usrp_test_rx.cc
@@ -48,4 +50,11 @@
$(GR_USRP_LA)
# $(GNURADIO_CORE_LA)
+
+usrp_test_tx_SOURCES = \
+ usrp_test_tx.cc
+
+usrp_test_tx_LDADD = \
+ $(GR_USRP_LA)
+
MOSTLYCLEANFILES = *~
Added:
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_tx.cc
===================================================================
---
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_tx.cc
(rev 0)
+++
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_tx.cc
2008-11-13 00:52:26 UTC (rev 9981)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <usrp_test_tx.h>
+#include <gr_io_signature.h>
+#include <gr_head.h>
+
+// Shared pointer constructor
+usrp_test_tx_sptr make_usrp_test_tx(int which, usrp_subdev_spec spec, int
interp, double freq, float amp)
+{
+ return gnuradio::get_initial_sptr(new usrp_test_tx(which, spec, interp,
freq, amp));
+}
+
+// Hierarchical block constructor, with no inputs or outputs
+usrp_test_tx::usrp_test_tx(int which, usrp_subdev_spec spec, int interp,
double freq, float amp) :
+ gr_top_block("usrp_test_tx")
+{
+ usrp_sink_c_sptr usrp = usrp_make_sink_c(which, interp);
+
+ db_base_sptr subdev = usrp->selected_subdev(spec);
+ printf("Subdevice name is %s\n", subdev->name().c_str());
+ printf("Subdevice freq range: (%g, %g)\n", subdev->freq_min(),
subdev->freq_max());
+
+ unsigned int mux = usrp->determine_tx_mux_value(spec);
+ printf("mux: %x\n", mux);
+ usrp->set_mux(mux);
+
+ float input_rate = usrp->dac_freq() / usrp->interp_rate();
+ printf("baseband rate: %g\n", input_rate);
+
+ usrp_tune_result r;
+ double target_freq = freq;
+ bool ok = usrp->tune(0, subdev, target_freq, &r);
+
+ printf("target_freq: %f\n", target_freq);
+ printf("ok: %s\n", ok ? "true" : "false");
+ printf("r.baseband_freq: %f\n", r.baseband_freq);
+ printf("r.dxc_freq: %f\n", r.dxc_freq);
+ printf("r.residual_freq: %f\n", r.residual_freq);
+ printf("r.inverted: %d\n", r.inverted);
+
+ /* The rest */
+ source = gr_make_sig_source_c(input_rate, GR_SIN_WAVE, 100e3, amp, 0);
+
+ connect(source, 0, usrp, 0);
+}
+
+int main(int argc, char *argv[])
+{
+ if(argc < 2) {
+ fprintf(stderr, "Please enter a target frequency\n");
+ return -1;
+ }
+
+ int which = 0; // specify which USRP board
+ usrp_subdev_spec spec(0,0); // specify the d'board side
+ int interp = 128; // set the intepolation rate
+ double freq = strtod(argv[1], NULL); // set the frequency
+ float amp = 10; // set the amplutide
+
+ usrp_test_tx_sptr top_block = make_usrp_test_tx(which, spec, interp, freq,
amp);
+ top_block->run();
+
+ return 0;
+}
Added:
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_tx.h
===================================================================
---
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_tx.h
(rev 0)
+++
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_tx.h
2008-11-13 00:52:26 UTC (rev 9981)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <gr_top_block.h>
+#include <usrp_sink_c.h>
+#include <gr_sig_source_c.h>
+
+class usrp_test_tx;
+typedef boost::shared_ptr<usrp_test_tx> usrp_test_tx_sptr;
+usrp_test_tx_sptr make_usrp_test_tx();
+
+class usrp_test_tx : public gr_top_block
+{
+private:
+ usrp_test_tx(int which, usrp_subdev_spec spec, int interp, double freq,
float amp);
+ friend usrp_test_tx_sptr make_usrp_test_tx(int which, usrp_subdev_spec
spec, int interp, double freq, float amp);
+
+ public:
+ gr_sig_source_c_sptr source;
+};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9981 - gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test,
trondeau <=