[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9467 - in gnuradio/branches/features/gr-usrp2: gnurad
From: |
jcorgan |
Subject: |
[Commit-gnuradio] r9467 - in gnuradio/branches/features/gr-usrp2: gnuradio-core/src/utils gr-usrp2/src gr-utils/src/python |
Date: |
Sat, 30 Aug 2008 20:48:32 -0600 (MDT) |
Author: jcorgan
Date: 2008-08-30 20:48:32 -0600 (Sat, 30 Aug 2008)
New Revision: 9467
Added:
gnuradio/branches/features/gr-usrp2/gnuradio-core/src/utils/read_cshort_binary.m
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_16sc_handler.cc
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_16sc_handler.h
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_16sc.cc
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_16sc.h
Modified:
gnuradio/branches/features/gr-usrp2/gnuradio-core/src/utils/Makefile.am
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/Makefile.am
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2.i
gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_32fc.h
gnuradio/branches/features/gr-usrp2/gr-utils/src/python/usrp2_rx_cfile.py
Log:
Adds usrp2.source_16sc, usrp2_rx_cfile.py support, Octave read routine.
Modified:
gnuradio/branches/features/gr-usrp2/gnuradio-core/src/utils/Makefile.am
===================================================================
--- gnuradio/branches/features/gr-usrp2/gnuradio-core/src/utils/Makefile.am
2008-08-31 01:29:41 UTC (rev 9466)
+++ gnuradio/branches/features/gr-usrp2/gnuradio-core/src/utils/Makefile.am
2008-08-31 02:48:32 UTC (rev 9467)
@@ -39,6 +39,7 @@
read_float_binary.m \
read_int_binary.m \
read_short_binary.m \
+ read_cshort_binary.m \
single_pole_iir.m \
write_float_binary.m \
write_short_binary.m
Added:
gnuradio/branches/features/gr-usrp2/gnuradio-core/src/utils/read_cshort_binary.m
===================================================================
---
gnuradio/branches/features/gr-usrp2/gnuradio-core/src/utils/read_cshort_binary.m
(rev 0)
+++
gnuradio/branches/features/gr-usrp2/gnuradio-core/src/utils/read_cshort_binary.m
2008-08-31 02:48:32 UTC (rev 9467)
@@ -0,0 +1,46 @@
+%
+% Copyright 2001,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.
+%
+
+function cv = read_cshort_binary (filename, count)
+
+ %% usage: read_cshort_binary (filename, [count])
+ %%
+ %% open filename and return the contents, treating them as
+ %% signed short integers
+ %%
+
+ m = nargchk (1,2,nargin);
+ if (m)
+ usage (m);
+ end
+
+ if (nargin < 2)
+ count = Inf;
+ end
+
+ f = fopen (filename, 'rb');
+ if (f < 0)
+ cv = 0;
+ else
+ v = fread (f, count, 'short');
+ fclose (f);
+ cv = v(1:2:end)+v(2:2:end)*j;
+ end
Modified: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/Makefile.am
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/Makefile.am
2008-08-31 01:29:41 UTC (rev 9466)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/Makefile.am
2008-08-31 02:48:32 UTC (rev 9467)
@@ -35,8 +35,10 @@
lib_LTLIBRARIES = libgr-usrp2.la
libgr_usrp2_la_SOURCES = \
+ rx_16sc_handler.cc \
rx_32fc_handler.cc \
usrp2_source_base.cc \
+ usrp2_source_16sc.cc \
usrp2_source_32fc.cc
# usrp2_source_16sc.cc
# usrp2_sink_base.cc
@@ -56,6 +58,7 @@
# usrp2_sink_16sc.h
noinst_HEADERS = \
+ rx_16sc_handler.h
rx_32fc_handler.h
# ----------------------------------------------------------------------
Added: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_16sc_handler.cc
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_16sc_handler.cc
(rev 0)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_16sc_handler.cc
2008-08-31 02:48:32 UTC (rev 9467)
@@ -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_16sc_handler.h>
+
+rx_16sc_handler::~rx_16sc_handler()
+{
+}
Added: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_16sc_handler.h
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_16sc_handler.h
(rev 0)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/rx_16sc_handler.h
2008-08-31 02:48:32 UTC (rev 9467)
@@ -0,0 +1,75 @@
+/* -*- 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_16SC_HANDLER_H
+#define INCLUDED_RX_16SC_HANDLER_H
+
+#include <usrp2/rx_nop_handler.h>
+#include <usrp2/copiers.h>
+
+#define RX_16SC_HANDLER_DEBUG 0
+
+class rx_16sc_handler : public usrp2::rx_nop_handler
+{
+ std::complex<int16_t> *d_dest;
+
+ // Private constructor
+ rx_16sc_handler(uint64_t max_samples, uint64_t max_quantum,
std::complex<int16_t> *dest)
+ : rx_nop_handler(max_samples, max_quantum), d_dest(dest) {}
+
+public:
+ // Shared pointer to one of these
+ typedef boost::shared_ptr<rx_16sc_handler> sptr;
+
+ // Factory function to return a shared pointer to a new instance
+ static sptr make(uint64_t max_samples, uint64_t max_quantum,
std::complex<int16_t> *dest)
+ {
+ if (RX_16SC_HANDLER_DEBUG)
+ printf("rx_16sc_handler: max_samples=%li max_quantum=%li\n",
max_samples, max_quantum);
+
+ return sptr(new rx_16sc_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_16SC_HANDLER_DEBUG)
+ printf("rx_16sc_handler: called with items=%zu ", nitems);
+
+ // Copy/reformat/endian swap USRP2 data to destination buffer
+ usrp2::copy_u2_complex_16_to_host_complex_16(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_16SC_HANDLER_DEBUG)
+ printf("ok to call again=%i\n", ok);
+
+ return ok;
+ }
+
+ ~rx_16sc_handler();
+};
+
+#endif /* INCLUDED_RX_16SC_HANDLER_H */
Modified: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2.i
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2.i 2008-08-31
01:29:41 UTC (rev 9466)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2.i 2008-08-31
02:48:32 UTC (rev 9467)
@@ -28,6 +28,7 @@
%{
#include <gnuradio_swig_bug_workaround.h>
//#include "usrp2_sink_32fc.h"
+#include "usrp2_source_16sc.h"
#include "usrp2_source_32fc.h"
%}
@@ -103,6 +104,32 @@
std::string mac_addr();
};
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(usrp2,source_16sc)
+
+usrp2_source_16sc_sptr
+usrp2_make_source_16sc(const std::string ifc, const std::string mac)
+ throw (std::runtime_error);
+
+class usrp2_source_16sc : public usrp2_source_base {
+
+protected:
+ usrp2_source_16sc(const std::string &ifc, const std::string &mac);
+
+public:
+ ~usrp2_source_16sc();
+
+ 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();
+};
+
+// ----------------------------------------------------------------
+
// create a more pythonic interface
%pythoncode %{
@@ -115,5 +142,5 @@
return None
usrp2_source_32fc_sptr.set_center_freq = __set_center_freq
-
+usrp2_source_16sc_sptr.set_center_freq = __set_center_freq
%}
Added: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_16sc.cc
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_16sc.cc
(rev 0)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_16sc.cc
2008-08-31 02:48:32 UTC (rev 9467)
@@ -0,0 +1,77 @@
+/* -*- 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_source_16sc.h>
+#include <rx_16sc_handler.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)
+{
+ return usrp2_source_16sc_sptr(new usrp2_source_16sc(ifc, mac_addr));
+}
+
+usrp2_source_16sc::usrp2_source_16sc(const std::string &ifc, const std::string
&mac_addr)
+ throw (std::runtime_error)
+ : usrp2_source_base("usrp2_source_16sc",
+ gr_make_io_signature(1, 1, sizeof(std::complex<int16_t>)),
+ ifc, mac_addr)
+{
+ set_output_multiple(USRP2_MIN_RX_SAMPLES);
+}
+
+usrp2_source_16sc::~usrp2_source_16sc()
+{
+}
+
+int
+usrp2_source_16sc::work(int noutput_items,
+ 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);
+
+ 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_16SC_DEBUG)
+ printf("work: produced=%i items from %i frames\n\n", j, f);
+
+ return j;
+}
Added: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_16sc.h
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_16sc.h
(rev 0)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_16sc.h
2008-08-31 02:48:32 UTC (rev 9467)
@@ -0,0 +1,54 @@
+/* -*- 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_SOURCE_C_H
+#define INCLUDED_USRP2_SOURCE_C_H
+
+#include <usrp2_source_base.h>
+
+class usrp2_source_16sc;
+typedef boost::shared_ptr<usrp2_source_16sc> usrp2_source_16sc_sptr;
+
+usrp2_source_16sc_sptr
+usrp2_make_source_16sc(const std::string &ifc="eth0",
+ const std::string &mac="")
+ throw (std::runtime_error);
+
+class usrp2_source_16sc : public usrp2_source_base {
+
+private:
+ friend usrp2_source_16sc_sptr
+ usrp2_make_source_16sc(const std::string &ifc,
+ const std::string &mac) throw (std::runtime_error);
+
+protected:
+ usrp2_source_16sc(const std::string &ifc, const std::string &mac) throw
(std::runtime_error);
+
+public:
+ ~usrp2_source_16sc();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_USRP2_SOURCE_16SC_H */
Modified: gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_32fc.h
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_32fc.h
2008-08-31 01:29:41 UTC (rev 9466)
+++ gnuradio/branches/features/gr-usrp2/gr-usrp2/src/usrp2_source_32fc.h
2008-08-31 02:48:32 UTC (rev 9467)
@@ -20,8 +20,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_USRP2_SOURCE_C_H
-#define INCLUDED_USRP2_SOURCE_C_H
+#ifndef INCLUDED_USRP2_SOURCE_32FC_H
+#define INCLUDED_USRP2_SOURCE_32FC_H
#include <usrp2_source_base.h>
Modified:
gnuradio/branches/features/gr-usrp2/gr-utils/src/python/usrp2_rx_cfile.py
===================================================================
--- gnuradio/branches/features/gr-usrp2/gr-utils/src/python/usrp2_rx_cfile.py
2008-08-31 01:29:41 UTC (rev 9466)
+++ gnuradio/branches/features/gr-usrp2/gr-utils/src/python/usrp2_rx_cfile.py
2008-08-31 02:48:32 UTC (rev 9467)
@@ -22,7 +22,7 @@
# Create a USRP2 source
if options.output_shorts:
self._u = usrp2.source_16sc(options.interface, options.mac_addr)
- self._sink = gr.file_sink(gr.sizeof_short, filename)
+ self._sink = gr.file_sink(gr.sizeof_short*2, filename)
else:
self._u = usrp2.source_32fc(options.interface, options.mac_addr)
self._sink = gr.file_sink(gr.sizeof_gr_complex, filename)
@@ -48,7 +48,7 @@
self.connect(self._u, self._sink)
else:
if options.output_shorts:
- self._head = gr.head(gr.sizeof_short, int(options.nsamples)*2)
+ self._head = gr.head(gr.sizeof_short*2, int(options.nsamples))
else:
self._head = gr.head(gr.sizeof_gr_complex,
int(options.nsamples))
@@ -106,7 +106,6 @@
sys.stderr.write('You must specify the frequency with -f FREQ\n');
raise SystemExit, 1
- options.output_shorts = False # Force off until source written
return (options, args[0])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9467 - in gnuradio/branches/features/gr-usrp2: gnuradio-core/src/utils gr-usrp2/src gr-utils/src/python,
jcorgan <=