libgr_usrp2_la_SOURCES = \
rx_16sc_handler.cc \
rx_32fc_handler.cc \
+ usrp2_base.cc \
usrp2_source_base.cc \
usrp2_source_16sc.cc \
- usrp2_source_32fc.cc
-# usrp2_source_16sc.cc
-# usrp2_sink_base.cc
-# usrp2_sink_32fc.cc
-# usrp2_sink_16sc.cc
+ usrp2_source_32fc.cc \
+ usrp2_sink_base.cc \
+ usrp2_sink_16sc.cc \
+ usrp2_sink_32fc.cc
libgr_usrp2_la_LIBADD = \
$(USRP2_LA) \
$(GNURADIO_CORE_LA)
grinclude_HEADERS = \
+ usrp2_base.h \
usrp2_source_base.h \
usrp2_source_32fc.h \
- usrp2_source_16sc.h
-# usrp2_sink_base.h \
-# usrp2_sink_32fc.h \
-# usrp2_sink_16sc.h
+ usrp2_source_16sc.h \
+ usrp2_sink_base.h \
+ usrp2_sink_16sc.h \
+ usrp2_sink_32fc.h
noinst_HEADERS = \
rx_16sc_handler.h \
%feature("autodoc", "1"); // generate python docstrings
%include "exception.i"
-%import "gnuradio.i" // the common stuff
+%import "gnuradio.i" // the common stuff
%{
#include <gnuradio_swig_bug_workaround.h>
-//#include "usrp2_sink_32fc.h"
#include "usrp2_source_16sc.h"
#include "usrp2_source_32fc.h"
+#include "usrp2_sink_16sc.h"
+#include "usrp2_sink_32fc.h"
%}
%include <usrp2/tune_result.h>
-#if 0
// ----------------------------------------------------------------
-class usrp2_sink_base : public gr_sync_block {
-
+class usrp2_base : public gr_sync_block
+{
protected:
- usrp2_sink_base(const std::string &name,
- gr_io_signature_sptr input_signature)
- throw (std::runtime_error);
+ usrp2_base() throw (std::runtime_error);
public:
- ~usrp2_sink_base();
+ ~usrp2_base();
+ std::string mac_addr() const;
};
// ----------------------------------------------------------------
-GR_SWIG_BLOCK_MAGIC(usrp2,sink_32fc)
-
-usrp2_sink_32fc_sptr
-usrp2_make_sink_32fc() throw (std::runtime_error);
-
-class usrp2_sink_32fc : public usrp2_sink_base {
-
+class usrp2_source_base : public usrp2_base
+{
protected:
- usrp2_sink_32fc();
+ usrp2_source_base() throw (std::runtime_error);
public:
- ~usrp2_sink_32fc();
+ ~usrp2_source_base();
+ bool set_gain(double gain);
+ %rename(_real_set_center_freq) set_center_freq;
+ bool set_center_freq(double frequency, usrp2::tune_result *r);
+ bool set_decim(int decimation_factor);
};
-#endif
// ----------------------------------------------------------------
-class usrp2_source_base : public gr_sync_block {
+GR_SWIG_BLOCK_MAGIC(usrp2,source_32fc)
+usrp2_source_32fc_sptr
+usrp2_make_source_32fc(const std::string ifc="eth0",
+ const std::string mac="")
+ throw (std::runtime_error);
+
+class usrp2_source_32fc : public usrp2_source_base
+{
protected:
- usrp2_source_base(const char *name,
- gr_io_signature_sptr output_signature)
- throw (std::runtime_error);
+ usrp2_source_32fc(const std::string &ifc, const std::string &mac);
public:
- ~usrp2_source_base();
+ ~usrp2_source_32fc();
};
// ----------------------------------------------------------------
-GR_SWIG_BLOCK_MAGIC(usrp2,source_32fc)
+GR_SWIG_BLOCK_MAGIC(usrp2,source_16sc)
-usrp2_source_32fc_sptr
-usrp2_make_source_32fc(const std::string ifc, const std::string mac)
+usrp2_source_16sc_sptr
+usrp2_make_source_16sc(const std::string ifc="eth0",
+ const std::string mac="")
throw (std::runtime_error);
-class usrp2_source_32fc : public usrp2_source_base {
+class usrp2_source_16sc : public usrp2_source_base
+{
+protected:
+ usrp2_source_16sc(const std::string &ifc, const std::string &mac);
+public:
+ ~usrp2_source_16sc();
+
+ std::string mac_addr();
+};
+
+// ----------------------------------------------------------------
+
+class usrp2_sink_base : public usrp2_base
+{
protected:
- usrp2_source_32fc(const std::string &ifc, const std::string &mac);
+ usrp2_sink_base() throw (std::runtime_error);
public:
- ~usrp2_source_32fc();
+ ~usrp2_sink_base();
bool set_gain(double gain);
%rename(_real_set_center_freq) set_center_freq;
bool set_center_freq(double frequency, usrp2::tune_result *r);
- bool set_decim(int decimation_factor);
-
- std::string mac_addr();
+ bool set_interp(int interp_factor);
};
// ----------------------------------------------------------------
-GR_SWIG_BLOCK_MAGIC(usrp2,source_16sc)
+GR_SWIG_BLOCK_MAGIC(usrp2,sink_32fc)
-usrp2_source_16sc_sptr
-usrp2_make_source_16sc(const std::string ifc, const std::string mac)
+usrp2_sink_32fc_sptr
+usrp2_make_sink_32fc(const std::string ifc="eth0",
+ const std::string mac="")
throw (std::runtime_error);
-class usrp2_source_16sc : public usrp2_source_base {
-
+class usrp2_sink_32fc : public usrp2_sink_base
+{
protected:
- usrp2_source_16sc(const std::string &ifc, const std::string &mac);
+ usrp2_sink_32fc(const std::string &ifc, const std::string &mac);
public:
- ~usrp2_source_16sc();
+ ~usrp2_sink_32fc();
+};
- bool set_gain(double gain);
- %rename(_real_set_center_freq) set_center_freq;
- bool set_center_freq(double frequency, usrp2::tune_result *r);
- bool set_decim(int decimation_factor);
+// ----------------------------------------------------------------
- std::string mac_addr();
+GR_SWIG_BLOCK_MAGIC(usrp2,sink_16sc)
+
+usrp2_sink_16sc_sptr
+usrp2_make_sink_16sc(const std::string ifc="eth0",
+ const std::string mac="")
+ throw (std::runtime_error);
+
+class usrp2_sink_16sc : public usrp2_sink_base
+{
+protected:
+ usrp2_sink_16sc(const std::string &ifc, const std::string &mac);
+
+public:
+ ~usrp2_sink_16sc();
};
// ----------------------------------------------------------------
usrp2_source_32fc_sptr.set_center_freq = __set_center_freq
usrp2_source_16sc_sptr.set_center_freq = __set_center_freq
+usrp2_sink_32fc_sptr.set_center_freq = __set_center_freq
+usrp2_sink_16sc_sptr.set_center_freq = __set_center_freq
%}
--- /dev/null
+/* -*- c++ -*- */
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <usrp2_base.h>
+#include <gr_io_signature.h>
+#include <iostream>
+
+usrp2_base::usrp2_base(const char *name,
+ gr_io_signature_sptr input_signature,
+ gr_io_signature_sptr output_signature,
+ const std::string &ifc,
+ const std::string &mac)
+ throw (std::runtime_error)
+ : gr_sync_block(name,
+ input_signature,
+ output_signature),
+ d_u2(usrp2::usrp2::sptr())
+{
+ d_u2 = usrp2::usrp2::make(ifc, mac);
+ if (!d_u2)
+ throw std::runtime_error("Unable to initialize USRP2!");
+}
+
+usrp2_base::~usrp2_base ()
+{
+ // NOP
+}
+
+std::string
+usrp2_base::mac_addr() const
+{
+ return d_u2->mac_addr();
+}
+
+bool
+usrp2_base::start()
+{
+ // Default implementation is NOP
+ return true;
+}
+
+bool
+usrp2_base::stop()
+{
+ // Default implementation is NOP
+ return true;
+}
--- /dev/null
+/* -*- c++ -*- */
+/*
+ * 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.
+ */
+
+#ifndef INCLUDED_USRP2_BASE_H
+#define INCLUDED_USRP2_BASE_H
+
+#include <gr_sync_block.h>
+#include <usrp2/usrp2.h>
+#include <stdexcept>
+
+// BIG ASS FIXME: get from lower layer MTU calculation
+#define USRP2_MIN_RX_SAMPLES 371
+
+/*!
+ * Base class for all USRP2 blocks
+ */
+class usrp2_base : public gr_sync_block
+{
+protected:
+ usrp2_base(const char *name,
+ gr_io_signature_sptr input_signature,
+ gr_io_signature_sptr output_signature,
+ const std::string &ifc,
+ const std::string &mac)
+ throw (std::runtime_error);
+
+ usrp2::usrp2::sptr d_u2;
+
+public:
+ ~usrp2_base();
+
+ /*!
+ * \brief Get USRP2 hardware MAC address
+ */
+ std::string mac_addr() const;
+
+ /*!
+ * \brief Called by scheduler when starting flowgraph
+ */
+ virtual bool start();
+
+ /*!
+ * \brief Called by scheduler when stopping flowgraph
+ */
+ virtual bool stop();
+
+ /*!
+ * \brief Derived class must override this
+ */
+ virtual int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items) = 0;
+};
+
+#endif /* INCLUDED_USRP2_BASE_H */
--- /dev/null
+/* -*- c++ -*- */
+/*
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <usrp2_sink_16sc.h>
+#include <usrp2/metadata.h>
+#include <gr_io_signature.h>
+#include <iostream>
+
+usrp2_sink_16sc_sptr
+usrp2_make_sink_16sc(const std::string &ifc, const std::string &mac_addr)
+ throw (std::runtime_error)
+{
+ return usrp2_sink_16sc_sptr(new usrp2_sink_16sc(ifc, mac_addr));
+}
+
+usrp2_sink_16sc::usrp2_sink_16sc(const std::string &ifc, const std::string &mac_addr)
+ throw (std::runtime_error)
+ : usrp2_sink_base("usrp2_sink_16sc",
+ gr_make_io_signature(1, 1, sizeof(std::complex<int16_t>)),
+ ifc, mac_addr)
+{
+ // NOP
+}
+
+usrp2_sink_16sc::~usrp2_sink_16sc()
+{
+ // NOP
+}
+
+int
+usrp2_sink_16sc::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ std::complex<int16_t> *in = (std::complex<int16_t> *)input_items[0];
+
+ usrp2::tx_metadata metadata;
+ metadata.timestamp = -1;
+ metadata.send_now = 1;
+ metadata.start_of_burst = 1;
+
+ bool ok = d_u2->tx_complex_int16(0, // FIXME: someday, streams will have channel numbers
+ in, noutput_items, &metadata);
+ if (!ok)
+ std::cerr << "usrp2_sink_16sc: tx_complex_int16 failed" << std::endl;
+
+ return noutput_items;
+}
--- /dev/null
+/* -*- c++ -*- */
+/*
+ * 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.
+ */
+
+#ifndef INCLUDED_USRP2_SINK_16SC_H
+#define INCLUDED_USRP2_SINK_16SC_H
+
+#include <usrp2_sink_base.h>
+
+class usrp2_sink_16sc;
+typedef boost::shared_ptr<usrp2_sink_16sc> usrp2_sink_16sc_sptr;
+
+usrp2_sink_16sc_sptr
+usrp2_make_sink_16sc(const std::string &ifc="eth0",
+ const std::string &mac="")
+ throw (std::runtime_error);
+
+class usrp2_sink_16sc : public usrp2_sink_base
+{
+private:
+ friend usrp2_sink_16sc_sptr
+ usrp2_make_sink_16sc(const std::string &ifc,
+ const std::string &mac)
+ throw (std::runtime_error);
+
+protected:
+ usrp2_sink_16sc(const std::string &ifc, const std::string &mac)
+ throw (std::runtime_error);
+
+public:
+ ~usrp2_sink_16sc();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_USRP2_SINK_16SC_H */
#endif
#include <usrp2_sink_32fc.h>
+#include <usrp2/metadata.h>
#include <gr_io_signature.h>
-#include <usrp_standard.h>
-#include <usrp_bytesex.h>
+#include <iostream>
usrp2_sink_32fc_sptr
-usrp2_make_sink_32fc() throw (std::runtime_error)
+usrp2_make_sink_32fc(const std::string &ifc, const std::string &mac_addr)
+ throw (std::runtime_error)
{
- return usrp2_sink_32fc_sptr(new usrp2_sink_32fc());
+ return usrp2_sink_32fc_sptr(new usrp2_sink_32fc(ifc, mac_addr));
}
-usrp2_sink_32fc::usrp2_sink_32fc() throw (std::runtime_error)
+usrp2_sink_32fc::usrp2_sink_32fc(const std::string &ifc, const std::string &mac_addr)
+ throw (std::runtime_error)
: usrp2_sink_base("usrp2_sink_32fc",
- gr_make_io_signature(1, 1, sizeof(gr_complex)))
+ gr_make_io_signature(1, 1, sizeof(gr_complex)),
+ ifc, mac_addr)
{
+ // NOP
}
usrp2_sink_32fc::~usrp2_sink_32fc()
{
+ // NOP
+}
+
+int
+usrp2_sink_32fc::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ gr_complex *in = (gr_complex *)input_items[0];
+
+ usrp2::tx_metadata metadata;
+ metadata.timestamp = -1;
+ metadata.send_now = 1;
+ metadata.start_of_burst = 1;
+
+ bool ok = d_u2->tx_complex_float(0, // FIXME: someday, streams will have channel numbers
+ in, noutput_items, &metadata);
+ if (!ok)
+ std::cerr << "usrp2_sink_32fc: tx_complex_float failed" << std::endl;
+
+ return noutput_items;
}
typedef boost::shared_ptr<usrp2_sink_32fc> usrp2_sink_32fc_sptr;
usrp2_sink_32fc_sptr
-usrp2_make_sink_32fc() throw (std::runtime_error);
+usrp2_make_sink_32fc(const std::string &ifc="eth0",
+ const std::string &mac="")
+ throw (std::runtime_error);
-class usrp2_sink_32fc : public usrp2_sink_base {
+class usrp2_sink_32fc : public usrp2_sink_base
+{
private:
-
friend usrp2_sink_32fc_sptr
- usrp2_make_sink_32fc() throw (std::runtime_error);
-
+ usrp2_make_sink_32fc(const std::string &ifc,
+ const std::string &mac)
+ throw (std::runtime_error);
+
protected:
- usrp2_sink_32fc() throw (std::runtime_error);
+ usrp2_sink_32fc(const std::string &ifc, const std::string &mac)
+ throw (std::runtime_error);
public:
~usrp2_sink_32fc();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
};
#endif /* INCLUDED_USRP2_SINK_32FC_H */
#include <usrp2_sink_base.h>
#include <gr_io_signature.h>
+#include <iostream>
-usrp2_sink_base::usrp2_sink_base(const std::string &name,
- gr_io_signature_sptr input_signature)
+#define USRP2_SINK_BASE_DEBUG 0
+
+usrp2_sink_base::usrp2_sink_base(const char *name,
+ gr_io_signature_sptr input_signature,
+ const std::string &ifc,
+ const std::string &mac)
throw (std::runtime_error)
- : gr_sync_block(name,
- input_signature,
- gr_make_io_signature(0, 0, 0))
+ : usrp2_base(name,
+ input_signature,
+ gr_make_io_signature(0, 0, 0),
+ ifc, mac)
{
+ // NOP
}
usrp2_sink_base::~usrp2_sink_base ()
{
+ // NOP
+}
+
+bool
+usrp2_sink_base::set_gain(double gain)
+{
+ return d_u2->set_tx_gain(gain);
+}
+
+bool
+usrp2_sink_base::set_center_freq(double frequency, usrp2::tune_result *tr)
+{
+ return d_u2->set_tx_center_freq(frequency, tr);
}
-int
-usrp2_sink_base::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+bool
+usrp2_sink_base::set_interp(int interp_factor)
{
- return noutput_items;
+ return d_u2->set_tx_interp(interp_factor);
}
#ifndef INCLUDED_USRP2_SINK_BASE_H
#define INCLUDED_USRP2_SINK_BASE_H
-#include <gr_sync_block.h>
-#include <stdexcept>
-
-class usrp2_sink_base : public gr_sync_block {
-
-private:
+#include <usrp2_base.h>
+/*!
+ * Base class for all USRP2 transmit blocks
+ */
+class usrp2_sink_base : public usrp2_base
+{
protected:
- usrp2_sink_base(const std::string &name,
- gr_io_signature_sptr input_signature)
+ usrp2_sink_base(const char *name,
+ gr_io_signature_sptr input_signature,
+ const std::string &ifc,
+ const std::string &mac)
throw (std::runtime_error);
-
+
public:
~usrp2_sink_base();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
+
+ /*!
+ * \brief Set transmitter gain
+ */
+ bool set_gain(double gain);
+
+ /*!
+ * \brief Set transmitter center frequency
+ */
+ bool set_center_freq(double frequency, usrp2::tune_result *tr);
+
+ /*!
+ * \brief Set transmit interpolation rate
+ */
+ bool set_interp(int interp_factor);
};
#endif /* INCLUDED_USRP2_SINK_BASE_H */
#include <gr_io_signature.h>
#include <iostream>
-#define USRP2_SOURCE_16SC_DEBUG 0
-
usrp2_source_16sc_sptr
usrp2_make_source_16sc(const std::string &ifc, const std::string &mac_addr)
throw (std::runtime_error)
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- if (USRP2_SOURCE_16SC_DEBUG)
- printf("work: noutput_items=%i\n", noutput_items);
-
std::complex<int16_t> *out = (std::complex<int16_t> *)output_items[0];
rx_16sc_handler::sptr handler = rx_16sc_handler::make(noutput_items, USRP2_MIN_RX_SAMPLES, out);
if (!ok)
std::cerr << "usrp2::rx_samples() failed" << std::endl;
- int j = handler->nsamples();
- int f = handler->nframes();
-
- if (USRP2_SOURCE_16SC_DEBUG)
- printf("work: produced=%i items from %i frames\n\n", j, f);
-
- return j;
+ return handler->nsamples();
}
const std::string &mac="")
throw (std::runtime_error);
-class usrp2_source_16sc : public usrp2_source_base {
-
+class usrp2_source_16sc : public usrp2_source_base
+{
private:
friend usrp2_source_16sc_sptr
usrp2_make_source_16sc(const std::string &ifc,
#include <gr_io_signature.h>
#include <iostream>
-#define USRP2_SOURCE_32FC_DEBUG 0
-
usrp2_source_32fc_sptr
usrp2_make_source_32fc(const std::string &ifc, const std::string &mac_addr)
throw (std::runtime_error)
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- if (USRP2_SOURCE_32FC_DEBUG)
- printf("work: noutput_items=%i\n", noutput_items);
-
gr_complex *out = (gr_complex *)output_items[0];
rx_32fc_handler::sptr handler = rx_32fc_handler::make(noutput_items, USRP2_MIN_RX_SAMPLES, out);
if (!ok)
std::cerr << "usrp2::rx_samples() failed" << std::endl;
- int j = handler->nsamples();
- int f = handler->nframes();
-
- if (USRP2_SOURCE_32FC_DEBUG)
- printf("work: produced=%i items from %i frames\n\n", j, f);
-
- return j;
+ return handler->nsamples();
}
const std::string &mac="")
throw (std::runtime_error);
-class usrp2_source_32fc : public usrp2_source_base {
-
+class usrp2_source_32fc : public usrp2_source_base
+{
private:
friend usrp2_source_32fc_sptr
usrp2_make_source_32fc(const std::string &ifc,
#include <gr_io_signature.h>
#include <iostream>
-#define USRP2_SOURCE_BASE_DEBUG 0
-
usrp2_source_base::usrp2_source_base(const char *name,
gr_io_signature_sptr output_signature,
const std::string &ifc,
const std::string &mac)
throw (std::runtime_error)
- : gr_sync_block(name,
- gr_make_io_signature(0, 0, 0),
- output_signature),
- d_u2(usrp2::usrp2::sptr())
+ : usrp2_base(name,
+ gr_make_io_signature(0, 0, 0),
+ output_signature,
+ ifc, mac)
{
- d_u2 = usrp2::usrp2::make(ifc, mac);
- if (!d_u2)
- throw std::runtime_error("Unable to initialize USRP2!");
+ // NOP
}
usrp2_source_base::~usrp2_source_base ()
{
+ // NOP
}
bool
return d_u2->set_rx_decim(decimation_factor);
}
-std::string
-usrp2_source_base::mac_addr()
-{
- return d_u2->mac_addr();
-}
-
bool
usrp2_source_base::start()
{
- if (USRP2_SOURCE_BASE_DEBUG)
- printf("usrp2_source_base::start()\n");
-
return d_u2->start_rx_streaming(0); // FIXME: someday sources will have channel #s
}
bool
usrp2_source_base::stop()
{
- if (USRP2_SOURCE_BASE_DEBUG)
- printf("usrp2_source_base::stop()\n");
-
return d_u2->stop_rx_streaming(0); // FIXME: someday sources will have channel #s
}
#ifndef INCLUDED_USRP2_SOURCE_BASE_H
#define INCLUDED_USRP2_SOURCE_BASE_H
-#include <gr_sync_block.h>
-#include <usrp2/usrp2.h>
-#include <stdexcept>
+#include <usrp2_base.h>
-// BIG ASS FIXME: get from lower layer MTU calculation
-#define USRP2_MIN_RX_SAMPLES 371
-
-class usrp2_source_base : public gr_sync_block {
-
+/*!
+ * Base class for all USRP2 source blocks
+ */
+class usrp2_source_base : public usrp2_base
+{
protected:
usrp2_source_base(const char *name,
gr_io_signature_sptr output_signature,
const std::string &mac)
throw (std::runtime_error);
- usrp2::usrp2::sptr d_u2;
-
public:
~usrp2_source_base();
*/
bool set_decim(int decimation_factor);
- /*!
- * \brief Get USRP2 hardware MAC address
- */
- std::string mac_addr();
-
/*!
* \brief Called by scheduler when starting flowgraph
*/
- bool start();
+ virtual bool start();
/*!
* \brief Called by scheduler when stopping flowgraph
*/
- bool stop();
-
- /*!
- * \brief Derived class must override this
- */
- virtual int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items) = 0;
+ virtual bool stop();
};
#endif /* INCLUDED_USRP2_SOURCE_BASE_H */
*/
/*!
- * Set receiver gain
+ * Set transmitter gain
*/
bool set_tx_gain(double gain);