summaryrefslogtreecommitdiff
path: root/gr-network/python/network
diff options
context:
space:
mode:
Diffstat (limited to 'gr-network/python/network')
-rw-r--r--gr-network/python/network/CMakeLists.txt2
-rw-r--r--gr-network/python/network/__init__.py9
-rw-r--r--gr-network/python/network/bindings/CMakeLists.txt20
-rw-r--r--gr-network/python/network/bindings/docstrings/tcp_sink_pydoc_template.h24
-rw-r--r--gr-network/python/network/bindings/docstrings/udp_sink_pydoc_template.h24
-rw-r--r--gr-network/python/network/bindings/docstrings/udp_source_pydoc_template.h24
-rw-r--r--gr-network/python/network/bindings/python_bindings.cc48
-rw-r--r--gr-network/python/network/bindings/tcp_sink_python.cc52
-rw-r--r--gr-network/python/network/bindings/udp_sink_python.cc54
-rw-r--r--gr-network/python/network/bindings/udp_source_python.cc55
10 files changed, 311 insertions, 1 deletions
diff --git a/gr-network/python/network/CMakeLists.txt b/gr-network/python/network/CMakeLists.txt
index 5cd946cc7b..213821f381 100644
--- a/gr-network/python/network/CMakeLists.txt
+++ b/gr-network/python/network/CMakeLists.txt
@@ -31,3 +31,5 @@ include(GrTest)
set(GR_TEST_TARGET_DEPS gnuradio-network)
set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig)
+
+add_subdirectory(bindings)
diff --git a/gr-network/python/network/__init__.py b/gr-network/python/network/__init__.py
index f5844994bb..6a927c19fb 100644
--- a/gr-network/python/network/__init__.py
+++ b/gr-network/python/network/__init__.py
@@ -13,7 +13,14 @@ description here (python/__init__.py).
from __future__ import unicode_literals
# import swig generated symbols into the network namespace
-from .network_swig import *
+import os
+
+try:
+ from .network_python import *
+except ImportError:
+ dirname, filename = os.path.split(os.path.abspath(__file__))
+ __path__.append(os.path.join(dirname, "bindings"))
+ from .network_python import *
# import any pure python here
#
diff --git a/gr-network/python/network/bindings/CMakeLists.txt b/gr-network/python/network/bindings/CMakeLists.txt
new file mode 100644
index 0000000000..80f02c00b2
--- /dev/null
+++ b/gr-network/python/network/bindings/CMakeLists.txt
@@ -0,0 +1,20 @@
+include(GrPybind)
+
+########################################################################
+# Python Bindings
+########################################################################
+
+list(APPEND network_python_files
+ # packet_headers_python.cc
+ tcp_sink_python.cc
+ # udp_header_types_python.cc
+ udp_sink_python.cc
+ udp_source_python.cc
+ python_bindings.cc)
+
+GR_PYBIND_MAKE_CHECK_HASH(network
+ ../../..
+ gr::network
+ "${network_python_files}")
+
+install(TARGETS network_python DESTINATION ${GR_PYTHON_DIR}/gnuradio/network COMPONENT pythonapi)
diff --git a/gr-network/python/network/bindings/docstrings/tcp_sink_pydoc_template.h b/gr-network/python/network/bindings/docstrings/tcp_sink_pydoc_template.h
new file mode 100644
index 0000000000..5ce85026f0
--- /dev/null
+++ b/gr-network/python/network/bindings/docstrings/tcp_sink_pydoc_template.h
@@ -0,0 +1,24 @@
+/*
+ * 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, network, __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_network_tcp_sink = R"doc()doc";
+
+
+static const char* __doc_gr_network_tcp_sink_tcp_sink = R"doc()doc";
+
+
+static const char* __doc_gr_network_tcp_sink_make = R"doc()doc";
diff --git a/gr-network/python/network/bindings/docstrings/udp_sink_pydoc_template.h b/gr-network/python/network/bindings/docstrings/udp_sink_pydoc_template.h
new file mode 100644
index 0000000000..583dcd9152
--- /dev/null
+++ b/gr-network/python/network/bindings/docstrings/udp_sink_pydoc_template.h
@@ -0,0 +1,24 @@
+/*
+ * 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, network, __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_network_udp_sink = R"doc()doc";
+
+
+static const char* __doc_gr_network_udp_sink_udp_sink = R"doc()doc";
+
+
+static const char* __doc_gr_network_udp_sink_make = R"doc()doc";
diff --git a/gr-network/python/network/bindings/docstrings/udp_source_pydoc_template.h b/gr-network/python/network/bindings/docstrings/udp_source_pydoc_template.h
new file mode 100644
index 0000000000..4c08528949
--- /dev/null
+++ b/gr-network/python/network/bindings/docstrings/udp_source_pydoc_template.h
@@ -0,0 +1,24 @@
+/*
+ * 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, network, __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_network_udp_source = R"doc()doc";
+
+
+static const char* __doc_gr_network_udp_source_udp_source = R"doc()doc";
+
+
+static const char* __doc_gr_network_udp_source_make = R"doc()doc";
diff --git a/gr-network/python/network/bindings/python_bindings.cc b/gr-network/python/network/bindings/python_bindings.cc
new file mode 100644
index 0000000000..3de111aa79
--- /dev/null
+++ b/gr-network/python/network/bindings/python_bindings.cc
@@ -0,0 +1,48 @@
+
+/*
+ * 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;
+
+// void bind_packet_headers(py::module&);
+void bind_tcp_sink(py::module&);
+// void bind_udp_header_types(py::module&);
+void bind_udp_sink(py::module&);
+void bind_udp_source(py::module&);
+
+// 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(network_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");
+
+ // bind_packet_headers(m);
+ bind_tcp_sink(m);
+ // bind_udp_header_types(m);
+ bind_udp_sink(m);
+ bind_udp_source(m);
+}
diff --git a/gr-network/python/network/bindings/tcp_sink_python.cc b/gr-network/python/network/bindings/tcp_sink_python.cc
new file mode 100644
index 0000000000..758e09fbb6
--- /dev/null
+++ b/gr-network/python/network/bindings/tcp_sink_python.cc
@@ -0,0 +1,52 @@
+/*
+ * 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(1) */
+/* BINDTOOL_USE_PYGCCXML(0) */
+/* BINDTOOL_HEADER_FILE(tcp_sink.h) */
+/* BINDTOOL_HEADER_FILE_HASH(0b9dbaad93be0a2d8c62ff046f3cc907) */
+/***********************************************************************************/
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/network/tcp_sink.h>
+// pydoc.h is automatically generated in the build directory
+#include <tcp_sink_pydoc.h>
+
+void bind_tcp_sink(py::module& m)
+{
+
+ using tcp_sink = ::gr::network::tcp_sink;
+
+
+ py::class_<tcp_sink,
+ gr::sync_block,
+ gr::block,
+ gr::basic_block,
+ std::shared_ptr<tcp_sink>>(m, "tcp_sink", D(tcp_sink))
+
+ .def(py::init(&tcp_sink::make),
+ py::arg("itemsize"),
+ py::arg("veclen"),
+ py::arg("host"),
+ py::arg("port"),
+ py::arg("sinkmode"),
+ D(tcp_sink, make))
+
+
+ ;
+}
diff --git a/gr-network/python/network/bindings/udp_sink_python.cc b/gr-network/python/network/bindings/udp_sink_python.cc
new file mode 100644
index 0000000000..5ce8c35ec5
--- /dev/null
+++ b/gr-network/python/network/bindings/udp_sink_python.cc
@@ -0,0 +1,54 @@
+/*
+ * 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(1) */
+/* BINDTOOL_USE_PYGCCXML(0) */
+/* BINDTOOL_HEADER_FILE(udp_sink.h) */
+/* BINDTOOL_HEADER_FILE_HASH(c998bf2a9132f90dc5c3dd252d9477cb) */
+/***********************************************************************************/
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/network/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::network::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("veclen"),
+ py::arg("host"),
+ py::arg("port"),
+ py::arg("header_type"),
+ py::arg("payloadsize"),
+ py::arg("send_eof"),
+ D(udp_sink, make))
+
+
+ ;
+}
diff --git a/gr-network/python/network/bindings/udp_source_python.cc b/gr-network/python/network/bindings/udp_source_python.cc
new file mode 100644
index 0000000000..c748b5f0f9
--- /dev/null
+++ b/gr-network/python/network/bindings/udp_source_python.cc
@@ -0,0 +1,55 @@
+/*
+ * 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(1) */
+/* BINDTOOL_USE_PYGCCXML(0) */
+/* BINDTOOL_HEADER_FILE(udp_source.h) */
+/* BINDTOOL_HEADER_FILE_HASH(e8dceb0f73955c17260a5277ff77a7bc) */
+/***********************************************************************************/
+
+#include <pybind11/complex.h>
+#include <pybind11/pybind11.h>
+#include <pybind11/stl.h>
+
+namespace py = pybind11;
+
+#include <gnuradio/network/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::network::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("vecLen"),
+ py::arg("port"),
+ py::arg("header_type"),
+ py::arg("payloadsize"),
+ py::arg("notify_missed"),
+ py::arg("source_zeros"),
+ py::arg("ipv6"),
+ D(udp_source, make))
+
+
+ ;
+}