diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2021-06-04 22:13:27 +0200 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2021-06-08 22:07:58 +0200 |
commit | f29be5398081e78ed0edeaf712cc608e770f2523 (patch) | |
tree | 2f872185ae4644f1f38c74d14507c2c00a138d11 | |
parent | 8b33608eb6144a9a092f7ba90722865cb1f6a430 (diff) |
uhd: pybind rfnoc_graph,_rx/tx_streamer
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
8 files changed, 261 insertions, 10 deletions
diff --git a/gr-uhd/python/uhd/bindings/CMakeLists.txt b/gr-uhd/python/uhd/bindings/CMakeLists.txt index 8d123da16c..b5116952fc 100644 --- a/gr-uhd/python/uhd/bindings/CMakeLists.txt +++ b/gr-uhd/python/uhd/bindings/CMakeLists.txt @@ -5,16 +5,26 @@ include(GrPybind) ######################################################################## list(APPEND uhd_python_files - uhd_types_python.cc - amsg_source_python.cc - usrp_block_python.cc - usrp_sink_python.cc - usrp_source_python.cc - python_bindings.cc) + uhd_types_python.cc + amsg_source_python.cc + usrp_block_python.cc + usrp_sink_python.cc + usrp_source_python.cc + python_bindings.cc + ) -GR_PYBIND_MAKE(uhd - ../../.. - gr::uhd - "${uhd_python_files}") +if(ENABLE_UHD_RFNOC) + add_definitions(-DGR_ENABLE_UHD_RFNOC) + list(APPEND uhd_python_files + rfnoc_graph_python.cc + rfnoc_rx_streamer_python.cc + rfnoc_tx_streamer_python.cc + ) +endif() + +GR_PYBIND_MAKE(uhd + ../../.. + gr::uhd + "${uhd_python_files}") install(TARGETS uhd_python DESTINATION ${GR_PYTHON_DIR}/gnuradio/uhd COMPONENT pythonapi) diff --git a/gr-uhd/python/uhd/bindings/docstrings/rfnoc_graph_pydoc_template.h b/gr-uhd/python/uhd/bindings/docstrings/rfnoc_graph_pydoc_template.h new file mode 100644 index 0000000000..d72f35dc01 --- /dev/null +++ b/gr-uhd/python/uhd/bindings/docstrings/rfnoc_graph_pydoc_template.h @@ -0,0 +1,36 @@ +/* + * Copyright 2021 Marcus Müller + * + * This file is part of GNU Radio + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ +#include "pydoc_macros.h" +#define D(...) DOC(gr, uhd, __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_uhd_rfnoc_graph = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_graph_make = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_graph_connect = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_graph_create_rx_streamer = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_graph_create_tx_streamer = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_graph_commit = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_graph_get_block_id = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_graph_set_time_source = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_graph_set_clock_source = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_graph_get_block_ref = R"doc()doc"; diff --git a/gr-uhd/python/uhd/bindings/docstrings/rfnoc_rx_streamer_pydoc_template.h b/gr-uhd/python/uhd/bindings/docstrings/rfnoc_rx_streamer_pydoc_template.h new file mode 100644 index 0000000000..86c3acf8d2 --- /dev/null +++ b/gr-uhd/python/uhd/bindings/docstrings/rfnoc_rx_streamer_pydoc_template.h @@ -0,0 +1,22 @@ +/* + * Copyright 2021 Marcus Müller + * + * This file is part of GNU Radio + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ +#include "pydoc_macros.h" +#define D(...) DOC(gr, uhd, __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_uhd_rfnoc_rx_streamer = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_rx_streamer_make = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_rx_streamer_get_unique_id = R"doc()doc"; diff --git a/gr-uhd/python/uhd/bindings/docstrings/rfnoc_tx_streamer_pydoc_template.h b/gr-uhd/python/uhd/bindings/docstrings/rfnoc_tx_streamer_pydoc_template.h new file mode 100644 index 0000000000..c0d974e495 --- /dev/null +++ b/gr-uhd/python/uhd/bindings/docstrings/rfnoc_tx_streamer_pydoc_template.h @@ -0,0 +1,22 @@ +/* + * Copyright 2021 Marcus Müller + * + * This file is part of GNU Radio + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ +#include "pydoc_macros.h" +#define D(...) DOC(gr, uhd, __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_uhd_rfnoc_tx_streamer = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_tx_streamer_make = R"doc()doc"; + +static const char* __doc_gr_uhd_rfnoc_tx_streamer_get_unique_id = R"doc()doc"; diff --git a/gr-uhd/python/uhd/bindings/python_bindings.cc b/gr-uhd/python/uhd/bindings/python_bindings.cc index e32d1b48cc..70b819df92 100644 --- a/gr-uhd/python/uhd/bindings/python_bindings.cc +++ b/gr-uhd/python/uhd/bindings/python_bindings.cc @@ -22,6 +22,9 @@ void bind_amsg_source(py::module&); void bind_usrp_block(py::module&); void bind_usrp_sink(py::module&); void bind_usrp_source(py::module&); +void bind_rfnoc_graph(py::module&); +void bind_rfnoc_rx_streamer(py::module&); +void bind_rfnoc_tx_streamer(py::module&); // We need this hack because import_array() returns NULL // for newer Python versions. @@ -48,6 +51,12 @@ PYBIND11_MODULE(uhd_python, m) bind_usrp_sink(m); bind_usrp_source(m); +#ifdef GR_ENABLE_UHD_RFNOC + bind_rfnoc_graph(m); + bind_rfnoc_rx_streamer(m); + bind_rfnoc_tx_streamer(m); +#endif + m.def( "get_version_string", []() { return ::uhd::get_version_string(); }, diff --git a/gr-uhd/python/uhd/bindings/rfnoc_graph_python.cc b/gr-uhd/python/uhd/bindings/rfnoc_graph_python.cc new file mode 100644 index 0000000000..0544a1e365 --- /dev/null +++ b/gr-uhd/python/uhd/bindings/rfnoc_graph_python.cc @@ -0,0 +1,66 @@ +/* + * Copyright 2021 Marcus Müller + * + * 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(rfnoc_graph.h) */ +/* BINDTOOL_HEADER_FILE_HASH(1e32bbc2f1a925bf00fafbcf5a16bf24) */ +/***********************************************************************************/ + +#include <pybind11/complex.h> +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> + +namespace py = pybind11; + +#include <gnuradio/uhd/rfnoc_graph.h> +// pydoc.h is automatically generated in the build directory +#include <rfnoc_graph_pydoc.h> + +void bind_rfnoc_graph(py::module& m) +{ + + using rfnoc_graph = ::gr::uhd::rfnoc_graph; + + + py::class_<rfnoc_graph, std::shared_ptr<rfnoc_graph>>( + m, "rfnoc_graph", D(rfnoc_graph)) + + .def(py::init(&rfnoc_graph::make), D(rfnoc_graph, make)) + .def("connect", + py::overload_cast<const std::string&, + const size_t, + const std::string&, + const size_t, + const bool>(&rfnoc_graph::connect), + D(rfnoc_graph, connect)) + .def("connect", + py::overload_cast<const std::string&, const std::string&, const bool>( + &rfnoc_graph::connect), + D(rfnoc_graph, connect)) + .def("create_rx_streamer", + &rfnoc_graph::create_rx_streamer, + D(rfnoc_graph, create_rx_streamer)) + .def("create_tx_streamer", + &rfnoc_graph::create_tx_streamer, + D(rfnoc_graph, create_tx_streamer)) + .def("commit", &rfnoc_graph::commit, D(rfnoc_graph, commit)) + .def("get_block_id", &rfnoc_graph::get_block_id, D(rfnoc_graph, get_block_id)) + .def("set_time_source", + &rfnoc_graph::set_time_source, + D(rfnoc_graph, set_time_source)) + .def("set_clock_source", + &rfnoc_graph::set_clock_source, + D(rfnoc_graph, set_clock_source)) + .def("get_block_ref", &rfnoc_graph::get_block_ref, D(rfnoc_graph, get_block_ref)); +} diff --git a/gr-uhd/python/uhd/bindings/rfnoc_rx_streamer_python.cc b/gr-uhd/python/uhd/bindings/rfnoc_rx_streamer_python.cc new file mode 100644 index 0000000000..fc8aa8c23c --- /dev/null +++ b/gr-uhd/python/uhd/bindings/rfnoc_rx_streamer_python.cc @@ -0,0 +1,43 @@ +/* + * Copyright 2021 Marcus Müller + * + * 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(rfnoc_rx_streamer.h) */ +/* BINDTOOL_HEADER_FILE_HASH(c9627fa218093e7f23303f35d8fe709cd) */ +/***********************************************************************************/ + +#include <pybind11/complex.h> +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> + +namespace py = pybind11; + +#include <gnuradio/uhd/rfnoc_rx_streamer.h> +// pydoc.h is automatically generated in the build directory +#include <rfnoc_rx_streamer_pydoc.h> + +void bind_rfnoc_rx_streamer(py::module& m) +{ + + using rfnoc_rx_streamer = ::gr::uhd::rfnoc_rx_streamer; + + + py::class_<rfnoc_rx_streamer, std::shared_ptr<rfnoc_rx_streamer>>( + m, "rfnoc_rx_streamer", D(rfnoc_rx_streamer)) + + .def(py::init(&rfnoc_rx_streamer::make), D(rfnoc_rx_streamer, make)) + .def("get_unique_id", + &rfnoc_rx_streamer::get_unique_id, + D(rfnoc_rx_streamer, get_unique_id)); +} diff --git a/gr-uhd/python/uhd/bindings/rfnoc_tx_streamer_python.cc b/gr-uhd/python/uhd/bindings/rfnoc_tx_streamer_python.cc new file mode 100644 index 0000000000..f35ad96b4f --- /dev/null +++ b/gr-uhd/python/uhd/bindings/rfnoc_tx_streamer_python.cc @@ -0,0 +1,43 @@ +/* + * Copyright 2021 Marcus Müller + * + * 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(rfnoc_tx_streamer.h) */ +/* BINDTOOL_HEADER_FILE_HASH(c9627fa218093e7f23303f35d8fe709c) */ +/***********************************************************************************/ + +#include <pybind11/complex.h> +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> + +namespace py = pybind11; + +#include <gnuradio/uhd/rfnoc_tx_streamer.h> +// pydoc.h is automatically generated in the build directory +#include <rfnoc_tx_streamer_pydoc.h> + +void bind_rfnoc_tx_streamer(py::module& m) +{ + + using rfnoc_tx_streamer = ::gr::uhd::rfnoc_tx_streamer; + + + py::class_<rfnoc_tx_streamer, std::shared_ptr<rfnoc_tx_streamer>>( + m, "rfnoc_tx_streamer", D(rfnoc_tx_streamer)) + + .def(py::init(&rfnoc_tx_streamer::make), D(rfnoc_tx_streamer, make)) + .def("get_unique_id", + &rfnoc_tx_streamer::get_unique_id, + D(rfnoc_tx_streamer, get_unique_id)); +} |