diff options
author | Josh Morman <jmorman@perspectalabs.com> | 2021-03-25 10:43:14 -0400 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-04-21 14:02:57 -0400 |
commit | 50c48b3321d59ff6fa296d672a723787f32e5345 (patch) | |
tree | 1f086658b3d4392caa98b99d466fead77c05e981 /gr-blocks | |
parent | d71c4550e04f74b09fba0bbe8d7cd07dda68ba35 (diff) |
blocks: remove deprecated network blocks
Signed-off-by: Josh Morman <jmorman@perspectalabs.com>
Diffstat (limited to 'gr-blocks')
23 files changed, 0 insertions, 1332 deletions
diff --git a/gr-blocks/grc/blocks.tree.yml b/gr-blocks/grc/blocks.tree.yml index 6e36974084..5fb790efd1 100644 --- a/gr-blocks/grc/blocks.tree.yml +++ b/gr-blocks/grc/blocks.tree.yml @@ -28,10 +28,6 @@ - blocks_message_strobe_random - blocks_tags_strobe - blocks_test_tag_variable_rate_ff -- Deprecated: - - blocks_tcp_server_sink - - blocks_udp_source - - blocks_udp_sink - File Operators: - blocks_wavfile_source - blocks_wavfile_sink diff --git a/gr-blocks/grc/blocks_tcp_server_sink.block.yml b/gr-blocks/grc/blocks_tcp_server_sink.block.yml deleted file mode 100644 index 32c5a8043b..0000000000 --- a/gr-blocks/grc/blocks_tcp_server_sink.block.yml +++ /dev/null @@ -1,54 +0,0 @@ -id: blocks_tcp_server_sink -label: TCP Server Sink (Deprecated) -flags: [ python, cpp ] - -parameters: -- id: type - label: Input Type - dtype: enum - options: [complex, float, int, short, byte] - option_attributes: - size: [gr.sizeof_gr_complex, gr.sizeof_float, gr.sizeof_int, gr.sizeof_short, - gr.sizeof_char] - hide: part -- id: ipaddr - label: Destination IP Address - dtype: string -- id: port - label: Destination Port - dtype: int -- id: noblock - label: Nonblocking Mode - dtype: enum - options: ['True', 'False'] - option_labels: ['On', 'Off'] -- id: vlen - label: Vec Length - dtype: int - default: '1' - hide: ${ 'part' if vlen == 1 else 'none' } - -inputs: -- domain: stream - dtype: ${ type } - vlen: ${ vlen } - -asserts: -- ${ vlen > 0 } - -templates: - imports: from gnuradio import blocks - make: blocks.tcp_server_sink(${type.size}*${vlen}, ${ipaddr}, ${port}, ${noblock}) - -cpp_templates: - includes: ['#include <gnuradio/blocks/tcp_server_sink.h>'] - declarations: 'blocks::tcp_server_sink::sptr ${id};' - make: 'this->${id} = blocks::tcp_server_sink::make(${type.size}*${vlen}, ${ipaddr}, ${port}, ${noblock});' - translations: - 'True': 'true' - 'False': 'false' - -documentation: |- - This block has been deprecated and replaced with more capable TCP source/sink blocks in Networking Tools. - -file_format: 1 diff --git a/gr-blocks/grc/blocks_udp_sink.block.yml b/gr-blocks/grc/blocks_udp_sink.block.yml deleted file mode 100644 index e000ba6f57..0000000000 --- a/gr-blocks/grc/blocks_udp_sink.block.yml +++ /dev/null @@ -1,57 +0,0 @@ -id: blocks_udp_sink -label: UDP Sink (Deprecated) -flags: [ python, cpp ] - -parameters: -- id: type - label: Input Type - dtype: enum - options: [complex, float, int, short, byte] - option_attributes: - size: [gr.sizeof_gr_complex, gr.sizeof_float, gr.sizeof_int, gr.sizeof_short, - gr.sizeof_char] - hide: part -- id: ipaddr - label: Destination IP Address - dtype: string -- id: port - label: Destination Port - dtype: int -- id: psize - label: Payload Size - dtype: int - default: '1472' -- id: eof - label: Send Null Pkt as EOF - dtype: bool - default: 'True' -- id: vlen - label: Vec Length - dtype: int - default: '1' - hide: ${ 'part' if vlen == 1 else 'none' } - -inputs: -- domain: stream - dtype: ${ type } - vlen: ${ vlen } - -asserts: -- ${ vlen > 0 } - -templates: - imports: from gnuradio import blocks - make: blocks.udp_sink(${type.size}*${vlen}, ${ipaddr}, ${port}, ${psize}, ${eof}) - -cpp_templates: - includes: ['#include <gnuradio/blocks/udp_sink.h>'] - declarations: 'blocks::udp_sink::sptr ${id};' - make: 'this->${id} = blocks::udp_sink::make(${type.size}*${vlen}, ${ipaddr}, ${port}, ${psize}, ${eof});' - translations: - 'True': 'true' - 'False': 'false' - -documentation: |- - This block has been deprecated and replaced with a more capable UDP sink block in Networking Tools. - -file_format: 1 diff --git a/gr-blocks/grc/blocks_udp_source.block.yml b/gr-blocks/grc/blocks_udp_source.block.yml deleted file mode 100644 index c5e1226527..0000000000 --- a/gr-blocks/grc/blocks_udp_source.block.yml +++ /dev/null @@ -1,59 +0,0 @@ -id: blocks_udp_source -label: UDP Source (Deprecated) -flags: [ throttle, python, cpp ] - -parameters: -- id: type - label: Output Type - dtype: enum - options: [complex, float, int, short, byte] - option_attributes: - size: [gr.sizeof_gr_complex, gr.sizeof_float, gr.sizeof_int, gr.sizeof_short, - gr.sizeof_char] - hide: part -- id: ipaddr - label: IP Address - dtype: string - default: 127.0.0.1 -- id: port - label: Port - dtype: int - default: '1234' -- id: psize - label: Payload Size - dtype: int - default: '1472' -- id: eof - label: Null Pkt is EOF - dtype: bool - default: 'True' -- id: vlen - label: Vec Length - dtype: int - default: '1' - hide: ${ 'part' if vlen == 1 else 'none' } - -outputs: -- domain: stream - dtype: ${ type } - vlen: ${ vlen } - -asserts: -- ${ vlen > 0 } - -templates: - imports: from gnuradio import blocks - make: blocks.udp_source(${type.size}*${vlen}, ${ipaddr}, ${port}, ${psize}, ${eof}) - -cpp_templates: - includes: ['#include <gnuradio/blocks/udp_source.h>'] - declarations: 'blocks::udp_source::sptr ${id};' - make: 'this->${id} = blocks::udp_source::make(${type.size}*${vlen}, ${ipaddr}, ${port}, ${psize}, ${eof});' - translations: - 'True': 'true' - 'False': 'false' - -documentation: |- - This block has been deprecated and replaced with a more capable UDP source block in Networking Tools. - -file_format: 1 diff --git a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt index cadc355f7a..c806c7d801 100644 --- a/gr-blocks/include/gnuradio/blocks/CMakeLists.txt +++ b/gr-blocks/include/gnuradio/blocks/CMakeLists.txt @@ -140,14 +140,11 @@ install(FILES tagged_stream_mux.h tagged_stream_multiply_length.h tags_strobe.h - tcp_server_sink.h test_tag_variable_rate_ff.h threshold_ff.h throttle.h transcendental.h uchar_to_float.h - udp_sink.h - udp_source.h unpack_k_bits_bb.h vco_f.h vco_c.h diff --git a/gr-blocks/include/gnuradio/blocks/tcp_server_sink.h b/gr-blocks/include/gnuradio/blocks/tcp_server_sink.h deleted file mode 100644 index 82c9becb14..0000000000 --- a/gr-blocks/include/gnuradio/blocks/tcp_server_sink.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2014 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_BLOCKS_TCP_SERVER_SINK_H -#define INCLUDED_BLOCKS_TCP_SERVER_SINK_H - -#include <gnuradio/blocks/api.h> -#include <gnuradio/sync_block.h> - -namespace gr { -namespace blocks { - -/*! - * \brief Send stream through a TCP socket. - * \ingroup networking_tools_blk - * - * \details - * Listen for incoming TCP connection(s). Duplicate data for each - * opened connection. Optionally can wait until first client connects - * before streaming starts. - */ -class BLOCKS_API tcp_server_sink : virtual public gr::sync_block -{ -public: - // gr::blocks::tcp_server_sink::sptr - typedef std::shared_ptr<tcp_server_sink> sptr; - - /*! - * \brief TCP Server Sink Constructor - * - * \param itemsize The size (in bytes) of the item datatype - * \param host The name or IP address of interface to bind to. - * \param port Port where to listen. - * \param noblock If false, wait until first client connects before - * streaming starts. In non blocking mode - * (noblock=true), drop data onto floor if no client - * is connected. - */ - static sptr - make(size_t itemsize, const std::string& host, int port, bool noblock = false); -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_BLOCKS_TCP_SERVER_SINK_H */ diff --git a/gr-blocks/include/gnuradio/blocks/udp_sink.h b/gr-blocks/include/gnuradio/blocks/udp_sink.h deleted file mode 100644 index 950aec1306..0000000000 --- a/gr-blocks/include/gnuradio/blocks/udp_sink.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007-2010,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_GR_UDP_SINK_H -#define INCLUDED_GR_UDP_SINK_H - -#include <gnuradio/blocks/api.h> -#include <gnuradio/sync_block.h> - -namespace gr { -namespace blocks { - -/*! - * \brief Write stream to an UDP socket. - * \ingroup networking_tools_blk - */ -class BLOCKS_API udp_sink : virtual public sync_block -{ -public: - // gr::blocks::udp_sink::sptr - typedef std::shared_ptr<udp_sink> sptr; - - /*! - * \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 - */ - static sptr make(size_t itemsize, - const std::string& host, - int port, - int payload_size = 1472, - bool eof = true); - - /*! \brief return the PAYLOAD_SIZE of the socket */ - virtual int payload_size() = 0; - - /*! \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. - */ - virtual void connect(const std::string& host, int port) = 0; - - /*! \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.*/ - virtual void disconnect() = 0; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_UDP_SINK_H */ diff --git a/gr-blocks/include/gnuradio/blocks/udp_source.h b/gr-blocks/include/gnuradio/blocks/udp_source.h deleted file mode 100644 index 8e5d037544..0000000000 --- a/gr-blocks/include/gnuradio/blocks/udp_source.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007-2010,2013,2015 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_GR_UDP_SOURCE_H -#define INCLUDED_GR_UDP_SOURCE_H - -#include <gnuradio/blocks/api.h> -#include <gnuradio/sync_block.h> - -namespace gr { -namespace blocks { - -/*! - * \brief Read stream from an UDP socket. - * \ingroup networking_tools_blk - */ -class BLOCKS_API udp_source : virtual public sync_block -{ -public: - // gr::blocks::udp_source::sptr - typedef std::shared_ptr<udp_source> sptr; - - /*! - * \brief UDP Source Constructor - * - * \param itemsize The size (in bytes) of the item datatype - * \param host The name or IP address of the transmitting 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) - */ - static sptr make(size_t itemsize, - const std::string& host, - int port, - int payload_size = 1472, - bool eof = true); - - /*! \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. - */ - virtual void connect(const std::string& host, int port) = 0; - - /*! \brief Cut the connection if we have one set up. - */ - virtual void disconnect() = 0; - - /*! \brief return the PAYLOAD_SIZE of the socket */ - virtual int payload_size() = 0; - - /*! \brief return the port number of the socket */ - virtual int get_port() = 0; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_UDP_SOURCE_H */ diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index 7957a0443f..cdffc6131c 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -145,14 +145,11 @@ set(BLOCKS_SOURCES threshold_ff_impl.cc throttle_impl.cc transcendental_impl.cc - tcp_server_sink_impl.cc tag_gate_impl.cc tagged_stream_align_impl.cc tagged_stream_mux_impl.cc uchar_array_to_float.cc uchar_to_float_impl.cc - udp_sink_impl.cc - udp_source_impl.cc unpack_k_bits_bb_impl.cc vco_f_impl.cc vco_c_impl.cc diff --git a/gr-blocks/lib/tcp_server_sink_impl.cc b/gr-blocks/lib/tcp_server_sink_impl.cc deleted file mode 100644 index 1b32f881a9..0000000000 --- a/gr-blocks/lib/tcp_server_sink_impl.cc +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007-2010,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "tcp_server_sink_impl.h" -#include <gnuradio/io_signature.h> -#include <gnuradio/thread/thread.h> -#include <boost/array.hpp> -#include <boost/asio.hpp> -#include <boost/format.hpp> -#include <algorithm> -#include <cstdio> -#include <cstring> -#include <memory> -#include <stdexcept> - -namespace gr { -namespace blocks { - -tcp_server_sink::sptr -tcp_server_sink::make(size_t itemsize, const std::string& host, int port, bool noblock) -{ - return gnuradio::make_block_sptr<tcp_server_sink_impl>(itemsize, host, port, noblock); -} - -tcp_server_sink_impl::tcp_server_sink_impl(size_t itemsize, - const std::string& host, - int port, - bool noblock) - : sync_block("tcp_server_sink", - io_signature::make(1, 1, itemsize), - io_signature::make(0, 0, 0)), - d_itemsize(itemsize), - d_acceptor(d_io_service), - d_writing(0) -{ - std::string s__port = (boost::format("%d") % port).str(); - std::string s__host = host.empty() ? std::string("localhost") : host; - boost::asio::ip::tcp::resolver resolver(d_io_service); - boost::asio::ip::tcp::resolver::query query( - s__host, s__port, boost::asio::ip::resolver_query_base::passive); - d_endpoint = *resolver.resolve(query); - - d_acceptor.open(d_endpoint.protocol()); - d_acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); - d_acceptor.bind(d_endpoint); - d_acceptor.listen(); - - if (!noblock) { - auto sock = std::make_unique<boost::asio::ip::tcp::socket>(d_io_service); - d_acceptor.accept(*sock, d_endpoint); - d_sockets.insert(std::move(sock)); - } - - d_socket = std::make_unique<boost::asio::ip::tcp::socket>(d_io_service); - d_acceptor.async_accept(*d_socket, - boost::bind(&tcp_server_sink_impl::do_accept, - this, - boost::asio::placeholders::error)); - d_io_serv_thread = - boost::thread(boost::bind(&boost::asio::io_service::run, &d_io_service)); -} - -void tcp_server_sink_impl::do_accept(const boost::system::error_code& error) -{ - if (!error) { - gr::thread::scoped_lock guard(d_writing_mut); - d_sockets.insert(std::move(d_socket)); - d_socket = std::make_unique<boost::asio::ip::tcp::socket>(d_io_service); - d_acceptor.async_accept(*d_socket, - boost::bind(&tcp_server_sink_impl::do_accept, - this, - boost::asio::placeholders::error)); - } -} - -void tcp_server_sink_impl::do_write( - const boost::system::error_code& error, - size_t len, - std::set<std::unique_ptr<boost::asio::ip::tcp::socket>>::iterator i) -{ - { - gr::thread::scoped_lock guard(d_writing_mut); - --d_writing; - if (error) { - d_sockets.erase(i); - } - } - d_writing_cond.notify_one(); -} - -tcp_server_sink_impl::~tcp_server_sink_impl() -{ - gr::thread::scoped_lock guard(d_writing_mut); - while (d_writing) { - d_writing_cond.wait(guard); - } - d_io_service.reset(); - d_io_service.stop(); - d_io_serv_thread.join(); -} - -int tcp_server_sink_impl::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]; - - gr::thread::scoped_lock guard(d_writing_mut); - while (d_writing) { - d_writing_cond.wait(guard); - } - - size_t data_len = std::min(size_t(BUF_SIZE), noutput_items * d_itemsize); - data_len -= data_len % d_itemsize; - memcpy(d_buf.data(), in, data_len); - for (auto i = std::begin(d_sockets); i != std::end(d_sockets); ++i) { - boost::asio::async_write(**i, - boost::asio::buffer(d_buf.data(), data_len), - boost::bind(&tcp_server_sink_impl::do_write, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred, - i)); - } - d_writing = d_sockets.size(); - - return data_len / d_itemsize; -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/tcp_server_sink_impl.h b/gr-blocks/lib/tcp_server_sink_impl.h deleted file mode 100644 index b7ff7af174..0000000000 --- a/gr-blocks/lib/tcp_server_sink_impl.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2014 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_GR_TCP_SERVER_SINK_IMPL_H -#define INCLUDED_GR_TCP_SERVER_SINK_IMPL_H - -#include <gnuradio/blocks/tcp_server_sink.h> -#include <boost/asio.hpp> -#include <boost/ptr_container/ptr_vector.hpp> -#include <set> - -namespace gr { -namespace blocks { - -class tcp_server_sink_impl : public tcp_server_sink -{ -private: - const size_t d_itemsize; - - boost::asio::io_service d_io_service; - gr::thread::thread d_io_serv_thread; - boost::asio::ip::tcp::endpoint d_endpoint; - std::unique_ptr<boost::asio::ip::tcp::socket> d_socket; - std::set<std::unique_ptr<boost::asio::ip::tcp::socket>> d_sockets; - boost::asio::ip::tcp::acceptor d_acceptor; - - enum { - BUF_SIZE = 256 * 1024, - }; - std::array<uint8_t, BUF_SIZE> d_buf; - - int d_writing; - boost::condition_variable d_writing_cond; - boost::mutex d_writing_mut; - - void do_accept(const boost::system::error_code& error); - void do_write(const boost::system::error_code& error, - std::size_t len, - std::set<std::unique_ptr<boost::asio::ip::tcp::socket>>::iterator); - -public: - tcp_server_sink_impl(size_t itemsize, - const std::string& host, - int port, - bool noblock); - ~tcp_server_sink_impl() override; - - int work(int noutput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) override; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_TCP_SERVER_SINK_IMPL_H */ diff --git a/gr-blocks/lib/udp_sink_impl.cc b/gr-blocks/lib/udp_sink_impl.cc deleted file mode 100644 index 4391461dac..0000000000 --- a/gr-blocks/lib/udp_sink_impl.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007-2010,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "udp_sink_impl.h" -#include <gnuradio/io_signature.h> -#include <gnuradio/thread/thread.h> -#include <boost/array.hpp> -#include <boost/asio.hpp> -#include <boost/format.hpp> -#include <cstddef> -#include <cstring> -#include <memory> -#include <stdexcept> - -namespace gr { -namespace blocks { - -udp_sink::sptr udp_sink::make( - size_t itemsize, const std::string& host, int port, int payload_size, bool eof) -{ - return gnuradio::make_block_sptr<udp_sink_impl>( - itemsize, host, port, payload_size, eof); -} - -udp_sink_impl::udp_sink_impl( - size_t itemsize, const std::string& host, int port, int payload_size, bool eof) - : sync_block( - "udp_sink", io_signature::make(1, 1, itemsize), io_signature::make(0, 0, 0)), - d_itemsize(itemsize), - d_payload_size(payload_size), - d_eof(eof), - d_connected(false) -{ - // Get the destination address - connect(host, port); -} - -// public constructor that returns a shared_ptr -udp_sink_impl::~udp_sink_impl() -{ - if (d_connected) - disconnect(); -} - -void udp_sink_impl::connect(const std::string& host, int port) -{ - if (d_connected) - disconnect(); - - std::string s_port = (boost::format("%d") % port).str(); - if (!host.empty()) { - boost::asio::ip::udp::resolver resolver(d_io_service); - boost::asio::ip::udp::resolver::query query( - host, s_port, boost::asio::ip::resolver_query_base::passive); - d_endpoint = *resolver.resolve(query); - - d_socket = std::make_unique<boost::asio::ip::udp::socket>(d_io_service); - d_socket->open(d_endpoint.protocol()); - - boost::asio::socket_base::reuse_address roption(true); - d_socket->set_option(roption); - - d_connected = true; - } -} - -void udp_sink_impl::disconnect() -{ - if (!d_connected) - return; - - gr::thread::scoped_lock guard(d_mutex); // protect d_socket from work() - - // Send a few zero-length packets to signal receiver we are done - boost::array<char, 0> send_buf; - if (d_eof) { - int i; - for (i = 0; i < 3; i++) - d_socket->send_to(boost::asio::buffer(send_buf), d_endpoint); - } - - d_socket->close(); - d_socket.reset(); - - d_connected = false; -} - -int udp_sink_impl::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]; - size_t r = 0; - std::ptrdiff_t bytes_sent = 0, bytes_to_send = 0; - const size_t total_size = noutput_items * d_itemsize; - - gr::thread::scoped_lock guard(d_mutex); // protect d_socket - - while (bytes_sent < static_cast<std::ptrdiff_t>(total_size)) { - bytes_to_send = std::min(static_cast<std::ptrdiff_t>(d_payload_size), - static_cast<std::ptrdiff_t>(total_size - bytes_sent)); - - if (d_connected) { - try { - r = d_socket->send_to( - boost::asio::buffer((void*)(in + bytes_sent), bytes_to_send), - d_endpoint); - } catch (std::exception& e) { - GR_LOG_ERROR(d_logger, boost::format("send error: %s") % e.what()); - return -1; - } - } else - r = bytes_to_send; // discarded for lack of connection - bytes_sent += r; - } - - return noutput_items; -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/udp_sink_impl.h b/gr-blocks/lib/udp_sink_impl.h deleted file mode 100644 index 0912a8a6dc..0000000000 --- a/gr-blocks/lib/udp_sink_impl.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007-2010,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_GR_UDP_SINK_IMPL_H -#define INCLUDED_GR_UDP_SINK_IMPL_H - -#include <gnuradio/blocks/udp_sink.h> -#include <boost/asio.hpp> -#include <memory> - -namespace gr { -namespace blocks { - -class udp_sink_impl : public udp_sink -{ -private: - const size_t d_itemsize; - - const int d_payload_size; // maximum transmission unit (packet length) - const bool d_eof; // send zero-length packet on disconnect - bool d_connected; // are we connected? - gr::thread::mutex d_mutex; // protects d_socket and d_connected - - std::unique_ptr<boost::asio::ip::udp::socket> d_socket; // handle to socket - boost::asio::ip::udp::endpoint d_endpoint; - boost::asio::io_service d_io_service; - -public: - udp_sink_impl( - size_t itemsize, const std::string& host, int port, int payload_size, bool eof); - ~udp_sink_impl() override; - - int payload_size() override { return d_payload_size; } - - void connect(const std::string& host, int port) override; - void disconnect() override; - - int work(int noutput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) override; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_UDP_SINK_IMPL_H */ diff --git a/gr-blocks/lib/udp_source_impl.cc b/gr-blocks/lib/udp_source_impl.cc deleted file mode 100644 index 11765de504..0000000000 --- a/gr-blocks/lib/udp_source_impl.cc +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007-2010,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "udp_source_impl.h" -#include <gnuradio/io_signature.h> -#include <gnuradio/math.h> -#include <gnuradio/prefs.h> -#include <cstddef> -#include <cstring> -#include <memory> - -namespace gr { -namespace blocks { - -const int udp_source_impl::BUF_SIZE_PAYLOADS = - gr::prefs::singleton()->get_long("udp_blocks", "buf_size_payloads", 50); - -udp_source::sptr udp_source::make( - size_t itemsize, const std::string& ipaddr, int port, int payload_size, bool eof) -{ - return gnuradio::make_block_sptr<udp_source_impl>( - itemsize, ipaddr, port, payload_size, eof); -} - -udp_source_impl::udp_source_impl( - size_t itemsize, const std::string& host, int port, int payload_size, bool eof) - : sync_block( - "udp_source", io_signature::make(0, 0, 0), io_signature::make(1, 1, itemsize)), - d_itemsize(itemsize), - d_payload_size(payload_size), - d_eof(eof), - d_connected(false), - d_rxbuf(4 * payload_size), - d_residbuf(BUF_SIZE_PAYLOADS * payload_size), - d_residual(0), - d_sent(0) -{ - connect(host, port); -} - -udp_source_impl::~udp_source_impl() -{ - if (d_connected) - disconnect(); -} - -void udp_source_impl::connect(const std::string& host, int port) -{ - if (d_connected) - disconnect(); - - d_host = host; - d_port = static_cast<unsigned short>(port); - - std::string s_port; - s_port = (boost::format("%d") % d_port).str(); - - if (!host.empty()) { - boost::asio::ip::udp::resolver resolver(d_io_service); - boost::asio::ip::udp::resolver::query query( - d_host, s_port, boost::asio::ip::resolver_query_base::passive); - d_endpoint = *resolver.resolve(query); - - d_socket = std::make_unique<boost::asio::ip::udp::socket>(d_io_service); - d_socket->open(d_endpoint.protocol()); - - boost::asio::socket_base::reuse_address roption(true); - d_socket->set_option(roption); - - d_socket->bind(d_endpoint); - - start_receive(); - d_udp_thread = - gr::thread::thread(boost::bind(&udp_source_impl::run_io_service, this)); - d_connected = true; - } -} - -void udp_source_impl::disconnect() -{ - gr::thread::scoped_lock lock(d_setlock); - - if (!d_connected) - return; - - d_io_service.reset(); - d_io_service.stop(); - d_udp_thread.join(); - - d_socket->close(); - d_socket.reset(); - - d_connected = false; -} - -// Return port number of d_socket -int udp_source_impl::get_port(void) -{ - // return d_endpoint.port(); - return d_socket->local_endpoint().port(); -} - -void udp_source_impl::start_receive() -{ - d_socket->async_receive_from( - boost::asio::buffer((void*)d_rxbuf.data(), d_payload_size), - d_endpoint_rcvd, - boost::bind(&udp_source_impl::handle_read, - this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); -} - -void udp_source_impl::handle_read(const boost::system::error_code& error, - size_t bytes_transferred) -{ - if (!error) { - { - boost::lock_guard<gr::thread::mutex> lock(d_udp_mutex); - if (d_eof && (bytes_transferred == 0)) { - // If we are using EOF notification, test for it and don't - // add anything to the output. - d_residual = WORK_DONE; - d_cond_wait.notify_one(); - return; - } else { - // Make sure we never go beyond the boundary of the - // residual buffer. This will just drop the last bit of - // data in the buffer if we've run out of room. - if ((int)(d_residual + bytes_transferred) >= - (BUF_SIZE_PAYLOADS * d_payload_size)) { - GR_LOG_WARN(d_logger, "Too much data; dropping packet."); - } else { - // otherwise, copy received data into local buffer for - // copying later. - memcpy(d_residbuf.data() + d_residual, - d_rxbuf.data(), - bytes_transferred); - d_residual += bytes_transferred; - } - } - d_cond_wait.notify_one(); - } - } - start_receive(); -} - -int udp_source_impl::work(int noutput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) -{ - gr::thread::scoped_lock l(d_setlock); - - char* out = (char*)output_items[0]; - - // Use async receive_from to get data from UDP buffer and wait - // on a conditional signal before proceeding. We use this - // because the conditional wait is interruptible while a - // synchronous receive_from is not. - boost::unique_lock<boost::mutex> lock(d_udp_mutex); - - // use timed_wait to avoid permanent blocking in the work function - d_cond_wait.timed_wait(lock, boost::posix_time::milliseconds(10)); - - if (d_residual < 0) { - return d_residual; - } - - const std::ptrdiff_t bytes_left_in_buffer = d_residual - d_sent; - auto bytes_to_send = - std::min<std::ptrdiff_t>(d_itemsize * noutput_items, bytes_left_in_buffer); - - // Copy the received data in the residual buffer to the output stream - memcpy(out, d_residbuf.data() + d_sent, bytes_to_send); - - // Keep track of where we are if we don't have enough output - // space to send all the data in the residbuf. - if (bytes_to_send == bytes_left_in_buffer) { - d_residual = 0; - d_sent = 0; - } else { - d_sent += bytes_to_send; - } - - return bytes_to_send / d_itemsize; -} - -} /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/udp_source_impl.h b/gr-blocks/lib/udp_source_impl.h deleted file mode 100644 index a2dc2dc9dc..0000000000 --- a/gr-blocks/lib/udp_source_impl.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007-2010,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_GR_UDP_SOURCE_IMPL_H -#define INCLUDED_GR_UDP_SOURCE_IMPL_H - -#include <gnuradio/blocks/udp_source.h> -#include <gnuradio/thread/thread.h> -#include <boost/asio.hpp> -#include <boost/format.hpp> -#include <cstddef> -#include <memory> - -namespace gr { -namespace blocks { - -class udp_source_impl : public udp_source -{ -private: - const size_t d_itemsize; - int d_payload_size; // maximum transmission unit (packet length) - const bool d_eof; // look for an EOF signal - bool d_connected; // are we connected? - std::vector<char> d_rxbuf; // get UDP buffer items - std::vector<char> d_residbuf; // hold buffer between calls - std::ptrdiff_t - d_residual; // hold information about number of bytes stored in residbuf - size_t d_sent; // track how much of d_residbuf we've outputted - - static const int - BUF_SIZE_PAYLOADS; //!< The d_residbuf size in multiples of d_payload_size - - std::string d_host; - unsigned short d_port; - - std::unique_ptr<boost::asio::ip::udp::socket> d_socket; - boost::asio::ip::udp::endpoint d_endpoint; - boost::asio::ip::udp::endpoint d_endpoint_rcvd; - boost::asio::io_service d_io_service; - - gr::thread::condition_variable d_cond_wait; - gr::thread::mutex d_udp_mutex; - gr::thread::thread d_udp_thread; - - void start_receive(); - void handle_read(const boost::system::error_code& error, size_t bytes_transferred); - void run_io_service() { d_io_service.run(); } - -public: - udp_source_impl( - size_t itemsize, const std::string& host, int port, int payload_size, bool eof); - ~udp_source_impl() override; - - void connect(const std::string& host, int port) override; - void disconnect() override; - - int payload_size() override { return d_payload_size; } - int get_port() override; - - int work(int noutput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) override; -}; - -} /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_UDP_SOURCE_H */ diff --git a/gr-blocks/python/blocks/bindings/CMakeLists.txt b/gr-blocks/python/blocks/bindings/CMakeLists.txt index 28e9c22537..b4e300a0f1 100644 --- a/gr-blocks/python/blocks/bindings/CMakeLists.txt +++ b/gr-blocks/python/blocks/bindings/CMakeLists.txt @@ -140,15 +140,12 @@ list(APPEND blocks_python_files tagged_stream_multiply_length_python.cc tagged_stream_mux_python.cc tags_strobe_python.cc - tcp_server_sink_python.cc test_tag_variable_rate_ff_python.cc threshold_ff_python.cc throttle_python.cc transcendental_python.cc tsb_vector_sink_python.cc uchar_to_float_python.cc - udp_sink_python.cc - udp_source_python.cc unpack_k_bits_python.cc unpack_k_bits_bb_python.cc unpacked_to_packed_python.cc diff --git a/gr-blocks/python/blocks/bindings/docstrings/tcp_server_sink_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/tcp_server_sink_pydoc_template.h deleted file mode 100644 index cca0eb1992..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/tcp_server_sink_pydoc_template.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_tcp_server_sink = R"doc()doc"; - - -static const char* __doc_gr_blocks_tcp_server_sink_tcp_server_sink = R"doc()doc"; - - -static const char* __doc_gr_blocks_tcp_server_sink_make = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/docstrings/udp_sink_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/udp_sink_pydoc_template.h deleted file mode 100644 index 316a0eed35..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/udp_sink_pydoc_template.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_udp_sink = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_sink_udp_sink_0 = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_sink_udp_sink_1 = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_sink_make = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_sink_payload_size = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_sink_connect = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_sink_disconnect = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/docstrings/udp_source_pydoc_template.h b/gr-blocks/python/blocks/bindings/docstrings/udp_source_pydoc_template.h deleted file mode 100644 index d0ed635ea3..0000000000 --- a/gr-blocks/python/blocks/bindings/docstrings/udp_source_pydoc_template.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ -#include "pydoc_macros.h" -#define D(...) DOC(gr, blocks, __VA_ARGS__) -/* - This file contains placeholders for docstrings for the Python bindings. - Do not edit! These were automatically extracted during the binding process - and will be overwritten during the build process - */ - - -static const char* __doc_gr_blocks_udp_source = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_source_udp_source_0 = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_source_udp_source_1 = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_source_make = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_source_connect = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_source_disconnect = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_source_payload_size = R"doc()doc"; - - -static const char* __doc_gr_blocks_udp_source_get_port = R"doc()doc"; diff --git a/gr-blocks/python/blocks/bindings/python_bindings.cc b/gr-blocks/python/blocks/bindings/python_bindings.cc index a9435c7107..7b8f0a4f3b 100644 --- a/gr-blocks/python/blocks/bindings/python_bindings.cc +++ b/gr-blocks/python/blocks/bindings/python_bindings.cc @@ -144,15 +144,12 @@ void bind_tagged_stream_align(py::module&); void bind_tagged_stream_multiply_length(py::module&); void bind_tagged_stream_mux(py::module&); void bind_tags_strobe(py::module&); -void bind_tcp_server_sink(py::module&); void bind_test_tag_variable_rate_ff(py::module&); void bind_threshold_ff(py::module&); void bind_throttle(py::module&); void bind_transcendental(py::module&); void bind_tsb_vector_sink(py::module&); void bind_uchar_to_float(py::module&); -void bind_udp_sink(py::module&); -void bind_udp_source(py::module&); void bind_unpack_k_bits(py::module&); void bind_unpack_k_bits_bb(py::module&); void bind_unpacked_to_packed(py::module&); @@ -318,15 +315,12 @@ PYBIND11_MODULE(blocks_python, m) bind_tagged_stream_multiply_length(m); bind_tagged_stream_mux(m); bind_tags_strobe(m); - bind_tcp_server_sink(m); bind_test_tag_variable_rate_ff(m); bind_threshold_ff(m); bind_throttle(m); bind_transcendental(m); bind_tsb_vector_sink(m); bind_uchar_to_float(m); - bind_udp_sink(m); - bind_udp_source(m); bind_unpack_k_bits(m); bind_unpack_k_bits_bb(m); bind_unpacked_to_packed(m); diff --git a/gr-blocks/python/blocks/bindings/tcp_server_sink_python.cc b/gr-blocks/python/blocks/bindings/tcp_server_sink_python.cc deleted file mode 100644 index f98317c411..0000000000 --- a/gr-blocks/python/blocks/bindings/tcp_server_sink_python.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(tcp_server_sink.h) */ -/* BINDTOOL_HEADER_FILE_HASH(9f8a488c6a838cb20c718b515e039594) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/tcp_server_sink.h> -// pydoc.h is automatically generated in the build directory -#include <tcp_server_sink_pydoc.h> - -void bind_tcp_server_sink(py::module& m) -{ - - using tcp_server_sink = ::gr::blocks::tcp_server_sink; - - - py::class_<tcp_server_sink, - gr::sync_block, - gr::block, - gr::basic_block, - std::shared_ptr<tcp_server_sink>>(m, "tcp_server_sink", D(tcp_server_sink)) - - .def(py::init(&tcp_server_sink::make), - py::arg("itemsize"), - py::arg("host"), - py::arg("port"), - py::arg("noblock") = false, - D(tcp_server_sink, make)) - - - ; -} diff --git a/gr-blocks/python/blocks/bindings/udp_sink_python.cc b/gr-blocks/python/blocks/bindings/udp_sink_python.cc deleted file mode 100644 index f13313b64b..0000000000 --- a/gr-blocks/python/blocks/bindings/udp_sink_python.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(udp_sink.h) */ -/* BINDTOOL_HEADER_FILE_HASH(b661fa9adabd289dfb26ffd01bab1a8d) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/udp_sink.h> -// pydoc.h is automatically generated in the build directory -#include <udp_sink_pydoc.h> - -void bind_udp_sink(py::module& m) -{ - - using udp_sink = ::gr::blocks::udp_sink; - - - py::class_<udp_sink, - gr::sync_block, - gr::block, - gr::basic_block, - std::shared_ptr<udp_sink>>(m, "udp_sink", D(udp_sink)) - - .def(py::init(&udp_sink::make), - py::arg("itemsize"), - py::arg("host"), - py::arg("port"), - py::arg("payload_size") = 1472, - py::arg("eof") = true, - D(udp_sink, make)) - - - .def("payload_size", &udp_sink::payload_size, D(udp_sink, payload_size)) - - - .def("connect", - &udp_sink::connect, - py::arg("host"), - py::arg("port"), - D(udp_sink, connect)) - - - .def("disconnect", &udp_sink::disconnect, D(udp_sink, disconnect)) - - ; -} diff --git a/gr-blocks/python/blocks/bindings/udp_source_python.cc b/gr-blocks/python/blocks/bindings/udp_source_python.cc deleted file mode 100644 index bc5590f6a0..0000000000 --- a/gr-blocks/python/blocks/bindings/udp_source_python.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -/***********************************************************************************/ -/* This file is automatically generated using bindtool and can be manually edited */ -/* The following lines can be configured to regenerate this file during cmake */ -/* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ -/* BINDTOOL_HEADER_FILE(udp_source.h) */ -/* BINDTOOL_HEADER_FILE_HASH(be808fc0ee5ca0d58c71e38a5734c955) */ -/***********************************************************************************/ - -#include <pybind11/complex.h> -#include <pybind11/pybind11.h> -#include <pybind11/stl.h> - -namespace py = pybind11; - -#include <gnuradio/blocks/udp_source.h> -// pydoc.h is automatically generated in the build directory -#include <udp_source_pydoc.h> - -void bind_udp_source(py::module& m) -{ - - using udp_source = ::gr::blocks::udp_source; - - - py::class_<udp_source, - gr::sync_block, - gr::block, - gr::basic_block, - std::shared_ptr<udp_source>>(m, "udp_source", D(udp_source)) - - .def(py::init(&udp_source::make), - py::arg("itemsize"), - py::arg("host"), - py::arg("port"), - py::arg("payload_size") = 1472, - py::arg("eof") = true, - D(udp_source, make)) - - - .def("connect", - &udp_source::connect, - py::arg("host"), - py::arg("port"), - D(udp_source, connect)) - - - .def("disconnect", &udp_source::disconnect, D(udp_source, disconnect)) - - - .def("payload_size", &udp_source::payload_size, D(udp_source, payload_size)) - - - .def("get_port", &udp_source::get_port, D(udp_source, get_port)) - - ; -} |