Update to GR 3.9.0. WIP with plenty of untested code.

This commit is contained in:
Nick Foster
2021-02-10 20:55:39 -08:00
parent 9c77b55c0b
commit fd1771f161
59 changed files with 207 additions and 16379 deletions

View File

@@ -50,16 +50,8 @@ GR_PYTHON_INSTALL(
sql.py
zmq_socket.py
Quaternion.py
msgq_runner.py
DESTINATION ${GR_PYTHON_DIR}/air_modes
)
########################################################################
# Handle the unit tests
########################################################################
#include(GrTest)
#set(GR_TEST_TARGET_DEPS gnuradio-gr-air-modes)
#set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig)
#GR_ADD_TEST(qa_gr-air-modes ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr-air-modes.py)
add_subdirectory(bindings)

View File

@@ -21,17 +21,14 @@
'''
This is the GNU Radio gr-air-modes package. It provides a library and
application for receiving Mode S / ADS-B signals from aircraft. Use
uhd_modes.py as the main application for receiving signals. cpr.py
modes_rx as the main application for receiving signals. cpr.py
provides an implementation of Compact Position Reporting. altitude.py
implements Gray-coded altitude decoding. Various plugins exist for SQL,
KML, and PlanePlotter-compliant SBS-1 emulation output. mlat.py provides
an experimental implementation of a multilateration solver.
'''
from __future__ import unicode_literals
# import swig generated symbols into the gr-air-modes namespace
from .air_modes_swig import *
from .air_modes_python import *
# import any pure python here
#
@@ -55,6 +52,8 @@ from .modes_types import *
from .altitude import *
from .cpr import cpr_decoder
from .html_template import html_template
from .msgq_runner import msgq_runner
#this is try/excepted in case the user doesn't have numpy installed
try:
from .flightgear import output_flightgear

0
python/altitude.py Executable file → Normal file
View File

0
python/az_map.py Executable file → Normal file
View File

View File

