Created
February 14, 2024 18:39
-
-
Save marcusmueller/f03ff708e0975c82dc80c06156c1ae3b to your computer and use it in GitHub Desktop.
reproduction Flowgraph for https://github.com/gnuradio/gnuradio/issues/5222
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2011 Free Software Foundation, Inc. | |
* | |
* This file was generated by gr_modtool, a tool from the GNU Radio framework | |
* This file is a part of gr-mymod | |
* | |
* SPDX-License-Identifier: GPL-3.0-or-later | |
* | |
*/ | |
#ifndef INCLUDED_MYMOD_API_H | |
#define INCLUDED_MYMOD_API_H | |
#include <gnuradio/attributes.h> | |
#ifdef gnuradio_mymod_EXPORTS | |
#define MYMOD_API __GR_ATTR_EXPORT | |
#else | |
#define MYMOD_API __GR_ATTR_IMPORT | |
#endif | |
#endif /* INCLUDED_MYMOD_API_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2011 Free Software Foundation, Inc. | |
# | |
# This file was generated by gr_modtool, a tool from the GNU Radio framework | |
# This file is a part of gr-mymod | |
# | |
# SPDX-License-Identifier: GPL-3.0-or-later | |
# | |
######################################################################## | |
# Include python install macros | |
######################################################################## | |
include(GrPython) | |
if(NOT PYTHONINTERP_FOUND) | |
return() | |
endif() | |
add_subdirectory(bindings) | |
######################################################################## | |
# Install python sources | |
######################################################################## | |
gr_python_install(FILES __init__.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/mymod) | |
######################################################################## | |
# Handle the unit tests | |
######################################################################## | |
include(GrTest) | |
set(GR_TEST_TARGET_DEPS gnuradio-mymod) | |
# Create a package directory that tests can import. It includes everything | |
# from `python/`. | |
add_custom_target( | |
copy_module_for_tests ALL | |
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR} | |
${PROJECT_BINARY_DIR}/test_modules/gnuradio/mymod/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...) | |
# | |
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for | |
# parsing the arguments given to that macro or function. | |
# It processes the arguments and defines a set of variables which hold the | |
# values of the respective options. | |
# | |
# The <options> argument contains all options for the respective macro, | |
# i.e. keywords which can be used when calling the macro without any value | |
# following, like e.g. the OPTIONAL keyword of the install() command. | |
# | |
# The <one_value_keywords> argument contains all keywords for this macro | |
# which are followed by one value, like e.g. DESTINATION keyword of the | |
# install() command. | |
# | |
# The <multi_value_keywords> argument contains all keywords for this macro | |
# which can be followed by more than one value, like e.g. the TARGETS or | |
# FILES keywords of the install() command. | |
# | |
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the | |
# keywords listed in <options>, <one_value_keywords> and | |
# <multi_value_keywords> a variable composed of the given <prefix> | |
# followed by "_" and the name of the respective keyword. | |
# These variables will then hold the respective value from the argument list. | |
# For the <options> keywords this will be TRUE or FALSE. | |
# | |
# All remaining arguments are collected in a variable | |
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether | |
# your macro was called with unrecognized parameters. | |
# | |
# As an example here a my_install() macro, which takes similar arguments as the | |
# real install() command: | |
# | |
# function(MY_INSTALL) | |
# set(options OPTIONAL FAST) | |
# set(oneValueArgs DESTINATION RENAME) | |
# set(multiValueArgs TARGETS CONFIGURATIONS) | |
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) | |
# ... | |
# | |
# Assume my_install() has been called like this: | |
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) | |
# | |
# After the cmake_parse_arguments() call the macro will have set the following | |
# variables: | |
# MY_INSTALL_OPTIONAL = TRUE | |
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() | |
# MY_INSTALL_DESTINATION = "bin" | |
# MY_INSTALL_RENAME = "" (was not used) | |
# MY_INSTALL_TARGETS = "foo;bar" | |
# MY_INSTALL_CONFIGURATIONS = "" (was not used) | |
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" | |
# | |
# You can the continue and process these variables. | |
# | |
# Keywords terminate lists of values, e.g. if directly after a one_value_keyword | |
# another recognized keyword follows, this is interpreted as the beginning of | |
# the new option. | |
# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in | |
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would | |
# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefore. | |
#============================================================================= | |
# Copyright 2010 Alexander Neundorf <neundorf@kde.org> | |
# | |
# Distributed under the OSI-approved BSD License (the "License"); | |
# see accompanying file Copyright.txt for details. | |
# | |
# This software is distributed WITHOUT ANY WARRANTY; without even the | |
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
# See the License for more information. | |
#============================================================================= | |
# (To distribute this file outside of CMake, substitute the full | |
# License text for the above reference.) | |
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) | |
return() | |
endif() | |
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) | |
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) | |
# first set all result variables to empty/FALSE | |
foreach(arg_name ${_singleArgNames} ${_multiArgNames}) | |
set(${prefix}_${arg_name}) | |
endforeach(arg_name) | |
foreach(option ${_optionNames}) | |
set(${prefix}_${option} FALSE) | |
endforeach(option) | |
set(${prefix}_UNPARSED_ARGUMENTS) | |
set(insideValues FALSE) | |
set(currentArgName) | |
# now iterate over all arguments and fill the result variables | |
foreach(currentArg ${ARGN}) | |
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword | |
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword | |
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword | |
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) | |
if(insideValues) | |
if("${insideValues}" STREQUAL "SINGLE") | |
set(${prefix}_${currentArgName} ${currentArg}) | |
set(insideValues FALSE) | |
elseif("${insideValues}" STREQUAL "MULTI") | |
list(APPEND ${prefix}_${currentArgName} ${currentArg}) | |
endif() | |
else(insideValues) | |
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) | |
endif(insideValues) | |
else() | |
if(NOT ${optionIndex} EQUAL -1) | |
set(${prefix}_${currentArg} TRUE) | |
set(insideValues FALSE) | |
elseif(NOT ${singleArgIndex} EQUAL -1) | |
set(currentArgName ${currentArg}) | |
set(${prefix}_${currentArgName}) | |
set(insideValues "SINGLE") | |
elseif(NOT ${multiArgIndex} EQUAL -1) | |
set(currentArgName ${currentArg}) | |
set(${prefix}_${currentArgName}) | |
set(insideValues "MULTI") | |
endif() | |
endif() | |
endforeach(currentArg) | |
# propagate the result variables to the caller: | |
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) | |
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) | |
endforeach(arg_name) | |
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) | |
endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -*- c++ -*- */ | |
/* | |
* Copyright 2024 gr-mymod author. | |
* | |
* SPDX-License-Identifier: GPL-3.0-or-later | |
*/ | |
#ifndef INCLUDED_MYMOD_MYBLOCK_H | |
#define INCLUDED_MYMOD_MYBLOCK_H | |
#include <gnuradio/mymod/api.h> | |
#include <gnuradio/sync_block.h> | |
namespace gr { | |
namespace mymod { | |
/*! | |
* \brief <+description of block+> | |
* \ingroup mymod | |
* | |
*/ | |
class MYMOD_API myblock : virtual public gr::sync_block | |
{ | |
public: | |
typedef std::shared_ptr<myblock> sptr; | |
/*! | |
* \brief Return a shared_ptr to a new instance of mymod::myblock. | |
* | |
* To avoid accidental use of raw pointers, mymod::myblock's | |
* constructor is in a private implementation | |
* class. mymod::myblock::make is the public interface for | |
* creating new instances. | |
*/ | |
static sptr make(); | |
}; | |
} // namespace mymod | |
} // namespace gr | |
#endif /* INCLUDED_MYMOD_MYBLOCK_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -*- c++ -*- */ | |
/* | |
* Copyright 2024 gr-mymod author. | |
* | |
* SPDX-License-Identifier: GPL-3.0-or-later | |
*/ | |
#include "myblock_impl.h" | |
#include <gnuradio/io_signature.h> | |
namespace gr { | |
namespace mymod { | |
#pragma message("set the following appropriately and remove this warning") | |
using input_type = float; | |
#pragma message("set the following appropriately and remove this warning") | |
using output_type = float; | |
myblock::sptr myblock::make() { return gnuradio::make_block_sptr<myblock_impl>(); } | |
/* | |
* The private constructor | |
*/ | |
myblock_impl::myblock_impl() | |
: gr::sync_block("myblock", | |
gr::io_signature::make( | |
1 /* min inputs */, 1 /* max inputs */, sizeof(input_type)), | |
gr::io_signature::make( | |
1 /* min outputs */, 1 /*max outputs */, sizeof(output_type))) | |
{ | |
} | |
/* | |
* Our virtual destructor. | |
*/ | |
myblock_impl::~myblock_impl() {} | |
int myblock_impl::work(int noutput_items, | |
gr_vector_const_void_star& input_items, | |
gr_vector_void_star& output_items) | |
{ | |
auto in = static_cast<const input_type*>(input_items[0]); | |
auto out = static_cast<output_type*>(output_items[0]); | |
#pragma message("Implement the signal processing in your block and remove this warning") | |
// Do <+signal processing+> | |
// Tell runtime system how many output items we produced. | |
return noutput_items; | |
} | |
} /* namespace mymod */ | |
} /* namespace gr */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* -*- c++ -*- */ | |
/* | |
* Copyright 2024 gr-mymod author. | |
* | |
* SPDX-License-Identifier: GPL-3.0-or-later | |
*/ | |
#ifndef INCLUDED_MYMOD_MYBLOCK_IMPL_H | |
#define INCLUDED_MYMOD_MYBLOCK_IMPL_H | |
#include <gnuradio/mymod/myblock.h> | |
namespace gr { | |
namespace mymod { | |
class myblock_impl : public myblock | |
{ | |
private: | |
// Nothing to declare in this block. | |
public: | |
myblock_impl(); | |
~myblock_impl(); | |
// Where all the action really happens | |
int work(int noutput_items, | |
gr_vector_const_void_star& input_items, | |
gr_vector_void_star& output_items); | |
}; | |
} // namespace mymod | |
} // namespace gr | |
#endif /* INCLUDED_MYMOD_MYBLOCK_IMPL_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2024 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, mymod, __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_mymod_myblock = R"doc()doc"; | |
static const char *__doc_gr_mymod_myblock_myblock = R"doc()doc"; | |
static const char *__doc_gr_mymod_myblock_make = R"doc()doc"; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2024 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(myblock.h) */ | |
/* BINDTOOL_HEADER_FILE_HASH(6e8e96e073690b3a21fad76a317efb40) */ | |
/***********************************************************************************/ | |
#include <pybind11/complex.h> | |
#include <pybind11/pybind11.h> | |
#include <pybind11/stl.h> | |
namespace py = pybind11; | |
#include <gnuradio/mymod/myblock.h> | |
// pydoc.h is automatically generated in the build directory | |
#include <myblock_pydoc.h> | |
void bind_myblock(py::module& m) | |
{ | |
using myblock = gr::mymod::myblock; | |
py::class_<myblock, gr::sync_block, gr::block, gr::basic_block, | |
std::shared_ptr<myblock>>(m, "myblock", D(myblock)) | |
.def(py::init(&myblock::make), | |
D(myblock,make) | |
) | |
; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef PYDOC_MACROS_H | |
#define PYDOC_MACROS_H | |
#define __EXPAND(x) x | |
#define __COUNT(_1, _2, _3, _4, _5, _6, _7, COUNT, ...) COUNT | |
#define __VA_SIZE(...) __EXPAND(__COUNT(__VA_ARGS__, 7, 6, 5, 4, 3, 2, 1)) | |
#define __CAT1(a, b) a##b | |
#define __CAT2(a, b) __CAT1(a, b) | |
#define __DOC1(n1) __doc_##n1 | |
#define __DOC2(n1, n2) __doc_##n1##_##n2 | |
#define __DOC3(n1, n2, n3) __doc_##n1##_##n2##_##n3 | |
#define __DOC4(n1, n2, n3, n4) __doc_##n1##_##n2##_##n3##_##n4 | |
#define __DOC5(n1, n2, n3, n4, n5) __doc_##n1##_##n2##_##n3##_##n4##_##n5 | |
#define __DOC6(n1, n2, n3, n4, n5, n6) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6 | |
#define __DOC7(n1, n2, n3, n4, n5, n6, n7) \ | |
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7 | |
#define DOC(...) __EXPAND(__EXPAND(__CAT2(__DOC, __VA_SIZE(__VA_ARGS__)))(__VA_ARGS__)) | |
#endif // PYDOC_MACROS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2020 Free Software Foundation, Inc. | |
* | |
* This file is part of GNU Radio | |
* | |
* SPDX-License-Identifier: GPL-3.0-or-later | |
* | |
*/ | |
#include <pybind11/pybind11.h> | |
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION | |
#include <numpy/arrayobject.h> | |
namespace py = pybind11; | |
// Headers for binding functions | |
/**************************************/ | |
// The following comment block is used for | |
// gr_modtool to insert function prototypes | |
// Please do not delete | |
/**************************************/ | |
// BINDING_FUNCTION_PROTOTYPES( | |
void bind_myblock(py::module& m); | |
// ) END BINDING_FUNCTION_PROTOTYPES | |
// We need this hack because import_array() returns NULL | |
// for newer Python versions. | |
// This function is also necessary because it ensures access to the C API | |
// and removes a warning. | |
void* init_numpy() | |
{ | |
import_array(); | |
return NULL; | |
} | |
PYBIND11_MODULE(mymod_python, m) | |
{ | |
// Initialize the numpy C API | |
// (otherwise we will see segmentation faults) | |
init_numpy(); | |
// Allow access to base block methods | |
py::module::import("gnuradio.gr"); | |
/**************************************/ | |
// The following comment block is used for | |
// gr_modtool to insert binding function calls | |
// Please do not delete | |
/**************************************/ | |
// BINDING_FUNCTION_CALLS( | |
bind_myblock(m); | |
// ) END BINDING_FUNCTION_CALLS | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
modname=mymod | |
blkname=myblock | |
gr_modtool newmod $modname | |
cd gr-$modname | |
gr_modtool add -t sync -l cpp $blkname | |
gr_modtool makeyaml -y $blkname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment