summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/io
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/lib/io')
-rw-r--r--gnuradio-core/src/lib/io/CMakeLists.txt24
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc87
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_sink.h59
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_sink.i35
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_source.cc151
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_source.h68
-rw-r--r--gnuradio-core/src/lib/io/gr_file_descriptor_source.i35
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink.cc84
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink.h58
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink.i45
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.cc125
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.h75
-rw-r--r--gnuradio-core/src/lib/io/gr_file_sink_base.i51
-rw-r--r--gnuradio-core/src/lib/io/gr_file_source.cc192
-rw-r--r--gnuradio-core/src/lib/io/gr_file_source.h107
-rw-r--r--gnuradio-core/src/lib/io/gr_file_source.i45
-rw-r--r--gnuradio-core/src/lib/io/gr_message_burst_source.cc144
-rw-r--r--gnuradio-core/src/lib/io/gr_message_burst_source.h71
-rw-r--r--gnuradio-core/src/lib/io/gr_message_burst_source.i38
-rw-r--r--gnuradio-core/src/lib/io/gr_message_debug.cc120
-rw-r--r--gnuradio-core/src/lib/io/gr_message_debug.h114
-rw-r--r--gnuradio-core/src/lib/io/gr_message_debug.i30
-rw-r--r--gnuradio-core/src/lib/io/gr_message_sink.cc119
-rw-r--r--gnuradio-core/src/lib/io/gr_message_sink.h82
-rw-r--r--gnuradio-core/src/lib/io/gr_message_sink.i43
-rw-r--r--gnuradio-core/src/lib/io/gr_message_source.cc141
-rw-r--r--gnuradio-core/src/lib/io/gr_message_source.h77
-rw-r--r--gnuradio-core/src/lib/io/gr_message_source.i42
-rw-r--r--gnuradio-core/src/lib/io/gr_pdu.cc79
-rw-r--r--gnuradio-core/src/lib/io/gr_pdu.h40
-rw-r--r--gnuradio-core/src/lib/io/gr_pdu.i30
-rw-r--r--gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc132
-rw-r--r--gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.h63
-rw-r--r--gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.i31
-rw-r--r--gnuradio-core/src/lib/io/gr_socket_pdu.cc157
-rw-r--r--gnuradio-core/src/lib/io/gr_socket_pdu.h203
-rw-r--r--gnuradio-core/src/lib/io/gr_socket_pdu.i33
-rw-r--r--gnuradio-core/src/lib/io/gr_stream_pdu_base.cc123
-rw-r--r--gnuradio-core/src/lib/io/gr_stream_pdu_base.h59
-rw-r--r--gnuradio-core/src/lib/io/gr_tagged_file_sink.cc216
-rw-r--r--gnuradio-core/src/lib/io/gr_tagged_file_sink.h72
-rw-r--r--gnuradio-core/src/lib/io/gr_tagged_file_sink.i35
-rw-r--r--gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc137
-rw-r--r--gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.h76
-rw-r--r--gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.i31
-rw-r--r--gnuradio-core/src/lib/io/gr_tuntap_pdu.cc145
-rw-r--r--gnuradio-core/src/lib/io/gr_tuntap_pdu.h74
-rw-r--r--gnuradio-core/src/lib/io/gr_tuntap_pdu.i30
-rw-r--r--gnuradio-core/src/lib/io/gr_udp_sink.cc304
-rw-r--r--gnuradio-core/src/lib/io/gr_udp_sink.h112
-rw-r--r--gnuradio-core/src/lib/io/gr_udp_sink.i46
-rw-r--r--gnuradio-core/src/lib/io/gr_udp_source.cc374
-rw-r--r--gnuradio-core/src/lib/io/gr_udp_source.h110
-rw-r--r--gnuradio-core/src/lib/io/gr_udp_source.i41
-rw-r--r--gnuradio-core/src/lib/io/gr_wavfile_sink.cc280
-rw-r--r--gnuradio-core/src/lib/io/gr_wavfile_sink.h138
-rw-r--r--gnuradio-core/src/lib/io/gr_wavfile_sink.i47
-rw-r--r--gnuradio-core/src/lib/io/gr_wavfile_source.cc171
-rw-r--r--gnuradio-core/src/lib/io/gr_wavfile_source.h95
-rw-r--r--gnuradio-core/src/lib/io/gr_wavfile_source.i42
-rw-r--r--gnuradio-core/src/lib/io/gri_wavfile.cc251
-rw-r--r--gnuradio-core/src/lib/io/gri_wavfile.h96
-rw-r--r--gnuradio-core/src/lib/io/io.i37
63 files changed, 0 insertions, 6172 deletions
diff --git a/gnuradio-core/src/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt
index 59ca06b5a2..7aeea798cd 100644
--- a/gnuradio-core/src/lib/io/CMakeLists.txt
+++ b/gnuradio-core/src/lib/io/CMakeLists.txt
@@ -37,9 +37,6 @@ list(APPEND gnuradio_core_sources
${CMAKE_CURRENT_SOURCE_DIR}/microtune_4937.cc
${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.cc
${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/gri_wavfile.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/gr_pdu.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/gr_stream_pdu_base.cc
)
########################################################################
@@ -60,9 +57,6 @@ install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/microtune_eval_board_defs.h
${CMAKE_CURRENT_SOURCE_DIR}/microtune_xxxx.h
${CMAKE_CURRENT_SOURCE_DIR}/ppio_ppdev.h
- ${CMAKE_CURRENT_SOURCE_DIR}/gri_wavfile.h
- ${CMAKE_CURRENT_SOURCE_DIR}/gr_pdu.h
- ${CMAKE_CURRENT_SOURCE_DIR}/gr_stream_pdu_base.h
DESTINATION ${GR_INCLUDE_DIR}/gnuradio
COMPONENT "core_devel"
)
@@ -84,29 +78,11 @@ endif(ENABLE_PYTHON)
# Handle triple-threat files that have cc, h, and i
########################################################################
set(gr_core_io_triple_threats
- gr_file_sink
- gr_file_sink_base
- gr_file_source
- gr_file_descriptor_sink
- gr_file_descriptor_source
- gr_message_debug
- gr_message_sink
- gr_message_source
- gr_message_burst_source
- gr_pdu_to_tagged_stream
microtune_xxxx_eval_board
microtune_4702_eval_board
microtune_4937_eval_board
ppio
sdr_1000
- gr_udp_sink
- gr_udp_source
- gr_wavfile_source
- gr_wavfile_sink
- gr_tagged_file_sink
- gr_tagged_stream_to_pdu
- gr_tuntap_pdu
- gr_socket_pdu
)
foreach(file_tt ${gr_core_io_triple_threats})
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc
deleted file mode 100644
index 099d46dbd0..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2010 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 <gr_file_descriptor_sink.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <stdio.h>
-
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
-gr_file_descriptor_sink::gr_file_descriptor_sink (size_t itemsize, int fd)
- : gr_sync_block ("file_descriptor_sink",
- gr_make_io_signature (1, 1, itemsize),
- gr_make_io_signature (0, 0, 0)),
- d_itemsize (itemsize), d_fd (fd)
-{
-}
-
-gr_file_descriptor_sink_sptr
-gr_make_file_descriptor_sink (size_t itemsize, int fd)
-{
- return gnuradio::get_initial_sptr(new gr_file_descriptor_sink (itemsize, fd));
-}
-
-gr_file_descriptor_sink::~gr_file_descriptor_sink ()
-{
- close (d_fd);
-}
-
-int
-gr_file_descriptor_sink::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *inbuf = (char *) input_items[0];
- unsigned long byte_size = noutput_items * d_itemsize;
-
- while (byte_size > 0){
- ssize_t r;
-
- r = write (d_fd, inbuf, byte_size);
- if (r == -1){
- if (errno == EINTR)
- continue;
- else {
- perror ("gr_file_descriptor_sink");
- return -1; // indicate we're done
- }
- }
- else {
- byte_size -= r;
- inbuf += r;
- }
- }
-
- return noutput_items;
-}
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h
deleted file mode 100644
index 3b1c1167f7..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 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_GR_FILE_DESCRIPTOR_SINK_H
-#define INCLUDED_GR_FILE_DESCRIPTOR_SINK_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-
-class gr_file_descriptor_sink;
-typedef boost::shared_ptr<gr_file_descriptor_sink> gr_file_descriptor_sink_sptr;
-
-GR_CORE_API gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd);
-
-/*!
- * \brief Write stream to file descriptor.
- * \ingroup sink_blk
- */
-
-class GR_CORE_API gr_file_descriptor_sink : public gr_sync_block
-{
- friend GR_CORE_API gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd);
-
- private:
- size_t d_itemsize;
- int d_fd;
-
- protected:
- gr_file_descriptor_sink (size_t itemsize, int fd);
-
- public:
- ~gr_file_descriptor_sink ();
-
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-
-#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SINK_H */
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i
deleted file mode 100644
index 2c256e44d1..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.i
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,file_descriptor_sink)
-
-gr_file_descriptor_sink_sptr
-gr_make_file_descriptor_sink (size_t itemsize, int fd);
-
-class gr_file_descriptor_sink : public gr_sync_block
-{
- protected:
- gr_file_descriptor_sink (size_t itemsize, int fd);
-
- public:
- ~gr_file_descriptor_sink ();
-};
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc b/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc
deleted file mode 100644
index a63abf96b7..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.cc
+++ /dev/null
@@ -1,151 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,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 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 <gr_file_descriptor_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>
-#include <stdio.h>
-#include <string.h>
-
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
-gr_file_descriptor_source::gr_file_descriptor_source (size_t itemsize,
- int fd,
- bool repeat)
- : gr_sync_block ("file_descriptor_source",
- gr_make_io_signature (0, 0, 0),
- gr_make_io_signature (1, 1, itemsize)),
- d_itemsize (itemsize), d_fd (fd), d_repeat (repeat),
- d_residue (new unsigned char[itemsize]), d_residue_len (0)
-{
-}
-
-// public constructor that returns a shared_ptr
-
-gr_file_descriptor_source_sptr
-gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat)
-{
- return gr_file_descriptor_source_sptr (
- new gr_file_descriptor_source (itemsize, fd, repeat));
-}
-
-gr_file_descriptor_source::~gr_file_descriptor_source ()
-{
- close (d_fd);
- delete [] d_residue;
-}
-
-int
-gr_file_descriptor_source::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- assert (noutput_items > 0);
-
- char *o = (char *) output_items[0];
- int nread = 0;
-
- while (1){
- int r = read_items (o, noutput_items - nread);
- if (r == -1){
- if (errno == EINTR)
- continue;
- else {
- perror ("file_descriptor_source[read]");
- return -1;
- }
- }
- else if (r == 0){ // end of file
- if (!d_repeat)
- break;
- else {
- flush_residue ();
- if (lseek (d_fd, 0, SEEK_SET) == -1){
- perror ("file_descriptor_source[lseek]");
- return -1;
- }
- }
- }
- else {
- o += r * d_itemsize;
- nread += r;
- break;
- }
- }
-
- if (nread == 0) // EOF
- return -1;
-
- return nread;
-}
-
-int
-gr_file_descriptor_source::read_items (char *buf, int nitems)
-{
- assert (nitems > 0);
- assert (d_residue_len < d_itemsize);
-
- int nbytes_read = 0;
-
- if (d_residue_len > 0){
- memcpy (buf, d_residue, d_residue_len);
- nbytes_read = d_residue_len;
- d_residue_len = 0;
- }
-
- int r = read (d_fd, buf + nbytes_read, nitems * d_itemsize - nbytes_read);
- if (r <= 0){
- handle_residue (buf, nbytes_read);
- return r;
- }
-
- r = handle_residue (buf, r + nbytes_read);
-
- if (r == 0) // block until we get something
- return read_items (buf, nitems);
-
- return r;
-}
-
-int
-gr_file_descriptor_source::handle_residue (char *buf, int nbytes_read)
-{
- assert (nbytes_read >= 0);
- int nitems_read = nbytes_read / d_itemsize;
- d_residue_len = nbytes_read % d_itemsize;
- if (d_residue_len > 0){
- // fprintf (stderr, "handle_residue: %d\n", d_residue_len);
- memcpy (d_residue, buf + nbytes_read - d_residue_len, d_residue_len);
- }
- return nitems_read;
-}
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.h b/gnuradio-core/src/lib/io/gr_file_descriptor_source.h
deleted file mode 100644
index ebabd81eda..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 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_GR_FILE_DESCRIPTOR_SOURCE_H
-#define INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-
-class gr_file_descriptor_source;
-typedef boost::shared_ptr<gr_file_descriptor_source> gr_file_descriptor_source_sptr;
-
-GR_CORE_API gr_file_descriptor_source_sptr
-gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat = false);
-
-/*!
- * \brief Read stream from file descriptor.
- * \ingroup source_blk
- */
-
-class GR_CORE_API gr_file_descriptor_source : public gr_sync_block
-{
- friend GR_CORE_API gr_file_descriptor_source_sptr
- gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat);
- private:
- size_t d_itemsize;
- int d_fd;
- bool d_repeat;
-
- unsigned char *d_residue;
- unsigned long d_residue_len;
-
- protected:
- gr_file_descriptor_source (size_t itemsize, int fd, bool repeat);
-
- int read_items (char *buf, int nitems);
- int handle_residue (char *buf, int nbytes_read);
- void flush_residue () { d_residue_len = 0; }
-
-
- public:
- ~gr_file_descriptor_source ();
-
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H */
diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_source.i b/gnuradio-core/src/lib/io/gr_file_descriptor_source.i
deleted file mode 100644
index 3ca0825225..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_descriptor_source.i
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,file_descriptor_source)
-
-gr_file_descriptor_source_sptr
-gr_make_file_descriptor_source (size_t itemsize, int fd, bool repeat=false);
-
-class gr_file_descriptor_source : public gr_sync_block
-{
- protected:
- gr_file_descriptor_source (size_t itemsize, int fd, bool repeat);
-
- public:
- ~gr_file_descriptor_source ();
-};
diff --git a/gnuradio-core/src/lib/io/gr_file_sink.cc b/gnuradio-core/src/lib/io/gr_file_sink.cc
deleted file mode 100644
index 10c8360cb6..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2006,2007,2010 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 <gr_file_sink.h>
-#include <gr_io_signature.h>
-#include <stdexcept>
-
-
-gr_file_sink_sptr
-gr_make_file_sink (size_t itemsize, const char *filename)
-{
- return gnuradio::get_initial_sptr(new gr_file_sink (itemsize, filename));
-}
-
-gr_file_sink::gr_file_sink(size_t itemsize, const char *filename)
- : gr_sync_block ("file_sink",
- gr_make_io_signature(1, 1, itemsize),
- gr_make_io_signature(0, 0, 0)),
- gr_file_sink_base(filename, true),
- d_itemsize(itemsize)
-{
-}
-
-gr_file_sink::~gr_file_sink ()
-{
-}
-
-int
-gr_file_sink::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *inbuf = (char*)input_items[0];
- int nwritten = 0;
-
- do_update(); // update d_fp is reqd
-
- if(!d_fp)
- return noutput_items; // drop output on the floor
-
- while(nwritten < noutput_items) {
- int count = fwrite(inbuf, d_itemsize, noutput_items - nwritten, d_fp);
- if(count == 0) {
- if(ferror(d_fp)) {
- std::stringstream s;
- s << "file_sink write failed with error " << fileno(d_fp) << std::endl;
- throw std::runtime_error(s.str());
- }
- else { // is EOF
- break;
- }
- }
- nwritten += count;
- inbuf += count * d_itemsize;
- }
-
- if(d_unbuffered)
- fflush (d_fp);
-
- return nwritten;
-}
diff --git a/gnuradio-core/src/lib/io/gr_file_sink.h b/gnuradio-core/src/lib/io/gr_file_sink.h
deleted file mode 100644
index e40ec9ab8d..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2007 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_GR_FILE_SINK_H
-#define INCLUDED_GR_FILE_SINK_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_file_sink_base.h>
-
-class gr_file_sink;
-typedef boost::shared_ptr<gr_file_sink> gr_file_sink_sptr;
-
-GR_CORE_API gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename);
-
-/*!
- * \brief Write stream to file.
- * \ingroup sink_blk
- */
-
-class GR_CORE_API gr_file_sink : public gr_sync_block, public gr_file_sink_base
-{
- friend GR_CORE_API gr_file_sink_sptr gr_make_file_sink(size_t itemsize, const char *filename);
-
- private:
- size_t d_itemsize;
-
- protected:
- gr_file_sink(size_t itemsize, const char *filename);
-
- public:
- ~gr_file_sink();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-#endif /* INCLUDED_GR_FILE_SINK_H */
diff --git a/gnuradio-core/src/lib/io/gr_file_sink.i b/gnuradio-core/src/lib/io/gr_file_sink.i
deleted file mode 100644
index 47ab9e9649..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink.i
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,file_sink)
-
-gr_file_sink_sptr
-gr_make_file_sink (size_t itemsize, const char *filename);
-
-class gr_file_sink : public gr_sync_block, public gr_file_sink_base
-{
- protected:
- gr_file_sink (size_t itemsize, const char *filename);
-
- public:
- ~gr_file_sink ();
-
- /*!
- * \brief open filename and begin output to it.
- */
- bool open(const char *filename);
-
- /*!
- * \brief close current output file.
- */
- void close();
-};
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.cc b/gnuradio-core/src/lib/io/gr_file_sink_base.cc
deleted file mode 100644
index d0aca418e7..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.cc
+++ /dev/null
@@ -1,125 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2006,2007,2009 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 <gr_file_sink_base.h>
-#include <cstdio>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <stdio.h>
-#include <gruel/thread.h>
-
-// win32 (mingw/msvc) specific
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
-#else
-#define OUR_O_BINARY 0
-#endif
-
-// should be handled via configure
-#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
-#else
-#define OUR_O_LARGEFILE 0
-#endif
-
-gr_file_sink_base::gr_file_sink_base(const char *filename, bool is_binary)
- : d_fp(0), d_new_fp(0), d_updated(false), d_is_binary(is_binary)
-{
- if (!open(filename))
- throw std::runtime_error ("can't open file");
-}
-
-gr_file_sink_base::~gr_file_sink_base ()
-{
- close();
- if (d_fp){
- fclose(d_fp);
- d_fp = 0;
- }
-}
-
-bool
-gr_file_sink_base::open(const char *filename)
-{
- gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function
-
- // we use the open system call to get access to the O_LARGEFILE flag.
- int fd;
- if ((fd = ::open (filename,
- O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY,
- 0664)) < 0){
- perror (filename);
- return false;
- }
- if (d_new_fp){ // if we've already got a new one open, close it
- fclose(d_new_fp);
- d_new_fp = 0;
- }
-
- if ((d_new_fp = fdopen (fd, d_is_binary ? "wb" : "w")) == NULL){
- perror (filename);
- ::close(fd); // don't leak file descriptor if fdopen fails.
- }
-
- d_updated = true;
- return d_new_fp != 0;
-}
-
-void
-gr_file_sink_base::close()
-{
- gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function
-
- if (d_new_fp){
- fclose(d_new_fp);
- d_new_fp = 0;
- }
- d_updated = true;
-}
-
-void
-gr_file_sink_base::do_update()
-{
- if (d_updated){
- gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block
- if (d_fp)
- fclose(d_fp);
- d_fp = d_new_fp; // install new file pointer
- d_new_fp = 0;
- d_updated = false;
- }
-}
-
-void
-gr_file_sink_base::set_unbuffered(bool unbuffered)
-{
- d_unbuffered = unbuffered;
-}
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.h b/gnuradio-core/src/lib/io/gr_file_sink_base.h
deleted file mode 100644
index 8a70cee768..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2007,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_GR_FILE_SINK_BASE_H
-#define INCLUDED_GR_FILE_SINK_BASE_H
-
-#include <gr_core_api.h>
-#include <boost/thread.hpp>
-#include <cstdio>
-
-/*!
- * \brief Common base class for file sinks
- */
-class GR_CORE_API gr_file_sink_base
-{
- protected:
- FILE *d_fp; // current FILE pointer
- FILE *d_new_fp; // new FILE pointer
- bool d_updated; // is there a new FILE pointer?
- bool d_is_binary;
- boost::mutex d_mutex;
- bool d_unbuffered;
-
- protected:
- gr_file_sink_base(const char *filename, bool is_binary);
-
- public:
- ~gr_file_sink_base();
-
- /*!
- * \brief Open filename and begin output to it.
- */
- bool open(const char *filename);
-
- /*!
- * \brief Close current output file.
- *
- * Closes current output file and ignores any output until
- * open is called to connect to another file.
- */
- void close();
-
- /*!
- * \brief if we've had an update, do it now.
- */
- void do_update();
-
-
- /*!
- * \brief turn on unbuffered writes for slower outputs
- */
- void set_unbuffered(bool unbuffered);
-};
-
-
-#endif /* INCLUDED_GR_FILE_SINK_BASE_H */
diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.i b/gnuradio-core/src/lib/io/gr_file_sink_base.i
deleted file mode 100644
index 993dba2770..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_sink_base.i
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2006 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 this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-class gr_file_sink_base
-{
- protected:
- gr_file_sink_base(const char *filename, bool is_binary);
-
- public:
- ~gr_file_sink_base();
-
- /*!
- * \brief Open filename and begin output to it.
- */
- bool open(const char *filename);
-
- /*!
- * \brief Close current output file.
- *
- * Closes current output file and ignores any output until
- * open is called to connect to another file.
- */
- void close();
-
- /*!
- * \brief if we've had an update, do it now.
- */
- void do_update();
-
- /*!
- *\brief turn on unbuffered mode for slow outputs
- */
- void set_unbuffered(bool unbuffered);
-};
diff --git a/gnuradio-core/src/lib/io/gr_file_source.cc b/gnuradio-core/src/lib/io/gr_file_source.cc
deleted file mode 100644
index 6da7abac21..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_source.cc
+++ /dev/null
@@ -1,192 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2010 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 <gruel/thread.h>
-#include <gr_file_source.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <stdio.h>
-
-// win32 (mingw/msvc) specific
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
-#else
-#define OUR_O_BINARY 0
-#endif
-// should be handled via configure
-#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
-#else
-#define OUR_O_LARGEFILE 0
-#endif
-
-gr_file_source::gr_file_source(size_t itemsize, const char *filename, bool repeat)
- : gr_sync_block("file_source",
- gr_make_io_signature (0, 0, 0),
- gr_make_io_signature (1, 1, itemsize)),
- d_itemsize(itemsize), d_fp(0), d_new_fp (0), d_repeat(repeat),
- d_updated(false)
-{
- open(filename, repeat);
-}
-
-// public constructor that returns a shared_ptr
-
-gr_file_source_sptr
-gr_make_file_source (size_t itemsize, const char *filename, bool repeat)
-{
- return gnuradio::get_initial_sptr(new gr_file_source (itemsize, filename, repeat));
-}
-
-gr_file_source::~gr_file_source ()
-{
- close();
- if(d_fp) {
- fclose(d_fp);
- d_fp = 0;
- }
-}
-
-int
-gr_file_source::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *o = (char *) output_items[0];
- int i;
- int size = noutput_items;
-
- do_update(); // update d_fp is reqd
- if(d_fp == NULL)
- throw std::runtime_error("work with file not open");
-
- gruel::scoped_lock lock(fp_mutex); // hold for the rest of this function
- while (size) {
- i = fread(o, d_itemsize, size, (FILE *) d_fp);
-
- size -= i;
- o += i * d_itemsize;
-
- if (size == 0) // done
- break;
-
- if (i > 0) // short read, try again
- continue;
-
- // We got a zero from fread. This is either EOF or error. In
- // any event, if we're in repeat mode, seek back to the beginning
- // of the file and try again, else break
-
- if (!d_repeat)
- break;
-
- if (fseek ((FILE *) d_fp, 0, SEEK_SET) == -1) {
- std::stringstream s;
- s << "[" << __FILE__ << "]" << " fseek failed" << std::endl;
- throw std::runtime_error(s.str());
- }
- }
-
- if (size > 0){ // EOF or error
- if (size == noutput_items) // we didn't read anything; say we're done
- return -1;
- return noutput_items - size; // else return partial result
- }
-
- return noutput_items;
-}
-
-bool
-gr_file_source::seek (long seek_point, int whence)
-{
- // obtain exclusive access for duration of this function
- gruel::scoped_lock lock(fp_mutex);
- return fseek((FILE *) d_fp, seek_point * d_itemsize, whence) == 0;
-}
-
-void
-gr_file_source::open(const char *filename, bool repeat)
-{
- // obtain exclusive access for duration of this function
- gruel::scoped_lock lock(fp_mutex);
-
- int fd;
-
- // we use "open" to use to the O_LARGEFILE flag
- if((fd = ::open(filename, O_RDONLY | OUR_O_LARGEFILE | OUR_O_BINARY)) < 0) {
- perror(filename);
- throw std::runtime_error("can't open file");
- }
-
- if(d_new_fp) {
- fclose(d_new_fp);
- d_new_fp = 0;
- }
-
- if((d_new_fp = fdopen (fd, "rb")) == NULL) {
- perror(filename);
- ::close(fd); // don't leak file descriptor if fdopen fails
- throw std::runtime_error("can't open file");
- }
-
- d_updated = true;
- d_repeat = repeat;
-}
-
-void
-gr_file_source::close()
-{
- // obtain exclusive access for duration of this function
- gruel::scoped_lock lock(fp_mutex);
-
- if(d_new_fp != NULL) {
- fclose(d_new_fp);
- d_new_fp = NULL;
- }
- d_updated = true;
-}
-
-void
-gr_file_source::do_update()
-{
- if(d_updated) {
- gruel::scoped_lock lock(fp_mutex); // hold while in scope
-
- if(d_fp)
- fclose(d_fp);
-
- d_fp = d_new_fp; // install new file pointer
- d_new_fp = 0;
- d_updated = false;
- }
-}
diff --git a/gnuradio-core/src/lib/io/gr_file_source.h b/gnuradio-core/src/lib/io/gr_file_source.h
deleted file mode 100644
index 0478fba04b..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_source.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 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_GR_FILE_SOURCE_H
-#define INCLUDED_GR_FILE_SOURCE_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <boost/thread/mutex.hpp>
-
-class gr_file_source;
-typedef boost::shared_ptr<gr_file_source> gr_file_source_sptr;
-
-GR_CORE_API gr_file_source_sptr
-gr_make_file_source (size_t itemsize, const char *filename, bool repeat = false);
-
-/*!
- * \brief Read stream from file
- * \ingroup source_blk
- */
-
-class GR_CORE_API gr_file_source : public gr_sync_block
-{
- private:
- size_t d_itemsize;
- FILE *d_fp;
- FILE *d_new_fp;
- bool d_repeat;
- bool d_updated;
-
- protected:
- gr_file_source(size_t itemsize, const char *filename, bool repeat);
-
- void do_update();
-
- boost::mutex fp_mutex;
-
- public:
- /*!
- * \brief Create a file source.
- *
- * Opens \p filename as a source of items into a flowgraph. The data
- * is expected to be in binary format, item after item. The \p
- * itemsize of the block determines the conversion from bits to
- * items.
- *
- * If \p repeat is turned on, the file will repeat the file after
- * it's reached the end.
- *
- * \param itemsize the size of each item in the file, in bytes
- * \param filename name of the file to source from
- * \param repeat repeat file from start
- */
- friend GR_CORE_API gr_file_source_sptr
- gr_make_file_source(size_t itemsize,
- const char *filename,
- bool repeat);
-
- ~gr_file_source();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
- /*!
- * \brief Seek file to \p seek_point relative to \p whence
- *
- * \param seek_point sample offset in file
- * \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek)
- */
- bool seek(long seek_point, int whence);
-
- /*!
- * \brief Opens a new file.
- *
- * \param filename name of the file to source from
- * \param repeat repeat file from start
- */
- void open(const char *filename, bool repeat);
-
- /*!
- * \brief Close the file handle.
- */
- void close();
-
-};
-
-#endif /* INCLUDED_GR_FILE_SOURCE_H */
diff --git a/gnuradio-core/src/lib/io/gr_file_source.i b/gnuradio-core/src/lib/io/gr_file_source.i
deleted file mode 100644
index e71cef0d14..0000000000
--- a/gnuradio-core/src/lib/io/gr_file_source.i
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004 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.
- */
-
-
-%constant int SEEK_SET = 0; /* Seek from beginning of file. */
-%constant int SEEK_CUR = 1; /* Seek from current position. */
-%constant int SEEK_END = 2; /* Seek from end of file. */
-
-
-GR_SWIG_BLOCK_MAGIC(gr,file_source)
-
-gr_file_source_sptr
-gr_make_file_source (size_t itemsize, const char *filename, bool repeat=false);
-
-class gr_file_source : public gr_sync_block
-{
- protected:
- gr_file_source (size_t itemsize, const char *filename, bool repeat);
-
- public:
- ~gr_file_source ();
-
- bool seek (long seek_point, int whence);
- void open (const char *filename, bool repeat);
- void close();
-};
diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.cc b/gnuradio-core/src/lib/io/gr_message_burst_source.cc
deleted file mode 100644
index e9e2dfd4dc..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_burst_source.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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 <gr_message_burst_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>
-#include <string.h>
-#include <gr_tags.h>
-
-// public constructor that returns a shared_ptr
-
-gr_message_burst_source_sptr
-gr_make_message_burst_source(size_t itemsize, int msgq_limit)
-{
- return gnuradio::get_initial_sptr(new gr_message_burst_source(itemsize, msgq_limit));
-}
-
-// public constructor that takes existing message queue
-gr_message_burst_source_sptr
-gr_make_message_burst_source(size_t itemsize, gr_msg_queue_sptr msgq)
-{
- return gnuradio::get_initial_sptr(new gr_message_burst_source(itemsize, msgq));
-}
-
-gr_message_burst_source::gr_message_burst_source (size_t itemsize, int msgq_limit)
- : gr_sync_block("message_burst_source",
- gr_make_io_signature(0, 0, 0),
- gr_make_io_signature(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false)
-{
- std::stringstream id;
- id << name() << unique_id();
- d_me = pmt::pmt_string_to_symbol(id.str());
-}
-
-gr_message_burst_source::gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq)
- : gr_sync_block("message_burst_source",
- gr_make_io_signature(0, 0, 0),
- gr_make_io_signature(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false)
-{
- std::stringstream id;
- id << name() << unique_id();
- d_me = pmt::pmt_string_to_symbol(id.str());
-}
-
-gr_message_burst_source::~gr_message_burst_source()
-{
-}
-
-int
-gr_message_burst_source::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *out = (char *) output_items[0];
- int nn = 0;
-
- uint64_t abs_sample_count = nitems_written(0);
-
- while (nn < noutput_items){
- if (d_msg){
- //
- // Consume whatever we can from the current message
- //
-
- int mm = std::min(noutput_items - nn, (int)((d_msg->length() - d_msg_offset) / d_itemsize));
- memcpy (out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize);
-
- nn += mm;
- out += mm * d_itemsize;
- d_msg_offset += mm * d_itemsize;
- assert(d_msg_offset <= d_msg->length());
-
- if (d_msg_offset == d_msg->length()){
- if (d_msg->type() == 1) // type == 1 sets EOF
- d_eof = true;
- d_msg.reset();
- //tag end of burst
- add_item_tag(0, //stream ID
- abs_sample_count+nn-1, //sample number
- pmt::pmt_string_to_symbol("tx_eob"),
- pmt::pmt_from_bool(1),
- d_me //block src id
- );
- }
- }
- else {
- //
- // No current message
- //
- if (d_msgq->empty_p() && nn > 0){ // no more messages in the queue, return what we've got
- break;
- }
-
- if (d_eof)
- return -1;
-
- d_msg = d_msgq->delete_head(); // block, waiting for a message
- d_msg_offset = 0;
- //tag start of burst
- add_item_tag(0, //stream ID
- abs_sample_count+nn, //sample number
- pmt::pmt_string_to_symbol("tx_sob"),
- pmt::pmt_from_bool(1),
- d_me //block src id
- );
-
-
- if ((d_msg->length() % d_itemsize) != 0)
- throw std::runtime_error("msg length is not a multiple of d_itemsize");
- }
- }
-
- return nn;
-}
diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.h b/gnuradio-core/src/lib/io/gr_message_burst_source.h
deleted file mode 100644
index 63e2201139..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_burst_source.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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_GR_MESSAGE_BURST_SOURCE_H
-#define INCLUDED_GR_MESSAGE_BURST_SOURCE_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_message.h>
-#include <gr_msg_queue.h>
-
-class gr_message_burst_source;
-typedef boost::shared_ptr<gr_message_burst_source> gr_message_burst_source_sptr;
-
-GR_CORE_API gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, int msgq_limit=0);
-GR_CORE_API gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq);
-
-/*!
- * \brief Turn received messages into a stream and tag them for UHD to send.
- * \ingroup source_blk
- */
-class GR_CORE_API gr_message_burst_source : public gr_sync_block
-{
- private:
- size_t d_itemsize;
- gr_msg_queue_sptr d_msgq;
- gr_message_sptr d_msg;
- unsigned d_msg_offset;
- bool d_eof;
-
- pmt::pmt_t d_me;
-
- friend GR_CORE_API gr_message_burst_source_sptr
- gr_make_message_burst_source(size_t itemsize, int msgq_limit);
- friend GR_CORE_API gr_message_burst_source_sptr
- gr_make_message_burst_source(size_t itemsize, gr_msg_queue_sptr msgq);
-
- protected:
- gr_message_burst_source (size_t itemsize, int msgq_limit);
- gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq);
-
- public:
- ~gr_message_burst_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_burst_source_H */
diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.i b/gnuradio-core/src/lib/io/gr_message_burst_source.i
deleted file mode 100644
index f7ad840c22..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_burst_source.i
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,message_burst_source);
-
-gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, int msgq_limit=0);
-gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq);
-
-class gr_message_burst_source : public gr_sync_block
-{
- protected:
- gr_message_burst_source (size_t itemsize, int msgq_limit);
- gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq);
-
- public:
- ~gr_message_burst_source ();
-
- gr_msg_queue_sptr msgq() const;
-};
diff --git a/gnuradio-core/src/lib/io/gr_message_debug.cc b/gnuradio-core/src/lib/io/gr_message_debug.cc
deleted file mode 100644
index 9eb1bb6399..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_debug.cc
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2005,2010,2012 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 <gr_message_debug.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <string.h>
-#include <iostream>
-
-// public constructor that returns a shared_ptr
-
-gr_message_debug_sptr
-gr_make_message_debug ()
-{
- return gnuradio::get_initial_sptr(new gr_message_debug());
-}
-
-void
-gr_message_debug::print(pmt::pmt_t msg)
-{
- std::cout << "******* MESSAGE DEBUG PRINT ********\n";
- pmt::pmt_print(msg);
- std::cout << "************************************\n";
-}
-
-void
-gr_message_debug::store(pmt::pmt_t msg)
-{
- gruel::scoped_lock guard(d_mutex);
- d_messages.push_back(msg);
-}
-
-void
-gr_message_debug::print_pdu(pmt::pmt_t pdu)
-{
- pmt::pmt_t meta = pmt::pmt_car(pdu);
- pmt::pmt_t vector = pmt::pmt_cdr(pdu);
- std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n";
- pmt::pmt_print(meta);
- size_t len = pmt::pmt_length(vector);
- std::cout << "pdu_length = " << len << std::endl;
- std::cout << "contents = " << std::endl;
- size_t offset(0);
- const uint8_t* d = (const uint8_t*) pmt_uniform_vector_elements(vector, offset);
- for(size_t i=0; i<len; i+=16){
- printf("%04x: ", ((unsigned int)i));
- for(size_t j=i; j<std::min(i+16,len); j++){
- printf("%02x ",d[j] );
- }
-
- std::cout << std::endl;
- }
-
- std::cout << "***********************************\n";
-}
-
-int
-gr_message_debug::num_messages()
-{
- return (int)d_messages.size();
-}
-
-pmt::pmt_t
-gr_message_debug::get_message(int i)
-{
- gruel::scoped_lock guard(d_mutex);
-
- if((size_t)i >= d_messages.size()) {
- throw std::runtime_error("gr_message_debug: index for message out of bounds.\n");
- }
-
- return d_messages[i];
-}
-
-gr_message_debug::gr_message_debug()
- : gr_block("message_debug",
- gr_make_io_signature(0, 0, 0),
- gr_make_io_signature(0, 0, 0))
-{
- message_port_register_in(pmt::mp("print"));
- set_msg_handler(pmt::mp("print"), boost::bind(&gr_message_debug::print, this, _1));
-
- message_port_register_in(pmt::mp("store"));
- set_msg_handler(pmt::mp("store"), boost::bind(&gr_message_debug::store, this, _1));
-
- message_port_register_in(pmt::mp("print_pdu"));
- set_msg_handler(pmt::mp("print_pdu"), boost::bind(&gr_message_debug::print_pdu, this, _1));
-}
-
-gr_message_debug::~gr_message_debug()
-{
-}
diff --git a/gnuradio-core/src/lib/io/gr_message_debug.h b/gnuradio-core/src/lib/io/gr_message_debug.h
deleted file mode 100644
index f1374e8062..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_debug.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2005,2012 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_GR_MESSAGE_DEBUG_H
-#define INCLUDED_GR_MESSAGE_DEBUG_H
-
-#include <gr_core_api.h>
-#include <gr_block.h>
-#include <gr_message.h>
-#include <gr_msg_queue.h>
-#include <gruel/thread.h>
-
-class gr_message_debug;
-typedef boost::shared_ptr<gr_message_debug> gr_message_debug_sptr;
-
-GR_CORE_API gr_message_debug_sptr gr_make_message_debug();
-
-/*!
- * \brief Print received messages to stdout
- * \ingroup sink_blk
- */
-class GR_CORE_API gr_message_debug : public gr_block
-{
- private:
- friend GR_CORE_API gr_message_debug_sptr
- gr_make_message_debug();
-
- /*!
- * \brief Messages received in this port are printed to stdout.
- *
- * This port receives messages from the scheduler's message handling
- * mechanism and prints it to stdout. This message handler function
- * is only meant to be used by the scheduler to handle messages
- * posted to port 'print'.
- *
- * \param msg A pmt message passed from the scheduler's message handling.
- */
- void print(pmt::pmt_t msg);
-
- /*!
- * \brief PDU formatted messages received in this port are printed to stdout.
- *
- * This port receives messages from the scheduler's message handling
- * mechanism and prints it to stdout. This message handler function
- * is only meant to be used by the scheduler to handle messages
- * posted to port 'print'.
- *
- * \param pdu A PDU message passed from the scheduler's message handling.
- */
- void print_pdu(pmt::pmt_t pdu);
-
- /*!
- * \brief Messages received in this port are stored in a vector.
- *
- * This port receives messages from the scheduler's message handling
- * mechanism and stores it in a vector. Messages can be retrieved
- * later using the 'get_message' function. This message handler
- * function is only meant to be used by the scheduler to handle
- * messages posted to port 'store'.
- *
- * \param msg A pmt message passed from the scheduler's message handling.
- */
- void store(pmt::pmt_t msg);
-
- gruel::mutex d_mutex;
- std::vector<pmt::pmt_t> d_messages;
-
- protected:
- gr_message_debug ();
-
- public:
- ~gr_message_debug ();
-
- /*!
- * \brief Reports the number of messages received by this block.
- */
- int num_messages();
-
- /*!
- * \brief Get a message (as a PMT) from the message vector at index \p i.
- *
- * Messages passed to the 'store' port will be stored in a
- * vector. This function retrieves those messages by index. They are
- * index in order of when they were received (all messages are just
- * pushed onto the back of a vector). This is mostly useful in
- * debugging message passing graphs and in QA code.
- *
- * \param i The index in the vector for the message to retrieve.
- *
- * \return a message at index \p i as a pmt_t.
- */
- pmt::pmt_t get_message(int i);
-};
-
-#endif /* INCLUDED_GR_MESSAGE_DEBUG_H */
diff --git a/gnuradio-core/src/lib/io/gr_message_debug.i b/gnuradio-core/src/lib/io/gr_message_debug.i
deleted file mode 100644
index 65d3bfc4aa..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_debug.i
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,message_debug);
-
-%{
-#include <gr_message_debug.h>
-%}
-
-%include "gr_message_debug.h"
-
diff --git a/gnuradio-core/src/lib/io/gr_message_sink.cc b/gnuradio-core/src/lib/io/gr_message_sink.cc
deleted file mode 100644
index 3816f5da48..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_sink.cc
+++ /dev/null
@@ -1,119 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2005,2010 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 <gr_message_sink.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <string.h>
-
-// public constructor that returns a shared_ptr
-
-gr_message_sink_sptr
-gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block)
-{
- return gnuradio::get_initial_sptr(new gr_message_sink(itemsize, msgq, dont_block));
-}
-gr_message_sink_sptr
-gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname)
-{
- return gnuradio::get_initial_sptr(new gr_message_sink(itemsize, msgq, dont_block, lengthtagname));
-}
-
-gr_message_sink::gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block)
- : gr_sync_block("message_sink",
- gr_make_io_signature(1, 1, itemsize),
- gr_make_io_signature(0, 0, 0)),
- d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), d_tags(false), d_items_read(0)
-{
-}
-
-gr_message_sink::gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname)
- : gr_sync_block("message_sink",
- gr_make_io_signature(1, 1, itemsize),
- gr_make_io_signature(0, 0, 0)),
- d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), d_tags(true), d_lengthtagname(lengthtagname), d_items_read(0)
-{
-}
-
-gr_message_sink::~gr_message_sink()
-{
-}
-
-int
-gr_message_sink::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- const char *in = (const char *) input_items[0];
-
- if (d_tags) {
- long packet_length = 0;
- std::vector<gr_tag_t> tags;
- this->get_tags_in_range(tags, 0, d_items_read, d_items_read+1);
- //const size_t ninput_items = noutput_items; //assumption for sync block, this can change
- for (unsigned int i = 0; i < tags.size(); i++) {
- if (pmt::pmt_symbol_to_string(tags[i].key) == d_lengthtagname) {
- packet_length = pmt::pmt_to_long(tags[i].value);
- }
- }
- assert(packet_length != 0);
-
- // FIXME run this multiple times if input_items >= N * packet_length
- if (noutput_items >= packet_length ) {
- // If the message queue is full we drop the packet.
- if (!d_msgq->full_p()) {
- gr_message_sptr msg = gr_make_message(0, // msg type
- d_itemsize, // arg1 for other end
- packet_length, // arg2 for other end (redundant)
- packet_length * d_itemsize); // len of msg
- memcpy(msg->msg(), in, packet_length * d_itemsize);
- d_msgq->handle(msg); // send it
- }
- d_items_read += packet_length;
- return packet_length;
- } else {
- return 0;
- }
- } else {
- // If the queue if full we drop all the data we got.
- if (!d_msgq->full_p()) {
- // build a message to hold whatever we've got
- gr_message_sptr msg = gr_make_message(0, // msg type
- d_itemsize, // arg1 for other end
- noutput_items, // arg2 for other end (redundant)
- noutput_items * d_itemsize); // len of msg
- memcpy(msg->msg(), in, noutput_items * d_itemsize);
-
- d_msgq->handle(msg); // send it
- }
- return noutput_items;
- }
-}
diff --git a/gnuradio-core/src/lib/io/gr_message_sink.h b/gnuradio-core/src/lib/io/gr_message_sink.h
deleted file mode 100644
index 2db84cff44..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_sink.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- 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 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_GR_MESSAGE_SINK_H
-#define INCLUDED_GR_MESSAGE_SINK_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_message.h>
-#include <gr_msg_queue.h>
-#include <string>
-
-class gr_message_sink;
-typedef boost::shared_ptr<gr_message_sink> gr_message_sink_sptr;
-
-GR_CORE_API gr_message_sink_sptr gr_make_message_sink (
- size_t itemsize,
- gr_msg_queue_sptr msgq,
- bool dont_block
-);
-
-GR_CORE_API gr_message_sink_sptr gr_make_message_sink (
- size_t itemsize,
- gr_msg_queue_sptr msgq,
- bool dont_block,
- const std::string& lengthtagname
-);
-
-/*!
- * \brief Gather received items into messages and insert into msgq
- * \ingroup sink_blk
- */
-class GR_CORE_API gr_message_sink : public gr_sync_block
-{
- private:
- size_t d_itemsize;
- gr_msg_queue_sptr d_msgq;
- bool d_dont_block;
- bool d_tags;
- std::string d_lengthtagname;
- uint64_t d_items_read;
-
- friend GR_CORE_API gr_message_sink_sptr
- gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq,
- bool dont_block);
- friend GR_CORE_API gr_message_sink_sptr
- gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq,
- bool dont_block, const std::string& lengthtagname);
-
- protected:
- gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block);
- gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block,
- const std::string& lengthtagname);
-
- public:
- ~gr_message_sink ();
-
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-#endif /* INCLUDED_GR_MESSAGE_SINK_H */
diff --git a/gnuradio-core/src/lib/io/gr_message_sink.i b/gnuradio-core/src/lib/io/gr_message_sink.i
deleted file mode 100644
index b22eff18c0..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_sink.i
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- 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 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,message_sink);
-
-#include <string>
-
-gr_message_sink_sptr gr_make_message_sink (size_t itemsize,
- gr_msg_queue_sptr msgq,
- bool dont_block);
-gr_message_sink_sptr gr_make_message_sink (size_t itemsize,
- gr_msg_queue_sptr msgq,
- bool dont_block,
- const std::string& lengthtagname);
-
-class gr_message_sink : public gr_sync_block
-{
- protected:
- gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block);
- gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname);
-
- public:
- ~gr_message_sink ();
-};
diff --git a/gnuradio-core/src/lib/io/gr_message_source.cc b/gnuradio-core/src/lib/io/gr_message_source.cc
deleted file mode 100644
index 0b79bb526b..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_source.cc
+++ /dev/null
@@ -1,141 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2005,2010 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 <gr_message_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>
-#include <string.h>
-
-
-// public constructor that returns a shared_ptr
-gr_message_source_sptr
-gr_make_message_source(size_t itemsize, int msgq_limit)
-{
- return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq_limit));
-}
-
-// public constructor that takes existing message queue
-gr_message_source_sptr
-gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq)
-{
- return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq));
-}
-
-// public constructor that takes existing message queue and adds messages length tags.
-gr_message_source_sptr
-gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname)
-{
- return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq, lengthtagname));
-}
-
-gr_message_source::gr_message_source (size_t itemsize, int msgq_limit)
- : gr_sync_block("message_source",
- gr_make_io_signature(0, 0, 0),
- gr_make_io_signature(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false),
- d_tags(false)
-{
-}
-
-gr_message_source::gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq)
- : gr_sync_block("message_source",
- gr_make_io_signature(0, 0, 0),
- gr_make_io_signature(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false), d_tags(false)
-{
-}
-
-gr_message_source::~gr_message_source()
-{}
-
-gr_message_source::gr_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname)
- : gr_sync_block("message_source",
- gr_make_io_signature(0, 0, 0),
- gr_make_io_signature(1, 1, itemsize)),
- d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false),
- d_tags(true), d_lengthtagname(lengthtagname)
-{
-}
-
-int
-gr_message_source::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *out = (char *) output_items[0];
- int nn = 0;
-
- while (nn < noutput_items){
- if (d_msg){
- //
- // Consume whatever we can from the current message
- //
- int mm = std::min(noutput_items - nn, (int)((d_msg->length() - d_msg_offset) / d_itemsize));
- memcpy (out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize);
-
- if (d_tags && (d_msg_offset == 0)) {
- const uint64_t offset = this->nitems_written(0) + nn;
- pmt::pmt_t key = pmt::pmt_string_to_symbol(d_lengthtagname);
- pmt::pmt_t value = pmt::pmt_from_long(d_msg->length());
- this->add_item_tag(0, offset, key, value);
- }
- nn += mm;
- out += mm * d_itemsize;
- d_msg_offset += mm * d_itemsize;
- assert(d_msg_offset <= d_msg->length());
-
- if (d_msg_offset == d_msg->length()){
- if (d_msg->type() == 1) // type == 1 sets EOF
- d_eof = true;
- d_msg.reset();
- }
- }
- else {
- //
- // No current message
- //
- if (d_msgq->empty_p() && nn > 0){ // no more messages in the queue, return what we've got
- break;
- }
-
- if (d_eof)
- return -1;
-
- d_msg = d_msgq->delete_head(); // block, waiting for a message
- d_msg_offset = 0;
-
- if ((d_msg->length() % d_itemsize) != 0)
- throw std::runtime_error("msg length is not a multiple of d_itemsize");
- }
- }
-
- return nn;
-}
diff --git a/gnuradio-core/src/lib/io/gr_message_source.h b/gnuradio-core/src/lib/io/gr_message_source.h
deleted file mode 100644
index 1828475987..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_source.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- 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 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_GR_MESSAGE_SOURCE_H
-#define INCLUDED_GR_MESSAGE_SOURCE_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_message.h>
-#include <gr_msg_queue.h>
-
-class gr_message_source;
-typedef boost::shared_ptr<gr_message_source> gr_message_source_sptr;
-
-GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0);
-GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq);
-GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq,
- const std::string& lengthtagname);
-
-/*!
- * \brief Turn received messages into a stream
- * \ingroup source_blk
- */
-class GR_CORE_API gr_message_source : public gr_sync_block
-{
- private:
- size_t d_itemsize;
- gr_msg_queue_sptr d_msgq;
- gr_message_sptr d_msg;
- unsigned d_msg_offset;
- bool d_eof;
- bool d_tags;
- // FIXME: Is this adequate tagname length.
- std::string d_lengthtagname;
-
- friend GR_CORE_API gr_message_source_sptr
- gr_make_message_source(size_t itemsize, int msgq_limit);
- friend GR_CORE_API gr_message_source_sptr
- gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq);
- friend GR_CORE_API gr_message_source_sptr
- gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname);
-
- protected:
- gr_message_source (size_t itemsize, int msgq_limit);
- gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq);
- gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname);
-
- public:
- ~gr_message_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_SOURCE_H */
diff --git a/gnuradio-core/src/lib/io/gr_message_source.i b/gnuradio-core/src/lib/io/gr_message_source.i
deleted file mode 100644
index bb1ddfcc31..0000000000
--- a/gnuradio-core/src/lib/io/gr_message_source.i
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- 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 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,message_source);
-
-#include <string>
-
-gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0);
-gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq);
-gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname);
-
-class gr_message_source : public gr_sync_block
-{
- protected:
- gr_message_source (size_t itemsize, int msgq_limit);
- gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq);
- gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname);
-
- public:
- ~gr_message_source ();
-
- gr_msg_queue_sptr msgq() const;
-};
diff --git a/gnuradio-core/src/lib/io/gr_pdu.cc b/gnuradio-core/src/lib/io/gr_pdu.cc
deleted file mode 100644
index 302fd7b9bb..0000000000
--- a/gnuradio-core/src/lib/io/gr_pdu.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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 <gr_pdu.h>
-
-size_t
-gr_pdu_itemsize(gr_pdu_vector_type type){
- switch(type){
- case pdu_byte:
- return 1;
- case pdu_float:
- return sizeof(float);
- case pdu_complex:
- return sizeof(gr_complex);
- default:
- throw std::runtime_error("bad type!");
- }
-}
-
-bool
-gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v){
- switch(type){
- case pdu_byte:
- return pmt::pmt_is_u8vector(v);
- case pdu_float:
- return pmt::pmt_is_f32vector(v);
- case pdu_complex:
- return pmt::pmt_is_c32vector(v);
- default:
- throw std::runtime_error("bad type!");
- }
-}
-
-pmt::pmt_t
-gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items){
- switch(type){
- case pdu_byte:
- return pmt::pmt_init_u8vector(items, buf);
- case pdu_float:
- return pmt::pmt_init_f32vector(items, (const float*)buf);
- case pdu_complex:
- return pmt::pmt_init_c32vector(items, (const gr_complex*)buf);
- default:
- throw std::runtime_error("bad type!");
- }
-}
-
-gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector){
- if(pmt_is_u8vector(vector))
- return pdu_byte;
- if(pmt_is_f32vector(vector))
- return pdu_float;
- if(pmt_is_c32vector(vector))
- return pdu_complex;
- throw std::runtime_error("bad type!");
-}
diff --git a/gnuradio-core/src/lib/io/gr_pdu.h b/gnuradio-core/src/lib/io/gr_pdu.h
deleted file mode 100644
index 53058ccb6c..0000000000
--- a/gnuradio-core/src/lib/io/gr_pdu.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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 GR_PDU_H
-#define GR_PDU_H
-
-#include <gr_core_api.h>
-#include <gr_complex.h>
-#include <gruel/pmt.h>
-
-#define PDU_PORT_ID pmt::mp("pdus")
-#define PDU_LENGTH_TAG pmt::mp("pdu_length")
-
-enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex };
-
-GR_CORE_API size_t gr_pdu_itemsize(gr_pdu_vector_type type);
-GR_CORE_API bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v);
-GR_CORE_API pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items);
-GR_CORE_API gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector);
-
-#endif
diff --git a/gnuradio-core/src/lib/io/gr_pdu.i b/gnuradio-core/src/lib/io/gr_pdu.i
deleted file mode 100644
index ada3a63a73..0000000000
--- a/gnuradio-core/src/lib/io/gr_pdu.i
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- 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 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.
- */
-
-%{
-#include <gr_pdu.h>
-%}
-
-enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex };
-
-
-
diff --git a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc
deleted file mode 100644
index a702b66a2b..0000000000
--- a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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 <gr_pdu_to_tagged_stream.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <string.h>
-
-
-// public constructor that returns a shared_ptr
-
-gr_pdu_to_tagged_stream_sptr
-gr_make_pdu_to_tagged_stream(gr_pdu_vector_type t)
-{
- return gnuradio::get_initial_sptr(new gr_pdu_to_tagged_stream(t));
-}
-
-gr_pdu_to_tagged_stream::gr_pdu_to_tagged_stream (gr_pdu_vector_type t)
- : gr_sync_block("pdu_to_tagged_stream",
- gr_make_io_signature(0, 0, 0),
- gr_make_io_signature(1, 1, gr_pdu_itemsize(t))),
- d_vectortype(t), d_itemsize(gr_pdu_itemsize(t))
-{
- message_port_register_in(PDU_PORT_ID);
-}
-
-gr_pdu_to_tagged_stream::~gr_pdu_to_tagged_stream()
-{
-}
-
-int
-gr_pdu_to_tagged_stream::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *out = (char *) output_items[0];
- int nout = 0;
-
- // if we have remaining output, send it
- if(d_remain.size() > 0){
- nout = std::min((size_t)d_remain.size()/d_itemsize, (size_t)noutput_items);
- memcpy(out, &d_remain[0], nout*d_itemsize);
- d_remain.erase( d_remain.begin(), d_remain.begin()+nout);
- noutput_items -= nout;
- out += nout*d_itemsize;
- }
-
- // if we have space for at least one item output as much as we can
- if(noutput_items > 0){
-
- // grab a message if one exists
- //pmt::pmt_t msg( delete_head_nowait( PDU_PORT_ID ) );
- pmt::pmt_t msg( delete_head_blocking( PDU_PORT_ID ) );
- if(msg.get() == NULL ){
- return nout;
- }
-
- // make sure type is valid
- if(!pmt::pmt_is_pair(msg)){
- throw std::runtime_error("received a malformed pdu message!");
- }
-
-// printf("got a msg\n");
-// pmt::pmt_print(msg);
-
- // grab the components of the pdu message
- pmt::pmt_t meta(pmt::pmt_car(msg)); // make sure this is NIL || Dict ?
- pmt::pmt_t vect(pmt::pmt_cdr(msg)); // make sure this is a vector?
-
- // compute offset for output tag
- uint64_t offset = nitems_written(0) + nout;
-
- // add a tag for pdu length
- add_item_tag(0, offset, PDU_LENGTH_TAG, pmt::pmt_from_long( pmt::pmt_length(vect) ), pmt::mp(alias()));
-
- // if we recieved metadata add it as tags
- if( !pmt_eq(meta, pmt::PMT_NIL) ){
- pmt::pmt_t pair(pmt::pmt_dict_keys( meta ));
- while( !pmt_eq(pair, pmt::PMT_NIL) ){
- pmt::pmt_t k(pmt::pmt_cdr(pair));
- pmt::pmt_t v(pmt::pmt_dict_ref(meta, k, pmt::PMT_NIL));
- add_item_tag(0, offset, k, v, pmt::mp(alias()));
- }
- }
-
- // copy vector output
- size_t ncopy = std::min((size_t)noutput_items, (size_t)pmt::pmt_length(vect));
- size_t nsave = pmt::pmt_length(vect) - ncopy;
-
- // copy output
- size_t io(0);
- nout += ncopy;
- memcpy(out, pmt_uniform_vector_elements(vect,io), ncopy*d_itemsize);
-
- // save leftover items if needed for next work call
- if(nsave > 0){
- d_remain.resize(nsave*d_itemsize, 0);
- memcpy(&d_remain[0], pmt_uniform_vector_elements(vect,ncopy), nsave*d_itemsize);
- }
-
- }
-
- return nout;
-}
diff --git a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.h b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.h
deleted file mode 100644
index 3105a3d386..0000000000
--- a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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_GR_PDU_TO_TAGGED_STREAM_H
-#define INCLUDED_GR_PDU_TO_TAGGED_STREAM_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_message.h>
-#include <gr_msg_queue.h>
-#include <gr_pdu.h>
-
-class gr_pdu_to_tagged_stream;
-typedef boost::shared_ptr<gr_pdu_to_tagged_stream> gr_pdu_to_tagged_stream_sptr;
-
-GR_CORE_API gr_pdu_to_tagged_stream_sptr gr_make_pdu_to_tagged_stream (gr_pdu_vector_type t);
-
-/*!
- * \brief Turn received messages into a stream
- * \ingroup source_blk
- */
-class GR_CORE_API gr_pdu_to_tagged_stream : public gr_sync_block
-{
- private:
- gr_pdu_vector_type d_vectortype;
- size_t d_itemsize;
- std::vector<uint8_t> d_remain;
-
- friend GR_CORE_API gr_pdu_to_tagged_stream_sptr
- gr_make_pdu_to_tagged_stream(gr_pdu_vector_type t);
-
- protected:
- gr_pdu_to_tagged_stream (gr_pdu_vector_type t);
-
- public:
- ~gr_pdu_to_tagged_stream ();
-
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
-};
-
-#endif /* INCLUDED_GR_PDU_TO_TAGGED_SOURCE_H */
diff --git a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.i b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.i
deleted file mode 100644
index ec760b309a..0000000000
--- a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.i
+++ /dev/null
@@ -1,31 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,pdu_to_tagged_stream);
-
-%{
-#include <gr_pdu_to_tagged_stream.h>
-%}
-
-%include <gr_pdu_to_tagged_stream.h>
-
-
diff --git a/gnuradio-core/src/lib/io/gr_socket_pdu.cc b/gnuradio-core/src/lib/io/gr_socket_pdu.cc
deleted file mode 100644
index bb374b3006..0000000000
--- a/gnuradio-core/src/lib/io/gr_socket_pdu.cc
+++ /dev/null
@@ -1,157 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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 <gr_socket_pdu.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <string.h>
-#include <iostream>
-#include <gr_pdu.h>
-#include <boost/format.hpp>
-
-// public constructor that returns a shared_ptr
-gr_socket_pdu_sptr
-gr_make_socket_pdu (std::string type, std::string addr, std::string port, int MTU)
-{
- return gnuradio::get_initial_sptr(new gr_socket_pdu(type,addr,port,MTU));
-}
-
-gr_socket_pdu::gr_socket_pdu (std::string type, std::string addr, std::string port, int MTU)
- : gr_stream_pdu_base(MTU)
-{
-
- if( (type == "TCP_SERVER") || (type == "TCP_CLIENT")){
- boost::asio::ip::tcp::resolver resolver(_io_service);
- boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(), addr, port);
- _tcp_endpoint = *resolver.resolve(query);
- }
- if( (type == "UDP_SERVER") || (type == "UDP_CLIENT")){
- boost::asio::ip::udp::resolver resolver(_io_service);
- boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(), addr, port);
- if( (type == "UDP_SERVER") ){
- _udp_endpoint = *resolver.resolve(query);
- } else {
- _udp_endpoint_other = *resolver.resolve(query);
- }
- }
-
- // register ports
- message_port_register_out(pmt::mp("pdus"));
- message_port_register_in(pmt::mp("pdus"));
-
- // set up socketry
- if (type == "TCP_SERVER"){
- _acceptor_tcp.reset(new boost::asio::ip::tcp::acceptor(_io_service, _tcp_endpoint));
- _acceptor_tcp->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
- start_tcp_accept();
- // bind tcp server send handler
- set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_socket_pdu::tcp_server_send, this, _1));
- } else if(type =="TCP_CLIENT"){
- boost::system::error_code error = boost::asio::error::host_not_found;
- _tcp_socket.reset(new boost::asio::ip::tcp::socket(_io_service));
- _tcp_socket->connect(_tcp_endpoint, error);
- if(error){
- throw boost::system::system_error(error);
- }
- set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_socket_pdu::tcp_client_send, this, _1));
- _tcp_socket->async_read_some(
- boost::asio::buffer(rxbuf),
- boost::bind(&gr_socket_pdu::handle_tcp_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
-
- } else if(type =="UDP_SERVER"){
- _udp_socket.reset(new boost::asio::ip::udp::socket(_io_service, _udp_endpoint));
- _udp_socket->async_receive_from( boost::asio::buffer(rxbuf), _udp_endpoint_other,
- boost::bind(&gr_socket_pdu::handle_udp_read, this,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred));
- set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_socket_pdu::udp_send, this, _1));
- } else if(type =="UDP_CLIENT"){
- _udp_socket.reset(new boost::asio::ip::udp::socket(_io_service, _udp_endpoint));
- _udp_socket->async_receive_from( boost::asio::buffer(rxbuf), _udp_endpoint_other,
- boost::bind(&gr_socket_pdu::handle_udp_read, this,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred));
- set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_socket_pdu::udp_send, this, _1));
- } else {
- throw std::runtime_error("unknown socket type!");
- }
-
- // start thread for io_service
- d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&gr_socket_pdu::run_io_service, this)));
- d_started = true;
-}
-
-void tcp_connection::handle_read(const boost::system::error_code& error/*error*/, size_t bytes_transferred)
- {
- if(!error)
- {
- pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&buf[0]);
- pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector);
-
- d_block->message_port_pub( pmt::mp("pdus"), pdu );
-
- socket_.async_read_some(
- boost::asio::buffer(buf),
- boost::bind(&tcp_connection::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
-
- } else {
- std::cout << "error occurred\n";
- }
-
- }
-
-
-void gr_socket_pdu::tcp_server_send(pmt::pmt_t msg){
- pmt::pmt_t vector = pmt::pmt_cdr(msg);
- for(size_t i=0; i<d_tcp_connections.size(); i++){
- d_tcp_connections[i]->send(vector);
- }
-}
-
-void gr_socket_pdu::tcp_client_send(pmt::pmt_t msg){
- pmt::pmt_t vector = pmt::pmt_cdr(msg);
- size_t len = pmt::pmt_length(vector);
- size_t offset(0);
- boost::array<char, 10000> txbuf;
- memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len);
- _tcp_socket->send(boost::asio::buffer(txbuf,len));
-}
-
-void gr_socket_pdu::udp_send(pmt::pmt_t msg){
- pmt::pmt_t vector = pmt::pmt_cdr(msg);
- size_t len = pmt::pmt_length(vector);
- size_t offset(0);
- boost::array<char, 10000> txbuf;
- memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len);
- if(_udp_endpoint_other.address().to_string() != "0.0.0.0")
- _udp_socket->send_to(boost::asio::buffer(txbuf,len), _udp_endpoint_other);
-}
diff --git a/gnuradio-core/src/lib/io/gr_socket_pdu.h b/gnuradio-core/src/lib/io/gr_socket_pdu.h
deleted file mode 100644
index 2fedb317db..0000000000
--- a/gnuradio-core/src/lib/io/gr_socket_pdu.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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_GR_SOCKET_PDU_H
-#define INCLUDED_GR_SOCKET_PDU_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_message.h>
-#include <gr_msg_queue.h>
-#include <gr_stream_pdu_base.h>
-#include <boost/array.hpp>
-#include <boost/asio.hpp>
-#include <iostream>
-
-class gr_socket_pdu;
-typedef boost::shared_ptr<gr_socket_pdu> gr_socket_pdu_sptr;
-
-GR_CORE_API gr_socket_pdu_sptr gr_make_socket_pdu (std::string type, std::string addr, std::string port, int MTU=10000);
-
-class tcp_connection
- : public boost::enable_shared_from_this<tcp_connection>
-{
-public:
- typedef boost::shared_ptr<tcp_connection> pointer;
- gr_socket_pdu *d_block;
- boost::array<char, 10000> buf;
-
- static pointer create(boost::asio::io_service& io_service)
- {
- return pointer(new tcp_connection(io_service));
- }
-
- boost::asio::ip::tcp::socket& socket()
- {
- return socket_;
- }
-
- void start(gr_socket_pdu* parent)
- {
- d_block = parent;
-// message_ = "connected to gr_socket_pdu\n";
-// boost::asio::async_write(socket_, boost::asio::buffer(message_),
-// boost::bind(&tcp_connection::handle_write, shared_from_this(),
-// boost::asio::placeholders::error,
-// boost::asio::placeholders::bytes_transferred));
-
- socket_.async_read_some(
- boost::asio::buffer(buf),
- boost::bind(&tcp_connection::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
- }
- void send(pmt::pmt_t vector){
- size_t len = pmt::pmt_length(vector);
- size_t offset(0);
- boost::array<char, 10000> txbuf;
- memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len);
- boost::asio::async_write(socket_, boost::asio::buffer(txbuf, len),
- boost::bind(&tcp_connection::handle_write, shared_from_this(),
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred));
- }
-
- ~tcp_connection(){
-// std::cout << "tcp_connection destroyed\n";
- }
-
-private:
- tcp_connection(boost::asio::io_service& io_service)
- : socket_(io_service)
- {
- }
-
- void handle_read(const boost::system::error_code& error/*error*/, size_t bytes_transferred);
-
- void handle_write(const boost::system::error_code& /*error*/,
- size_t /*bytes_transferred*/)
- {
- }
-
- boost::asio::ip::tcp::socket socket_;
- std::string message_;
-};
-
-
-/*!
- * \brief Gather received items into messages and insert into msgq
- * \ingroup sink_blk
- */
-class GR_CORE_API gr_socket_pdu : public gr_stream_pdu_base
-{
- private:
- friend GR_CORE_API gr_socket_pdu_sptr
- gr_make_socket_pdu(std::string type, std::string addr, std::string port, int MTU);
-
- boost::asio::io_service _io_service;
-
- boost::array<char, 10000> rxbuf;
-
- // tcp specific
- boost::asio::ip::tcp::endpoint _tcp_endpoint;
-
- // specific to tcp server
- boost::shared_ptr<boost::asio::ip::tcp::acceptor> _acceptor_tcp;
- std::vector<tcp_connection::pointer> d_tcp_connections;
- void tcp_server_send(pmt::pmt_t msg);
- void tcp_client_send(pmt::pmt_t msg);
- void udp_send(pmt::pmt_t msg);
-
- // specific to tcp client
- boost::shared_ptr<boost::asio::ip::tcp::socket> _tcp_socket;
-
- // specific to udp client/server
- boost::asio::ip::udp::endpoint _udp_endpoint;
- boost::asio::ip::udp::endpoint _udp_endpoint_other;
- boost::shared_ptr<boost::asio::ip::udp::socket> _udp_socket;
-
- void handle_receive(const boost::system::error_code& error, std::size_t ){
- }
-
- void start_tcp_accept(){
- tcp_connection::pointer new_connection =
- tcp_connection::create(_acceptor_tcp->get_io_service());
-
- _acceptor_tcp->async_accept(new_connection->socket(),
- boost::bind(&gr_socket_pdu::handle_tcp_accept, this, new_connection,
- boost::asio::placeholders::error));
- }
-
- void handle_tcp_accept(tcp_connection::pointer new_connection, const boost::system::error_code& error){
- if (!error)
- {
- new_connection->start(this);
- d_tcp_connections.push_back(new_connection);
- start_tcp_accept();
- } else {
- std::cout << error << std::endl;
- }
- }
-
- void run_io_service(){
- _io_service.run();
- }
-
- void handle_udp_read(const boost::system::error_code& error/*error*/, size_t bytes_transferred){
- if(!error){
- pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&rxbuf[0]);
- pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector);
-
- message_port_pub( pmt::mp("pdus"), pdu );
-
- _udp_socket->async_receive_from( boost::asio::buffer(rxbuf), _udp_endpoint_other,
- boost::bind(&gr_socket_pdu::handle_udp_read, this,
- boost::asio::placeholders::error,
- boost::asio::placeholders::bytes_transferred));
- } else {
- throw boost::system::system_error(error);
-// std::cout << "error occurred\n";
- }
- }
- void handle_tcp_read(const boost::system::error_code& error/*error*/, size_t bytes_transferred){
- if(!error)
- {
- pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&rxbuf[0]);
- pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector);
-
- message_port_pub( pmt::mp("pdus"), pdu );
-
- _tcp_socket->async_read_some(
- boost::asio::buffer(rxbuf),
- boost::bind(&gr_socket_pdu::handle_tcp_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
-
- } else {
- //std::cout << "error occurred\n";
- throw boost::system::system_error(error);
- }
- }
-
- protected:
- gr_socket_pdu (std::string type, std::string addr, std::string port, int MTU=10000);
- public:
- ~gr_socket_pdu () {}
-};
-
-#endif /* INCLUDED_GR_TUNTAP_PDU_H */
diff --git a/gnuradio-core/src/lib/io/gr_socket_pdu.i b/gnuradio-core/src/lib/io/gr_socket_pdu.i
deleted file mode 100644
index 3e20b63e20..0000000000
--- a/gnuradio-core/src/lib/io/gr_socket_pdu.i
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- 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 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,socket_pdu);
-
-%ignore tcp_connection;
-
-%{
-#include <gr_socket_pdu.h>
-%}
-
-%include "gr_stream_pdu_base.h"
-%include "gr_socket_pdu.h"
-
diff --git a/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc b/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc
deleted file mode 100644
index 7250c33e59..0000000000
--- a/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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 <ciso646>
-#include <gr_stream_pdu_base.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <string.h>
-#include <iostream>
-#include <gr_pdu.h>
-#include <boost/asio.hpp>
-#include <boost/format.hpp>
-
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
-static const long timeout_us = 100*1000; //100ms
-
-gr_stream_pdu_base::gr_stream_pdu_base (int MTU)
- : gr_sync_block("stream_pdu_base",
- gr_make_io_signature(0, 0, 0),
- gr_make_io_signature(0, 0, 0)),
- d_finished(false), d_started(false), d_fd(-1)
-{
- // reserve space for rx buffer
- d_rxbuf.resize(MTU,0);
-}
-
-gr_stream_pdu_base::~gr_stream_pdu_base()
-{
- stop_rxthread();
-}
-
-void gr_stream_pdu_base::stop_rxthread(){
- d_finished = true;
- if(d_started){
- d_thread->interrupt();
- d_thread->join();
- }
- }
-
-void gr_stream_pdu_base::start_rxthread(pmt::pmt_t _rxport){
- rxport = _rxport;
- d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&gr_stream_pdu_base::run, this)));
- d_started = true;
- }
-
-void gr_stream_pdu_base::run(){
- while(!d_finished) {
- if(not wait_ready()){ continue; }
- const int result = read( d_fd, &d_rxbuf[0], d_rxbuf.size() );
- if(result <= 0){ throw std::runtime_error("gr_stream_pdu_base, bad socket read!"); }
- pmt::pmt_t vector = pmt::pmt_init_u8vector(result, &d_rxbuf[0]);
- pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector);
- message_port_pub(rxport, pdu);
- }
-}
-
-void gr_stream_pdu_base::send(pmt::pmt_t msg){
- pmt::pmt_t vector = pmt::pmt_cdr(msg);
- size_t offset(0);
- size_t itemsize(gr_pdu_itemsize(type_from_pmt(vector)));
- int len( pmt::pmt_length(vector)*itemsize );
-
- const int rv = write(d_fd, pmt::pmt_uniform_vector_elements(vector, offset), len);
- if(rv != len){
- std::cerr << boost::format("WARNING: gr_stream_pdu_base::send(pdu) write failed! (d_fd=%d, len=%d, rv=%d)")
- % d_fd % len % rv << std::endl;
- }
-}
-
-int
-gr_stream_pdu_base::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- throw std::runtime_error("should not be called.\n");
- return 0;
-}
-
-bool gr_stream_pdu_base::wait_ready(){
- //setup timeval for timeout
- timeval tv;
- tv.tv_sec = 0;
- tv.tv_usec = timeout_us;
-
- //setup rset for timeout
- fd_set rset;
- FD_ZERO(&rset);
- FD_SET(d_fd, &rset);
-
- //call select with timeout on receive socket
- return ::select(d_fd+1, &rset, NULL, NULL, &tv) > 0;
-}
diff --git a/gnuradio-core/src/lib/io/gr_stream_pdu_base.h b/gnuradio-core/src/lib/io/gr_stream_pdu_base.h
deleted file mode 100644
index 35bacf523f..0000000000
--- a/gnuradio-core/src/lib/io/gr_stream_pdu_base.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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_GR_STREAM_PDU_BASE_H
-#define INCLUDED_GR_STREAM_PDU_BASE_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_message.h>
-#include <gr_msg_queue.h>
-
-/*!
- * \brief Gather received items into messages and insert into msgq
- * \ingroup sink_blk
- */
-class GR_CORE_API gr_stream_pdu_base : public gr_sync_block
-{
- public:
- boost::shared_ptr<boost::thread> d_thread;
- bool d_finished;
- bool d_started;
- std::vector<uint8_t> d_rxbuf;
- void run();
- int d_fd;
- gr_stream_pdu_base (int MTU=10000);
- ~gr_stream_pdu_base ();
- void send(pmt::pmt_t msg);
- bool wait_ready();
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
- void start_rxthread(pmt::pmt_t _rxport);
- void stop_rxthread();
- private:
- pmt::pmt_t rxport;
-};
-
-typedef boost::shared_ptr<gr_stream_pdu_base> gr_stream_pdu_base_sptr;
-
-#endif /* INCLUDED_GR_TUNTAP_PDU_H */
diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc b/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc
deleted file mode 100644
index 6d642088e2..0000000000
--- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.cc
+++ /dev/null
@@ -1,216 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2010 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 <gr_tagged_file_sink.h>
-#include <gr_io_signature.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <iostream>
-
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
-#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
-#else
-#define OUR_O_BINARY 0
-#endif
-
-// should be handled via configure
-#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
-#else
-#define OUR_O_LARGEFILE 0
-#endif
-
-
-gr_tagged_file_sink::gr_tagged_file_sink (size_t itemsize, double samp_rate)
- : gr_sync_block ("tagged_file_sink",
- gr_make_io_signature (1, 1, itemsize),
- gr_make_io_signature (0, 0, 0)),
- d_itemsize (itemsize), d_n(0), d_sample_rate(samp_rate)
-{
- d_state = NOT_IN_BURST;
- d_last_N = 0;
- d_timeval = 0;
-}
-
-gr_tagged_file_sink_sptr
-gr_make_tagged_file_sink (size_t itemsize, double samp_rate)
-{
- return gnuradio::get_initial_sptr(new gr_tagged_file_sink (itemsize, samp_rate));
-}
-
-gr_tagged_file_sink::~gr_tagged_file_sink ()
-{
-}
-
-int
-gr_tagged_file_sink::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *inbuf = (char *) input_items[0];
-
- uint64_t start_N = nitems_read(0);
- uint64_t end_N = start_N + (uint64_t)(noutput_items);
- pmt::pmt_t bkey = pmt::pmt_string_to_symbol("burst");
- //pmt::pmt_t tkey = pmt::pmt_string_to_symbol("time"); // use gr_tags::key_time
-
- std::vector<gr_tag_t> all_tags;
- get_tags_in_range(all_tags, 0, start_N, end_N);
-
- std::sort(all_tags.begin(), all_tags.end(), gr_tag_t::offset_compare);
-
- std::vector<gr_tag_t>::iterator vitr = all_tags.begin();
-
- int idx = 0, idx_stop = 0;
- while(idx < noutput_items) {
- if(d_state == NOT_IN_BURST) {
- while(vitr != all_tags.end()) {
- if((pmt::pmt_eqv((*vitr).key, bkey)) &&
- pmt::pmt_is_true((*vitr).value)) {
-
- uint64_t N = (*vitr).offset;
- idx = (int)(N - start_N);
-
- //std::cout << std::endl << "Found start of burst: "
- // << idx << ", " << N << std::endl;
-
- // Find time burst occurred by getting latest time tag and extrapolating
- // to new time based on sample rate of this block.
- std::vector<gr_tag_t> time_tags;
- //get_tags_in_range(time_tags, 0, d_last_N, N, gr_tags::key_time);
- get_tags_in_range(time_tags, 0, d_last_N, N,
- pmt::pmt_string_to_symbol("time"));
- if(time_tags.size() > 0) {
- const gr_tag_t tag = time_tags[time_tags.size()-1];
-
- uint64_t time_nitems = tag.offset;
-
- // Get time based on last time tag from USRP
- pmt::pmt_t time = tag.value;
- int tsecs = pmt::pmt_to_long(pmt::pmt_tuple_ref(time, 0));
- double tfrac = pmt::pmt_to_double(pmt::pmt_tuple_ref(time, 1));
-
- // Get new time from last time tag + difference in time to when
- // burst tag occured based on the sample rate
- double delta = (double)(N - time_nitems) / d_sample_rate;
- d_timeval = (double)tsecs + tfrac + delta;
-
- //std::cout.setf(std::ios::fixed, std::ios::floatfield);
- //std::cout.precision(8);
- //std::cout << "Time found: " << (double)tsecs + tfrac << std::endl;
- //std::cout << " time: " << d_timeval << std::endl;
- //std::cout << " time at N = " << time_nitems << " burst N = " << N << std::endl;
- }
- else {
- // if no time tag, use last seen tag and update time based on
- // sample rate of the block
- d_timeval += (double)(N - d_last_N) / d_sample_rate;
- //std::cout << "Time not found" << std::endl;
- //std::cout << " time: " << d_timeval << std::endl;
- }
- d_last_N = N;
-
- std::stringstream filename;
- filename.setf(std::ios::fixed, std::ios::floatfield);
- filename.precision(8);
- filename << "file" << unique_id() << "_" << d_n << "_" << d_timeval << ".dat";
- d_n++;
-
- int fd;
- if ((fd = ::open (filename.str().c_str(),
- O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY,
- 0664)) < 0){
- perror (filename.str().c_str());
- return -1;
- }
-
- // FIXME:
- //if ((d_handle = fdopen (fd, d_is_binary ? "wb" : "w")) == NULL){
- if ((d_handle = fdopen (fd, "wb")) == NULL){
- perror (filename.str().c_str());
- ::close(fd); // don't leak file descriptor if fdopen fails.
- }
-
- //std::cout << "Created new file: " << filename.str() << std::endl;
-
- d_state = IN_BURST;
- break;
- }
-
- vitr++;
- }
- if(d_state == NOT_IN_BURST)
- return noutput_items;
- }
- else { // In burst
- while(vitr != all_tags.end()) {
- if((pmt::pmt_eqv((*vitr).key, bkey)) &&
- pmt::pmt_is_false((*vitr).value)) {
- uint64_t N = (*vitr).offset;
- idx_stop = (int)N - start_N;
-
- //std::cout << "Found end of burst: "
- // << idx_stop << ", " << N << std::endl;
-
- int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize,
- idx_stop-idx, d_handle);
- if (count == 0) {
- if(ferror(d_handle)) {
- perror("gr_tagged_file_sink: error writing file");
- }
- }
- idx = idx_stop;
- d_state = NOT_IN_BURST;
- vitr++;
- fclose(d_handle);
- break;
- }
- else {
- vitr++;
- }
- }
- if(d_state == IN_BURST) {
- int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize,
- noutput_items-idx, d_handle);
- if (count == 0) {
- if(ferror(d_handle)) {
- perror("gr_tagged_file_sink: error writing file");
- }
- }
- idx = noutput_items;
- }
- }
- }
-
- return noutput_items;
-}
diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.h b/gnuradio-core/src/lib/io/gr_tagged_file_sink.h
deleted file mode 100644
index d6f931a677..0000000000
--- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2010 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_GR_TAGGED_FILE_SINK_H
-#define INCLUDED_GR_TAGGED_FILE_SINK_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <cstdio> // for FILE
-
-class gr_tagged_file_sink;
-typedef boost::shared_ptr<gr_tagged_file_sink> gr_tagged_file_sink_sptr;
-
-GR_CORE_API gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize,
- double samp_rate);
-
-/*!
- * \brief Write stream to file descriptor.
- * \ingroup sink_blk
- */
-
-class GR_CORE_API gr_tagged_file_sink : public gr_sync_block
-{
- friend GR_CORE_API gr_tagged_file_sink_sptr gr_make_tagged_file_sink (size_t itemsize,
- double samp_rate);
-
- private:
- enum {
- NOT_IN_BURST = 0,
- IN_BURST
- };
-
- size_t d_itemsize;
- int d_state;
- FILE *d_handle;
- int d_n;
- double d_sample_rate;
- uint64_t d_last_N;
- double d_timeval;
-
- protected:
- gr_tagged_file_sink (size_t itemsize, double samp_rate);
-
- public:
- ~gr_tagged_file_sink ();
-
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-
-#endif /* INCLUDED_GR_TAGGED_FILE_SINK_H */
diff --git a/gnuradio-core/src/lib/io/gr_tagged_file_sink.i b/gnuradio-core/src/lib/io/gr_tagged_file_sink.i
deleted file mode 100644
index 2f2596e122..0000000000
--- a/gnuradio-core/src/lib/io/gr_tagged_file_sink.i
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2010 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,tagged_file_sink)
-
-gr_tagged_file_sink_sptr
-gr_make_tagged_file_sink (size_t itemsize, double samp_rate);
-
-class gr_tagged_file_sink : public gr_sync_block
-{
- protected:
- gr_tagged_file_sink (size_t itemsize, double samp_rate);
-
- public:
- ~gr_tagged_file_sink ();
-};
diff --git a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc
deleted file mode 100644
index 1b869edfab..0000000000
--- a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc
+++ /dev/null
@@ -1,137 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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 <gr_tagged_stream_to_pdu.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <string.h>
-
-// public constructor that returns a shared_ptr
-
-gr_tagged_stream_to_pdu_sptr
-gr_make_tagged_stream_to_pdu(gr_pdu_vector_type t)
-{
- return gnuradio::get_initial_sptr(new gr_tagged_stream_to_pdu(t));
-}
-
-gr_tagged_stream_to_pdu::gr_tagged_stream_to_pdu (gr_pdu_vector_type t)
- : gr_sync_block("tagged_stream_to_pdu",
- gr_make_io_signature(1, 1, gr_pdu_itemsize(t)),
- gr_make_io_signature(0, 0, 0)),
- d_vectortype(t), d_itemsize(gr_pdu_itemsize(t)), d_inpdu(false),
- d_pdu_meta(pmt::PMT_NIL), d_pdu_vector(pmt::PMT_NIL)
-{
- message_port_register_out(PDU_PORT_ID);
-}
-
-gr_tagged_stream_to_pdu::~gr_tagged_stream_to_pdu()
-{
- printf("destructor running\n");
-}
-
-int
-gr_tagged_stream_to_pdu::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- const uint8_t *in = (const uint8_t*) input_items[0];
- uint64_t abs_N = nitems_read(0);
-
- // if we are not in a pdu already, start a new one
- if(!d_inpdu){
- get_tags_in_range(d_tags, 0, abs_N, abs_N+1);
- bool found_length_tag(false);
- for(d_tags_itr = d_tags.begin(); (d_tags_itr != d_tags.end()) && (!found_length_tag); d_tags_itr++){
- if( pmt::pmt_equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){
- if( (*d_tags_itr).offset != abs_N ){
- throw std::runtime_error("expected next pdu length tag on a different item...");
- }
- found_length_tag = true;
- d_pdu_length = pmt::pmt_to_long( (*d_tags_itr).value );
- d_pdu_remain = d_pdu_length;
- d_pdu_meta = pmt::pmt_make_dict();
- break;
- } // if have length tag
- } // iter over tags
- if(!found_length_tag){
- throw std::runtime_error("tagged stream does not contain a pdu_length tag!");
- }
- }
-
- size_t ncopy = std::min((size_t)noutput_items, d_pdu_remain);
-
- // copy any tags in this range into our meta object
- get_tags_in_range(d_tags, 0, abs_N, abs_N+ncopy);
- for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++){
- if( ! pmt_equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){
- d_pdu_meta = pmt_dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value);
- }
- }
-
- // copy samples for this vector into either a pmt or our save buffer
- if(ncopy == d_pdu_remain){ // we will send this pdu
- if(d_save.size() == 0){
- d_pdu_vector = gr_pdu_make_vector(d_vectortype, in, ncopy);
- send_message();
- } else {
- size_t oldsize = d_save.size();
- d_save.resize((oldsize + ncopy)*d_itemsize, 0);
- memcpy( &d_save[oldsize*d_itemsize], in, ncopy*d_itemsize );
- d_pdu_vector = gr_pdu_make_vector(d_vectortype, &d_save[0], d_pdu_length);
- send_message();
- d_save.clear();
- }
- } else {
- d_inpdu = true;
- size_t oldsize = d_save.size();
- d_save.resize( (oldsize+ncopy)*d_itemsize );
- memcpy( &d_save[oldsize*d_itemsize], in, ncopy*d_itemsize );
- d_pdu_remain -= ncopy;
- }
-
- return ncopy;
-}
-
-void gr_tagged_stream_to_pdu::send_message(){
-
- if(pmt::pmt_length(d_pdu_vector) != d_pdu_length){
- throw std::runtime_error("msg length not correct");
- }
-
- pmt::pmt_t msg = pmt::pmt_cons( d_pdu_meta, d_pdu_vector );
- message_port_pub( PDU_PORT_ID, msg );
-
- d_pdu_meta = pmt::PMT_NIL;
- d_pdu_vector = pmt::PMT_NIL;
- d_pdu_length = 0;
- d_pdu_remain = 0;
- d_inpdu = false;
-}
diff --git a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.h b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.h
deleted file mode 100644
index c3fff35815..0000000000
--- a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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_GR_TAGGED_STREAM_TO_PDU_H
-#define INCLUDED_GR_TAGGED_STREAM_TO_PDU_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_message.h>
-#include <gr_msg_queue.h>
-#include <gr_pdu.h>
-
-class gr_tagged_stream_to_pdu;
-typedef boost::shared_ptr<gr_tagged_stream_to_pdu> gr_tagged_stream_to_pdu_sptr;
-
-GR_CORE_API gr_tagged_stream_to_pdu_sptr gr_make_tagged_stream_to_pdu (gr_pdu_vector_type t);
-
-/*!
- * \brief Turn received messages into a stream
- * \ingroup source_blk
- */
-class GR_CORE_API gr_tagged_stream_to_pdu : public gr_sync_block
-{
- private:
- gr_pdu_vector_type d_vectortype;
- size_t d_itemsize;
-
- std::vector<uint8_t> d_save;
-
- std::vector<gr_tag_t> d_tags;
- std::vector<gr_tag_t>::iterator d_tags_itr;
-
- bool d_inpdu;
-
- size_t d_pdu_length;
- size_t d_pdu_remain;
- pmt::pmt_t d_pdu_meta;
- pmt::pmt_t d_pdu_vector;
-
- friend GR_CORE_API gr_tagged_stream_to_pdu_sptr
- gr_make_tagged_stream_to_pdu(gr_pdu_vector_type t);
-
- protected:
- gr_tagged_stream_to_pdu (gr_pdu_vector_type t);
-
- public:
- ~gr_tagged_stream_to_pdu ();
-
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
- void send_message();
-
-};
-
-#endif /* INCLUDED_GR_PDU_TO_TAGGED_SOURCE_H */
diff --git a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.i b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.i
deleted file mode 100644
index f12987b74c..0000000000
--- a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.i
+++ /dev/null
@@ -1,31 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,tagged_stream_to_pdu);
-
-%{
-#include <gr_tagged_stream_to_pdu.h>
-%}
-
-%include <gr_tagged_stream_to_pdu.h>
-
-
diff --git a/gnuradio-core/src/lib/io/gr_tuntap_pdu.cc b/gnuradio-core/src/lib/io/gr_tuntap_pdu.cc
deleted file mode 100644
index 8dd4b18a10..0000000000
--- a/gnuradio-core/src/lib/io/gr_tuntap_pdu.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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 <gr_tuntap_pdu.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdexcept>
-#include <string.h>
-#include <iostream>
-#include <gr_pdu.h>
-#include <boost/format.hpp>
-
-#if (defined(linux) || defined(__linux) || defined(__linux__))
-
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <arpa/inet.h>
-#include <linux/if.h>
-
-
-// public constructor that returns a shared_ptr
-
-gr_tuntap_pdu_sptr
-gr_make_tuntap_pdu (std::string dev, int MTU)
-{
- return gnuradio::get_initial_sptr(new gr_tuntap_pdu(dev, MTU));
-}
-
-gr_tuntap_pdu::gr_tuntap_pdu (std::string dev, int MTU)
- : gr_stream_pdu_base(MTU)
-{
-
- // make the tuntap
- char dev_cstr[1024];
- memset(dev_cstr, 0x00, 1024);
- strncpy(dev_cstr, dev.c_str(), std::min(sizeof(dev_cstr), dev.size()));
- d_fd = tun_alloc(dev_cstr);
- if(d_fd <= 0){
- throw std::runtime_error("TunTap make: tun_alloc failed (are you running as root?)");
- }
-
- std::cout << boost::format(
- "Allocated virtual ethernet interface: %s\n"
- "You must now use ifconfig to set its IP address. E.g.,\n"
- " $ sudo ifconfig %s 192.168.200.1\n"
- "Be sure to use a different address in the same subnet for each machine.\n"
- ) % dev % dev << std::endl;
-
- // set up output message port
- message_port_register_out(pmt::mp("pdus"));
- start_rxthread(pmt::mp("pdus"));
-
- // set up input message port
- message_port_register_in(pmt::mp("pdus"));
- set_msg_handler(pmt::mp("pdus"), boost::bind(&gr_tuntap_pdu::send, this, _1));
-}
-
-
-int gr_tuntap_pdu::tun_alloc(char *dev, int flags) {
- struct ifreq ifr;
- int fd, err;
- const char *clonedev = "/dev/net/tun";
-
- /* Arguments taken by the function:
- *
- * char *dev: the name of an interface (or '\0'). MUST have enough
- * space to hold the interface name if '\0' is passed
- * int flags: interface flags (eg, IFF_TUN etc.)
- */
-
- /* open the clone device */
- if( (fd = open(clonedev, O_RDWR)) < 0 ) {
- return fd;
- }
-
- /* preparation of the struct ifr, of type "struct ifreq" */
- memset(&ifr, 0, sizeof(ifr));
-
- ifr.ifr_flags = flags; /* IFF_TUN or IFF_TAP, plus maybe IFF_NO_PI */
-
- if (*dev) {
- /* if a device name was specified, put it in the structure; otherwise,
- * the kernel will try to allocate the "next" device of the
- * specified type */
- strncpy(ifr.ifr_name, dev, IFNAMSIZ);
- }
-
- /* try to create the device */
- if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ) {
- close(fd);
- return err;
- }
-
- /* if the operation was successful, write back the name of the
- * interface to the variable "dev", so the caller can know
- * it. Note that the caller MUST reserve space in *dev (see calling
- * code below) */
- strcpy(dev, ifr.ifr_name);
-
- /* this is the special file descriptor that the caller will use to talk
- * with the virtual interface */
- return fd;
-}
-
-#else //if not linux
-
-gr_block_sptr
-gr_make_tuntap_pdu(std::string dev, int MTU)
-{
- gr_block_sptr rv;
- throw std::runtime_error("tuntap only implemented on linux");
- return rv;
-}
-
-#endif
diff --git a/gnuradio-core/src/lib/io/gr_tuntap_pdu.h b/gnuradio-core/src/lib/io/gr_tuntap_pdu.h
deleted file mode 100644
index 18c83f42b2..0000000000
--- a/gnuradio-core/src/lib/io/gr_tuntap_pdu.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012 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_GR_TUNTAP_PDU_H
-#define INCLUDED_GR_TUNTAP_PDU_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_message.h>
-#include <gr_msg_queue.h>
-#include <gr_stream_pdu_base.h>
-
-#if (defined(linux) || defined(__linux) || defined(__linux__))
-
-#include <linux/if_tun.h>
-
-class gr_tuntap_pdu;
-typedef boost::shared_ptr<gr_tuntap_pdu> gr_tuntap_pdu_sptr;
-
-GR_CORE_API gr_tuntap_pdu_sptr gr_make_tuntap_pdu (std::string dev, int MTU=10000);
-
-/*!
- * \brief Gather received items into messages and insert into msgq
- * \ingroup sink_blk
- */
-class GR_CORE_API gr_tuntap_pdu : public gr_stream_pdu_base
-{
- private:
- friend GR_CORE_API gr_tuntap_pdu_sptr
- gr_make_tuntap_pdu(std::string dev, int MTU);
- int tun_alloc(char* dev, int flags = IFF_TAP | IFF_NO_PI);
- std::string d_dev;
- protected:
- gr_tuntap_pdu (std::string dev, int MTU=10000);
-
- public:
- ~gr_tuntap_pdu () {}
-
-};
-
-#else // if not linux
-
-class gr_tuntap_pdu
-{
-private:
- gr_tuntap_pdu() {};
-public:
- ~gr_tuntap_pdu() {};
-};
-
-GR_CORE_API gr_block_sptr gr_make_tuntap_pdu (std::string dev, int MTU=0);
-
-#endif
-
-#endif /* INCLUDED_GR_TUNTAP_PDU_H */
diff --git a/gnuradio-core/src/lib/io/gr_tuntap_pdu.i b/gnuradio-core/src/lib/io/gr_tuntap_pdu.i
deleted file mode 100644
index 589bbc3853..0000000000
--- a/gnuradio-core/src/lib/io/gr_tuntap_pdu.i
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- 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 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,tuntap_pdu);
-
-%{
-#include <gr_tuntap_pdu.h>
-%}
-
-%include "gr_tuntap_pdu.h"
-
diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.cc b/gnuradio-core/src/lib/io/gr_udp_sink.cc
deleted file mode 100644
index 6b1d34ef7e..0000000000
--- a/gnuradio-core/src/lib/io/gr_udp_sink.cc
+++ /dev/null
@@ -1,304 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008,2009,2010 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.
- */
-
-#include <boost/asio.hpp>
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <gr_udp_sink.h>
-#include <gr_io_signature.h>
-#include <stdexcept>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#if defined(HAVE_NETDB_H)
-#include <netdb.h>
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h> //usually included by <netdb.h>?
-#endif
-typedef void* optval_t;
-#elif defined(HAVE_WINDOWS_H)
-// if not posix, assume winsock
-#define USING_WINSOCK
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#define SHUT_RDWR 2
-typedef char* optval_t;
-#endif
-
-#include <gruel/thread.h>
-
-#define SNK_VERBOSE 0
-
-static int is_error( int perr )
-{
- // Compare error to posix error code; return nonzero if match.
-#if defined(USING_WINSOCK)
-#define ENOPROTOOPT 109
-#define ECONNREFUSED 111
- // All codes to be checked for must be defined below
- int werr = WSAGetLastError();
- switch( werr ) {
- case WSAETIMEDOUT:
- return( perr == EAGAIN );
- case WSAENOPROTOOPT:
- return( perr == ENOPROTOOPT );
- case WSAECONNREFUSED:
- return( perr == ECONNREFUSED );
- default:
- fprintf(stderr,"gr_udp_source/is_error: unknown error %d\n", perr );
- throw std::runtime_error("internal error");
- }
- return 0;
-#else
- return( perr == errno );
-#endif
-}
-
-static void report_error( const char *msg1, const char *msg2 )
-{
- // Deal with errors, both posix and winsock
-#if defined(USING_WINSOCK)
- int werr = WSAGetLastError();
- fprintf(stderr, "%s: winsock error %d\n", msg1, werr );
-#else
- perror(msg1);
-#endif
- if( msg2 != NULL )
- throw std::runtime_error(msg2);
- return;
-}
-
-gr_udp_sink::gr_udp_sink (size_t itemsize,
- const char *host, unsigned short port,
- int payload_size, bool eof)
- : gr_sync_block ("udp_sink",
- gr_make_io_signature (1, 1, itemsize),
- gr_make_io_signature (0, 0, 0)),
- d_itemsize (itemsize), d_payload_size(payload_size), d_eof(eof),
- d_socket(-1), d_connected(false)
-{
-#if defined(USING_WINSOCK) // for Windows (with MinGW)
- // initialize winsock DLL
- WSADATA wsaData;
- int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
- if( iResult != NO_ERROR ) {
- report_error( "gr_udp_source WSAStartup", "can't open socket" );
- }
-#endif
-
- // create socket
- d_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if(d_socket == -1) {
- report_error("socket open","can't open socket");
- }
-
- // Don't wait when shutting down
- linger lngr;
- lngr.l_onoff = 1;
- lngr.l_linger = 0;
- if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) {
- if( !is_error(ENOPROTOOPT) ) { // no SO_LINGER for SOCK_DGRAM on Windows
- report_error("SO_LINGER","can't set socket option SO_LINGER");
- }
- }
-
- // Get the destination address
- connect(host, port);
-}
-
-// public constructor that returns a shared_ptr
-
-gr_udp_sink_sptr
-gr_make_udp_sink (size_t itemsize,
- const char *host, unsigned short port,
- int payload_size, bool eof)
-{
- return gnuradio::get_initial_sptr(new gr_udp_sink (itemsize,
- host, port,
- payload_size, eof));
-}
-
-gr_udp_sink::~gr_udp_sink ()
-{
- if (d_connected)
- disconnect();
-
- if (d_socket != -1){
- shutdown(d_socket, SHUT_RDWR);
-#if defined(USING_WINSOCK)
- closesocket(d_socket);
-#else
- ::close(d_socket);
-#endif
- d_socket = -1;
- }
-
-#if defined(USING_WINSOCK) // for Windows (with MinGW)
- // free winsock resources
- WSACleanup();
-#endif
-}
-
-int
-gr_udp_sink::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- const char *in = (const char *) input_items[0];
- ssize_t r=0, bytes_sent=0, bytes_to_send=0;
- ssize_t total_size = noutput_items*d_itemsize;
-
- #if SNK_VERBOSE
- printf("Entered udp_sink\n");
- #endif
-
- gruel::scoped_lock guard(d_mutex); // protect d_socket
-
- while(bytes_sent < total_size) {
- bytes_to_send = std::min((ssize_t)d_payload_size, (total_size-bytes_sent));
-
- if(d_connected) {
- r = send(d_socket, (in+bytes_sent), bytes_to_send, 0);
- if(r == -1) { // error on send command
- if( is_error(ECONNREFUSED) )
- r = bytes_to_send; // discard data until receiver is started
- else {
- report_error("udp_sink",NULL); // there should be no error case where
- return -1; // this function should not exit immediately
- }
- }
- }
- else
- r = bytes_to_send; // discarded for lack of connection
- bytes_sent += r;
-
- #if SNK_VERBOSE
- printf("\tbyte sent: %d bytes\n", r);
- #endif
- }
-
- #if SNK_VERBOSE
- printf("Sent: %d bytes (noutput_items: %d)\n", bytes_sent, noutput_items);
- #endif
-
- return noutput_items;
-}
-
-void gr_udp_sink::connect( const char *host, unsigned short port )
-{
- if(d_connected)
- disconnect();
-
- if(host != NULL ) {
- // Get the destination address
- struct addrinfo *ip_dst;
- struct addrinfo hints;
- memset( (void*)&hints, 0, sizeof(hints) );
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_protocol = IPPROTO_UDP;
- char port_str[12];
- sprintf( port_str, "%d", port );
-
- // FIXME leaks if report_error throws below
- int ret = getaddrinfo( host, port_str, &hints, &ip_dst );
- if( ret != 0 )
- report_error("gr_udp_source/getaddrinfo",
- "can't initialize destination socket" );
-
- // don't need d_mutex lock when !d_connected
- if(::connect(d_socket, ip_dst->ai_addr, ip_dst->ai_addrlen) == -1) {
- report_error("socket connect","can't connect to socket");
- }
- d_connected = true;
-
- freeaddrinfo(ip_dst);
- }
-
- return;
-}
-
-void gr_udp_sink::disconnect()
-{
- if(!d_connected)
- return;
-
- #if SNK_VERBOSE
- printf("gr_udp_sink disconnecting\n");
- #endif
-
- gruel::scoped_lock guard(d_mutex); // protect d_socket from work()
-
- // Send a few zero-length packets to signal receiver we are done
- if(d_eof) {
- int i;
- for( i = 0; i < 3; i++ )
- (void) send( d_socket, NULL, 0, 0 ); // ignore errors
- }
-
- // Sending EOF can produce ERRCONNREFUSED errors that won't show up
- // until the next send or recv, which might confuse us if it happens
- // on a new connection. The following does a nonblocking recv to
- // clear any such errors.
- timeval timeout;
- timeout.tv_sec = 0; // zero time for immediate return
- timeout.tv_usec = 0;
- fd_set readfds;
- FD_ZERO(&readfds);
- FD_SET(d_socket, &readfds);
- int r = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout);
- if(r < 0) {
- #if SNK_VERBOSE
- report_error("udp_sink/select",NULL);
- #endif
- }
- else if(r > 0) { // call recv() to get error return
- r = recv(d_socket, (char*)&readfds, sizeof(readfds), 0);
- if(r < 0) {
- #if SNK_VERBOSE
- report_error("udp_sink/recv",NULL);
- #endif
- }
- }
-
- // Since I can't find any way to disconnect a datagram socket in Cygwin,
- // we just leave it connected but disable sending.
-#if 0
- // zeroed address structure should reset connection
- struct sockaddr addr;
- memset( (void*)&addr, 0, sizeof(addr) );
- // addr.sa_family = AF_UNSPEC; // doesn't work on Cygwin
- // addr.sa_family = AF_INET; // doesn't work on Cygwin
-
- if(::connect(d_socket, &addr, sizeof(addr)) == -1)
- report_error("socket connect","can't connect to socket");
-#endif
-
- d_connected = false;
-
- return;
-}
diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.h b/gnuradio-core/src/lib/io/gr_udp_sink.h
deleted file mode 100644
index bf042a6d12..0000000000
--- a/gnuradio-core/src/lib/io/gr_udp_sink.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008,2009,2010 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_GR_UDP_SINK_H
-#define INCLUDED_GR_UDP_SINK_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gruel/thread.h>
-
-class gr_udp_sink;
-typedef boost::shared_ptr<gr_udp_sink> gr_udp_sink_sptr;
-
-GR_CORE_API gr_udp_sink_sptr
-gr_make_udp_sink (size_t itemsize,
- const char *host, unsigned short port,
- int payload_size=1472, bool eof=true);
-
-/*!
- * \brief Write stream to an UDP socket.
- * \ingroup sink_blk
- *
- * \param itemsize The size (in bytes) of the item datatype
- * \param host The name or IP address of the receiving host; use
- * NULL or None for no connection
- * \param port Destination port to connect to on receiving host
- * \param payload_size UDP payload size by default set to 1472 =
- * (1500 MTU - (8 byte UDP header) - (20 byte IP header))
- * \param eof Send zero-length packet on disconnect
- */
-
-class GR_CORE_API gr_udp_sink : public gr_sync_block
-{
- friend GR_CORE_API gr_udp_sink_sptr gr_make_udp_sink (size_t itemsize,
- const char *host,
- unsigned short port,
- int payload_size, bool eof);
- private:
- size_t d_itemsize;
-
- int d_payload_size; // maximum transmission unit (packet length)
- bool d_eof; // send zero-length packet on disconnect
- int d_socket; // handle to socket
- bool d_connected; // are we connected?
- gruel::mutex d_mutex; // protects d_socket and d_connected
-
- protected:
- /*!
- * \brief UDP Sink Constructor
- *
- * \param itemsize The size (in bytes) of the item datatype
- * \param host The name or IP address of the receiving host; use
- * NULL or None for no connection
- * \param port Destination port to connect to on receiving host
- * \param payload_size UDP payload size by default set to
- * 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header))
- * \param eof Send zero-length packet on disconnect
- */
- gr_udp_sink (size_t itemsize,
- const char *host, unsigned short port,
- int payload_size, bool eof);
-
- public:
- ~gr_udp_sink ();
-
- /*! \brief return the PAYLOAD_SIZE of the socket */
- int payload_size() { return d_payload_size; }
-
- /*! \brief Change the connection to a new destination
- *
- * \param host The name or IP address of the receiving host; use
- * NULL or None to break the connection without closing
- * \param port Destination port to connect to on receiving host
- *
- * Calls disconnect() to terminate any current connection first.
- */
- void connect( const char *host, unsigned short port );
-
- /*! \brief Send zero-length packet (if eof is requested) then stop sending
- *
- * Zero-byte packets can be interpreted as EOF by gr_udp_source. Note that
- * disconnect occurs automatically when the sink is destroyed, but not when
- * its top_block stops.*/
- void disconnect();
-
- // should we export anything else?
-
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-#endif /* INCLUDED_GR_UDP_SINK_H */
diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.i b/gnuradio-core/src/lib/io/gr_udp_sink.i
deleted file mode 100644
index ba7043937a..0000000000
--- a/gnuradio-core/src/lib/io/gr_udp_sink.i
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2010 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.
- */
-
-
-GR_SWIG_BLOCK_MAGIC(gr,udp_sink)
-
-gr_udp_sink_sptr
-gr_make_udp_sink (size_t itemsize,
- const char *host, unsigned short port,
- int payload_size=1472, bool eof=true) throw (std::runtime_error);
-
-class gr_udp_sink : public gr_sync_block
-{
- protected:
- gr_udp_sink (size_t itemsize,
- const char *host, unsigned short port,
- int payload_size, bool eof)
- throw (std::runtime_error);
-
- public:
- ~gr_udp_sink ();
-
- int payload_size() { return d_payload_size; }
- void connect( const char *host, unsigned short port );
- void disconnect();
-
-};
diff --git a/gnuradio-core/src/lib/io/gr_udp_source.cc b/gnuradio-core/src/lib/io/gr_udp_source.cc
deleted file mode 100644
index eca8e89d01..0000000000
--- a/gnuradio-core/src/lib/io/gr_udp_source.cc
+++ /dev/null
@@ -1,374 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008,2009,2010 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 <gr_udp_source.h>
-#include <gr_io_signature.h>
-#include <stdexcept>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-
-#if defined(HAVE_NETDB_H)
-#include <netdb.h>
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-typedef void* optval_t;
-
-// ntohs() on FreeBSD may require both netinet/in.h and arpa/inet.h, in order
-#if defined(HAVE_NETINET_IN_H)
-#include <netinet/in.h>
-#endif
-#if defined(HAVE_ARPA_INET_H)
-#include <arpa/inet.h>
-#endif
-
-#elif defined(HAVE_WINDOWS_H)
-// if not posix, assume winsock
-#define USING_WINSOCK
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#define SHUT_RDWR 2
-typedef char* optval_t;
-#endif
-
-#define USE_SELECT 1 // non-blocking receive on all platforms
-#define USE_RCV_TIMEO 0 // non-blocking receive on all but Cygwin
-#define SRC_VERBOSE 0
-
-static int is_error( int perr )
-{
- // Compare error to posix error code; return nonzero if match.
-#if defined(USING_WINSOCK)
-#define ENOPROTOOPT 109
- // All codes to be checked for must be defined below
- int werr = WSAGetLastError();
- switch( werr ) {
- case WSAETIMEDOUT:
- return( perr == EAGAIN );
- case WSAENOPROTOOPT:
- return( perr == ENOPROTOOPT );
- default:
- fprintf(stderr,"gr_udp_source/is_error: unknown error %d\n", perr );
- throw std::runtime_error("internal error");
- }
- return 0;
-#else
- return( perr == errno );
-#endif
-}
-
-static void report_error( const char *msg1, const char *msg2 )
-{
- // Deal with errors, both posix and winsock
-#if defined(USING_WINSOCK)
- int werr = WSAGetLastError();
- fprintf(stderr, "%s: winsock error %d\n", msg1, werr );
-#else
- perror(msg1);
-#endif
- if( msg2 != NULL )
- throw std::runtime_error(msg2);
- return;
-}
-
-gr_udp_source::gr_udp_source(size_t itemsize, const char *host,
- unsigned short port, int payload_size,
- bool eof, bool wait)
- : gr_sync_block ("udp_source",
- gr_make_io_signature(0, 0, 0),
- gr_make_io_signature(1, 1, itemsize)),
- d_itemsize(itemsize), d_payload_size(payload_size),
- d_eof(eof), d_wait(wait), d_socket(-1), d_residual(0), d_temp_offset(0)
-{
- int ret = 0;
-
-#if defined(USING_WINSOCK) // for Windows (with MinGW)
- // initialize winsock DLL
- WSADATA wsaData;
- int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
- if( iResult != NO_ERROR ) {
- report_error( "gr_udp_source WSAStartup", "can't open socket" );
- }
-#endif
-
- // Set up the address stucture for the source address and port numbers
- // Get the source IP address from the host name
- struct addrinfo *ip_src; // store the source IP address to use
- struct addrinfo hints;
- memset( (void*)&hints, 0, sizeof(hints) );
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_DGRAM;
- hints.ai_protocol = IPPROTO_UDP;
- hints.ai_flags = AI_PASSIVE;
- char port_str[12];
- sprintf( port_str, "%d", port );
-
- // FIXME leaks if report_error throws below
- ret = getaddrinfo( host, port_str, &hints, &ip_src );
- if( ret != 0 )
- report_error("gr_udp_source/getaddrinfo",
- "can't initialize source socket" );
-
- // FIXME leaks if report_error throws below
- d_temp_buff = new char[d_payload_size]; // allow it to hold up to payload_size bytes
-
- // create socket
- d_socket = socket(ip_src->ai_family, ip_src->ai_socktype,
- ip_src->ai_protocol);
- if(d_socket == -1) {
- report_error("socket open","can't open socket");
- }
-
- // Turn on reuse address
- int opt_val = 1;
- if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (optval_t)&opt_val, sizeof(int)) == -1) {
- report_error("SO_REUSEADDR","can't set socket option SO_REUSEADDR");
- }
-
- // Don't wait when shutting down
- linger lngr;
- lngr.l_onoff = 1;
- lngr.l_linger = 0;
- if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) {
- if( !is_error(ENOPROTOOPT) ) { // no SO_LINGER for SOCK_DGRAM on Windows
- report_error("SO_LINGER","can't set socket option SO_LINGER");
- }
- }
-
-#if USE_RCV_TIMEO
- // Set a timeout on the receive function to not block indefinitely
- // This value can (and probably should) be changed
- // Ignored on Cygwin
-#if defined(USING_WINSOCK)
- DWORD timeout = 1000; // milliseconds
-#else
- timeval timeout;
- timeout.tv_sec = 1;
- timeout.tv_usec = 0;
-#endif
- if(setsockopt(d_socket, SOL_SOCKET, SO_RCVTIMEO, (optval_t)&timeout, sizeof(timeout)) == -1) {
- report_error("SO_RCVTIMEO","can't set socket option SO_RCVTIMEO");
- }
-#endif // USE_RCV_TIMEO
-
- // bind socket to an address and port number to listen on
- if(bind (d_socket, ip_src->ai_addr, ip_src->ai_addrlen) == -1) {
- report_error("socket bind","can't bind socket");
- }
- freeaddrinfo(ip_src);
-
-}
-
-gr_udp_source_sptr
-gr_make_udp_source (size_t itemsize, const char *ipaddr,
- unsigned short port, int payload_size, bool eof, bool wait)
-{
- return gnuradio::get_initial_sptr(new gr_udp_source (itemsize, ipaddr,
- port, payload_size, eof, wait));
-}
-
-gr_udp_source::~gr_udp_source ()
-{
- delete [] d_temp_buff;
-
- if (d_socket != -1){
- shutdown(d_socket, SHUT_RDWR);
-#if defined(USING_WINSOCK)
- closesocket(d_socket);
-#else
- ::close(d_socket);
-#endif
- d_socket = -1;
- }
-
-#if defined(USING_WINSOCK) // for Windows (with MinGW)
- // free winsock resources
- WSACleanup();
-#endif
-}
-
-int
-gr_udp_source::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- char *out = (char *) output_items[0];
- ssize_t r=0, nbytes=0, bytes_received=0;
- ssize_t total_bytes = (ssize_t)(d_itemsize*noutput_items);
-
- #if SRC_VERBOSE
- printf("\nEntered udp_source\n");
- #endif
-
- // Remove items from temp buffer if they are in there
- if(d_residual) {
- nbytes = std::min(d_residual, total_bytes);
- memcpy(out, d_temp_buff+d_temp_offset, nbytes);
- bytes_received = nbytes;
-
- #if SRC_VERBOSE
- printf("\tTemp buff size: %d offset: %d (bytes_received: %d) (noutput_items: %d)\n",
- d_residual, d_temp_offset, bytes_received, noutput_items);
- #endif
-
- // Increment pointer
- out += bytes_received;
-
- // Update indexing of amount of bytes left in the buffer
- d_residual -= nbytes;
- d_temp_offset += nbytes;
-
- // Return now with what we've got.
- assert(nbytes % d_itemsize == 0);
- return nbytes/d_itemsize;
- }
-
- while(1) {
- // get the data into our output buffer and record the number of bytes
-
-#if USE_SELECT
- // RCV_TIMEO doesn't work on all systems (e.g., Cygwin)
- // use select() instead of, or in addition to RCV_TIMEO
- fd_set readfds;
- timeval timeout;
- timeout.tv_sec = 1; // Init timeout each iteration. Select can modify it.
- timeout.tv_usec = 0;
- FD_ZERO(&readfds);
- FD_SET(d_socket, &readfds);
- r = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout);
- if(r < 0) {
- report_error("udp_source/select",NULL);
- return -1;
- }
- else if(r == 0 ) { // timed out
- if( d_wait ) {
- // Allow boost thread interrupt, then try again
- //boost::this_thread::interruption_point();
- //continue;
- return 0;
- }
- else
- return -1;
- }
-#endif // USE_SELECT
-
- // This is a non-blocking call with a timeout set in the constructor
- r = recv(d_socket, d_temp_buff, d_payload_size, 0); // get the entire payload or the what's available
-
- // If r > 0, round it down to a multiple of d_itemsize
- // (If sender is broken, don't propagate problem)
- if (r > 0)
- r = (r/d_itemsize) * d_itemsize;
-
- // Check if there was a problem; forget it if the operation just timed out
- if(r == -1) {
- if( is_error(EAGAIN) ) { // handle non-blocking call timeout
- #if SRC_VERBOSE
- printf("UDP receive timed out\n");
- #endif
-
- if( d_wait ) {
- // Allow boost thread interrupt, then try again
- //boost::this_thread::interruption_point();
- //continue;
- return 0;
- }
- else
- return -1;
- }
- else {
- report_error("udp_source/recv",NULL);
- return -1;
- }
- }
- else if(r==0) {
- if(d_eof) {
- // zero-length packet interpreted as EOF
-
- #if SNK_VERBOSE
- printf("\tzero-length packet received; returning EOF\n");
- #endif
-
- return -1;
- }
- else{
- // do we need to allow boost thread interrupt?
- boost::this_thread::interruption_point();
- continue;
- }
- }
- else {
- // Calculate the number of bytes we can take from the buffer in this call
- nbytes = std::min(r, total_bytes-bytes_received);
-
- // adjust the total number of bytes we have to round down to nearest integer of an itemsize
- nbytes -= ((bytes_received+nbytes) % d_itemsize);
-
- // copy the number of bytes we want to look at here
- memcpy(out, d_temp_buff, nbytes);
-
- d_residual = r - nbytes; // save the number of bytes stored
- d_temp_offset=nbytes; // reset buffer index
-
- // keep track of the total number of bytes received
- bytes_received += nbytes;
-
- // increment the pointer
- out += nbytes;
-
- // Immediately return when data comes in
- break;
- }
-
- #if SNK_VERBOSE
- printf("\tbytes received: %d bytes (nbytes: %d)\n", bytes, nbytes);
- #endif
- }
-
- #if SRC_VERBOSE
- printf("Total Bytes Received: %d (bytes_received / noutput_items = %d / %d)\n",
- bytes_received, bytes_received, noutput_items);
- #endif
-
- // bytes_received is already set to some integer multiple of itemsize
- return bytes_received/d_itemsize;
-}
-
-// Return port number of d_socket
-int gr_udp_source::get_port(void)
-{
- sockaddr_in name;
- socklen_t len = sizeof(name);
- int ret = getsockname( d_socket, (sockaddr*)&name, &len );
- if( ret ) {
- report_error("gr_udp_source/getsockname",NULL);
- return -1;
- }
- return ntohs(name.sin_port);
-}
diff --git a/gnuradio-core/src/lib/io/gr_udp_source.h b/gnuradio-core/src/lib/io/gr_udp_source.h
deleted file mode 100644
index 56dcb3c0a9..0000000000
--- a/gnuradio-core/src/lib/io/gr_udp_source.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2008,2009,2010 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_GR_UDP_SOURCE_H
-#define INCLUDED_GR_UDP_SOURCE_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gruel/thread.h>
-
-class gr_udp_source;
-typedef boost::shared_ptr<gr_udp_source> gr_udp_source_sptr;
-
-GR_CORE_API gr_udp_source_sptr gr_make_udp_source(size_t itemsize, const char *host,
- unsigned short port,
- int payload_size=1472,
- bool eof=true, bool wait=true);
-
-/*!
- * \brief Read stream from an UDP socket.
- * \ingroup source_blk
- *
- * \param itemsize The size (in bytes) of the item datatype
- * \param host The name or IP address of the receiving host; can be
- * NULL, None, or "0.0.0.0" to allow reading from any
- * interface on the host
- * \param port The port number on which to receive data; use 0 to
- * have the system assign an unused port number
- * \param payload_size UDP payload size by default set to 1472 =
- * (1500 MTU - (8 byte UDP header) - (20 byte IP header))
- * \param eof Interpret zero-length packet as EOF (default: true)
- * \param wait Wait for data if not immediately available
- * (default: true)
- *
-*/
-
-class GR_CORE_API gr_udp_source : public gr_sync_block
-{
- friend GR_CORE_API gr_udp_source_sptr gr_make_udp_source(size_t itemsize,
- const char *host,
- unsigned short port,
- int payload_size,
- bool eof, bool wait);
-
- private:
- size_t d_itemsize;
- int d_payload_size; // maximum transmission unit (packet length)
- bool d_eof; // zero-length packet is EOF
- bool d_wait; // wait if data if not immediately available
- int d_socket; // handle to socket
- char *d_temp_buff; // hold buffer between calls
- ssize_t d_residual; // hold information about number of bytes stored in the temp buffer
- size_t d_temp_offset; // point to temp buffer location offset
-
- protected:
- /*!
- * \brief UDP Source Constructor
- *
- * \param itemsize The size (in bytes) of the item datatype
- * \param host The name or IP address of the receiving host; can be
- * NULL, None, or "0.0.0.0" to allow reading from any
- * interface on the host
- * \param port The port number on which to receive data; use 0 to
- * have the system assign an unused port number
- * \param payload_size UDP payload size by default set to 1472 =
- * (1500 MTU - (8 byte UDP header) - (20 byte IP header))
- * \param eof Interpret zero-length packet as EOF (default: true)
- * \param wait Wait for data if not immediately available
- * (default: true)
- */
- gr_udp_source(size_t itemsize, const char *host, unsigned short port,
- int payload_size, bool eof, bool wait);
-
- public:
- ~gr_udp_source();
-
- /*! \brief return the PAYLOAD_SIZE of the socket */
- int payload_size() { return d_payload_size; }
-
- /*! \brief return the port number of the socket */
- int get_port();
-
- // should we export anything else?
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-
-#endif /* INCLUDED_GR_UDP_SOURCE_H */
diff --git a/gnuradio-core/src/lib/io/gr_udp_source.i b/gnuradio-core/src/lib/io/gr_udp_source.i
deleted file mode 100644
index 18823a356f..0000000000
--- a/gnuradio-core/src/lib/io/gr_udp_source.i
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2007,2010 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,udp_source)
-
-gr_udp_source_sptr
-gr_make_udp_source (size_t itemsize, const char *host,
- unsigned short port, int payload_size=1472,
- bool eof=true, bool wait=true) throw (std::runtime_error);
-
-class gr_udp_source : public gr_sync_block
-{
- protected:
- gr_udp_source (size_t itemsize, const char *host,
- unsigned short port, int payload_size, bool eof, bool wait) throw (std::runtime_error);
-
- public:
- ~gr_udp_source ();
-
- int payload_size() { return d_payload_size; }
- int get_port();
-};
diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc b/gnuradio-core/src/lib/io/gr_wavfile_sink.cc
deleted file mode 100644
index 8526032f6d..0000000000
--- a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc
+++ /dev/null
@@ -1,280 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2006,2007,2008,2009,2010,2011 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 <gr_wavfile_sink.h>
-#include <gr_io_signature.h>
-#include <gri_wavfile.h>
-#include <stdexcept>
-#include <climits>
-#include <cstring>
-#include <cmath>
-#include <fcntl.h>
-#include <gruel/thread.h>
-#include <boost/math/special_functions/round.hpp>
-
-// win32 (mingw/msvc) specific
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
-#else
-#define OUR_O_BINARY 0
-#endif
-
-// should be handled via configure
-#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
-#else
-#define OUR_O_LARGEFILE 0
-#endif
-
-
-gr_wavfile_sink_sptr
-gr_make_wavfile_sink(const char *filename,
- int n_channels,
- unsigned int sample_rate,
- int bits_per_sample)
-{
- return gnuradio::get_initial_sptr(new gr_wavfile_sink (filename,
- n_channels,
- sample_rate,
- bits_per_sample));
-}
-
-gr_wavfile_sink::gr_wavfile_sink(const char *filename,
- int n_channels,
- unsigned int sample_rate,
- int bits_per_sample)
- : gr_sync_block ("wavfile_sink",
- gr_make_io_signature(1, n_channels, sizeof(float)),
- gr_make_io_signature(0, 0, 0)),
- d_sample_rate(sample_rate), d_nchans(n_channels),
- d_fp(0), d_new_fp(0), d_updated(false)
-{
- if (bits_per_sample != 8 && bits_per_sample != 16) {
- throw std::runtime_error("Invalid bits per sample (supports 8 and 16)");
- }
- d_bytes_per_sample = bits_per_sample / 8;
- d_bytes_per_sample_new = d_bytes_per_sample;
-
- if (!open(filename)) {
- throw std::runtime_error ("can't open file");
- }
-
- if (bits_per_sample == 8) {
- d_max_sample_val = 0xFF;
- d_min_sample_val = 0;
- d_normalize_fac = d_max_sample_val/2;
- d_normalize_shift = 1;
- } else {
- d_max_sample_val = 0x7FFF;
- d_min_sample_val = -0x7FFF;
- d_normalize_fac = d_max_sample_val;
- d_normalize_shift = 0;
- if (bits_per_sample != 16) {
- fprintf(stderr, "Invalid bits per sample value requested, using 16");
- }
- }
-}
-
-
-bool
-gr_wavfile_sink::open(const char* filename)
-{
- gruel::scoped_lock guard(d_mutex);
-
- // we use the open system call to get access to the O_LARGEFILE flag.
- int fd;
- if ((fd = ::open (filename,
- O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY,
- 0664)) < 0){
- perror (filename);
- return false;
- }
-
- if (d_new_fp) { // if we've already got a new one open, close it
- fclose(d_new_fp);
- d_new_fp = 0;
- }
-
- if ((d_new_fp = fdopen (fd, "wb")) == NULL) {
- perror (filename);
- ::close(fd); // don't leak file descriptor if fdopen fails.
- return false;
- }
- d_updated = true;
-
- if (!gri_wavheader_write(d_new_fp,
- d_sample_rate,
- d_nchans,
- d_bytes_per_sample_new)) {
- fprintf(stderr, "[%s] could not write to WAV file\n", __FILE__);
- exit(-1);
- }
-
- return true;
-}
-
-
-void
-gr_wavfile_sink::close()
-{
- gruel::scoped_lock guard(d_mutex);
-
- if (!d_fp)
- return;
-
- close_wav();
-}
-
-void gr_wavfile_sink::close_wav()
-{
- unsigned int byte_count = d_sample_count * d_bytes_per_sample;
-
- gri_wavheader_complete(d_fp, byte_count);
-
- fclose(d_fp);
- d_fp = NULL;
-}
-
-
-gr_wavfile_sink::~gr_wavfile_sink ()
-{
- if (d_new_fp) {
- fclose(d_new_fp);
- }
-
- close();
-}
-
-
-int
-gr_wavfile_sink::work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- float **in = (float **) &input_items[0];
- int n_in_chans = input_items.size();
-
- short int sample_buf_s;
-
- int nwritten;
-
- gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block
- do_update(); // update: d_fp is reqd
- if (!d_fp) // drop output on the floor
- return noutput_items;
-
- for (nwritten = 0; nwritten < noutput_items; nwritten++) {
- for (int chan = 0; chan < d_nchans; chan++) {
- // Write zeros to channels which are in the WAV file
- // but don't have any inputs here
- if (chan < n_in_chans) {
- sample_buf_s =
- convert_to_short(in[chan][nwritten]);
- } else {
- sample_buf_s = 0;
- }
-
- gri_wav_write_sample(d_fp, sample_buf_s, d_bytes_per_sample);
-
- if (feof(d_fp) || ferror(d_fp)) {
- fprintf(stderr, "[%s] file i/o error\n", __FILE__);
- close();
- exit(-1);
- }
- d_sample_count++;
- }
- }
-
- return nwritten;
-}
-
-
-short int
-gr_wavfile_sink::convert_to_short(float sample)
-{
- sample += d_normalize_shift;
- sample *= d_normalize_fac;
- if (sample > d_max_sample_val) {
- sample = d_max_sample_val;
- } else if (sample < d_min_sample_val) {
- sample = d_min_sample_val;
- }
-
- return (short int) boost::math::iround(sample);
-}
-
-
-void
-gr_wavfile_sink::set_bits_per_sample(int bits_per_sample)
-{
- gruel::scoped_lock guard(d_mutex);
- if (bits_per_sample == 8 || bits_per_sample == 16) {
- d_bytes_per_sample_new = bits_per_sample / 8;
- }
-}
-
-
-void
-gr_wavfile_sink::set_sample_rate(unsigned int sample_rate)
-{
- gruel::scoped_lock guard(d_mutex);
- d_sample_rate = sample_rate;
-}
-
-
-void
-gr_wavfile_sink::do_update()
-{
- if (!d_updated) {
- return;
- }
-
- if (d_fp) {
- close_wav();
- }
-
- d_fp = d_new_fp; // install new file pointer
- d_new_fp = 0;
- d_sample_count = 0;
- d_bytes_per_sample = d_bytes_per_sample_new;
-
- if (d_bytes_per_sample == 1) {
- d_max_sample_val = UCHAR_MAX;
- d_min_sample_val = 0;
- d_normalize_fac = d_max_sample_val/2;
- d_normalize_shift = 1;
- } else if (d_bytes_per_sample == 2) {
- d_max_sample_val = SHRT_MAX;
- d_min_sample_val = SHRT_MIN;
- d_normalize_fac = d_max_sample_val;
- d_normalize_shift = 0;
- }
-
- d_updated = false;
-}
diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.h b/gnuradio-core/src/lib/io/gr_wavfile_sink.h
deleted file mode 100644
index 162151b7a8..0000000000
--- a/gnuradio-core/src/lib/io/gr_wavfile_sink.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008,2009 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_GR_WAVFILE_SINK_H
-#define INCLUDED_GR_WAVFILE_SINK_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <gr_file_sink_base.h>
-#include <boost/thread.hpp>
-
-class gr_wavfile_sink;
-typedef boost::shared_ptr<gr_wavfile_sink> gr_wavfile_sink_sptr;
-
-/*
- * \p filename The .wav file to be opened
- * \p n_channels Number of channels (2 = stereo or I/Q output)
- * \p sample_rate Sample rate [S/s]
- * \p bits_per_sample 16 or 8 bit, default is 16
- */
-GR_CORE_API gr_wavfile_sink_sptr
-gr_make_wavfile_sink (const char *filename,
- int n_channels,
- unsigned int sample_rate,
- int bits_per_sample = 16);
-
-/*!
- * \brief Write stream to a Microsoft PCM (.wav) file.
- *
- * Values must be floats within [-1;1].
- * Check gr_make_wavfile_sink() for extra info.
- *
- * \ingroup sink_blk
- */
-class GR_CORE_API gr_wavfile_sink : public gr_sync_block
-{
-private:
- friend GR_CORE_API gr_wavfile_sink_sptr gr_make_wavfile_sink (const char *filename,
- int n_channels,
- unsigned int sample_rate,
- int bits_per_sample);
-
- gr_wavfile_sink(const char *filename,
- int n_channels,
- unsigned int sample_rate,
- int bits_per_sample);
-
- unsigned d_sample_rate;
- int d_nchans;
- unsigned d_sample_count;
- int d_bytes_per_sample;
- int d_bytes_per_sample_new;
- int d_max_sample_val;
- int d_min_sample_val;
- int d_normalize_shift;
- int d_normalize_fac;
-
- FILE *d_fp;
- FILE *d_new_fp;
- bool d_updated;
- boost::mutex d_mutex;
-
- /*!
- * \brief Convert a sample value within [-1;+1] to a corresponding
- * short integer value
- */
- short convert_to_short(float sample);
-
- /*!
- * \brief If any file changes have occurred, update now. This is called
- * internally by work() and thus doesn't usually need to be called by
- * hand.
- */
- void do_update();
-
- /*!
- * \brief Writes information to the WAV header which is not available
- * a-priori (chunk size etc.) and closes the file. Not thread-safe and
- * assumes d_fp is a valid file pointer, should thus only be called by
- * other methods.
- */
- void close_wav();
-
-public:
- ~gr_wavfile_sink ();
-
- /*!
- * \brief Opens a new file and writes a WAV header. Thread-safe.
- */
- bool open(const char* filename);
-
- /*!
- * \brief Closes the currently active file and completes the WAV
- * header. Thread-safe.
- */
- void close();
-
- /*!
- * \brief Set the sample rate. This will not affect the WAV file
- * currently opened. Any following open() calls will use this new
- * sample rate.
- */
- void set_sample_rate(unsigned int sample_rate);
-
- /*!
- * \brief Set bits per sample. This will not affect the WAV file
- * currently opened (see set_sample_rate()). If the value is neither
- * 8 nor 16, the call is ignored and the current value is kept.
- */
- void set_bits_per_sample(int bits_per_sample);
-
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
-};
-
-#endif /* INCLUDED_GR_WAVFILE_SINK_H */
diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.i b/gnuradio-core/src/lib/io/gr_wavfile_sink.i
deleted file mode 100644
index 48d1130bd2..0000000000
--- a/gnuradio-core/src/lib/io/gr_wavfile_sink.i
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- 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.
- */
-
-
-GR_SWIG_BLOCK_MAGIC(gr,wavfile_sink);
-
-gr_wavfile_sink_sptr
-gr_make_wavfile_sink (const char *filename,
- int n_channels,
- unsigned int sample_rate,
- int bits_per_sample = 16) throw (std::runtime_error);
-
-class gr_wavfile_sink : public gr_sync_block
-{
-protected:
- gr_wavfile_sink(const char *filename,
- int n_channels,
- unsigned int sample_rate,
- int bits_per_sample) throw (std::runtime_error);
-
-public:
- ~gr_wavfile_sink ();
- bool open(const char* filename);
- void close();
- void set_sample_rate(unsigned int sample_rate);
- void set_bits_per_sample(int bits_per_sample);
-};
-
diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.cc b/gnuradio-core/src/lib/io/gr_wavfile_source.cc
deleted file mode 100644
index c8372868ba..0000000000
--- a/gnuradio-core/src/lib/io/gr_wavfile_source.cc
+++ /dev/null
@@ -1,171 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2008,2010 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 <gr_wavfile_source.h>
-#include <gr_io_signature.h>
-#include <gri_wavfile.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <stdexcept>
-
-// win32 (mingw/msvc) specific
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-#ifdef O_BINARY
-#define OUR_O_BINARY O_BINARY
-#else
-#define OUR_O_BINARY 0
-#endif
-// should be handled via configure
-#ifdef O_LARGEFILE
-#define OUR_O_LARGEFILE O_LARGEFILE
-#else
-#define OUR_O_LARGEFILE 0
-#endif
-
-
-gr_wavfile_source_sptr
-gr_make_wavfile_source (const char *filename, bool repeat)
-{
- return gnuradio::get_initial_sptr(new gr_wavfile_source (filename, repeat));
-}
-
-
-gr_wavfile_source::gr_wavfile_source (const char *filename, bool repeat)
- : gr_sync_block ("wavfile_source",
- gr_make_io_signature (0, 0, 0),
- gr_make_io_signature (1, 2, sizeof(float))),
- d_fp(NULL), d_repeat(repeat),
- d_sample_rate(1), d_nchans(1), d_bytes_per_sample(2), d_first_sample_pos(0),
- d_samples_per_chan(0), d_sample_idx(0)
-{
- // we use "open" to use to the O_LARGEFILE flag
-
- int fd;
- if ((fd = open (filename, O_RDONLY | OUR_O_LARGEFILE | OUR_O_BINARY)) < 0) {
- perror (filename);
- throw std::runtime_error ("can't open file");
- }
-
- if ((d_fp = fdopen (fd, "rb")) == NULL) {
- perror (filename);
- throw std::runtime_error ("can't open file");
- }
-
- // Scan headers, check file validity
- if (!gri_wavheader_parse(d_fp,
- d_sample_rate,
- d_nchans,
- d_bytes_per_sample,
- d_first_sample_pos,
- d_samples_per_chan)) {
- throw std::runtime_error("is not a valid wav file");
- }
-
- if (d_samples_per_chan == 0) {
- throw std::runtime_error("WAV file does not contain any samples");
- }
-
- if (d_bytes_per_sample == 1) {
- d_normalize_fac = 128;
- d_normalize_shift = 1;
- } else {
- d_normalize_fac = 0x7FFF;
- d_normalize_shift = 0;
- }
-
- // Re-set the output signature
- set_output_signature(gr_make_io_signature(1, d_nchans, sizeof(float)));
-}
-
-
-gr_wavfile_source::~gr_wavfile_source ()
-{
- fclose(d_fp);
-}
-
-
-int
-gr_wavfile_source::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- float **out = (float **) &output_items[0];
- int n_out_chans = output_items.size();
-
- int i;
- short sample;
-
- for (i = 0; i < noutput_items; i++) {
- if (d_sample_idx >= d_samples_per_chan) {
- if (!d_repeat) {
- // if nothing was read at all, say we're done.
- return i ? i : -1;
- }
-
- if (fseek (d_fp, d_first_sample_pos, SEEK_SET) == -1) {
- fprintf(stderr, "[%s] fseek failed\n", __FILE__);
- exit(-1);
- }
-
- d_sample_idx = 0;
- }
-
- for (int chan = 0; chan < d_nchans; chan++) {
- sample = gri_wav_read_sample(d_fp, d_bytes_per_sample);
-
- if (chan < n_out_chans) {
- out[chan][i] = convert_to_float(sample);
- }
- }
-
- d_sample_idx++;
-
- // OK, EOF is not necessarily an error. But we're not going to
- // deal with handling corrupt wav files, so if they give us any
- // trouble they won't be processed. Serves them bloody right.
- if (feof(d_fp) || ferror(d_fp)) {
- if (i == 0) {
- fprintf(stderr, "[%s] WAV file has corrupted header or i/o error\n", __FILE__);
- return -1;
- }
- return i;
- }
- }
-
- return noutput_items;
-}
-
-
-float
-gr_wavfile_source::convert_to_float(short int sample)
-{
- float sample_out = (float) sample;
- sample_out /= d_normalize_fac;
- sample_out -= d_normalize_shift;
- return sample_out;
-}
diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.h b/gnuradio-core/src/lib/io/gr_wavfile_source.h
deleted file mode 100644
index 02e6e36788..0000000000
--- a/gnuradio-core/src/lib/io/gr_wavfile_source.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,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_GR_WAVFILE_SOURCE_H
-#define INCLUDED_GR_WAVFILE_SOURCE_H
-
-#include <gr_core_api.h>
-#include <gr_sync_block.h>
-#include <cstdio> // for FILE
-
-class gr_wavfile_source;
-typedef boost::shared_ptr<gr_wavfile_source> gr_wavfile_source_sptr;
-
-GR_CORE_API gr_wavfile_source_sptr
-gr_make_wavfile_source (const char *filename, bool repeat = false);
-
-/*!
- * \brief Read stream from a Microsoft PCM (.wav) file, output floats
- *
- * Unless otherwise called, values are within [-1;1].
- * Check gr_make_wavfile_source() for extra info.
- *
- * \ingroup source_blk
- */
-
-class GR_CORE_API gr_wavfile_source : public gr_sync_block
-{
-private:
- friend GR_CORE_API gr_wavfile_source_sptr gr_make_wavfile_source (const char *filename,
- bool repeat);
- gr_wavfile_source(const char *filename, bool repeat);
-
- FILE *d_fp;
- bool d_repeat;
-
- unsigned d_sample_rate;
- int d_nchans;
- int d_bytes_per_sample;
- int d_first_sample_pos;
- unsigned d_samples_per_chan;
- unsigned d_sample_idx;
- int d_normalize_shift;
- int d_normalize_fac;
-
- /*!
- * \brief Convert an integer sample value to a float value within [-1;1]
- */
- float convert_to_float(short int sample);
-
-public:
- ~gr_wavfile_source ();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
- /*!
- * \brief Read the sample rate as specified in the wav file header
- */
- unsigned int sample_rate() const { return d_sample_rate; };
-
- /*!
- * \brief Return the number of bits per sample as specified in the wav
- * file header. Only 8 or 16 bit are supported here.
- */
- int bits_per_sample() const { return d_bytes_per_sample * 8; };
-
- /*!
- * \brief Return the number of channels in the wav file as specified in
- * the wav file header. This is also the max number of outputs you can
- * have.
- */
- int channels() const { return d_nchans; };
-};
-
-#endif /* INCLUDED_GR_WAVFILE_SOURCE_H */
diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.i b/gnuradio-core/src/lib/io/gr_wavfile_source.i
deleted file mode 100644
index 5af2224f14..0000000000
--- a/gnuradio-core/src/lib/io/gr_wavfile_source.i
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- 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.
- */
-
-GR_SWIG_BLOCK_MAGIC(gr,wavfile_source);
-
-gr_wavfile_source_sptr
-gr_make_wavfile_source (const char *filename,
- bool repeat = false) throw (std::runtime_error);
-
-class gr_wavfile_source : public gr_sync_block
-{
-private:
- gr_wavfile_source(const char *filename,
- bool repeat) throw (std::runtime_error);
-
-public:
- ~gr_wavfile_source();
-
- unsigned int sample_rate();
- int bits_per_sample();
- int channels();
-};
-
diff --git a/gnuradio-core/src/lib/io/gri_wavfile.cc b/gnuradio-core/src/lib/io/gri_wavfile.cc
deleted file mode 100644
index 277e6b7b0e..0000000000
--- a/gnuradio-core/src/lib/io/gri_wavfile.cc
+++ /dev/null
@@ -1,251 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2004,2008,2012 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 <gri_wavfile.h>
-#include <cstring>
-#include <stdint.h>
-#include <boost/detail/endian.hpp> //BOOST_BIG_ENDIAN
-
-# define VALID_COMPRESSION_TYPE 0x0001
-
-// Basically, this is the opposite of htonx() and ntohx()
-// Define host to/from worknet (little endian) short and long
-#ifdef BOOST_BIG_ENDIAN
-
- static inline uint16_t __gri_wav_bs16(uint16_t x)
- {
- return (x>>8) | (x<<8);
- }
-
- static inline uint32_t __gri_wav_bs32(uint32_t x)
- {
- return (uint32_t(__gri_wav_bs16(uint16_t(x&0xfffful)))<<16) | (__gri_wav_bs16(uint16_t(x>>16)));
- }
-
- #define htowl(x) __gri_wav_bs32(x)
- #define wtohl(x) __gri_wav_bs32(x)
- #define htows(x) __gri_wav_bs16(x)
- #define wtohs(x) __gri_wav_bs16(x)
-
-#else
-
- #define htowl(x) uint32_t(x)
- #define wtohl(x) uint32_t(x)
- #define htows(x) uint16_t(x)
- #define wtohs(x) uint16_t(x)
-
-#endif // BOOST_BIG_ENDIAN
-
-// WAV files are always little-endian, so we need some byte switching macros
-static inline uint32_t host_to_wav(uint32_t x) { return htowl(x); }
-static inline uint16_t host_to_wav(uint16_t x) { return htows(x); }
-static inline int16_t host_to_wav(int16_t x) { return htows(x); }
-static inline uint32_t wav_to_host(uint32_t x) { return wtohl(x); }
-static inline uint16_t wav_to_host(uint16_t x) { return wtohs(x); }
-static inline int16_t wav_to_host(int16_t x) { return wtohs(x); }
-
-bool
-gri_wavheader_parse(FILE *fp,
- unsigned int &sample_rate_o,
- int &nchans_o,
- int &bytes_per_sample_o,
- int &first_sample_pos_o,
- unsigned int &samples_per_chan_o)
-{
- // _o variables take return values
- char str_buf[8] = {0};
-
- uint32_t file_size;
- uint32_t fmt_hdr_skip;
- uint16_t compression_type;
- uint16_t nchans;
- uint32_t sample_rate;
- uint32_t avg_bytes_per_sec;
- uint16_t block_align;
- uint16_t bits_per_sample;
- uint32_t chunk_size;
-
- size_t fresult;
-
- fresult = fread(str_buf, 1, 4, fp);
- if (fresult != 4 || strncmp(str_buf, "RIFF", 4) || feof(fp)) {
- return false;
- }
-
- fresult = fread(&file_size, 1, 4, fp);
-
- fresult = fread(str_buf, 1, 8, fp);
- if (fresult != 8 || strncmp(str_buf, "WAVEfmt ", 8) || feof(fp)) {
- return false;
- }
-
- fresult = fread(&fmt_hdr_skip, 1, 4, fp);
-
- fresult = fread(&compression_type, 1, 2, fp);
- if (wav_to_host(compression_type) != VALID_COMPRESSION_TYPE) {
- return false;
- }
-
- fresult = fread(&nchans, 1, 2, fp);
- fresult = fread(&sample_rate, 1, 4, fp);
- fresult = fread(&avg_bytes_per_sec, 1, 4, fp);
- fresult = fread(&block_align, 1, 2, fp);
- fresult = fread(&bits_per_sample, 1, 2, fp);
-
- if (ferror(fp)) {
- return false;
- }
-
- fmt_hdr_skip = wav_to_host(fmt_hdr_skip);
- nchans = wav_to_host(nchans);
- sample_rate = wav_to_host(sample_rate);
- bits_per_sample = wav_to_host(bits_per_sample);
-
- if (bits_per_sample != 8 && bits_per_sample != 16) {
- return false;
- }
-
- fmt_hdr_skip -= 16;
- if (fmt_hdr_skip) {
- fseek(fp, fmt_hdr_skip, SEEK_CUR);
- }
-
- // data chunk
- fresult = fread(str_buf, 1, 4, fp);
- if (strncmp(str_buf, "data", 4)) {
- return false;
- }
-
- fresult = fread(&chunk_size, 1, 4, fp);
- if (ferror(fp)) {
- return false;
- }
-
- // More byte swapping
- chunk_size = wav_to_host(chunk_size);
-
- // Output values
- sample_rate_o = (unsigned) sample_rate;
- nchans_o = (int) nchans;
- bytes_per_sample_o = (int) (bits_per_sample / 8);
- first_sample_pos_o = (int) ftell(fp);
- samples_per_chan_o = (unsigned) (chunk_size / (bytes_per_sample_o * nchans));
- return true;
-}
-
-
-short int
-gri_wav_read_sample(FILE *fp, int bytes_per_sample)
-{
- int16_t buf_16bit;
-
- if(!fread(&buf_16bit, bytes_per_sample, 1, fp)) {
- return 0;
- }
- if(bytes_per_sample == 1) {
- return (short) buf_16bit;
- }
- return (short)wav_to_host(buf_16bit);
-}
-
-
-bool
-gri_wavheader_write(FILE *fp,
- unsigned int sample_rate,
- int nchans,
- int bytes_per_sample)
-{
- const int header_len = 44;
- char wav_hdr[header_len] = "RIFF\0\0\0\0WAVEfmt \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0data\0\0\0";
- uint16_t nchans_f = (uint16_t) nchans;
- uint32_t sample_rate_f = (uint32_t) sample_rate;
- uint16_t block_align = bytes_per_sample * nchans;
- uint32_t avg_bytes = sample_rate * block_align;
- uint16_t bits_per_sample = bytes_per_sample * 8;
-
- nchans_f = host_to_wav(nchans_f);
- sample_rate_f = host_to_wav(sample_rate_f);
- block_align = host_to_wav(block_align);
- avg_bytes = host_to_wav(avg_bytes);
- bits_per_sample = host_to_wav(bits_per_sample);
-
- wav_hdr[16] = 0x10; // no extra bytes
- wav_hdr[20] = 0x01; // no compression
- memcpy((void *) (wav_hdr + 22), (void *) &nchans_f, 2);
- memcpy((void *) (wav_hdr + 24), (void *) &sample_rate_f, 4);
- memcpy((void *) (wav_hdr + 28), (void *) &avg_bytes, 4);
- memcpy((void *) (wav_hdr + 32), (void *) &block_align, 2);
- memcpy((void *) (wav_hdr + 34), (void *) &bits_per_sample, 2);
-
- fwrite(&wav_hdr, 1, header_len, fp);
- if (ferror(fp)) {
- return false;
- }
-
- return true;
-}
-
-
-void
-gri_wav_write_sample(FILE *fp, short int sample, int bytes_per_sample)
-{
- void *data_ptr;
- unsigned char buf_8bit;
- int16_t buf_16bit;
-
- if (bytes_per_sample == 1) {
- buf_8bit = (unsigned char) sample;
- data_ptr = (void *) &buf_8bit;
- } else {
- buf_16bit = host_to_wav((int16_t) sample);
- data_ptr = (void *) &buf_16bit;
- }
-
- fwrite(data_ptr, 1, bytes_per_sample, fp);
-}
-
-
-bool
-gri_wavheader_complete(FILE *fp, unsigned int byte_count)
-{
- uint32_t chunk_size = (uint32_t) byte_count;
- chunk_size = host_to_wav(chunk_size);
-
- fseek(fp, 40, SEEK_SET);
- fwrite(&chunk_size, 1, 4, fp);
-
- chunk_size = (uint32_t) byte_count + 36; // fmt chunk and data header
- chunk_size = host_to_wav(chunk_size);
- fseek(fp, 4, SEEK_SET);
-
- fwrite(&chunk_size, 1, 4, fp);
-
- if (ferror(fp)) {
- return false;
- }
-
- return true;
-}
diff --git a/gnuradio-core/src/lib/io/gri_wavfile.h b/gnuradio-core/src/lib/io/gri_wavfile.h
deleted file mode 100644
index 16280e34a9..0000000000
--- a/gnuradio-core/src/lib/io/gri_wavfile.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* -*- 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.
- */
-
-// This file stores all the RIFF file type knowledge for the gr_wavfile_*
-// blocks.
-
-#include <gr_core_api.h>
-#include <cstdio>
-
-/*!
- * \brief Read signal information from a given WAV file.
- *
- * \param[in] fp File pointer to an opened, empty file.
- * \param[out] sample_rate Stores the sample rate [S/s]
- * \param[out] nchans Number of channels
- * \param[out] bytes_per_sample Bytes per sample, can either be 1 or 2 (corresponding o
- * 8 or 16 bit samples, respectively)
- * \param[out] first_sample_pos Number of the first byte containing a sample. Use this
- * with fseek() to jump from the end of the file to the
- * first sample when in repeat mode.
- * \param[out] samples_per_chan Number of samples per channel
- * \return True on a successful read, false if the file could not be read or is
- * not a valid WAV file.
- */
-bool
-gri_wavheader_parse(FILE *fp,
- unsigned int &sample_rate,
- int &nchans,
- int &bytes_per_sample,
- int &first_sample_pos,
- unsigned int &samples_per_chan);
-
-
-/*!
- * \brief Read one sample from an open WAV file at the current position.
- *
- * Takes care of endianness.
- */
-short int
-gri_wav_read_sample(FILE *fp, int bytes_per_sample);
-
-
-/*!
- * \brief Write a valid RIFF file header
- *
- * Note: Some header values are kept blank because they're usually not known
- * a-priori (file and chunk lengths). Use gri_wavheader_complete() to fill
- * these in.
- */
-bool
-gri_wavheader_write(FILE *fp,
- unsigned int sample_rate,
- int nchans,
- int bytes_per_sample);
-
-/*!
- * \brief Write one sample to an open WAV file at the current position.
- *
- * Takes care of endianness.
- */
-void
-gri_wav_write_sample(FILE *fp, short int sample, int bytes_per_sample);
-
-
-/*!
- * \brief Complete a WAV header
- *
- * Note: The stream position is changed during this function. If anything
- * needs to be written to the WAV file after calling this function (which
- * shouldn't happen), you need to fseek() to the end of the file (or
- * whereever).
- *
- * \param[in] fp File pointer to an open WAV file with a blank header
- * \param[in] byte_count Length of all samples written to the file in bytes.
- */
-bool
-gri_wavheader_complete(FILE *fp, unsigned int byte_count);
diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i
index e2de4eb976..6cd3e06f47 100644
--- a/gnuradio-core/src/lib/io/io.i
+++ b/gnuradio-core/src/lib/io/io.i
@@ -26,10 +26,6 @@
#include "config.h"
#endif
-#include <gr_file_sink.h>
-#include <gr_file_source.h>
-#include <gr_file_descriptor_sink.h>
-#include <gr_file_descriptor_source.h>
#include <gr_histo_sink_f.h>
#include <microtune_4702_eval_board.h>
#include <microtune_4937_eval_board.h>
@@ -37,27 +33,8 @@
#include <gr_oscope_sink_x.h>
#include <gr_oscope_sink_f.h>
#include <ppio.h>
-#include <gr_message_source.h>
-#include <gr_message_burst_source.h>
-#include <gr_message_sink.h>
-#include <gr_udp_sink.h>
-#include <gr_udp_source.h>
-#include <gr_wavfile_sink.h>
-#include <gr_wavfile_source.h>
-#include <gr_tagged_file_sink.h>
-#include <gr_pdu_to_tagged_stream.h>
-#include <gr_tagged_stream_to_pdu.h>
-#include <gr_message_debug.h>
-#include <gr_pdu.h>
-#include <gr_tuntap_pdu.h>
-#include <gr_socket_pdu.h>
%}
-%include "gr_file_sink_base.i"
-%include "gr_file_sink.i"
-%include "gr_file_source.i"
-%include "gr_file_descriptor_sink.i"
-%include "gr_file_descriptor_source.i"
%include "gr_histo_sink.i"
%include "microtune_xxxx_eval_board.i"
%include "microtune_4702_eval_board.i"
@@ -65,19 +42,5 @@
%include "sdr_1000.i"
%include "gr_oscope_sink.i"
%include "ppio.i"
-%include "gr_message_source.i"
-%include "gr_message_burst_source.i"
-%include "gr_message_sink.i"
-%include "gr_udp_sink.i"
-%include "gr_udp_source.i"
-%include "gr_wavfile_sink.i"
-%include "gr_wavfile_source.i"
-%include "gr_tagged_file_sink.i"
-%include "gr_pdu_to_tagged_stream.i"
-%include "gr_tagged_stream_to_pdu.i"
-%include "gr_message_debug.i"
-%include "gr_pdu.i"
-%include "gr_tuntap_pdu.i"
-%include "gr_socket_pdu.i"