[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4529 - in gnuradio/branches/developers/n4hy/ofdm/gnur
From: |
trondeau |
Subject: |
[Commit-gnuradio] r4529 - in gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib: general io |
Date: |
Mon, 19 Feb 2007 16:30:37 -0700 (MST) |
Author: trondeau
Date: 2007-02-19 16:30:36 -0700 (Mon, 19 Feb 2007)
New Revision: 4529
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.cc
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.h
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.i
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.cc
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.h
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.i
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/Makefile.am
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/io.i
Log:
move ofdm2 to ofdm migration
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.cc
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.cc
2007-02-19 23:01:03 UTC (rev 4528)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.cc
2007-02-19 23:30:36 UTC (rev 4529)
@@ -30,16 +30,16 @@
#include <math.h>
gr_fft_vcc_sptr
-gr_make_fft_vcc (int fft_size, bool forward,const std::vector<float> window)
+gr_make_fft_vcc (int fft_size, bool forward,const std::vector<float> window,
bool shift)
{
- return gr_fft_vcc_sptr (new gr_fft_vcc (fft_size, forward, window));
+ return gr_fft_vcc_sptr (new gr_fft_vcc (fft_size, forward, window, shift));
}
-gr_fft_vcc::gr_fft_vcc (int fft_size, bool forward, const std::vector<float>
window)
+gr_fft_vcc::gr_fft_vcc (int fft_size, bool forward, const std::vector<float>
window, bool shift)
: gr_sync_block ("fft_vcc",
gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex)),
gr_make_io_signature (1, 1, fft_size * sizeof (gr_complex))),
- d_fft_size(fft_size)
+ d_fft_size(fft_size), d_forward(forward), d_shift(shift)
{
d_fft = new gri_fft_complex (d_fft_size, forward);
@@ -66,27 +66,43 @@
int count = 0;
while (count++ < noutput_items){
-
+
// copy input into optimally aligned buffer
-
+
if (d_window.size()){
gr_complex *dst = d_fft->get_inbuf();
for (unsigned int i = 0; i < d_fft_size; i++) // apply window
dst[i] = in[i] * d_window[i];
}
- else
- memcpy (d_fft->get_inbuf(), in, input_data_size);
-
+ else {
+ if(!d_forward && d_shift) { // apply an ifft shift on the data
+ gr_complex *dst = d_fft->get_inbuf();
+ unsigned int len = (unsigned int)(floor(d_fft_size/2.0)); // half
length of complex array
+ memcpy(&dst[0], &in[len], sizeof(gr_complex)*(d_fft_size - len));
+ memcpy(&dst[d_fft_size - len], &in[0], sizeof(gr_complex)*len);
+ }
+ else {
+ memcpy (d_fft->get_inbuf(), in, input_data_size);
+ }
+ }
+
// compute the fft
d_fft->execute ();
-
- // cpoy result to our output
- memcpy (out, d_fft->get_outbuf (), output_data_size);
-
+
+ // copy result to our output
+ if(d_forward && d_shift) { // apply a fft shift on the data
+ unsigned int len = (unsigned int)(ceil(d_fft_size/2.0));
+ memcpy(&out[0], &d_fft->get_outbuf()[len],
sizeof(gr_complex)*(d_fft_size - len));
+ memcpy(&out[d_fft_size - len], &d_fft->get_outbuf()[0],
sizeof(gr_complex)*len);
+ }
+ else {
+ memcpy (out, d_fft->get_outbuf (), output_data_size);
+ }
+
in += d_fft_size;
out += d_fft_size;
}
-
+
return noutput_items;
}
@@ -100,3 +116,18 @@
else
return false;
}
+
+/*
+fftshift
+
+ for(i=0; i < ceil(d_occupied_carriers/2.0); i++) {
+ unsigned int k=ceil(d_occupied_carriers/2.0);
+ out[i] = gr_complex(-1+2*in[i+k],0);
+ }
+ for(; i < d_vlen - ceil(d_occupied_carriers/2.0); i++) {
+ out[i]=gr_complex(0,0);
+ }
+ for(unsigned int j=0;i<d_vlen;i++,j++) {
+ out[i]= gr_complex((-1+2*in[j]),0);
+ }
+*/
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.h
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.h
2007-02-19 23:01:03 UTC (rev 4528)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.h
2007-02-19 23:30:36 UTC (rev 4529)
@@ -31,7 +31,7 @@
typedef boost::shared_ptr<gr_fft_vcc> gr_fft_vcc_sptr;
gr_fft_vcc_sptr
-gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window);
+gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window,
bool shift=false);
/*!
* \brief Compute forward or reverse FFT. complex vector in / complex vector
out.
@@ -41,13 +41,15 @@
class gr_fft_vcc : public gr_sync_block
{
friend gr_fft_vcc_sptr
- gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float>
window);
+ gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float>
window, bool shift);
unsigned int d_fft_size;
std::vector<float> d_window;
gri_fft_complex *d_fft;
+ bool d_forward;
+ bool d_shift;
- gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window);
+ gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window,
bool shift);
public:
~gr_fft_vcc ();
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.i
2007-02-19 23:01:03 UTC (rev 4528)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_fft_vcc.i
2007-02-19 23:30:36 UTC (rev 4529)
@@ -23,12 +23,12 @@
GR_SWIG_BLOCK_MAGIC(gr, fft_vcc)
gr_fft_vcc_sptr
-gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window);
+gr_make_fft_vcc (int fft_size, bool forward, const std::vector<float> window,
bool shift=false);
class gr_fft_vcc : public gr_sync_block
{
protected:
- gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window);
+ gr_fft_vcc (int fft_size, bool forward, const std::vector<float> window,
bool shift);
public:
bool set_window(const std::vector<float> window);
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/Makefile.am
===================================================================
--- gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/Makefile.am
2007-02-19 23:01:03 UTC (rev 4528)
+++ gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/Makefile.am
2007-02-19 23:30:36 UTC (rev 4529)
@@ -34,6 +34,7 @@
gr_file_descriptor_source.cc \
gr_message_sink.cc \
gr_message_source.cc \
+ gr_message_vector_source.cc \
gr_oscope_guts.cc \
gr_oscope_sink_f.cc \
gr_oscope_sink_x.cc \
@@ -61,6 +62,7 @@
gr_file_descriptor_source.h \
gr_message_sink.h \
gr_message_source.h \
+ gr_message_vector_source.h \
gr_oscope_guts.h \
gr_oscope_sink_f.h \
gr_oscope_sink_x.h \
@@ -92,6 +94,7 @@
gr_file_descriptor_source.i \
gr_message_sink.i \
gr_message_source.i \
+ gr_message_vector_source.i \
gr_oscope_sink.i \
microtune_xxxx_eval_board.i \
microtune_4702_eval_board.i \
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.cc
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.cc
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.cc
2007-02-19 23:30:36 UTC (rev 4529)
@@ -0,0 +1,97 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005 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 2, 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 <gr_message_vector_source.h>
+#include <gr_io_signature.h>
+#include <cstdio>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdexcept>
+
+
+// public constructor that returns a shared_ptr
+
+gr_message_vector_source_sptr
+gr_make_message_vector_source(size_t max_msg_size, int msgq_limit)
+{
+ return gr_message_vector_source_sptr(new
gr_message_vector_source(max_msg_size,msgq_limit));
+}
+
+gr_message_vector_source::gr_message_vector_source (size_t max_msg_size, int
msgq_limit)
+ : gr_sync_block("message_vector_source",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(1, 1, 2*sizeof(int) + max_msg_size *
sizeof(char))), // Make room for length fields
+ d_max_msg_size(max_msg_size), d_msgq(gr_make_msg_queue(msgq_limit)),
d_eof(false)
+{
+}
+
+gr_message_vector_source::~gr_message_vector_source()
+{
+}
+
+int
+gr_message_vector_source::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ /*
+ char *out = (char *) output_items[0];
+
+ if (d_eof)
+ return -1;
+
+ gr_message_sptr msg = d_msgq->delete_head();
+
+ if (msg->type() == 1) { // type == 1 sets EOF
+ d_eof = true;
+ }
+
+ assert(msg->length() <= d_max_msg_size);
+ memset((int*)out, msg->length(), 1);
+ memcpy (&out[4], (msg->msg()), msg->length());
+ */
+
+ char *out = (char *) output_items[0];
+ gr_frame *myframe = (gr_frame*)out;
+
+ if (d_eof)
+ return -1;
+
+ gr_message_sptr msg = d_msgq->delete_head();
+
+ if (msg->type() == 1) { // type == 1 sets EOF
+ d_eof = true;
+ }
+
+ assert(msg->length() <= d_max_msg_size);
+ myframe->length = msg->length();
+ myframe->mtu = d_max_msg_size;
+ memcpy (myframe->data, (msg->msg()), msg->length());
+
+ return 1;
+}
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.h
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.h
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.h
2007-02-19 23:30:36 UTC (rev 4529)
@@ -0,0 +1,63 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005 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 2, 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_GR_MESSAGE_VECTOR_SOURCE_H
+#define INCLUDED_GR_MESSAGE_VECTOR_SOURCE_H
+
+#include <gr_sync_block.h>
+#include <gr_message.h>
+#include <gr_msg_queue.h>
+#include <gr_frame.h>
+
+class gr_message_vector_source;
+typedef boost::shared_ptr<gr_message_vector_source>
gr_message_vector_source_sptr;
+
+gr_message_vector_source_sptr gr_make_message_vector_source (size_t
max_msg_size, int msgq_limit=0);
+
+/*!
+ * \brief Turn received messages into vectors
+ * \ingroup source
+ */
+class gr_message_vector_source : public gr_sync_block
+{
+ private:
+ size_t d_max_msg_size;
+ gr_msg_queue_sptr d_msgq;
+ bool d_eof;
+
+ friend gr_message_vector_source_sptr
+ gr_make_message_vector_source(size_t max_msg_size, int msgq_limit);
+
+ protected:
+ gr_message_vector_source (size_t max_msg_size, int msgq_limit);
+
+ public:
+ ~gr_message_vector_source ();
+
+ gr_msg_queue_sptr msgq() const { return d_msgq; }
+
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_GR_MESSAGE_VECTOR_SOURCE_H */
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.i
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/gr_message_vector_source.i
2007-02-19 23:30:36 UTC (rev 4529)
@@ -0,0 +1,36 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2005 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 2, 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.
+ */
+
+GR_SWIG_BLOCK_MAGIC(gr,message_vector_source);
+
+gr_message_vector_source_sptr gr_make_message_vector_source (size_t
max_msg_size, int msgq_limit=0);
+
+class gr_message_vector_source : public gr_sync_block
+{
+ protected:
+ gr_message_vector_source (size_t itemsize, int msgq_limit);
+
+ public:
+ ~gr_message_vector_source ();
+
+ gr_msg_queue_sptr msgq() const;
+};
Modified: gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/io.i
===================================================================
--- gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/io.i
2007-02-19 23:01:03 UTC (rev 4528)
+++ gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/io.i
2007-02-19 23:30:36 UTC (rev 4529)
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2007 Free Software Foundation, Inc.
+ * Copyright 2004 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -34,8 +34,9 @@
#include <ppio.h>
#include <gr_message_source.h>
#include <gr_message_sink.h>
-#include <gr_udp_sink.h>
-#include <gr_udp_source.h>
+#include <gr_message_vector_source.h>
+#include <gr_udp_sink.cc>
+#include <gr_udp_source.cc>
%}
@@ -50,6 +51,7 @@
%include "gr_oscope_sink.i"
%include "ppio.i"
%include "gr_message_source.i"
+%include "gr_message_vector_source.i"
%include "gr_message_sink.i"
%include "gr_udp_sink.i"
%include "gr_udp_source.i"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4529 - in gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib: general io,
trondeau <=