Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gr-network's UDP Sink in GNU Radio >= 3.10 #982

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ include(FindPkgConfig)
find_package(Gnuradio-osmosdr REQUIRED)

set(GR_REQUIRED_COMPONENTS RUNTIME ANALOG AUDIO BLOCKS DIGITAL FILTER FFT PMT)
find_package(Gnuradio REQUIRED COMPONENTS analog audio blocks digital filter fft)
find_package(Gnuradio REQUIRED COMPONENTS analog audio blocks digital filter fft network)
if(Gnuradio_VERSION VERSION_LESS "3.8")
find_package(Volk)
endif()
Expand Down
1 change: 1 addition & 0 deletions resources/news.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

NEW: Added SoapyRemote to AppImage and DMG releases.
NEW: Added SoapyPlutoSDR to DMG release.
NEW: Preliminary support for GNU Radio 3.10.
FIXED: Compatibility with case-sensitive filesystems on MacOS.


Expand Down
12 changes: 11 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,17 @@ target_link_libraries(${PROJECT_NAME}
${VOLK_LIBRARIES}
)

if(NOT Gnuradio_VERSION VERSION_LESS "3.8")
if(NOT Gnuradio_VERSION VERSION_LESS "3.10")
target_link_libraries(${PROJECT_NAME}
gnuradio::gnuradio-analog
gnuradio::gnuradio-blocks
gnuradio::gnuradio-digital
gnuradio::gnuradio-filter
gnuradio::gnuradio-network
gnuradio::gnuradio-audio
Volk::volk
)
elseif(NOT Gnuradio_VERSION VERSION_LESS "3.8")
target_link_libraries(${PROJECT_NAME}
gnuradio::gnuradio-analog
gnuradio::gnuradio-blocks
Expand Down
20 changes: 19 additions & 1 deletion src/interfaces/udp_sink_f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#if GNURADIO_VERSION < 0x031000
#include <gnuradio/blocks/udp_sink.h>
#else
#include <gnuradio/network/udp_header_types.h>
#include <gnuradio/network/udp_sink.h>
#endif

#include <gnuradio/hier_block2.h>
#include <gnuradio/blocks/float_to_short.h>
#include <gnuradio/blocks/udp_sink.h>
#include <gnuradio/io_signature.h>

#include <iostream>
Expand Down Expand Up @@ -52,6 +58,7 @@ udp_sink_f::udp_sink_f()
{

d_f2s = gr::blocks::float_to_short::make(1, 32767);
#if GNURADIO_VERSION < 0x031000
#ifdef GQRX_OS_MACX
// There seems to be excessive packet loss (even to localhost) on OS X
// unless the buffer size is limited.
Expand All @@ -60,6 +67,7 @@ udp_sink_f::udp_sink_f()
d_sink = gr::blocks::udp_sink::make(sizeof(short), "localhost", 7355);
#endif
d_sink->disconnect();
#endif

d_inter = gr::blocks::interleave::make(sizeof(float));
d_null0 = gr::blocks::null_sink::make(sizeof(float));
Expand Down Expand Up @@ -87,6 +95,10 @@ void udp_sink_f::start_streaming(const std::string host, int port, bool stereo)
std::cout << ", Port: " << std::to_string(port) << ", ";
std::cout << (stereo ? "Stereo" : "Mono") << std::endl;

#if GNURADIO_VERSION >= 0x031000
d_sink = gr::network::udp_sink::make(sizeof(short), 1, host, port, HEADERTYPE_NONE, 1448, true);
#endif

if (stereo)
{
connect(self(), 0, d_inter, 0);
Expand All @@ -102,7 +114,9 @@ void udp_sink_f::start_streaming(const std::string host, int port, bool stereo)
}
unlock();

#if GNURADIO_VERSION < 0x031000
d_sink->connect(host, port);
#endif
}


Expand All @@ -116,5 +130,9 @@ void udp_sink_f::stop_streaming(void)

std::cout << "Disconnected UDP streaming" << std::endl;

#if GNURADIO_VERSION < 0x031000
d_sink->disconnect();
#else
d_sink = nullptr;
#endif
}
11 changes: 10 additions & 1 deletion src/interfaces/udp_sink_f.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@
#ifndef UDP_SINK_F_H
#define UDP_SINK_F_H

#if GNURADIO_VERSION < 0x031000
#include <gnuradio/blocks/udp_sink.h>
#else
#include <gnuradio/network/udp_sink.h>
#endif

#include <gnuradio/hier_block2.h>
#include <gnuradio/blocks/float_to_short.h>
#include <gnuradio/blocks/udp_sink.h>
#include <gnuradio/blocks/interleave.h>
#include <gnuradio/blocks/null_sink.h>

Expand All @@ -50,7 +55,11 @@ class udp_sink_f : public gr::hier_block2
void stop_streaming(void);

private:
#if GNURADIO_VERSION < 0x031000
gr::blocks::udp_sink::sptr d_sink; /*!< The gnuradio UDP sink. */
#else
gr::network::udp_sink::sptr d_sink; /*!< The gnuradio UDP sink. */
#endif
gr::blocks::float_to_short::sptr d_f2s; /*!< Converts float to short. */
gr::blocks::interleave::sptr d_inter; /*!< Stereo interleaver. */
gr::blocks::null_sink::sptr d_null0; /*!< Null sink for mono. */
Expand Down