[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9465 - gnuradio/branches/features/gr-usrp2/gr-usrp2/s
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r9465 - gnuradio/branches/features/gr-usrp2/gr-usrp2/src |
Date: |
Sat, 30 Aug 2008 17:00:51 -0600 (MDT) |
Author: jcorgan
Date: 2008-08-30 17:00:50 -0600 (Sat, 30 Aug 2008)
New Revision: 9465
Added:
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_32fc_handler.cc
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_32fc_handler.h
Modified:
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/Makefile.am
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_32fc.cc
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_base.cc
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_base.h
Log:
Initial implementation of usrp2.source_32fc work function. Minimal testing,
but appears to work.
Modified: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/Makefile.am
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/Makefile.am
2008-08-30 22:15:38 UTC (rev 9464)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/Makefile.am
2008-08-30 23:00:50 UTC (rev 9465)
@@ -35,6 +35,7 @@
lib_LTLIBRARIES = libgr-usrp2.la
libgr_usrp2_la_SOURCES = \
+ rx_32fc_handler.cc \
usrp2_source_base.cc \
usrp2_source_32fc.cc
# usrp2_source_16sc.cc
@@ -54,6 +55,8 @@
# usrp2_sink_32fc.h \
# usrp2_sink_16sc.h
+noinst_HEADERS = \
+ rx_32fc_handler.h
# ----------------------------------------------------------------------
# C++ binaries, not installed
Added: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_32fc_handler.cc
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_32fc_handler.cc
(rev 0)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_32fc_handler.cc
2008-08-30 23:00:50 UTC (rev 9465)
@@ -0,0 +1,31 @@
+/* -*- 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 <rx_32fc_handler.h>
+
+rx_32fc_handler::~rx_32fc_handler()
+{
+}
Added: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_32fc_handler.h
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_32fc_handler.h
(rev 0)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_32fc_handler.h
2008-08-30 23:00:50 UTC (rev 9465)
@@ -0,0 +1,76 @@
+/* -*- 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_RX_32FC_HANDLER_H
+#define INCLUDED_RX_32FC_HANDLER_H
+
+#include <usrp2/rx_nop_handler.h>
+#include <usrp2/copiers.h>
+#include <gr_complex.h>
+
+#define RX_32FC_HANDLER_DEBUG 0
+
+class rx_32fc_handler : public usrp2::rx_nop_handler
+{
+ gr_complex *d_dest;
+
+ // Private constructor
+ rx_32fc_handler(uint64_t max_samples, uint64_t max_quantum, gr_complex *dest)
+ : rx_nop_handler(max_samples, max_quantum), d_dest(dest) {}
+
+public:
+ // Shared pointer to one of these
+ typedef boost::shared_ptr<rx_32fc_handler> sptr;
+
+ // Factory function to return a shared pointer to a new instance
+ static sptr make(uint64_t max_samples, uint64_t max_quantum, gr_complex
*dest)
+ {
+ if (RX_32FC_HANDLER_DEBUG)
+ printf("rx_32fc_handler: max_samples=%li max_quantum=%li\n",
max_samples, max_quantum);
+
+ return sptr(new rx_32fc_handler(max_samples, max_quantum, dest));
+ }
+
+ // Invoked by USRP2 API when samples are available
+ bool operator()(const uint32_t *items, size_t nitems, const
usrp2::rx_metadata *metadata)
+ {
+ if (RX_32FC_HANDLER_DEBUG)
+ printf("rx_32fc_handler: called with items=%zu ", nitems);
+
+ // Copy/reformat/endian swap USRP2 data to destination buffer
+ usrp2::copy_u2_complex_16_to_host_complex_float(nitems, items, d_dest);
+ d_dest += nitems;
+
+ // FIXME: do something with metadata
+
+ // Determine if there is room to be called again
+ bool ok = rx_nop_handler::operator()(items, nitems, metadata);
+ if (RX_32FC_HANDLER_DEBUG)
+ printf("ok to call again=%i\n", ok);
+
+ return ok;
+ }
+
+ ~rx_32fc_handler();
+};
+
+#endif /* INCLUDED_RX_32FC_HANDLER_H */
Modified: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_32fc.cc
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_32fc.cc
2008-08-30 22:15:38 UTC (rev 9464)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_32fc.cc
2008-08-30 23:00:50 UTC (rev 9465)
@@ -25,8 +25,12 @@
#endif
#include <usrp2_source_32fc.h>
+#include <rx_32fc_handler.h>
#include <gr_io_signature.h>
+#include <iostream>
+#define USRP2_SOURCE_32FC_DEBUG 0
+
usrp2_source_32fc_sptr
usrp2_make_source_32fc(const std::string &interface,
const std::string &mac_addr)
@@ -42,6 +46,7 @@
gr_make_io_signature(1, 1, sizeof(gr_complex)),
interface, mac_addr)
{
+ set_output_multiple(USRP2_MIN_RX_SAMPLES);
}
usrp2_source_32fc::~usrp2_source_32fc()
@@ -50,8 +55,25 @@
int
usrp2_source_32fc::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
- return noutput_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);
+
+ bool ok = d_u2->rx_samples(0, handler.get());
+ 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;
}
Modified: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_base.cc
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_base.cc
2008-08-30 22:15:38 UTC (rev 9464)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_base.cc
2008-08-30 23:00:50 UTC (rev 9465)
@@ -72,3 +72,21 @@
{
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
+}
Modified: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_base.h
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_base.h
2008-08-30 22:15:38 UTC (rev 9464)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_base.h
2008-08-30 23:00:50 UTC (rev 9465)
@@ -27,6 +27,9 @@
#include <usrp2/usrp2.h>
#include <stdexcept>
+// BIG ASS FIXME: get from lower layer MTU calculation
+#define USRP2_MIN_RX_SAMPLES 371
+
class usrp2_source_base : public gr_sync_block {
protected:
@@ -62,6 +65,16 @@
std::string mac_addr();
/*!
+ * \brief Called by scheduler when starting flowgraph
+ */
+ bool start();
+
+ /*!
+ * \brief Called by scheduler when stopping flowgraph
+ */
+ bool stop();
+
+ /*!
* \brief Derived class must override this
*/
virtual int work(int noutput_items,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9465 - gnuradio/branches/features/gr-usrp2/gr-usrp2/src,
jcorgan <=