[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9996 - gnuradio/branches/features/cppdb/gnuradio-exam
From: |
trondeau |
Subject: |
[Commit-gnuradio] r9996 - gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test |
Date: |
Sat, 15 Nov 2008 18:24:26 -0700 (MST) |
Author: trondeau
Date: 2008-11-15 18:24:26 -0700 (Sat, 15 Nov 2008)
New Revision: 9996
Modified:
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/Makefile.am
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.cc
Log:
Added options parser to receive test script; this adds the boost
program_options dependency, which I don't think a problem (see
ax_boost_program_options.m4).
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-15 21:22:11 UTC (rev 9995)
+++
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/Makefile.am
2008-11-16 01:24:26 UTC (rev 9996)
@@ -47,6 +47,7 @@
usrp_test_rx.cc
usrp_test_rx_LDADD = \
+ -lboost_program_options-gcc43-mt \
$(GR_USRP_LA)
# $(GNURADIO_CORE_LA)
Modified:
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.cc
===================================================================
---
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.cc
2008-11-15 21:22:11 UTC (rev 9995)
+++
gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test/usrp_test_rx.cc
2008-11-16 01:24:26 UTC (rev 9996)
@@ -22,7 +22,12 @@
#include <usrp_test_rx.h>
#include <gr_io_signature.h>
#include <gr_head.h>
+#include <stdexcept>
+#include <iostream>
+#include <boost/program_options.hpp>
+namespace po = boost::program_options;
+
// Shared pointer constructor
usrp_test_rx_sptr make_usrp_test_rx(int which, usrp_subdev_spec spec,
int decim, double freq, float gain)
@@ -69,6 +74,10 @@
printf("r.residual_freq: %f\n", r.residual_freq);
printf("r.inverted: %d\n", r.inverted);
+ if(!ok) {
+ throw std::runtime_error("Could not set frequency.");
+ }
+
/* The rest */
gr_block_sptr head = gr_make_head(sizeof(gr_complex), 1024);
sink = gr_make_vector_sink_c();
@@ -79,17 +88,82 @@
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 decim = 64; // set the decimation rate
- double freq = strtod(argv[1], NULL); // set the frequency
+ double freq = 0; // set the frequency
float gain = -1; // set the gain; -1 will set the
mid-point gain
+ po::options_description cmdconfig("Program options");
+ cmdconfig.add_options()
+ ("help,h", "produce help message")
+ ("which,w", po::value<int>(), "select which USRP board")
+ ("rx-subdev-spec,R", po::value<std::string>(), "select USRP Rx side and
port")
+ ("decim,d", po::value<int>(), "set fpga decimation rate")
+ ("frequency,f", po::value<double>(), "set RF frequency")
+ ("gain,g", po::value<float>(&gain), "set gain in dB")
+ ;
+
+ po::variables_map vm;
+ po::store(po::command_line_parser(argc, argv).
+ options(cmdconfig).run(), vm);
+ po::notify(vm);
+
+ if (vm.count("help")) {
+ std::cout << cmdconfig << "\n";
+ return 1;
+ }
+
+ if(vm.count("frequency")) {
+ freq = vm["frequency"].as<double>();
+ }
+ else {
+ fprintf(stderr, "You must specify a frequency.\n");
+ return -1;
+ }
+
+ if(vm.count("which")) {
+ which = vm["which"].as<double>();
+ }
+
+ if(vm.count("decim")) {
+ decim = vm["decim"].as<int>();
+ }
+
+ if(vm.count("gain")) {
+ gain = vm["gain"].as<float>();
+ }
+
+ if(vm.count("rx-subdev-spec")) {
+ std::string s = vm["rx-subdev-spec"].as<std::string>();
+ if(s == "A" || s == "A:0" || s == "0:0") {
+ spec.side = 0;
+ spec.subdev = 0;
+ }
+ else if(s == "A:1" || s == "0:1") {
+ spec.side = 0;
+ spec.subdev = 1;
+ }
+ else if(s == "B" || s == "B:0" || s == "1:0") {
+ spec.side = 1;
+ spec.subdev = 0;
+ }
+ else if(s == "B:1" || s == "1:1") {
+ spec.side = 1;
+ spec.subdev = 1;
+ }
+ else {
+ fprintf(stderr, "Incorrect subdevice specifications.\n");
+ return -1;
+ }
+
+ }
+
+ printf("which: %d\n", which);
+ printf("decim: %d\n", decim);
+ printf("freq: %g\n", freq);
+ printf("gain: %f\n", gain);
+
usrp_test_rx_sptr top_block = make_usrp_test_rx(which, spec,
decim, freq, gain);
top_block->run();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9996 - gnuradio/branches/features/cppdb/gnuradio-examples/c++/usrp_test,
trondeau <=