[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r4160 - gnuradio/branches/developers/n4hy/ofdm/gnuradi
From: |
trondeau |
Subject: |
[Commit-gnuradio] r4160 - gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io |
Date: |
Wed, 20 Dec 2006 00:40:04 -0700 (MST) |
Author: trondeau
Date: 2006-12-20 00:40:04 -0700 (Wed, 20 Dec 2006)
New Revision: 4160
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/io/Makefile.am
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/io.i
Log:
adding a source to take in messages and produce a vector
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
2006-12-20 07:39:21 UTC (rev 4159)
+++ gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/Makefile.am
2006-12-20 07:40:04 UTC (rev 4160)
@@ -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 \
@@ -57,8 +58,10 @@
gr_file_source.h \
gr_file_descriptor_sink.h \
gr_file_descriptor_source.h \
+ gr_frame.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 \
@@ -88,6 +91,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
2006-12-20 07:40:04 UTC (rev 4160)
@@ -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
2006-12-20 07:40:04 UTC (rev 4160)
@@ -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
2006-12-20 07:40:04 UTC (rev 4160)
@@ -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
2006-12-20 07:39:21 UTC (rev 4159)
+++ gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io/io.i
2006-12-20 07:40:04 UTC (rev 4160)
@@ -33,6 +33,7 @@
#include <gr_oscope_sink_f.h>
#include <ppio.h>
#include <gr_message_source.h>
+#include <gr_message_vector_source.h>
#include <gr_message_sink.h>
%}
@@ -48,5 +49,6 @@
%include "gr_oscope_sink.i"
%include "ppio.i"
%include "gr_message_source.i"
+%include "gr_message_vector_source.i"
%include "gr_message_sink.i"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r4160 - gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/io,
trondeau <=