summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/sphinx/source/gr/index.rst2
-rw-r--r--docs/sphinx/source/gr/sink_blk.rst1
-rw-r--r--docs/sphinx/source/gr/source_blk.rst1
-rwxr-xr-xgnuradio-core/src/examples/network/audio_sink.py8
-rwxr-xr-xgnuradio-core/src/examples/network/audio_source.py3
-rwxr-xr-xgnuradio-core/src/examples/network/dial_tone_sink.py10
-rwxr-xr-xgnuradio-core/src/examples/network/dial_tone_source.py2
-rwxr-xr-xgnuradio-core/src/examples/network/vector_sink.py7
-rwxr-xr-xgnuradio-core/src/examples/network/vector_source.py3
-rw-r--r--gnuradio-core/src/lib/io/CMakeLists.txt2
-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/io.i4
-rwxr-xr-xgnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py99
-rw-r--r--grc/blocks/block_tree.xml2
-rw-r--r--grc/blocks/gr_udp_sink.xml77
-rw-r--r--grc/blocks/gr_udp_source.xml85
21 files changed, 14 insertions, 1279 deletions
diff --git a/docs/sphinx/source/gr/index.rst b/docs/sphinx/source/gr/index.rst
index 92f3b9e271..bd43888ec7 100644
--- a/docs/sphinx/source/gr/index.rst
+++ b/docs/sphinx/source/gr/index.rst
@@ -28,7 +28,6 @@ Signal Sources
gnuradio.gr.vector_source_f
gnuradio.gr.vector_source_i
gnuradio.gr.vector_source_s
- gnuradio.gr.udp_source
Signal Sinks
^^^^^^^^^^^^
@@ -46,7 +45,6 @@ Signal Sinks
gnuradio.gr.vector_sink_s
gnuradio.gr.histo_sink_f
gnuradio.gr.oscope_sink_f
- gnuradio.gr.udp_sink
Information Coding and Decoding
diff --git a/docs/sphinx/source/gr/sink_blk.rst b/docs/sphinx/source/gr/sink_blk.rst
index d738db1d09..1e82765456 100644
--- a/docs/sphinx/source/gr/sink_blk.rst
+++ b/docs/sphinx/source/gr/sink_blk.rst
@@ -11,4 +11,3 @@ gnuradio.gr: Signal Sinks
.. autooldblock:: gnuradio.gr.vector_sink_s
.. autooldblock:: gnuradio.gr.histo_sink_f
.. autooldblock:: gnuradio.gr.oscope_sink_f
-.. autooldblock:: gnuradio.gr.udp_sink
diff --git a/docs/sphinx/source/gr/source_blk.rst b/docs/sphinx/source/gr/source_blk.rst
index ff7b123878..1ef77349f6 100644
--- a/docs/sphinx/source/gr/source_blk.rst
+++ b/docs/sphinx/source/gr/source_blk.rst
@@ -8,5 +8,4 @@ gnuradio.gr: Signal Sources
.. autooldblock:: gnuradio.gr.vector_source_f
.. autooldblock:: gnuradio.gr.vector_source_i
.. autooldblock:: gnuradio.gr.vector_source_s
-.. autooldblock:: gnuradio.gr.udp_source
diff --git a/gnuradio-core/src/examples/network/audio_sink.py b/gnuradio-core/src/examples/network/audio_sink.py
index 72a678816c..0e412de5ae 100755
--- a/gnuradio-core/src/examples/network/audio_sink.py
+++ b/gnuradio-core/src/examples/network/audio_sink.py
@@ -21,6 +21,7 @@
#
from gnuradio import gr
+from gnuradio import blocks
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import sys
@@ -34,8 +35,7 @@ except ImportError:
class audio_sink(gr.top_block):
def __init__(self, host, port, pkt_size, sample_rate, eof, wait):
gr.top_block.__init__(self, "audio_sink")
- src = gr.udp_source(gr.sizeof_float, host, port, pkt_size,
- eof=eof, wait=wait)
+ src = blocks.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof)
dst = audio.sink(sample_rate)
self.connect(src, dst)
@@ -51,8 +51,6 @@ if __name__ == '__main__':
help="audio signal sample rate [default=%default]")
parser.add_option("", "--no-eof", action="store_true", default=False,
help="don't send EOF on disconnect")
- parser.add_option("", "--no-wait", action="store_true", default=False,
- help="don't wait for source")
(options, args) = parser.parse_args()
if len(args) != 0:
parser.print_help()
@@ -61,7 +59,7 @@ if __name__ == '__main__':
# Create an instance of a hierarchical block
top_block = audio_sink(options.host, options.port,
options.packet_size, options.sample_rate,
- not options.no_eof, not options.no_wait)
+ not options.no_eof)
try:
# Run forever
diff --git a/gnuradio-core/src/examples/network/audio_source.py b/gnuradio-core/src/examples/network/audio_source.py
index 0baf7d2e91..577beff84c 100755
--- a/gnuradio-core/src/examples/network/audio_source.py
+++ b/gnuradio-core/src/examples/network/audio_source.py
@@ -21,6 +21,7 @@
#
from gnuradio import gr
+from gnuradio import blocks
from gnuradio.eng_option import eng_option
from optparse import OptionParser
import sys
@@ -35,7 +36,7 @@ class audio_source(gr.top_block):
def __init__(self, host, port, pkt_size, sample_rate, eof):
gr.top_block.__init__(self, "audio_source")
self.audio = audio.source(sample_rate)
- self.sink = gr.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
+ self.sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
self.connect(self.audio, self.sink)
if __name__ == '__main__':
diff --git a/gnuradio-core/src/examples/network/dial_tone_sink.py b/gnuradio-core/src/examples/network/dial_tone_sink.py
index 83ad376c0c..fee6ded846 100755
--- a/gnuradio-core/src/examples/network/dial_tone_sink.py
+++ b/gnuradio-core/src/examples/network/dial_tone_sink.py
@@ -21,14 +21,14 @@
#
from gnuradio import gr, audio
+from gnuradio import blocks
from gnuradio.eng_option import eng_option
from optparse import OptionParser
class dial_tone_sink(gr.top_block):
- def __init__(self, host, port, pkt_size, sample_rate, eof, wait):
+ def __init__(self, host, port, pkt_size, sample_rate, eof):
gr.top_block.__init__(self, "dial_tone_sink")
- udp = gr.udp_source(gr.sizeof_float, host, port, pkt_size,
- eof=eof, wait=wait)
+ udp = blokcs.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof)
sink = audio.sink(sample_rate)
self.connect(udp, sink)
@@ -44,8 +44,6 @@ if __name__ == '__main__':
help="audio signal sample rate [default=%default]")
parser.add_option("", "--no-eof", action="store_true", default=False,
help="don't send EOF on disconnect")
- parser.add_option("", "--no-wait", action="store_true", default=False,
- help="don't wait for source")
(options, args) = parser.parse_args()
if len(args) != 0:
parser.print_help()
@@ -54,7 +52,7 @@ if __name__ == '__main__':
# Create an instance of a hierarchical block
top_block = dial_tone_sink(options.host, options.port,
options.packet_size, options.sample_rate,
- not options.no_eof, not options.no_wait)
+ not options.no_eof)
try:
# Run forever
diff --git a/gnuradio-core/src/examples/network/dial_tone_source.py b/gnuradio-core/src/examples/network/dial_tone_source.py
index d0d3cc7a8d..44f05dc83c 100755
--- a/gnuradio-core/src/examples/network/dial_tone_source.py
+++ b/gnuradio-core/src/examples/network/dial_tone_source.py
@@ -47,7 +47,7 @@ class dial_tone_source(gr.top_block):
# Throttle needed here to account for the other side's audio card sampling rate
thr = blocks.throttle(gr.sizeof_float, sample_rate)
- sink = gr.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
+ sink = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
self.connect(src0, (add, 0))
self.connect(src1, (add, 1))
self.connect(add, thr, sink)
diff --git a/gnuradio-core/src/examples/network/vector_sink.py b/gnuradio-core/src/examples/network/vector_sink.py
index c220278e11..c0397d1e43 100755
--- a/gnuradio-core/src/examples/network/vector_sink.py
+++ b/gnuradio-core/src/examples/network/vector_sink.py
@@ -29,8 +29,7 @@ class vector_sink(gr.top_block):
def __init__(self, host, port, pkt_size, eof, wait):
gr.top_block.__init__(self, "vector_sink")
- udp = gr.udp_source(gr.sizeof_float, host, port, pkt_size,
- eof=eof, wait=wait)
+ udp = blocks.udp_source(gr.sizeof_float, host, port, pkt_size, eof=eof)
sink = blocks.file_sink(gr.sizeof_float, "received.dat")
self.connect(udp, sink)
@@ -44,8 +43,6 @@ if __name__ == "__main__":
help="packet size.")
parser.add_option("", "--no-eof", action="store_true", default=False,
help="don't send EOF on disconnect")
- parser.add_option("", "--no-wait", action="store_true", default=False,
- help="don't wait for source")
(options, args) = parser.parse_args()
if len(args) != 0:
parser.print_help()
@@ -54,7 +51,7 @@ if __name__ == "__main__":
# Create an instance of a hierarchical block
top_block = vector_sink(options.host, options.port,
options.packet_size,
- not options.no_eof, not options.no_wait)
+ not options.no_eof)
try:
# Run forever
diff --git a/gnuradio-core/src/examples/network/vector_source.py b/gnuradio-core/src/examples/network/vector_source.py
index d322dda3b8..b960a6d96a 100755
--- a/gnuradio-core/src/examples/network/vector_source.py
+++ b/gnuradio-core/src/examples/network/vector_source.py
@@ -21,6 +21,7 @@
#
from gnuradio import gr
+from gnuradio import blocks
from gnuradio.eng_option import eng_option
from optparse import OptionParser
@@ -29,7 +30,7 @@ class vector_source(gr.top_block):
gr.top_block.__init__(self, "vector_source")
data = [i*0.01 for i in range(1000)]
vec = gr.vector_source_f(data, True)
- udp = gr.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
+ udp = blocks.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof)
self.connect(vec, udp)
if __name__ == '__main__':
diff --git a/gnuradio-core/src/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt
index afd1d46b3e..7aeea798cd 100644
--- a/gnuradio-core/src/lib/io/CMakeLists.txt
+++ b/gnuradio-core/src/lib/io/CMakeLists.txt
@@ -83,8 +83,6 @@ set(gr_core_io_triple_threats
microtune_4937_eval_board
ppio
sdr_1000
- gr_udp_sink
- gr_udp_source
)
foreach(file_tt ${gr_core_io_triple_threats})
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/io.i b/gnuradio-core/src/lib/io/io.i
index 5cbb8620a3..6cd3e06f47 100644
--- a/gnuradio-core/src/lib/io/io.i
+++ b/gnuradio-core/src/lib/io/io.i
@@ -33,8 +33,6 @@
#include <gr_oscope_sink_x.h>
#include <gr_oscope_sink_f.h>
#include <ppio.h>
-#include <gr_udp_sink.h>
-#include <gr_udp_source.h>
%}
%include "gr_histo_sink.i"
@@ -44,7 +42,5 @@
%include "sdr_1000.i"
%include "gr_oscope_sink.i"
%include "ppio.i"
-%include "gr_udp_sink.i"
-%include "gr_udp_source.i"
diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py b/gnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py
deleted file mode 100755
index 0a719990e1..0000000000
--- a/gnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 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.
-#
-
-from gnuradio import gr, gr_unittest
-from threading import Timer
-
-class test_udp_sink_source(gr_unittest.TestCase):
-
- def setUp(self):
- self.tb_snd = gr.top_block()
- self.tb_rcv = gr.top_block()
-
- def tearDown(self):
- self.tb_rcv = None
- self.tb_snd = None
-
- def test_001(self):
- port = 65500
-
- n_data = 16
- src_data = [float(x) for x in range(n_data)]
- expected_result = tuple(src_data)
- src = gr.vector_source_f(src_data)
- udp_snd = gr.udp_sink( gr.sizeof_float, 'localhost', port )
- self.tb_snd.connect( src, udp_snd )
-
- udp_rcv = gr.udp_source( gr.sizeof_float, 'localhost', port )
- dst = gr.vector_sink_f()
- self.tb_rcv.connect( udp_rcv, dst )
-
- self.tb_rcv.start()
- self.tb_snd.run()
- udp_snd.disconnect()
- self.timeout = False
- q = Timer(3.0,self.stop_rcv)
- q.start()
- self.tb_rcv.wait()
- q.cancel()
-
- result_data = dst.data()
- self.assertEqual(expected_result, result_data)
- self.assert_(not self.timeout)
-
- def test_002(self):
- udp_rcv = gr.udp_source( gr.sizeof_float, '0.0.0.0', 0, eof=False )
- rcv_port = udp_rcv.get_port()
-
- udp_snd = gr.udp_sink( gr.sizeof_float, '127.0.0.1', 65500 )
- udp_snd.connect( 'localhost', rcv_port )
-
- n_data = 16
- src_data = [float(x) for x in range(n_data)]
- expected_result = tuple(src_data)
- src = gr.vector_source_f(src_data)
- dst = gr.vector_sink_f()
-
- self.tb_snd.connect( src, udp_snd )
- self.tb_rcv.connect( udp_rcv, dst )
-
- self.tb_rcv.start()
- self.tb_snd.run()
- udp_snd.disconnect()
- self.timeout = False
- q = Timer(3.0,self.stop_rcv)
- q.start()
- self.tb_rcv.wait()
- q.cancel()
-
- result_data = dst.data()
- self.assertEqual(expected_result, result_data)
- self.assert_(self.timeout) # source ignores EOF?
-
- def stop_rcv(self):
- self.timeout = True
- self.tb_rcv.stop()
- #print "tb_rcv stopped by Timer"
-
-if __name__ == '__main__':
- gr_unittest.run(test_udp_sink_source, "test_udp_sink_source.xml")
-
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index 62117e69ec..e9da1ec880 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -12,7 +12,6 @@
<block>random_source_x</block>
<block>gr_null_source</block>
<block>blks2_tcp_source</block>
- <block>gr_udp_source</block>
<block>pad_source</block>
<block>virtual_source</block>
</cat>
@@ -21,7 +20,6 @@
<block>gr_vector_sink_x</block>
<block>gr_null_sink</block>
<block>blks2_tcp_sink</block>
- <block>gr_udp_sink</block>
<block>pad_sink</block>
<block>virtual_sink</block>
</cat>
diff --git a/grc/blocks/gr_udp_sink.xml b/grc/blocks/gr_udp_sink.xml
deleted file mode 100644
index 45f81075f0..0000000000
--- a/grc/blocks/gr_udp_sink.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##UDP Sink
-###################################################
- -->
-<block>
- <name>UDP Sink</name>
- <key>gr_udp_sink</key>
- <import>from gnuradio import gr</import>
- <make>gr.udp_sink($type.size*$vlen, $ipaddr, $port, $psize, $eof)</make>
- <callback>set_mtu($mtu)</callback>
- <param>
- <name>Input Type</name>
- <key>type</key>
- <type>enum</type>
- <option>
- <name>Complex</name>
- <key>complex</key>
- <opt>size:gr.sizeof_gr_complex</opt>
- </option>
- <option>
- <name>Float</name>
- <key>float</key>
- <opt>size:gr.sizeof_float</opt>
- </option>
- <option>
- <name>Int</name>
- <key>int</key>
- <opt>size:gr.sizeof_int</opt>
- </option>
- <option>
- <name>Short</name>
- <key>short</key>
- <opt>size:gr.sizeof_short</opt>
- </option>
- <option>
- <name>Byte</name>
- <key>byte</key>
- <opt>size:gr.sizeof_char</opt>
- </option>
- </param>
- <param>
- <name>Destination IP Address</name>
- <key>ipaddr</key>
- <type>string</type>
- </param>
- <param>
- <name>Destination Port</name>
- <key>port</key>
- <type>int</type>
- </param>
- <param>
- <name>Payload Size</name>
- <key>psize</key>
- <value>1472</value>
- <type>int</type>
- </param>
- <param>
- <name>Send Null Pkt as EOF</name>
- <key>eof</key>
- <value>True</value>
- <type>bool</type>
- </param>
- <param>
- <name>Vec Length</name>
- <key>vlen</key>
- <value>1</value>
- <type>int</type>
- </param>
- <check>$vlen &gt; 0</check>
- <sink>
- <name>in</name>
- <type>$type</type>
- <vlen>$vlen</vlen>
- </sink>
-</block>
diff --git a/grc/blocks/gr_udp_source.xml b/grc/blocks/gr_udp_source.xml
deleted file mode 100644
index a1b961651f..0000000000
--- a/grc/blocks/gr_udp_source.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0"?>
-<!--
-###################################################
-##UDP Source
-###################################################
- -->
-<block>
- <name>UDP Source</name>
- <key>gr_udp_source</key>
- <import>from gnuradio import gr</import>
- <make>gr.udp_source($type.size*$vlen, $ipaddr, $port, $psize, $eof, $wait)</make>
- <callback>set_mtu($mtu)</callback>
- <param>
- <name>Output Type</name>
- <key>type</key>
- <type>enum</type>
- <option>
- <name>Complex</name>
- <key>complex</key>
- <opt>size:gr.sizeof_gr_complex</opt>
- </option>
- <option>
- <name>Float</name>
- <key>float</key>
- <opt>size:gr.sizeof_float</opt>
- </option>
- <option>
- <name>Int</name>
- <key>int</key>
- <opt>size:gr.sizeof_int</opt>
- </option>
- <option>
- <name>Short</name>
- <key>short</key>
- <opt>size:gr.sizeof_short</opt>
- </option>
- <option>
- <name>Byte</name>
- <key>byte</key>
- <opt>size:gr.sizeof_char</opt>
- </option>
- </param>
- <param>
- <name>IP Address</name>
- <key>ipaddr</key>
- <value>127.0.0.1</value>
- <type>string</type>
- </param>
- <param>
- <name>Port</name>
- <key>port</key>
- <value>1234</value>
- <type>int</type>
- </param>
- <param>
- <name>Payload Size</name>
- <key>psize</key>
- <value>1472</value>
- <type>int</type>
- </param>
- <param>
- <name>Null Pkt is EOF</name>
- <key>eof</key>
- <value>True</value>
- <type>bool</type>
- </param>
- <param>
- <name>Wait for Data</name>
- <key>wait</key>
- <value>True</value>
- <type>bool</type>
- </param>
- <param>
- <name>Vec Length</name>
- <key>vlen</key>
- <value>1</value>
- <type>int</type>
- </param>
- <check>$vlen &gt; 0</check>
- <source>
- <name>out</name>
- <type>$type</type>
- <vlen>$vlen</vlen>
- </source>
-</block>