Skip to content

Commit

Permalink
gnuradio: add pregenerated python bindings files.
Browse files Browse the repository at this point in the history
The gnuradio python bindings could be generated during cmake configuration step,
but the process might have issues with crawling through gnuradio headers in system path.
And the bindings generation process takes relatively long time, so just add the generated files for git tracking
and the files are marked to be regenerated automatically if neccessary.
  • Loading branch information
rjonaitis committed Sep 8, 2024
1 parent c1ed15f commit 172f209
Show file tree
Hide file tree
Showing 6 changed files with 427 additions and 5 deletions.
2 changes: 0 additions & 2 deletions plugins/gr-limesdr/python/bindings/.gitignore

This file was deleted.

8 changes: 5 additions & 3 deletions plugins/gr-limesdr/python/bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ include(GrPybind)

list(APPEND limesdr_python_files sink_python.cc source_python.cc python_bindings.cc)

execute_process(COMMAND gr_modtool bind source WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

execute_process(COMMAND gr_modtool bind sink WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
# Generates the *_python.cc files, they could be generated with each CMake config run and not require Git tracking.
# But because the bindings rarely change and bindings generation script can have issues when crawling though system header includes,
# the generated bindings files are added to Git tracking, and marked to auto re-generate if needed.
# execute_process(COMMAND gr_modtool bind source WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
# execute_process(COMMAND gr_modtool bind sink WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

if(ENABLE_RFE)
list(APPEND limesdr_python_files rfe_python.cc)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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, limesdr, __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_limesdr_sink = R"doc()doc";


static const char* __doc_gr_limesdr_sink_sink_0 = R"doc()doc";


static const char* __doc_gr_limesdr_sink_sink_1 = R"doc()doc";


static const char* __doc_gr_limesdr_sink_make = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_center_freq = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_antenna = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_nco = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_bandwidth = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_digital_filter = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_gain = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_sample_rate = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_oversampling = R"doc()doc";


static const char* __doc_gr_limesdr_sink_calibrate = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_buffer_size = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_tcxo_dac = R"doc()doc";


static const char* __doc_gr_limesdr_sink_write_lms_reg = R"doc()doc";


static const char* __doc_gr_limesdr_sink_set_gpio_dir = R"doc()doc";


static const char* __doc_gr_limesdr_sink_write_gpio = R"doc()doc";


static const char* __doc_gr_limesdr_sink_read_gpio = R"doc()doc";
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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, limesdr, __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_limesdr_source = R"doc()doc";


static const char* __doc_gr_limesdr_source_source_0 = R"doc()doc";


static const char* __doc_gr_limesdr_source_source_1 = R"doc()doc";


static const char* __doc_gr_limesdr_source_make = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_center_freq = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_antenna = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_nco = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_bandwidth = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_digital_filter = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_gain = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_sample_rate = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_oversampling = R"doc()doc";


static const char* __doc_gr_limesdr_source_calibrate = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_buffer_size = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_tcxo_dac = R"doc()doc";


static const char* __doc_gr_limesdr_source_write_lms_reg = R"doc()doc";


static const char* __doc_gr_limesdr_source_set_gpio_dir = R"doc()doc";


static const char* __doc_gr_limesdr_source_write_gpio = R"doc()doc";


static const char* __doc_gr_limesdr_source_read_gpio = R"doc()doc";
136 changes: 136 additions & 0 deletions plugins/gr-limesdr/python/bindings/sink_python.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* 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(1) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(sink.h) */
/* BINDTOOL_HEADER_FILE_HASH(f2afded25eae99fdd12ae231bd440d70) */
/***********************************************************************************/

#include <pybind11/complex.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

namespace py = pybind11;

#include <limesdr/sink.h>
// pydoc.h is automatically generated in the build directory
#include <sink_pydoc.h>

void bind_sink(py::module& m)
{

using sink = ::gr::limesdr::sink;


py::class_<sink, gr::sync_block, gr::block, gr::basic_block, std::shared_ptr<sink>>(
m, "sink", D(sink))

.def(py::init(&sink::make),
py::arg("serial"),
py::arg("channel_mode"),
py::arg("filename"),
py::arg("length_tag_name"),
D(sink, make))


.def("set_center_freq",
&sink::set_center_freq,
py::arg("freq"),
py::arg("chan") = 0,
D(sink, set_center_freq))


.def("set_antenna",
&sink::set_antenna,
py::arg("antenna"),
py::arg("channel") = 0,
D(sink, set_antenna))


.def("set_nco",
&sink::set_nco,
py::arg("nco_freq"),
py::arg("channel"),
D(sink, set_nco))


.def("set_bandwidth",
&sink::set_bandwidth,
py::arg("analog_bandw"),
py::arg("channel") = 0,
D(sink, set_bandwidth))


.def("set_digital_filter",
&sink::set_digital_filter,
py::arg("digital_bandw"),
py::arg("channel"),
D(sink, set_digital_filter))


.def("set_gain",
&sink::set_gain,
py::arg("gain_dB"),
py::arg("channel") = 0,
D(sink, set_gain))


.def("set_sample_rate",
&sink::set_sample_rate,
py::arg("rate"),
D(sink, set_sample_rate))


.def("set_oversampling",
&sink::set_oversampling,
py::arg("oversample"),
D(sink, set_oversampling))


.def("calibrate",
&sink::calibrate,
py::arg("bandw"),
py::arg("channel") = 0,
D(sink, calibrate))


.def("set_buffer_size",
&sink::set_buffer_size,
py::arg("size"),
D(sink, set_buffer_size))


.def("set_tcxo_dac",
&sink::set_tcxo_dac,
py::arg("dacVal") = 125,
D(sink, set_tcxo_dac))


.def("write_lms_reg",
&sink::write_lms_reg,
py::arg("address"),
py::arg("val"),
D(sink, write_lms_reg))


.def("set_gpio_dir", &sink::set_gpio_dir, py::arg("dir"), D(sink, set_gpio_dir))


.def("write_gpio", &sink::write_gpio, py::arg("out"), D(sink, write_gpio))


.def("read_gpio", &sink::read_gpio, D(sink, read_gpio))

;
}
Loading

0 comments on commit 172f209

Please sign in to comment.