@@ -29,7 +29,9 @@ include(GrPybind)
########################################################################
list(APPEND air_modes_python_files
python_bindings.cc)
python_bindings.cc
preamble_python.cc
slicer_python.cc)
GR_PYBIND_MAKE_OOT(air_modes
../..

View File

@@ -7,7 +7,7 @@
*
*/
#include "pydoc_macros.h"
#define D(...) DOC(gr,air-modes, __VA_ARGS__ )
#define D(...) DOC(gr,air_modes, __VA_ARGS__ )
/*
This file contains placeholders for docstrings for the Python bindings.
Do not edit! These were automatically extracted during the binding process
@@ -16,12 +16,27 @@
static const char *__doc_gr_air-modes_preamble = R"doc()doc";
static const char *__doc_gr_air_modes_preamble = R"doc()doc";
static const char *__doc_gr_air-modes_preamble_preamble = R"doc()doc";
static const char *__doc_gr_air_modes_preamble_preamble_0 = R"doc()doc";
static const char *__doc_gr_air-modes_preamble_make = R"doc()doc";
static const char *__doc_gr_air_modes_preamble_preamble_1 = R"doc()doc";
static const char *__doc_gr_air_modes_preamble_make = R"doc()doc";
static const char *__doc_gr_air_modes_preamble_set_rate = R"doc()doc";
static const char *__doc_gr_air_modes_preamble_set_threshold = R"doc()doc";
static const char *__doc_gr_air_modes_preamble_get_rate = R"doc()doc";
static const char *__doc_gr_air_modes_preamble_get_threshold = R"doc()doc";

View File

@@ -7,7 +7,7 @@
*
*/
#include "pydoc_macros.h"
#define D(...) DOC(gr,air-modes, __VA_ARGS__ )
#define D(...) DOC(gr,air_modes, __VA_ARGS__ )
/*
This file contains placeholders for docstrings for the Python bindings.
Do not edit! These were automatically extracted during the binding process
@@ -16,12 +16,12 @@
static const char *__doc_gr_air-modes_slicer = R"doc()doc";
static const char *__doc_gr_air_modes_slicer = R"doc()doc";
static const char *__doc_gr_air-modes_slicer_slicer = R"doc()doc";
static const char *__doc_gr_air_modes_slicer_slicer = R"doc()doc";
static const char *__doc_gr_air-modes_slicer_make = R"doc()doc";
static const char *__doc_gr_air_modes_slicer_make = R"doc()doc";

View File

@@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(preamble.h) */
/* BINDTOOL_HEADER_FILE_HASH(99cc0f448ffd5f8da017452a42ffb8c1) */
/* BINDTOOL_HEADER_FILE_HASH(7ce2f89dad5c95a56a123d11871bad67) */
/***********************************************************************************/
#include <pybind11/complex.h>
@@ -23,26 +23,54 @@
namespace py = pybind11;
#include <air-modes/preamble.h>
#include <air_modes/preamble.h>
// pydoc.h is automatically generated in the build directory
#include <preamble_pydoc.h>
void bind_preamble(py::module& m)
{
using preamble = gr::air-modes::preamble;
using preamble = ::gr::air_modes::preamble;
py::class_<preamble, gr::block, gr::basic_block,
std::shared_ptr<preamble>>(m, "preamble", D(preamble))
.def(py::init(&preamble::make),
py::arg("channel_rate"),
py::arg("threshold_db"),
D(preamble,make)
)
.def("set_rate",&preamble::set_rate,
py::arg("channel_rate"),
D(preamble,set_rate)
)
.def("set_threshold",&preamble::set_threshold,
py::arg("threshold_db"),
D(preamble,set_threshold)
)
.def("get_rate",&preamble::get_rate,
D(preamble,get_rate)
)
.def("get_threshold",&preamble::get_threshold,
D(preamble,get_threshold)
)
;

View File

@@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(slicer.h) */
/* BINDTOOL_HEADER_FILE_HASH(eec2a2cee44fc77b3705ab2abfac8702) */
/* BINDTOOL_HEADER_FILE_HASH(de5bad12b8ae0f22c88c9cd886eaf8cc) */
/***********************************************************************************/
#include <pybind11/complex.h>
@@ -23,20 +23,21 @@
namespace py = pybind11;
#include <air-modes/slicer.h>
#include <air_modes/slicer.h>
// pydoc.h is automatically generated in the build directory
#include <slicer_pydoc.h>
void bind_slicer(py::module& m)
{
using slicer = gr::air-modes::slicer;
using slicer = ::gr::air_modes::slicer;
py::class_<slicer, gr::block, gr::basic_block,
py::class_<slicer, gr::sync_block, gr::block, gr::basic_block,
std::shared_ptr<slicer>>(m, "slicer", D(slicer))
.def(py::init(&slicer::make),
py::arg("queue"),
D(slicer,make)
)

0
python/cpr.py Executable file → Normal file
View File

0
python/flightgear.py Executable file → Normal file
View File

0
python/get_uniq.py Executable file → Normal file
View File

0
python/mlat.py Executable file → Normal file
View File

70
python/msgq_runner.py Normal file
View File

@@ -0,0 +1,70 @@
#
# Copyright 2009 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
#
"""
Convenience class for dequeuing messages from a gr.msg_queue and
invoking a callback.
Creates a Python thread that does a blocking read on the supplied
gr.msg_queue, then invokes callback each time a msg is received.
If the msg type is not 0, then it is treated as a signal to exit
its loop.
If the callback raises an exception, and the runner was created
with 'exit_on_error' equal to True, then the runner will store the
exception and exit its loop, otherwise the exception is ignored.
To get the exception that the callback raised, if any, call
exit_error() on the object.
To manually stop the runner, call stop() on the object.
To determine if the runner has exited, call exited() on the object.
"""
from gnuradio import gr
import threading
class msgq_runner(threading.Thread):
def __init__(self, msgq, callback, exit_on_error=False):
threading.Thread.__init__(self)
self._msgq = msgq
self._callback = callback
self._exit_on_error = exit_on_error
self._done = False
self._exited = False
self._exit_error = None
self.setDaemon(1)
self.start()
def run(self):
while not self._done:
msg = self._msgq.delete_head()
if msg.type() != 0:
self.stop()
else:
try:
self._callback(msg)
except Exception as e:
if self._exit_on_error:
self._exit_error = e
self.stop()
self._exited = True
def stop(self):
self._done = True
def exited(self):
return self._exited
def exit_error(self):
return self._exit_error

View File

@@ -23,7 +23,7 @@
# You pass it options, it gives you data.
# It uses the pubsub interface to allow clients to subscribe to its data feeds.
from gnuradio import gr, gru, eng_notation, filter, blocks
from gnuradio import gr, eng_notation, filter, blocks
from gnuradio.filter import optfir
from gnuradio.eng_option import eng_option
from gnuradio.gr.pubsub import pubsub
@@ -81,7 +81,7 @@ class modes_radio (gr.top_block, pubsub):
server_addr += ["tcp://*:%i" % options.tcp]
self._sender = air_modes.zmq_pubsub_iface(context, subaddr=None, pubaddr=server_addr)
self._async_sender = gru.msgq_runner(self._queue, self.send)
self._async_sender = air_modes.msgq_runner(self._queue, self.send)
def send(self, msg):
self._sender["dl_data"] = msg.to_string()