diff options
author | Jacob Gilbert <jacob.gilbert@protonmail.com> | 2021-03-13 18:10:44 -0800 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-03-18 16:35:41 -0400 |
commit | a8a9913136a64da903f190493bdc117b5349625e (patch) | |
tree | cb14b39daa613397e324efd063f688c91e9b3bfa /gnuradio-runtime/python/gnuradio | |
parent | bd1e4d470c83470f1a54c2c4c85c8e475c070bfa (diff) |
gr-pdu: move pdu blocks to gr::pdu
Moving the following from gr::blocks into gr-pdu:
- pdu_filter block
- pdu_remove block
- pdu_set block
- pdu_to_tagged_stream block
- random_pdu block
- tagged_stream_to_pdu block
Moving the following from gr::blocks into gr-network:
- socket_pdu block
- stream_pdu_base (noblock)
- tcp_connection (noblock)
- tuntap_pdu block
Moving the following from gr::blocks into gr:
- pdu (noblock, general PDU functions)
Signed-off-by: Jacob Gilbert <jacob.gilbert@protonmail.com>
Diffstat (limited to 'gnuradio-runtime/python/gnuradio')
5 files changed, 150 insertions, 1 deletions
diff --git a/gnuradio-runtime/python/gnuradio/__init__.py b/gnuradio-runtime/python/gnuradio/__init__.py index 2326c3ab89..45bc91bf4d 100644 --- a/gnuradio-runtime/python/gnuradio/__init__.py +++ b/gnuradio-runtime/python/gnuradio/__init__.py @@ -57,4 +57,5 @@ if path.endswith(path_ending): __path__.append(os.path.join(build_path, 'gr-utils')) __path__.append(os.path.join(build_path, 'gr-uhd', 'python')) __path__.append(os.path.join(build_path, 'gr-pdu', 'python')) + __path__.append(os.path.join(build_path, 'gr-network', 'python')) __path__.append(os.path.join(build_path, 'gr-zeromq', 'python')) diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/CMakeLists.txt b/gnuradio-runtime/python/gnuradio/gr/bindings/CMakeLists.txt index 17b1a30590..ef8f1f10dd 100644 --- a/gnuradio-runtime/python/gnuradio/gr/bindings/CMakeLists.txt +++ b/gnuradio-runtime/python/gnuradio/gr/bindings/CMakeLists.txt @@ -42,6 +42,7 @@ messages/msg_queue_python.cc msg_handler_python.cc msg_queue_python.cc nco_python.cc + pdu_python.cc prefs_python.cc # pycallback_object_python.cc random_python.cc @@ -81,7 +82,7 @@ messages/msg_queue_python.cc # xoroshiro128p_python.cc python_bindings.cc) -GR_PYBIND_MAKE_CHECK_HASH(gr +GR_PYBIND_MAKE_CHECK_HASH(gr ../../../.. gr::gr "${gr_python_files}") diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/docstrings/pdu_pydoc_template.h b/gnuradio-runtime/python/gnuradio/gr/bindings/docstrings/pdu_pydoc_template.h new file mode 100644 index 0000000000..8ba6b5ddd0 --- /dev/null +++ b/gnuradio-runtime/python/gnuradio/gr/bindings/docstrings/pdu_pydoc_template.h @@ -0,0 +1,51 @@ +/* + * Copyright 2021 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, __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_msgport_names_bpdu = R"doc()doc"; + + +static const char* __doc_gr_msgport_names_cpdu = R"doc()doc"; + + +static const char* __doc_gr_msgport_names_dict = R"doc()doc"; + + +static const char* __doc_gr_msgport_names_fpdu = R"doc()doc"; + + +static const char* __doc_gr_msgport_names_msg = R"doc()doc"; + + +static const char* __doc_gr_msgport_names_pdu = R"doc()doc"; + + +static const char* __doc_gr_msgport_names_pdus = R"doc()doc"; + + +static const char* __doc_gr_msgport_names_vec = R"doc()doc"; + + +static const char* __doc_gr_pdu_itemsize = R"doc()doc"; + + +static const char* __doc_gr_pdu_type_matches = R"doc()doc"; + + +static const char* __doc_gr_pdu_make_pdu_vector = R"doc()doc"; + + +static const char* __doc_gr_pdu_type_from_pmt = R"doc()doc"; diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/pdu_python.cc b/gnuradio-runtime/python/gnuradio/gr/bindings/pdu_python.cc new file mode 100644 index 0000000000..98df9acd8c --- /dev/null +++ b/gnuradio-runtime/python/gnuradio/gr/bindings/pdu_python.cc @@ -0,0 +1,94 @@ +/* + * Copyright 2021 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(pdu.h) */ +/* BINDTOOL_HEADER_FILE_HASH(2b56328d8782d0a1816df04928cd83c5) */ +/***********************************************************************************/ + +#include <pybind11/complex.h> +#include <pybind11/pybind11.h> +#include <pybind11/stl.h> + +namespace py = pybind11; + +#include <gnuradio/pdu.h> +// pydoc.h is automatically generated in the build directory +#include <pdu_pydoc.h> + +void bind_pdu(py::module& m) +{ + + py::module m_types = m.def_submodule("types"); + + py::enum_<::gr::types::vector_type>(m_types, "vector_type") + .value("byte_t", ::gr::types::byte_t) // 0 + .value("float_t", ::gr::types::float_t) // 1 + .value("complex_t", ::gr::types::complex_t) // 2 + .export_values(); + + py::implicitly_convertible<int, ::gr::types::vector_type>(); + + + py::module m_msgport_names = m.def_submodule("msgport_names"); + + m_msgport_names.def("bpdu", &::gr::msgport_names::bpdu, D(msgport_names, bpdu)); + + + m_msgport_names.def("cpdu", &::gr::msgport_names::cpdu, D(msgport_names, cpdu)); + + + m_msgport_names.def("dict", &::gr::msgport_names::dict, D(msgport_names, dict)); + + + m_msgport_names.def("fpdu", &::gr::msgport_names::fpdu, D(msgport_names, fpdu)); + + + m_msgport_names.def("msg", &::gr::msgport_names::msg, D(msgport_names, msg)); + + + m_msgport_names.def("pdu", &::gr::msgport_names::pdu, D(msgport_names, pdu)); + + + m_msgport_names.def("pdus", &::gr::msgport_names::pdus, D(msgport_names, pdus)); + + + m_msgport_names.def("vec", &::gr::msgport_names::vec, D(msgport_names, vec)); + + + py::module m_pdu = m.def_submodule("pdu"); + + m_pdu.def("itemsize", &::gr::pdu::itemsize, py::arg("type"), D(pdu, itemsize)); + + + m_pdu.def("type_matches", + &::gr::pdu::type_matches, + py::arg("type"), + py::arg("v"), + D(pdu, type_matches)); + + + m_pdu.def("make_pdu_vector", + &::gr::pdu::make_pdu_vector, + py::arg("type"), + py::arg("buf"), + py::arg("items"), + D(pdu, make_pdu_vector)); + + + m_pdu.def("type_from_pmt", + &::gr::pdu::type_from_pmt, + py::arg("vector"), + D(pdu, type_from_pmt)); +} diff --git a/gnuradio-runtime/python/gnuradio/gr/bindings/python_bindings.cc b/gnuradio-runtime/python/gnuradio/gr/bindings/python_bindings.cc index 8307fa8790..c180116c80 100644 --- a/gnuradio-runtime/python/gnuradio/gr/bindings/python_bindings.cc +++ b/gnuradio-runtime/python/gnuradio/gr/bindings/python_bindings.cc @@ -52,6 +52,7 @@ void bind_msg_queue(py::module&); void bind_msg_handler(py::module&); void bind_msg_queue(py::module&); void bind_nco(py::module&); +void bind_pdu(py::module&); void bind_prefs(py::module&); // void bind_pycallback_object(py::module&); void bind_random(py::module&); @@ -152,6 +153,7 @@ PYBIND11_MODULE(gr_python, m) bind_nco(m); + bind_pdu(m); bind_prefs(m); // // bind_pycallback_object(m); bind_random(m); |