diff --git a/CMakeLists.txt b/CMakeLists.txt index c887145..befeb8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ # This file is a part of gr-sandia_utils # # SPDX-License-Identifier: GPL-3.0-or-later +# ######################################################################## # Project setup @@ -30,7 +31,7 @@ list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules) # Set the version information here set(VERSION_MAJOR 3) -set(VERSION_API 8) +set(VERSION_API 9) set(VERSION_ABI 0) set(VERSION_PATCH git) @@ -72,7 +73,8 @@ ENDIF() ######################################################################## # Install directories ######################################################################## -find_package(Gnuradio "3.8" REQUIRED COMPONENTS runtime pmt blocks filter fft) +include(FindPkgConfig) +find_package(Gnuradio "3.9" REQUIRED COMPONENTS runtime pmt blocks filter fft) include(GrVersion) include(GrPlatform) #define LIB_SUFFIX @@ -133,6 +135,19 @@ endif(APPLE) ######################################################################## find_package(Doxygen) +######################################################################## +# PyBind11 Related +######################################################################## + +find_package(pybind11 REQUIRED) +execute_process( + COMMAND "${PYTHON_EXECUTABLE}" -c + "try:\n import numpy\n import os\n inc_path = numpy.get_include()\n if os.path.exists(os.path.join(inc_path, 'numpy', 'arrayobject.h')):\n print(inc_path, end='')\nexcept:\n pass" + OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIR) +# format path in CMake-style for consistency with other path variables +# (a consistent style helps conda builds by using the same path separators) +file(TO_CMAKE_PATH "${PYTHON_NUMPY_INCLUDE_DIR}" PYTHON_NUMPY_INCLUDE_DIR) + ######################################################################## # Setup doxygen option ######################################################################## @@ -162,13 +177,13 @@ add_subdirectory(include/sandia_utils) add_subdirectory(lib) add_subdirectory(apps) add_subdirectory(docs) +# NOTE: manually update below to use GRC to generate C++ flowgraphs w/o python if(ENABLE_PYTHON) - message(STATUS "PYTHON components are enabled") - add_subdirectory(swig) + message(STATUS "PYTHON and GRC components are enabled") add_subdirectory(python) add_subdirectory(grc) else(ENABLE_PYTHON) - message(STATUS "PYTHON components are disabled") + message(STATUS "PYTHON and GRC components are disabled") endif(ENABLE_PYTHON) ######################################################################## diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index b553111..70af254 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -4,6 +4,7 @@ # This file is a part of gr-sandia_utils # # SPDX-License-Identifier: GPL-3.0-or-later +# ######################################################################## # Setup dependencies diff --git a/docs/doxygen/CMakeLists.txt b/docs/doxygen/CMakeLists.txt index 7562e64..0668ed7 100644 --- a/docs/doxygen/CMakeLists.txt +++ b/docs/doxygen/CMakeLists.txt @@ -4,6 +4,7 @@ # This file is a part of gr-sandia_utils # # SPDX-License-Identifier: GPL-3.0-or-later +# ######################################################################## # Create the doxygen configuration file @@ -16,6 +17,7 @@ file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} abs_top_builddir) set(HAVE_DOT ${DOXYGEN_DOT_FOUND}) set(enable_html_docs YES) set(enable_latex_docs NO) +set(enable_mathjax NO) set(enable_xml_docs YES) configure_file( diff --git a/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in index 834df72..4f006fc 100644 --- a/docs/doxygen/Doxyfile.in +++ b/docs/doxygen/Doxyfile.in @@ -199,13 +199,6 @@ TAB_SIZE = 8 ALIASES = -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding -# "class=itcl::class" will allow you to use the command class in the -# itcl::class meaning. - -TCL_SUBST = - # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list @@ -723,8 +716,6 @@ EXCLUDE_PATTERNS = */.deps/* \ EXCLUDE_SYMBOLS = ad9862 \ numpy \ - *swig* \ - *Swig* \ *my_top_block* \ *my_graph* \ *app_top_block* \ @@ -1220,14 +1211,14 @@ FORMULA_TRANSPARENT = YES # output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. -USE_MATHJAX = NO +USE_MATHJAX = @enable_mathjax@ # When MathJax is enabled you can set the default output format to be used for # the MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and # SVG. The default value is HTML-CSS, which is slower, but has the best # compatibility. -MATHJAX_FORMAT = HTML-CSS +MATHJAX_FORMAT = SVG # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination @@ -1239,12 +1230,12 @@ MATHJAX_FORMAT = HTML-CSS # However, it is strongly recommended to install a local # copy of MathJax from http://www.mathjax.org before deployment. -MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest +MATHJAX_RELPATH = @MATHJAX2_PATH@ # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension # names that should be enabled during MathJax rendering. -MATHJAX_EXTENSIONS = +MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols # The MATHJAX_CODEFILE tag can be used to specify a file with javascript # pieces of code that will be used on startup of the MathJax code. @@ -1680,11 +1671,6 @@ EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- @@ -1697,15 +1683,6 @@ PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -MSCGEN_PATH = - # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. @@ -1834,7 +1811,7 @@ DIRECTORY_GRAPH = YES # HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible in IE 9+ (other browsers do not have this requirement). -DOT_IMAGE_FORMAT = png +DOT_IMAGE_FORMAT = svg # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. diff --git a/docs/doxygen/pydoc_macros.h b/docs/doxygen/pydoc_macros.h new file mode 100644 index 0000000..98bf7cd --- /dev/null +++ b/docs/doxygen/pydoc_macros.h @@ -0,0 +1,19 @@ +#ifndef PYDOC_MACROS_H +#define PYDOC_MACROS_H + +#define __EXPAND(x) x +#define __COUNT(_1, _2, _3, _4, _5, _6, _7, COUNT, ...) COUNT +#define __VA_SIZE(...) __EXPAND(__COUNT(__VA_ARGS__, 7, 6, 5, 4, 3, 2, 1)) +#define __CAT1(a, b) a##b +#define __CAT2(a, b) __CAT1(a, b) +#define __DOC1(n1) __doc_##n1 +#define __DOC2(n1, n2) __doc_##n1##_##n2 +#define __DOC3(n1, n2, n3) __doc_##n1##_##n2##_##n3 +#define __DOC4(n1, n2, n3, n4) __doc_##n1##_##n2##_##n3##_##n4 +#define __DOC5(n1, n2, n3, n4, n5) __doc_##n1##_##n2##_##n3##_##n4##_##n5 +#define __DOC6(n1, n2, n3, n4, n5, n6) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6 +#define __DOC7(n1, n2, n3, n4, n5, n6, n7) \ + __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7 +#define DOC(...) __EXPAND(__EXPAND(__CAT2(__DOC, __VA_SIZE(__VA_ARGS__)))(__VA_ARGS__)) + +#endif // PYDOC_MACROS_H \ No newline at end of file diff --git a/docs/doxygen/swig_doc.py b/docs/doxygen/update_pydoc.py similarity index 59% rename from docs/doxygen/swig_doc.py rename to docs/doxygen/update_pydoc.py index db4789b..e6b4544 100644 --- a/docs/doxygen/swig_doc.py +++ b/docs/doxygen/update_pydoc.py @@ -2,21 +2,22 @@ # Copyright 2010-2012 Free Software Foundation, Inc. # # This file was generated by gr_modtool, a tool from the GNU Radio framework -# This file is a part of gr-sandia_utils +# This file is a part of gnuradio # # SPDX-License-Identifier: GPL-3.0-or-later # +# """ -Creates the swig_doc.i SWIG interface file. -Execute using: python swig_doc.py xml_path outputfilename +Updates the *pydoc_h files for a module +Execute using: python update_pydoc.py xml_path outputfilename -The file instructs SWIG to transfer the doxygen comments into the +The file instructs Pybind11 to transfer the doxygen comments into the python docstrings. """ -from __future__ import unicode_literals -import sys, time +import os, sys, time, glob, re, json +from argparse import ArgumentParser from doxyxml import DoxyIndex, DoxyClass, DoxyFriend, DoxyFunction, DoxyFile from doxyxml import DoxyOther, base @@ -74,6 +75,7 @@ def utoascii(text): return '' out = text.encode('ascii', 'replace') # swig will require us to replace blackslash with 4 backslashes + # TODO: evaluate what this should be for pybind11 out = out.replace(b'\\', b'\\\\\\\\') out = out.replace(b'"', b'\\"').decode('ascii') return str(out) @@ -102,7 +104,7 @@ def format_params(parameteritems): entry_templ = '%feature("docstring") {name} "{docstring}"' def make_entry(obj, name=None, templ="{description}", description=None, params=[]): """ - Create a docstring entry for a swig interface file. + Create a docstring key/value pair, where the key is the object name. obj - a doxyxml object from which documentation will be extracted. name - the name of the C object (defaults to obj.name()) @@ -113,6 +115,8 @@ def make_entry(obj, name=None, templ="{description}", description=None, params=[ """ if name is None: name=obj.name() + if hasattr(obj,'_parse_data') and hasattr(obj._parse_data,'definition'): + name=obj._parse_data.definition.split(' ')[-1] if "operator " in name: return '' if description is None: @@ -121,56 +125,28 @@ def make_entry(obj, name=None, templ="{description}", description=None, params=[ description += '\n\n' description += utoascii(format_params(params)) docstring = templ.format(description=description) - if not docstring: - return '' - return entry_templ.format( - name=name, - docstring=docstring, - ) - - -def make_func_entry(func, name=None, description=None, params=None): - """ - Create a function docstring entry for a swig interface file. - func - a doxyxml object from which documentation will be extracted. - name - the name of the C object (defaults to func.name()) - description - if this optional variable is set then it's value is - used as the description instead of extracting it from func. - params - a parameter list that overrides using func.params. - """ - #if params is None: - # params = func.params - #params = [prm.declname for prm in params] - #if params: - # sig = "Params: (%s)" % ", ".join(params) - #else: - # sig = "Params: (NONE)" - #templ = "{description}\n\n" + sig - #return make_entry(func, name=name, templ=utoascii(templ), - # description=description) - return make_entry(func, name=name, description=description, params=params) + return {name: docstring} def make_class_entry(klass, description=None, ignored_methods=[], params=None): """ - Create a class docstring for a swig interface file. + Create a class docstring key/value pair. """ if params is None: params = klass.params - output = [] - output.append(make_entry(klass, description=description, params=params)) + output = {} + output.update(make_entry(klass, description=description, params=params)) for func in klass.in_category(DoxyFunction): if func.name() not in ignored_methods: name = klass.name() + '::' + func.name() - output.append(make_func_entry(func, name=name)) - return "\n\n".join(output) + output.update(make_entry(func, name=name)) + return output def make_block_entry(di, block): """ - Create class and function docstrings of a gnuradio block for a - swig interface file. + Create class and function docstrings of a gnuradio block """ descriptions = [] # Get the documentation associated with the class. @@ -195,18 +171,16 @@ def make_block_entry(di, block): super_description = "\n\n".join(descriptions) # Associate the combined description with the class and # the make function. - output = [] - output.append(make_class_entry(block, description=super_description)) - output.append(make_func_entry(make_func, description=super_description, + output = {} + output.update(make_class_entry(block, description=super_description)) + output.update(make_entry(make_func, description=super_description, params=block.params)) - return "\n\n".join(output) + return output def make_block2_entry(di, block): """ - Create class and function docstrings of a new style gnuradio block for a - swig interface file. + Create class and function docstrings of a new style gnuradio block """ - descriptions = [] # For new style blocks all the relevant documentation should be # associated with the 'make' method. class_description = combine_descriptions(block) @@ -215,28 +189,21 @@ def make_block2_entry(di, block): description = class_description + "\n\nConstructor Specific Documentation:\n\n" + make_description # Associate the combined description with the class and # the make function. - output = [] - output.append(make_class_entry( + output = {} + output.update(make_class_entry( block, description=description, ignored_methods=['make'], params=make_func.params)) makename = block.name() + '::make' - output.append(make_func_entry( + output.update(make_entry( make_func, name=makename, description=description, params=make_func.params)) - return "\n\n".join(output) + return output -def make_swig_interface_file(di, swigdocfilename, custom_output=None): +def get_docstrings_dict(di, custom_output=None): - output = [""" -/* - * This file was automatically generated using swig_doc.py. - * - * Any changes to it will be lost next time it is regenerated. - */ -"""] - - if custom_output is not None: - output.append(custom_output) + output = {} + if custom_output: + output.update(custom_output) # Create docstrings for the blocks. blocks = di.in_category(Block) @@ -249,7 +216,7 @@ def make_swig_interface_file(di, swigdocfilename, custom_output=None): # Don't want to risk writing to output twice. if make_func.name() not in make_funcs: make_funcs.add(make_func.name()) - output.append(make_block_entry(di, block)) + output.update(make_block_entry(di, block)) except block.ParsingError: sys.stderr.write('Parsing error for block {0}\n'.format(block.name())) raise @@ -261,7 +228,7 @@ def make_swig_interface_file(di, swigdocfilename, custom_output=None): # Don't want to risk writing to output twice. if make_func_name not in make_funcs: make_funcs.add(make_func_name) - output.append(make_block2_entry(di, block)) + output.update(make_block2_entry(di, block)) except block.ParsingError: sys.stderr.write('Parsing error for block {0}\n'.format(block.name())) raise @@ -272,7 +239,7 @@ def make_swig_interface_file(di, swigdocfilename, custom_output=None): if f.name() not in make_funcs and not f.name().startswith('std::')] for f in funcs: try: - output.append(make_func_entry(f)) + output.update(make_entry(f)) except f.ParsingError: sys.stderr.write('Parsing error for function {0}\n'.format(f.name())) @@ -283,37 +250,97 @@ def make_swig_interface_file(di, swigdocfilename, custom_output=None): if k.name() not in block_names and not k.name().startswith('std::')] for k in klasses: try: - output.append(make_class_entry(k)) + output.update(make_class_entry(k)) except k.ParsingError: sys.stderr.write('Parsing error for class {0}\n'.format(k.name())) # Docstrings are not created for anything that is not a function or a class. # If this excludes anything important please add it here. - output = "\n\n".join(output) - - swig_doc = open(swigdocfilename, 'w') - swig_doc.write(output) - swig_doc.close() + return output + +def sub_docstring_in_pydoc_h(pydoc_files, docstrings_dict, output_dir, filter_str=None): + if filter_str: + docstrings_dict = {k: v for k, v in docstrings_dict.items() if k.startswith(filter_str)} + + with open(os.path.join(output_dir,'docstring_status'),'w') as status_file: + + for pydoc_file in pydoc_files: + if filter_str: + filter_str2 = "::".join((filter_str,os.path.split(pydoc_file)[-1].split('_pydoc_template.h')[0])) + docstrings_dict2 = {k: v for k, v in docstrings_dict.items() if k.startswith(filter_str2)} + else: + docstrings_dict2 = docstrings_dict + + + + file_in = open(pydoc_file,'r').read() + for key, value in docstrings_dict2.items(): + file_in_tmp = file_in + try: + doc_key = key.split("::") + # if 'gr' in doc_key: + # doc_key.remove('gr') + doc_key = '_'.join(doc_key) + regexp = r'(__doc_{} =\sR\"doc\()[^)]*(\)doc\")'.format(doc_key) + regexp = re.compile(regexp, re.MULTILINE) + + (file_in, nsubs) = regexp.subn(r'\1'+value+r'\2', file_in, count=1) + if nsubs == 1: + status_file.write("PASS: " + pydoc_file + "\n") + except KeyboardInterrupt: + raise KeyboardInterrupt + except: # be permissive, TODO log, but just leave the docstring blank + status_file.write("FAIL: " + pydoc_file + "\n") + file_in = file_in_tmp + + output_pathname = os.path.join(output_dir, os.path.basename(pydoc_file).replace('_template.h','.h')) + # FIXME: Remove this debug print + print('output docstrings to {}'.format(output_pathname)) + with open(output_pathname,'w') as file_out: + file_out.write(file_in) + +def copy_docstring_templates(pydoc_files, output_dir): + with open(os.path.join(output_dir,'docstring_status'),'w') as status_file: + for pydoc_file in pydoc_files: + file_in = open(pydoc_file,'r').read() + output_pathname = os.path.join(output_dir, os.path.basename(pydoc_file).replace('_template.h','.h')) + # FIXME: Remove this debug print + print('copy docstrings to {}'.format(output_pathname)) + with open(output_pathname,'w') as file_out: + file_out.write(file_in) + status_file.write("DONE") + +def argParse(): + """Parses commandline args.""" + desc='Scrape the doxygen generated xml for docstrings to insert into python bindings' + parser = ArgumentParser(description=desc) + + parser.add_argument("function", help="Operation to perform on docstrings", choices=["scrape","sub","copy"]) + + parser.add_argument("--xml_path") + parser.add_argument("--bindings_dir") + parser.add_argument("--output_dir") + parser.add_argument("--json_path") + parser.add_argument("--filter", default=None) + + return parser.parse_args() if __name__ == "__main__": # Parse command line options and set up doxyxml. - err_msg = "Execute using: python swig_doc.py xml_path outputfilename" - if len(sys.argv) != 3: - raise Exception(err_msg) - xml_path = sys.argv[1] - swigdocfilename = sys.argv[2] - di = DoxyIndex(xml_path) - - # gnuradio.gr.msq_queue.insert_tail and delete_head create errors unless docstrings are defined! - # This is presumably a bug in SWIG. - #msg_q = di.get_member(u'gr_msg_queue', DoxyClass) - #insert_tail = msg_q.get_member(u'insert_tail', DoxyFunction) - #delete_head = msg_q.get_member(u'delete_head', DoxyFunction) - output = [] - #output.append(make_func_entry(insert_tail, name='gr_py_msg_queue__insert_tail')) - #output.append(make_func_entry(delete_head, name='gr_py_msg_queue__delete_head')) - custom_output = "\n\n".join(output) - - # Generate the docstrings interface file. - make_swig_interface_file(di, swigdocfilename, custom_output=custom_output) + args = argParse() + if args.function.lower() == 'scrape': + di = DoxyIndex(args.xml_path) + docstrings_dict = get_docstrings_dict(di) + with open(args.json_path, 'w') as fp: + json.dump(docstrings_dict, fp) + elif args.function.lower() == 'sub': + with open(args.json_path, 'r') as fp: + docstrings_dict = json.load(fp) + pydoc_files = glob.glob(os.path.join(args.bindings_dir,'*_pydoc_template.h')) + sub_docstring_in_pydoc_h(pydoc_files, docstrings_dict, args.output_dir, args.filter) + elif args.function.lower() == 'copy': + pydoc_files = glob.glob(os.path.join(args.bindings_dir,'*_pydoc_template.h')) + copy_docstring_templates(pydoc_files, args.output_dir) + + diff --git a/include/sandia_utils/block_buffer.h b/include/sandia_utils/block_buffer.h index ff96089..2b85eb7 100644 --- a/include/sandia_utils/block_buffer.h +++ b/include/sandia_utils/block_buffer.h @@ -38,7 +38,7 @@ namespace sandia_utils { class SANDIA_UTILS_API block_buffer : virtual public gr::block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of sandia_utils::block_buffer. diff --git a/include/sandia_utils/burst_power_detector.h b/include/sandia_utils/burst_power_detector.h index c7fd36c..a2ad497 100644 --- a/include/sandia_utils/burst_power_detector.h +++ b/include/sandia_utils/burst_power_detector.h @@ -30,7 +30,7 @@ namespace sandia_utils { class SANDIA_UTILS_API burst_power_detector : virtual public gr::sync_block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of sandia_utils::burst_power_detector. diff --git a/include/sandia_utils/complex_to_interleaved_short.h b/include/sandia_utils/complex_to_interleaved_short.h index e64a393..519f108 100644 --- a/include/sandia_utils/complex_to_interleaved_short.h +++ b/include/sandia_utils/complex_to_interleaved_short.h @@ -31,7 +31,7 @@ namespace sandia_utils { class SANDIA_UTILS_API complex_to_interleaved_short : virtual public gr::sync_interpolator { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of diff --git a/include/sandia_utils/compute_stats.h b/include/sandia_utils/compute_stats.h index eee2507..62b70cb 100644 --- a/include/sandia_utils/compute_stats.h +++ b/include/sandia_utils/compute_stats.h @@ -28,7 +28,7 @@ namespace sandia_utils { class SANDIA_UTILS_API compute_stats : virtual public gr::block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of sandia_utils::compute_stats. diff --git a/include/sandia_utils/file_sink.h b/include/sandia_utils/file_sink.h index e4c7bdf..6a6da64 100644 --- a/include/sandia_utils/file_sink.h +++ b/include/sandia_utils/file_sink.h @@ -62,7 +62,7 @@ enum trigger_type_t { MANUAL = 0, TRIGGERED = 1 }; class SANDIA_UTILS_API file_sink : virtual public gr::sync_block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of sandia_utils::file_sink. diff --git a/include/sandia_utils/file_source.h b/include/sandia_utils/file_source.h index 8c2f269..a70d8c0 100644 --- a/include/sandia_utils/file_source.h +++ b/include/sandia_utils/file_source.h @@ -40,7 +40,7 @@ namespace sandia_utils { class SANDIA_UTILS_API file_source : virtual public gr::sync_block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Create a file source. diff --git a/include/sandia_utils/interleaved_short_to_complex.h b/include/sandia_utils/interleaved_short_to_complex.h index 6b5170d..428774d 100644 --- a/include/sandia_utils/interleaved_short_to_complex.h +++ b/include/sandia_utils/interleaved_short_to_complex.h @@ -29,7 +29,7 @@ namespace sandia_utils { class SANDIA_UTILS_API interleaved_short_to_complex : virtual public gr::sync_decimator { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of diff --git a/include/sandia_utils/invert_tune.h b/include/sandia_utils/invert_tune.h index 6176369..26f61a0 100644 --- a/include/sandia_utils/invert_tune.h +++ b/include/sandia_utils/invert_tune.h @@ -32,7 +32,7 @@ namespace sandia_utils { class SANDIA_UTILS_API invert_tune : virtual public gr::block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of sandia_utils::invert_tune. diff --git a/include/sandia_utils/message_vector_file_sink.h b/include/sandia_utils/message_vector_file_sink.h index 992489d..ada58e6 100644 --- a/include/sandia_utils/message_vector_file_sink.h +++ b/include/sandia_utils/message_vector_file_sink.h @@ -32,7 +32,7 @@ namespace sandia_utils { class SANDIA_UTILS_API message_vector_file_sink : virtual public gr::block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of diff --git a/include/sandia_utils/message_vector_raster_file_sink.h b/include/sandia_utils/message_vector_raster_file_sink.h index f4d08ae..45fce68 100644 --- a/include/sandia_utils/message_vector_raster_file_sink.h +++ b/include/sandia_utils/message_vector_raster_file_sink.h @@ -35,7 +35,7 @@ namespace sandia_utils { class SANDIA_UTILS_API message_vector_raster_file_sink : virtual public gr::block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of diff --git a/include/sandia_utils/sandia_tag_debug.h b/include/sandia_utils/sandia_tag_debug.h index 57e7d73..8adbbf1 100644 --- a/include/sandia_utils/sandia_tag_debug.h +++ b/include/sandia_utils/sandia_tag_debug.h @@ -44,7 +44,7 @@ class SANDIA_UTILS_API sandia_tag_debug : virtual public sync_block { public: // gr::blocks::tag_debug::sptr - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * Build a tag debug block diff --git a/include/sandia_utils/stream_gate.h b/include/sandia_utils/stream_gate.h index a7b2c48..09c23da 100644 --- a/include/sandia_utils/stream_gate.h +++ b/include/sandia_utils/stream_gate.h @@ -31,7 +31,7 @@ template class SANDIA_UTILS_API stream_gate : virtual public gr::block { public: - typedef boost::shared_ptr> sptr; + typedef std::shared_ptr> sptr; /*! * \brief Return a shared_ptr to a new instance of sandia_utils::stream_gate. diff --git a/include/sandia_utils/tag_debug_file.h b/include/sandia_utils/tag_debug_file.h index 413372c..e3fef86 100644 --- a/include/sandia_utils/tag_debug_file.h +++ b/include/sandia_utils/tag_debug_file.h @@ -44,7 +44,7 @@ namespace sandia_utils { class SANDIA_UTILS_API tag_debug_file : virtual public gr::sync_block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * Build a tag debug block diff --git a/include/sandia_utils/tagged_bits_to_bytes.h b/include/sandia_utils/tagged_bits_to_bytes.h index f6b1164..66b10c1 100644 --- a/include/sandia_utils/tagged_bits_to_bytes.h +++ b/include/sandia_utils/tagged_bits_to_bytes.h @@ -60,7 +60,7 @@ namespace sandia_utils { class SANDIA_UTILS_API tagged_bits_to_bytes : virtual public gr::block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of sandia_utils::tagged_bits_to_bytes. diff --git a/include/sandia_utils/vita49_tcp_msg_source.h b/include/sandia_utils/vita49_tcp_msg_source.h index 91b287d..623c1bd 100644 --- a/include/sandia_utils/vita49_tcp_msg_source.h +++ b/include/sandia_utils/vita49_tcp_msg_source.h @@ -28,7 +28,7 @@ namespace gr class SANDIA_UTILS_API vita49_tcp_msg_source : virtual public gr::block { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /*! * \brief Return a shared_ptr to a new instance of sandia_utils::vita49_tcp_msg_source. diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index c7cbf6c..5ab8350 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -4,6 +4,7 @@ # This file is a part of gr-sandia_utils # # SPDX-License-Identifier: GPL-3.0-or-later +# ######################################################################## # Setup library @@ -71,7 +72,6 @@ if(NOT sandia_utils_sources) return() endif(NOT sandia_utils_sources) -# library target_link_libraries(gnuradio-sandia_utils gnuradio::gnuradio-runtime gnuradio::gnuradio-filter) target_link_libraries(gnuradio-sandia_utils Boost::chrono) diff --git a/lib/file_sink/file_writer_base.h b/lib/file_sink/file_writer_base.h index 947a246..7d597a2 100644 --- a/lib/file_sink/file_writer_base.h +++ b/lib/file_sink/file_writer_base.h @@ -29,7 +29,7 @@ namespace gr class SANDIA_UTILS_API file_writer_base { public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; typedef boost::function callback; /*! diff --git a/lib/file_source/file_reader_base.h b/lib/file_source/file_reader_base.h index 087a972..ca5c1fd 100644 --- a/lib/file_source/file_reader_base.h +++ b/lib/file_source/file_reader_base.h @@ -67,7 +67,7 @@ namespace gr gr::logger_ptr d_logger; public: - typedef boost::shared_ptr sptr; + typedef std::shared_ptr sptr; /** * Consructor diff --git a/lib/file_source/file_reader_bluefile.h b/lib/file_source/file_reader_bluefile.h index 209f316..04b2a7f 100644 --- a/lib/file_source/file_reader_bluefile.h +++ b/lib/file_source/file_reader_bluefile.h @@ -31,7 +31,7 @@ namespace gr int d_bps; public: - // typedef boost::shared_ptr sptr; + // typedef std::shared_ptr sptr; /** * Consructor diff --git a/lib/file_source/file_reader_raw_header.h b/lib/file_source/file_reader_raw_header.h index 1abfc6d..9ba5268 100644 --- a/lib/file_source/file_reader_raw_header.h +++ b/lib/file_source/file_reader_raw_header.h @@ -22,7 +22,7 @@ namespace gr private: // nothing here public: - // typedef boost::shared_ptr sptr; + // typedef std::shared_ptr sptr; file_reader_raw_header( size_t itemsize, gr::logger_ptr logger ) : file_reader_base( itemsize, logger ) { diff --git a/lib/file_source_impl.cc b/lib/file_source_impl.cc index 2adb7cb..9bbb381 100644 --- a/lib/file_source_impl.cc +++ b/lib/file_source_impl.cc @@ -126,7 +126,7 @@ bool file_source_impl::start() // NOTE: d_finished should be something explicitly thread safe. But since // nothing breaks on concurrent access, I'll just leave it as bool. d_finished = false; - d_thread = boost::shared_ptr( + d_thread = std::shared_ptr( new gr::thread::thread(boost::bind(&file_source_impl::run, this))); } diff --git a/lib/file_source_impl.h b/lib/file_source_impl.h index ef2a8f0..5795863 100644 --- a/lib/file_source_impl.h +++ b/lib/file_source_impl.h @@ -66,7 +66,7 @@ class file_source_impl : public file_source std::string d_filename; // message thread objects - boost::shared_ptr d_thread; + std::shared_ptr d_thread; bool d_finished; public: diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 8ecfa4d..1193c65 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -4,6 +4,7 @@ # This file is a part of gr-sandia_utils # # SPDX-License-Identifier: GPL-3.0-or-later +# ######################################################################## # Include python install macros @@ -13,6 +14,8 @@ if(NOT PYTHONINTERP_FOUND) return() endif() +add_subdirectory(bindings) + ######################################################################## # Install python sources ######################################################################## diff --git a/python/__init__.py b/python/__init__.py index 4ff7230..a6b8701 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -1,5 +1,6 @@ -# -# Copyright 2008,2009 Free Software Foundation, Inc. +# Copyright 2018, 2019, 2020 National Technology & Engineering Solutions of Sandia, LLC +# (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government +# retains certain rights in this software. # # SPDX-License-Identifier: GPL-3.0-or-later # @@ -10,17 +11,17 @@ This is the GNU Radio SANDIA_UTILS module. Place your Python package description here (python/__init__.py). ''' -from __future__ import unicode_literals +import os -# import swig generated symbols into the sandia_utils namespace +# import pybind11 generated symbols into the sandia_utils namespace try: # this might fail if the module is python-only - from .sandia_utils_swig import * -except ImportError as e: - print("GR-Sandia_Utils Import Error: {}".format(e)) + from .sandia_utils_python import * +except ModuleNotFoundError: pass # import any pure python here +# from .file_monitor import file_monitor from .max_every_n import max_every_n from .message_file_debug import message_file_debug diff --git a/python/bindings/CMakeLists.txt b/python/bindings/CMakeLists.txt new file mode 100644 index 0000000..04733e4 --- /dev/null +++ b/python/bindings/CMakeLists.txt @@ -0,0 +1,54 @@ +# Copyright 2018, 2019, 2020 National Technology & Engineering Solutions of Sandia, LLC +# (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government +# retains certain rights in this software. +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +######################################################################## +# Check if there is C++ code at all +######################################################################## +if(NOT sandia_utils_sources) + MESSAGE(STATUS "No C++ sources... skipping python bindings") + return() +endif(NOT sandia_utils_sources) + +######################################################################## +# Check for pygccxml +######################################################################## +GR_PYTHON_CHECK_MODULE_RAW( + "pygccxml" + "import pygccxml" + PYGCCXML_FOUND + ) + +include(GrPybind) + +######################################################################## +# Python Bindings +######################################################################## + +list(APPEND sandia_utils_python_files + block_buffer_python.cc + burst_power_detector_python.cc + complex_to_interleaved_short_python.cc + compute_stats_python.cc + constants_python.cc + file_sink_python.cc + file_source_python.cc + interleaved_short_to_complex_python.cc + invert_tune_python.cc + message_vector_file_sink_python.cc + message_vector_raster_file_sink_python.cc + sandia_tag_debug_python.cc + stream_gate_python.cc + tag_debug_file_python.cc + tagged_bits_to_bytes_python.cc + python_bindings.cc) + +GR_PYBIND_MAKE_OOT(sandia_utils + ../.. + gr::sandia_utils + "${sandia_utils_python_files}") + +install(TARGETS sandia_utils_python DESTINATION ${GR_PYTHON_DIR}/sandia_utils COMPONENT pythonapi) diff --git a/python/bindings/README.md b/python/bindings/README.md new file mode 100644 index 0000000..e69de29 diff --git a/python/bindings/bind_oot_file.py b/python/bindings/bind_oot_file.py new file mode 100644 index 0000000..91719f7 --- /dev/null +++ b/python/bindings/bind_oot_file.py @@ -0,0 +1,57 @@ +import warnings +import argparse +import os +from gnuradio.bindtool import BindingGenerator +import pathlib +import sys + +parser = argparse.ArgumentParser(description='Bind a GR Out of Tree Block') +parser.add_argument('--module', type=str, + help='Name of gr module containing file to bind (e.g. fft digital analog)') + +parser.add_argument('--output_dir', default='/tmp', + help='Output directory of generated bindings') +parser.add_argument('--prefix', help='Prefix of Installed GNU Radio') +parser.add_argument('--src', help='Directory of gnuradio source tree', + default=os.path.dirname(os.path.abspath(__file__))+'/../../..') + +parser.add_argument( + '--filename', help="File to be parsed") + +parser.add_argument( + '--defines', help='Set additional defines for precompiler',default=(), nargs='*') +parser.add_argument( + '--include', help='Additional Include Dirs, separated', default=(), nargs='*') + +parser.add_argument( + '--status', help='Location of output file for general status (used during cmake)', default=None +) +parser.add_argument( + '--flag_automatic', default='0' +) +parser.add_argument( + '--flag_pygccxml', default='0' +) + +args = parser.parse_args() + +prefix = args.prefix +output_dir = args.output_dir +defines = tuple(','.join(args.defines).split(',')) +includes = ','.join(args.include) +name = args.module + +namespace = ['gr', name] +prefix_include_root = name + + +with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + + bg = BindingGenerator(prefix, namespace, + prefix_include_root, output_dir, define_symbols=defines, addl_includes=includes, + catch_exceptions=False, write_json_output=False, status_output=args.status, + flag_automatic=True if args.flag_automatic.lower() in [ + '1', 'true'] else False, + flag_pygccxml=True if args.flag_pygccxml.lower() in ['1', 'true'] else False) + bg.gen_file_binding(args.filename) diff --git a/python/bindings/block_buffer_python.cc b/python/bindings/block_buffer_python.cc new file mode 100644 index 0000000..d6167eb --- /dev/null +++ b/python/bindings/block_buffer_python.cc @@ -0,0 +1,83 @@ +/* + * 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(block_buffer.h) */ +/* BINDTOOL_HEADER_FILE_HASH(0d1f871ab6a28e9fb16d845fae4b4e48) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_block_buffer(py::module& m) +{ + + using block_buffer = ::gr::sandia_utils::block_buffer; + + + py::class_>(m, "block_buffer", D(block_buffer)) + + .def(py::init(&block_buffer::make), + py::arg("itemsize"), + py::arg("nsamples"), + py::arg("samp_rate"), + py::arg("pass_data") = true, + D(block_buffer,make) + ) + + + + + + + .def("set_nsamples",&block_buffer::set_nsamples, + py::arg("nsamples"), + D(block_buffer,set_nsamples) + ) + + + + .def("set_pass_data",&block_buffer::set_pass_data, + py::arg("pass_data"), + D(block_buffer,set_pass_data) + ) + + + + .def("get_pass_data",&block_buffer::get_pass_data, + D(block_buffer,get_pass_data) + ) + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/burst_power_detector_python.cc b/python/bindings/burst_power_detector_python.cc new file mode 100644 index 0000000..f9ecee8 --- /dev/null +++ b/python/bindings/burst_power_detector_python.cc @@ -0,0 +1,63 @@ +/* + * 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(burst_power_detector.h) */ +/* BINDTOOL_HEADER_FILE_HASH(a0379597f98814dd4b348c6ae67ffc50) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_burst_power_detector(py::module& m) +{ + + using burst_power_detector = ::gr::sandia_utils::burst_power_detector; + + + py::class_>(m, "burst_power_detector", D(burst_power_detector)) + + .def(py::init(&burst_power_detector::make), + py::arg("naverage"), + py::arg("nguard"), + py::arg("threshold"), + py::arg("holdoff"), + D(burst_power_detector,make) + ) + + + + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/complex_to_interleaved_short_python.cc b/python/bindings/complex_to_interleaved_short_python.cc new file mode 100644 index 0000000..b19d05d --- /dev/null +++ b/python/bindings/complex_to_interleaved_short_python.cc @@ -0,0 +1,68 @@ +/* + * 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(complex_to_interleaved_short.h) */ +/* BINDTOOL_HEADER_FILE_HASH(c3152d1f278090b55b671fdae62e5f0a) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_complex_to_interleaved_short(py::module& m) +{ + + using complex_to_interleaved_short = ::gr::sandia_utils::complex_to_interleaved_short; + + + py::class_>(m, "complex_to_interleaved_short", D(complex_to_interleaved_short)) + + .def(py::init(&complex_to_interleaved_short::make), + py::arg("vector") = false, + py::arg("scale") = 1., + D(complex_to_interleaved_short,make) + ) + + + + + + + .def("set_scale",&complex_to_interleaved_short::set_scale, + py::arg("scale"), + D(complex_to_interleaved_short,set_scale) + ) + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/compute_stats_python.cc b/python/bindings/compute_stats_python.cc new file mode 100644 index 0000000..2b392be --- /dev/null +++ b/python/bindings/compute_stats_python.cc @@ -0,0 +1,59 @@ +/* + * 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(compute_stats.h) */ +/* BINDTOOL_HEADER_FILE_HASH(2d40d22b48a78ab58d1003a61be1ed84) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_compute_stats(py::module& m) +{ + + using compute_stats = ::gr::sandia_utils::compute_stats; + + + py::class_>(m, "compute_stats", D(compute_stats)) + + .def(py::init(&compute_stats::make), + D(compute_stats,make) + ) + + + + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/constants_python.cc b/python/bindings/constants_python.cc new file mode 100644 index 0000000..7b6fa3b --- /dev/null +++ b/python/bindings/constants_python.cc @@ -0,0 +1,66 @@ +/* + * Copyright 2018, 2019, 2020 National Technology & Engineering Solutions of Sandia, LLC + * (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government + * retains certain rights in this software. + * + * 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(file_sink.h) */ +/* BINDTOOL_HEADER_FILE_HASH(d3aa4331c3c53279c538c785f41ded79) */ +/***********************************************************************************/ + +#include +#include +#include +#include + +namespace py = pybind11; + +#include + +void bind_constants(py::module& m) +{ + m.add_object("TIME_KEY", py::cast([]() {return &::gr::sandia_utils::TIME_KEY; }, py::return_value_policy::reference)); + m.add_object("RX_TIME_KEY", py::cast([]() {return &::gr::sandia_utils::RX_TIME_KEY; }, py::return_value_policy::reference)); + m.add_object("TX_TIME_KEY", py::cast([]() {return &::gr::sandia_utils::TX_TIME_KEY; }, py::return_value_policy::reference)); + m.add_object("CMD_DIRECTION", py::cast([]() {return &::gr::sandia_utils::CMD_DIRECTION; }, py::return_value_policy::reference)); + m.add_object("CMD_RX", py::cast([]() {return &::gr::sandia_utils::CMD_RX; }, py::return_value_policy::reference)); + m.add_object("CMD_TX", py::cast([]() {return &::gr::sandia_utils::CMD_TX; }, py::return_value_policy::reference)); + m.add_object("CMD_LO_FREQ_KEY", py::cast([]() {return &::gr::sandia_utils::CMD_LO_FREQ_KEY; }, py::return_value_policy::reference)); + m.add_object("CMD_RATE_KEY", py::cast([]() {return &::gr::sandia_utils::CMD_RATE_KEY; }, py::return_value_policy::reference)); + m.add_object("CMD_BW_KEY", py::cast([]() {return &::gr::sandia_utils::CMD_BW_KEY; }, py::return_value_policy::reference)); + + m.add_object("RATE_KEY", py::cast([]() {return &::gr::sandia_utils::RATE_KEY; }, py::return_value_policy::reference)); + m.add_object("FREQ_KEY", py::cast([]() {return &::gr::sandia_utils::FREQ_KEY; }, py::return_value_policy::reference)); + m.add_object("BURST_START_KEY", py::cast([]() {return &::gr::sandia_utils::BURST_START_KEY; }, py::return_value_policy::reference)); + m.add_object("BURST_STOP_KEY", py::cast([]() {return &::gr::sandia_utils::BURST_STOP_KEY; }, py::return_value_policy::reference)); + m.add_object("PDU_KEY", py::cast([]() {return &::gr::sandia_utils::PDU_KEY; }, py::return_value_policy::reference)); + m.add_object("FNAME_KEY", py::cast([]() {return &::gr::sandia_utils::FNAME_KEY; }, py::return_value_policy::reference)); + m.add_object("IN_KEY", py::cast([]() {return &::gr::sandia_utils::IN_KEY; }, py::return_value_policy::reference)); + m.add_object("OUT_KEY", py::cast([]() {return &::gr::sandia_utils::OUT_KEY; }, py::return_value_policy::reference)); + m.add_object("TUNE_KEY", py::cast([]() {return &::gr::sandia_utils::TUNE_KEY; }, py::return_value_policy::reference)); + + py::enum_<::gr::sandia_utils::STUB_MODE>(m, "STUB_MODE") + .value("DROP_STUB", gr::sandia_utils::DROP_STUB) // 0 + .value("PAD_RIGHT", gr::sandia_utils::PAD_RIGHT) // 1 + .value("PAD_LEFT", gr::sandia_utils::PAD_LEFT) // 1 + .export_values(); + + +} + + + + + + + + diff --git a/python/bindings/docstrings/README.md b/python/bindings/docstrings/README.md new file mode 100644 index 0000000..295455a --- /dev/null +++ b/python/bindings/docstrings/README.md @@ -0,0 +1 @@ +This directory stores templates for docstrings that are scraped from the include header files for each block \ No newline at end of file diff --git a/python/bindings/docstrings/block_buffer_pydoc_template.h b/python/bindings/docstrings/block_buffer_pydoc_template.h new file mode 100644 index 0000000..0f93017 --- /dev/null +++ b/python/bindings/docstrings/block_buffer_pydoc_template.h @@ -0,0 +1,39 @@ +/* + * 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,sandia_utils, __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_sandia_utils_block_buffer = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_block_buffer_block_buffer_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_block_buffer_block_buffer_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_block_buffer_make = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_block_buffer_set_nsamples = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_block_buffer_set_pass_data = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_block_buffer_get_pass_data = R"doc()doc"; + + diff --git a/python/bindings/docstrings/burst_power_detector_pydoc_template.h b/python/bindings/docstrings/burst_power_detector_pydoc_template.h new file mode 100644 index 0000000..ab99f09 --- /dev/null +++ b/python/bindings/docstrings/burst_power_detector_pydoc_template.h @@ -0,0 +1,27 @@ +/* + * 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,sandia_utils, __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_sandia_utils_burst_power_detector = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_burst_power_detector_burst_power_detector = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_burst_power_detector_make = R"doc()doc"; + + diff --git a/python/bindings/docstrings/complex_to_interleaved_short_pydoc_template.h b/python/bindings/docstrings/complex_to_interleaved_short_pydoc_template.h new file mode 100644 index 0000000..04727a3 --- /dev/null +++ b/python/bindings/docstrings/complex_to_interleaved_short_pydoc_template.h @@ -0,0 +1,33 @@ +/* + * 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,sandia_utils, __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_sandia_utils_complex_to_interleaved_short = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_complex_to_interleaved_short_complex_to_interleaved_short_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_complex_to_interleaved_short_complex_to_interleaved_short_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_complex_to_interleaved_short_make = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_complex_to_interleaved_short_set_scale = R"doc()doc"; + + diff --git a/python/bindings/docstrings/compute_stats_pydoc_template.h b/python/bindings/docstrings/compute_stats_pydoc_template.h new file mode 100644 index 0000000..3abec72 --- /dev/null +++ b/python/bindings/docstrings/compute_stats_pydoc_template.h @@ -0,0 +1,27 @@ +/* + * 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,sandia_utils, __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_sandia_utils_compute_stats = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_compute_stats_compute_stats = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_compute_stats_make = R"doc()doc"; + + diff --git a/python/bindings/docstrings/file_sink_pydoc_template.h b/python/bindings/docstrings/file_sink_pydoc_template.h new file mode 100644 index 0000000..1d6431c --- /dev/null +++ b/python/bindings/docstrings/file_sink_pydoc_template.h @@ -0,0 +1,81 @@ +/* + * 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,sandia_utils, __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_sandia_utils_file_sink = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_file_sink_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_file_sink_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_make = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_set_recording = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_get_recording = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_set_second_align = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_get_second_align = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_set_mode_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_get_mode = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_set_mode_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_set_gen_new_folder = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_get_gen_new_folder = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_set_freq = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_get_freq = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_set_rate = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_get_rate = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_set_nsamples = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_get_nsamples = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_set_file_num_rollover = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_sink_get_file_num_rollover = R"doc()doc"; + + diff --git a/python/bindings/docstrings/file_source_pydoc_template.h b/python/bindings/docstrings/file_source_pydoc_template.h new file mode 100644 index 0000000..dcf5dd3 --- /dev/null +++ b/python/bindings/docstrings/file_source_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,sandia_utils, __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_sandia_utils_file_source = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_source_file_source_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_source_file_source_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_source_make = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_source_seek = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_source_open = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_source_close = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_source_set_begin_tag = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_source_set_file_queue_depth = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_source_add_file_tags = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_file_source_set_msg_hop_period = R"doc()doc"; + + diff --git a/python/bindings/docstrings/interleaved_short_to_complex_pydoc_template.h b/python/bindings/docstrings/interleaved_short_to_complex_pydoc_template.h new file mode 100644 index 0000000..eaceb68 --- /dev/null +++ b/python/bindings/docstrings/interleaved_short_to_complex_pydoc_template.h @@ -0,0 +1,36 @@ +/* + * 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,sandia_utils, __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_sandia_utils_interleaved_short_to_complex = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_interleaved_short_to_complex_interleaved_short_to_complex_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_interleaved_short_to_complex_interleaved_short_to_complex_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_interleaved_short_to_complex_make = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_interleaved_short_to_complex_set_swap = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_interleaved_short_to_complex_set_scale = R"doc()doc"; + + diff --git a/python/bindings/docstrings/invert_tune_pydoc_template.h b/python/bindings/docstrings/invert_tune_pydoc_template.h new file mode 100644 index 0000000..ad99787 --- /dev/null +++ b/python/bindings/docstrings/invert_tune_pydoc_template.h @@ -0,0 +1,27 @@ +/* + * 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,sandia_utils, __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_sandia_utils_invert_tune = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_invert_tune_invert_tune = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_invert_tune_make = R"doc()doc"; + + diff --git a/python/bindings/docstrings/message_vector_file_sink_pydoc_template.h b/python/bindings/docstrings/message_vector_file_sink_pydoc_template.h new file mode 100644 index 0000000..0a0f007 --- /dev/null +++ b/python/bindings/docstrings/message_vector_file_sink_pydoc_template.h @@ -0,0 +1,33 @@ +/* + * 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,sandia_utils, __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_sandia_utils_message_vector_file_sink = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_message_vector_file_sink_message_vector_file_sink_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_message_vector_file_sink_message_vector_file_sink_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_message_vector_file_sink_make = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_message_vector_file_sink_get_filename = R"doc()doc"; + + diff --git a/python/bindings/docstrings/message_vector_raster_file_sink_pydoc_template.h b/python/bindings/docstrings/message_vector_raster_file_sink_pydoc_template.h new file mode 100644 index 0000000..6b0ec45 --- /dev/null +++ b/python/bindings/docstrings/message_vector_raster_file_sink_pydoc_template.h @@ -0,0 +1,36 @@ +/* + * 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,sandia_utils, __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_sandia_utils_message_vector_raster_file_sink = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_message_vector_raster_file_sink_message_vector_raster_file_sink_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_message_vector_raster_file_sink_message_vector_raster_file_sink_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_message_vector_raster_file_sink_make = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_message_vector_raster_file_sink_reset = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_message_vector_raster_file_sink_get_filename = R"doc()doc"; + + diff --git a/python/bindings/docstrings/sandia_tag_debug_pydoc_template.h b/python/bindings/docstrings/sandia_tag_debug_pydoc_template.h new file mode 100644 index 0000000..fb77c67 --- /dev/null +++ b/python/bindings/docstrings/sandia_tag_debug_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,sandia_utils, __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_sandia_utils_sandia_tag_debug = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_sandia_tag_debug_sandia_tag_debug_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_sandia_tag_debug_sandia_tag_debug_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_sandia_tag_debug_make = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_sandia_tag_debug_current_tags = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_sandia_tag_debug_get_tag = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_sandia_tag_debug_clear_tags = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_sandia_tag_debug_num_tags = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_sandia_tag_debug_set_display = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_sandia_tag_debug_set_key_filter = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_sandia_tag_debug_key_filter = R"doc()doc"; + + diff --git a/python/bindings/docstrings/stream_gate_pydoc_template.h b/python/bindings/docstrings/stream_gate_pydoc_template.h new file mode 100644 index 0000000..1250e42 --- /dev/null +++ b/python/bindings/docstrings/stream_gate_pydoc_template.h @@ -0,0 +1,24 @@ +/* + * Copyright 2018, 2019, 2020 National Technology & Engineering Solutions of Sandia, LLC + * (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government + * retains certain rights in this software. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ +#include "pydoc_macros.h" +#define D(...) DOC(gr,sandia_utils, __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_sandia_utils_stream_gate = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_stream_gate_make = R"doc()doc"; + + diff --git a/python/bindings/docstrings/tag_debug_file_pydoc_template.h b/python/bindings/docstrings/tag_debug_file_pydoc_template.h new file mode 100644 index 0000000..6823fe5 --- /dev/null +++ b/python/bindings/docstrings/tag_debug_file_pydoc_template.h @@ -0,0 +1,48 @@ +/* + * 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,sandia_utils, __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_sandia_utils_tag_debug_file = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tag_debug_file_tag_debug_file_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tag_debug_file_tag_debug_file_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tag_debug_file_make = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tag_debug_file_current_tags = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tag_debug_file_num_tags = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tag_debug_file_set_display = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tag_debug_file_set_filewrite = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tag_debug_file_set_key_filter = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tag_debug_file_key_filter = R"doc()doc"; + + diff --git a/python/bindings/docstrings/tagged_bits_to_bytes_pydoc_template.h b/python/bindings/docstrings/tagged_bits_to_bytes_pydoc_template.h new file mode 100644 index 0000000..b8e7c41 --- /dev/null +++ b/python/bindings/docstrings/tagged_bits_to_bytes_pydoc_template.h @@ -0,0 +1,39 @@ +/* + * 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,sandia_utils, __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_sandia_utils_tagged_bits_to_bytes = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tagged_bits_to_bytes_tagged_bits_to_bytes_0 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tagged_bits_to_bytes_tagged_bits_to_bytes_1 = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tagged_bits_to_bytes_make = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tagged_bits_to_bytes_set_vlen = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tagged_bits_to_bytes_set_little_endian_flag = R"doc()doc"; + + + static const char *__doc_gr_sandia_utils_tagged_bits_to_bytes_set_sample_rate = R"doc()doc"; + + diff --git a/python/bindings/file_sink_python.cc b/python/bindings/file_sink_python.cc new file mode 100644 index 0000000..7ef9928 --- /dev/null +++ b/python/bindings/file_sink_python.cc @@ -0,0 +1,186 @@ +/* + * 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(file_sink.h) */ +/* BINDTOOL_HEADER_FILE_HASH(d3aa4331c3c53279c538c785f41ded79) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_file_sink(py::module& m) +{ + + using file_sink = ::gr::sandia_utils::file_sink; + + + py::class_>(m, "file_sink", D(file_sink)) + + .def(py::init(&file_sink::make), + py::arg("data_type"), + py::arg("itemsize"), + py::arg("file_type"), + py::arg("mode"), + py::arg("nsamples"), + py::arg("rate"), + py::arg("out_dir"), + py::arg("name_spec"), + py::arg("debug") = false, + D(file_sink,make) + ) + + + + + + + .def("set_recording",&file_sink::set_recording, + py::arg("state"), + D(file_sink,set_recording) + ) + + + + .def("get_recording",&file_sink::get_recording, + D(file_sink,get_recording) + ) + + + + .def("set_second_align",&file_sink::set_second_align, + py::arg("align"), + D(file_sink,set_second_align) + ) + + + + .def("get_second_align",&file_sink::get_second_align, + D(file_sink,get_second_align) + ) + + + + .def("set_mode",(void (file_sink::*)(gr::sandia_utils::trigger_type_t))&file_sink::set_mode, + py::arg("mode"), + D(file_sink,set_mode,0) + ) + + + + .def("get_mode",&file_sink::get_mode, + D(file_sink,get_mode) + ) + + + + .def("set_mode",(void (file_sink::*)(int))&file_sink::set_mode, + py::arg("mode"), + D(file_sink,set_mode,1) + ) + + + + .def("set_gen_new_folder",&file_sink::set_gen_new_folder, + py::arg("value"), + D(file_sink,set_gen_new_folder) + ) + + + + .def("get_gen_new_folder",&file_sink::get_gen_new_folder, + D(file_sink,get_gen_new_folder) + ) + + + + .def("set_freq",&file_sink::set_freq, + py::arg("freq"), + D(file_sink,set_freq) + ) + + + + .def("get_freq",&file_sink::get_freq, + D(file_sink,get_freq) + ) + + + + .def("set_rate",&file_sink::set_rate, + py::arg("rate"), + D(file_sink,set_rate) + ) + + + + .def("get_rate",&file_sink::get_rate, + D(file_sink,get_rate) + ) + + + + .def("set_nsamples",&file_sink::set_nsamples, + py::arg("nsamples"), + D(file_sink,set_nsamples) + ) + + + + .def("get_nsamples",&file_sink::get_nsamples, + D(file_sink,get_nsamples) + ) + + + + .def("set_file_num_rollover",&file_sink::set_file_num_rollover, + py::arg("rollover"), + D(file_sink,set_file_num_rollover) + ) + + + + .def("get_file_num_rollover",&file_sink::get_file_num_rollover, + D(file_sink,get_file_num_rollover) + ) + + ; + + py::enum_<::gr::sandia_utils::trigger_type_t>(m,"trigger_type_t") + .value("MANUAL", ::gr::sandia_utils::MANUAL) // 0 + .value("TRIGGERED", ::gr::sandia_utils::TRIGGERED) // 1 + .export_values() + ; + + py::implicitly_convertible(); + + + +} + + + + + + + + diff --git a/python/bindings/file_source_python.cc b/python/bindings/file_source_python.cc new file mode 100644 index 0000000..72fb964 --- /dev/null +++ b/python/bindings/file_source_python.cc @@ -0,0 +1,114 @@ +/* + * 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(file_source.h) */ +/* BINDTOOL_HEADER_FILE_HASH(56cac55772cf4c09bfdc68914ead43ef) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_file_source(py::module& m) +{ + + using file_source = ::gr::sandia_utils::file_source; + + + py::class_>(m, "file_source", D(file_source)) + + .def(py::init(&file_source::make), + py::arg("itemsize"), + py::arg("filename"), + py::arg("type"), + py::arg("repeat") = false, + py::arg("force_new") = false, + D(file_source,make) + ) + + + + + + + .def("seek",&file_source::seek, + py::arg("seek_point"), + py::arg("whence"), + D(file_source,seek) + ) + + + + .def("open",&file_source::open, + py::arg("filename"), + py::arg("repeat"), + D(file_source,open) + ) + + + + .def("close",&file_source::close, + D(file_source,close) + ) + + + + .def("set_begin_tag",&file_source::set_begin_tag, + py::arg("val"), + D(file_source,set_begin_tag) + ) + + + + .def("set_file_queue_depth",&file_source::set_file_queue_depth, + py::arg("depth"), + D(file_source,set_file_queue_depth) + ) + + + + .def("add_file_tags",&file_source::add_file_tags, + py::arg("tag"), + D(file_source,add_file_tags) + ) + + + + .def("set_msg_hop_period",&file_source::set_msg_hop_period, + py::arg("period_ms"), + D(file_source,set_msg_hop_period) + ) + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/header_utils.py b/python/bindings/header_utils.py new file mode 100644 index 0000000..165124e --- /dev/null +++ b/python/bindings/header_utils.py @@ -0,0 +1,78 @@ +# Utilities for reading values in header files + +from argparse import ArgumentParser +import re + + +class PybindHeaderParser: + def __init__(self, pathname): + with open(pathname,'r') as f: + self.file_txt = f.read() + + def get_flag_automatic(self): + # p = re.compile(r'BINDTOOL_GEN_AUTOMATIC\(([^\s])\)') + # m = p.search(self.file_txt) + m = re.search(r'BINDTOOL_GEN_AUTOMATIC\(([^\s])\)', self.file_txt) + if (m and m.group(1) == '1'): + return True + else: + return False + + def get_flag_pygccxml(self): + # p = re.compile(r'BINDTOOL_USE_PYGCCXML\(([^\s])\)') + # m = p.search(self.file_txt) + m = re.search(r'BINDTOOL_USE_PYGCCXML\(([^\s])\)', self.file_txt) + if (m and m.group(1) == '1'): + return True + else: + return False + + def get_header_filename(self): + # p = re.compile(r'BINDTOOL_HEADER_FILE\(([^\s]*)\)') + # m = p.search(self.file_txt) + m = re.search(r'BINDTOOL_HEADER_FILE\(([^\s]*)\)', self.file_txt) + if (m): + return m.group(1) + else: + return None + + def get_header_file_hash(self): + # p = re.compile(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)') + # m = p.search(self.file_txt) + m = re.search(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)', self.file_txt) + if (m): + return m.group(1) + else: + return None + + def get_flags(self): + return f'{self.get_flag_automatic()};{self.get_flag_pygccxml()};{self.get_header_filename()};{self.get_header_file_hash()};' + + + +def argParse(): + """Parses commandline args.""" + desc='Reads the parameters from the comment block in the pybind files' + parser = ArgumentParser(description=desc) + + parser.add_argument("function", help="Operation to perform on comment block of pybind file", choices=["flag_auto","flag_pygccxml","header_filename","header_file_hash","all"]) + parser.add_argument("pathname", help="Pathname of pybind c++ file to read, e.g. blockname_python.cc") + + return parser.parse_args() + +if __name__ == "__main__": + # Parse command line options and set up doxyxml. + args = argParse() + + pbhp = PybindHeaderParser(args.pathname) + + if args.function == "flag_auto": + print(pbhp.get_flag_automatic()) + elif args.function == "flag_pygccxml": + print(pbhp.get_flag_pygccxml()) + elif args.function == "header_filename": + print(pbhp.get_header_filename()) + elif args.function == "header_file_hash": + print(pbhp.get_header_file_hash()) + elif args.function == "all": + print(pbhp.get_flags()) \ No newline at end of file diff --git a/python/bindings/interleaved_short_to_complex_python.cc b/python/bindings/interleaved_short_to_complex_python.cc new file mode 100644 index 0000000..e576062 --- /dev/null +++ b/python/bindings/interleaved_short_to_complex_python.cc @@ -0,0 +1,76 @@ +/* + * 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(interleaved_short_to_complex.h) */ +/* BINDTOOL_HEADER_FILE_HASH(85290bcc03c2cca82cfe4074d0135fad) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_interleaved_short_to_complex(py::module& m) +{ + + using interleaved_short_to_complex = ::gr::sandia_utils::interleaved_short_to_complex; + + + py::class_>(m, "interleaved_short_to_complex", D(interleaved_short_to_complex)) + + .def(py::init(&interleaved_short_to_complex::make), + py::arg("vector_input") = false, + py::arg("swap") = false, + py::arg("scale") = 1., + D(interleaved_short_to_complex,make) + ) + + + + + + + .def("set_swap",&interleaved_short_to_complex::set_swap, + py::arg("swap"), + D(interleaved_short_to_complex,set_swap) + ) + + + + .def("set_scale",&interleaved_short_to_complex::set_scale, + py::arg("scale"), + D(interleaved_short_to_complex,set_scale) + ) + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/invert_tune_python.cc b/python/bindings/invert_tune_python.cc new file mode 100644 index 0000000..38a5861 --- /dev/null +++ b/python/bindings/invert_tune_python.cc @@ -0,0 +1,59 @@ +/* + * 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(invert_tune.h) */ +/* BINDTOOL_HEADER_FILE_HASH(03e1bfbf96f4f6d0ae8b94bb84a3cee2) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_invert_tune(py::module& m) +{ + + using invert_tune = ::gr::sandia_utils::invert_tune; + + + py::class_>(m, "invert_tune", D(invert_tune)) + + .def(py::init(&invert_tune::make), + D(invert_tune,make) + ) + + + + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/message_vector_file_sink_python.cc b/python/bindings/message_vector_file_sink_python.cc new file mode 100644 index 0000000..5c40cfd --- /dev/null +++ b/python/bindings/message_vector_file_sink_python.cc @@ -0,0 +1,66 @@ +/* + * 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(message_vector_file_sink.h) */ +/* BINDTOOL_HEADER_FILE_HASH(40ba6db46863a15b455b28a5422a9623) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_message_vector_file_sink(py::module& m) +{ + + using message_vector_file_sink = ::gr::sandia_utils::message_vector_file_sink; + + + py::class_>(m, "message_vector_file_sink", D(message_vector_file_sink)) + + .def(py::init(&message_vector_file_sink::make), + py::arg("filename"), + D(message_vector_file_sink,make) + ) + + + + + + + .def("get_filename",&message_vector_file_sink::get_filename, + D(message_vector_file_sink,get_filename) + ) + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/message_vector_raster_file_sink_python.cc b/python/bindings/message_vector_raster_file_sink_python.cc new file mode 100644 index 0000000..fb06c6c --- /dev/null +++ b/python/bindings/message_vector_raster_file_sink_python.cc @@ -0,0 +1,73 @@ +/* + * 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(message_vector_raster_file_sink.h) */ +/* BINDTOOL_HEADER_FILE_HASH(67b3c2b56e98c2561c23beec40e47e13) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_message_vector_raster_file_sink(py::module& m) +{ + + using message_vector_raster_file_sink = ::gr::sandia_utils::message_vector_raster_file_sink; + + + py::class_>(m, "message_vector_raster_file_sink", D(message_vector_raster_file_sink)) + + .def(py::init(&message_vector_raster_file_sink::make), + py::arg("filename"), + py::arg("n_rows"), + D(message_vector_raster_file_sink,make) + ) + + + + + + + .def("reset",&message_vector_raster_file_sink::reset, + D(message_vector_raster_file_sink,reset) + ) + + + + .def("get_filename",&message_vector_raster_file_sink::get_filename, + D(message_vector_raster_file_sink,get_filename) + ) + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/python_bindings.cc b/python/bindings/python_bindings.cc new file mode 100644 index 0000000..8688326 --- /dev/null +++ b/python/bindings/python_bindings.cc @@ -0,0 +1,83 @@ +/* + * Copyright 2018, 2019, 2020 National Technology & Engineering Solutions of Sandia, LLC + * (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government + * retains certain rights in this software. + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#include + +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#include + +namespace py = pybind11; + +// Headers for binding functions +/**************************************/ +// The following comment block is used for +// gr_modtool to insert function prototypes +// Please do not delete +/**************************************/ +// BINDING_FUNCTION_PROTOTYPES( + void bind_block_buffer(py::module& m); + void bind_burst_power_detector(py::module& m); + void bind_interleaved_short_to_complex(py::module& m); + void bind_complex_to_interleaved_short(py::module& m); + void bind_file_sink(py::module& m); + void bind_invert_tune(py::module& m); + void bind_file_source(py::module& m); + void bind_message_vector_file_sink(py::module& m); + void bind_message_vector_raster_file_sink(py::module& m); + void bind_tag_debug_file(py::module& m); + void bind_sandia_tag_debug(py::module& m); + void bind_tagged_bits_to_bytes(py::module& m); + void bind_stream_gate(py::module& m); + void bind_compute_stats(py::module& m); + void bind_constants(py::module& m); +// ) END BINDING_FUNCTION_PROTOTYPES + + +// 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(sandia_utils_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"); + + /**************************************/ + // The following comment block is used for + // gr_modtool to insert binding function calls + // Please do not delete + /**************************************/ + // BINDING_FUNCTION_CALLS( + bind_block_buffer(m); + bind_burst_power_detector(m); + bind_interleaved_short_to_complex(m); + bind_complex_to_interleaved_short(m); + bind_file_sink(m); + bind_invert_tune(m); + bind_file_source(m); + bind_message_vector_file_sink(m); + bind_message_vector_raster_file_sink(m); + bind_tag_debug_file(m); + bind_sandia_tag_debug(m); + bind_tagged_bits_to_bytes(m); + bind_stream_gate(m); + bind_compute_stats(m); + bind_constants(m); + // ) END BINDING_FUNCTION_CALLS +} diff --git a/python/bindings/sandia_tag_debug_python.cc b/python/bindings/sandia_tag_debug_python.cc new file mode 100644 index 0000000..ddf562d --- /dev/null +++ b/python/bindings/sandia_tag_debug_python.cc @@ -0,0 +1,108 @@ +/* + * 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(sandia_tag_debug.h) */ +/* BINDTOOL_HEADER_FILE_HASH(0274b64a97497ed79b5fb631eba51f9a) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_sandia_tag_debug(py::module& m) +{ + + using sandia_tag_debug = ::gr::sandia_utils::sandia_tag_debug; + + + py::class_>(m, "sandia_tag_debug", D(sandia_tag_debug)) + + .def(py::init(&sandia_tag_debug::make), + py::arg("sizeof_stream_item"), + py::arg("name"), + py::arg("key_filter") = "", + py::arg("store_all") = true, + D(sandia_tag_debug,make) + ) + + + + + + + .def("current_tags",&sandia_tag_debug::current_tags, + D(sandia_tag_debug,current_tags) + ) + + + + .def("get_tag",&sandia_tag_debug::get_tag, + py::arg("idx"), + D(sandia_tag_debug,get_tag) + ) + + + + .def("clear_tags",&sandia_tag_debug::clear_tags, + D(sandia_tag_debug,clear_tags) + ) + + + + .def("num_tags",&sandia_tag_debug::num_tags, + D(sandia_tag_debug,num_tags) + ) + + + + .def("set_display",&sandia_tag_debug::set_display, + py::arg("d"), + D(sandia_tag_debug,set_display) + ) + + + + .def("set_key_filter",&sandia_tag_debug::set_key_filter, + py::arg("key_filter"), + D(sandia_tag_debug,set_key_filter) + ) + + + + .def("key_filter",&sandia_tag_debug::key_filter, + D(sandia_tag_debug,key_filter) + ) + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/stream_gate_python.cc b/python/bindings/stream_gate_python.cc new file mode 100644 index 0000000..573e30d --- /dev/null +++ b/python/bindings/stream_gate_python.cc @@ -0,0 +1,62 @@ +/* + * Copyright 2018, 2019, 2020 National Technology & Engineering Solutions of Sandia, LLC + * (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government + * retains certain rights in this software. + * + * 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(stream_gate.h) */ +/* BINDTOOL_HEADER_FILE_HASH(319ecf9669abd63365872a056fb154fa) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +template +void bind_stream_gate_template(py::module& m, const char* classname) +{ + using stream_gate = gr::sandia_utils::stream_gate; + + py::class_>(m, classname) + + .def(py::init(&gr::sandia_utils::stream_gate::make), + py::arg("flow_data") = true, + py::arg("consume_data") = true, + D(stream_gate,make) + ); +} + +void bind_stream_gate(py::module& m) +{ + bind_stream_gate_template(m, "stream_gate_b"); + bind_stream_gate_template(m, "stream_gate_s"); + bind_stream_gate_template(m, "stream_gate_i"); + bind_stream_gate_template(m, "stream_gate_f"); + bind_stream_gate_template(m, "stream_gate_c"); +} + + + + + + + + diff --git a/python/bindings/tag_debug_file_python.cc b/python/bindings/tag_debug_file_python.cc new file mode 100644 index 0000000..449b30e --- /dev/null +++ b/python/bindings/tag_debug_file_python.cc @@ -0,0 +1,103 @@ +/* + * 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(tag_debug_file.h) */ +/* BINDTOOL_HEADER_FILE_HASH(b9353be4511d0d3b88b1732781b10825) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_tag_debug_file(py::module& m) +{ + + using tag_debug_file = ::gr::sandia_utils::tag_debug_file; + + + py::class_>(m, "tag_debug_file", D(tag_debug_file)) + + .def(py::init(&tag_debug_file::make), + py::arg("sizeof_stream_item"), + py::arg("name"), + py::arg("key_filter"), + py::arg("filename"), + D(tag_debug_file,make) + ) + + + + + + + .def("current_tags",&tag_debug_file::current_tags, + D(tag_debug_file,current_tags) + ) + + + + .def("num_tags",&tag_debug_file::num_tags, + D(tag_debug_file,num_tags) + ) + + + + .def("set_display",&tag_debug_file::set_display, + py::arg("d"), + D(tag_debug_file,set_display) + ) + + + + .def("set_filewrite",&tag_debug_file::set_filewrite, + py::arg("w"), + py::arg("clear") = false, + D(tag_debug_file,set_filewrite) + ) + + + + .def("set_key_filter",&tag_debug_file::set_key_filter, + py::arg("key_filter"), + D(tag_debug_file,set_key_filter) + ) + + + + .def("key_filter",&tag_debug_file::key_filter, + D(tag_debug_file,key_filter) + ) + + ; + + + + +} + + + + + + + + diff --git a/python/bindings/tagged_bits_to_bytes_python.cc b/python/bindings/tagged_bits_to_bytes_python.cc new file mode 100644 index 0000000..e6ecfd0 --- /dev/null +++ b/python/bindings/tagged_bits_to_bytes_python.cc @@ -0,0 +1,85 @@ +/* + * 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(tagged_bits_to_bytes.h) */ +/* BINDTOOL_HEADER_FILE_HASH(60995d1608f97ae8eac5a69e37a6a858) */ +/***********************************************************************************/ + +#include +#include +#include + +namespace py = pybind11; + +#include +// pydoc.h is automatically generated in the build directory +#include + +void bind_tagged_bits_to_bytes(py::module& m) +{ + + using tagged_bits_to_bytes = ::gr::sandia_utils::tagged_bits_to_bytes; + + + py::class_>(m, "tagged_bits_to_bytes", D(tagged_bits_to_bytes)) + + .def(py::init(&tagged_bits_to_bytes::make), + py::arg("key") = "BURST", + py::arg("little_endian") = false, + py::arg("stub_mode") = 0, + py::arg("v_len") = 1, + py::arg("sample_rate") = 1, + D(tagged_bits_to_bytes,make) + ) + + + + + + + .def("set_vlen",&tagged_bits_to_bytes::set_vlen, + py::arg("vlen"), + D(tagged_bits_to_bytes,set_vlen) + ) + + + + .def("set_little_endian_flag",&tagged_bits_to_bytes::set_little_endian_flag, + py::arg("lsb_first"), + D(tagged_bits_to_bytes,set_little_endian_flag) + ) + + + + .def("set_sample_rate",&tagged_bits_to_bytes::set_sample_rate, + py::arg("samp_rate"), + D(tagged_bits_to_bytes,set_sample_rate) + ) + + ; + + + + +} + + + + + + + + diff --git a/python/build_utils.py b/python/build_utils.py deleted file mode 100644 index 3fc6192..0000000 --- a/python/build_utils.py +++ /dev/null @@ -1,213 +0,0 @@ -# -# Copyright 2004,2009,2012 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# SPDX-License-Identifier: GPL-3.0-or-later -# - -"""Misc utilities used at build time -""" - -import re, os, os.path -from build_utils_codes import * - - -# set srcdir to the directory that contains Makefile.am -try: - srcdir = os.environ['srcdir'] -except KeyError, e: - srcdir = "." -srcdir = srcdir + '/' - -# set do_makefile to either true or false dependeing on the environment -try: - if os.environ['do_makefile'] == '0': - do_makefile = False - else: - do_makefile = True -except KeyError, e: - do_makefile = False - -# set do_sources to either true or false dependeing on the environment -try: - if os.environ['do_sources'] == '0': - do_sources = False - else: - do_sources = True -except KeyError, e: - do_sources = True - -name_dict = {} - -def log_output_name (name): - (base, ext) = os.path.splitext (name) - ext = ext[1:] # drop the leading '.' - - entry = name_dict.setdefault (ext, []) - entry.append (name) - -def open_and_log_name (name, dir): - global do_sources - if do_sources: - f = open (name, dir) - else: - f = None - log_output_name (name) - return f - -def expand_template (d, template_filename, extra = ""): - '''Given a dictionary D and a TEMPLATE_FILENAME, expand template into output file - ''' - global do_sources - output_extension = extract_extension (template_filename) - template = open_src (template_filename, 'r') - output_name = d['NAME'] + extra + '.' + output_extension - log_output_name (output_name) - if do_sources: - output = open (output_name, 'w') - do_substitution (d, template, output) - output.close () - template.close () - -def output_glue (dirname): - output_makefile_fragment () - output_ifile_include (dirname) - -def output_makefile_fragment (): - global do_makefile - if not do_makefile: - return -# overwrite the source, which must be writable; this should have been -# checked for beforehand in the top-level Makefile.gen.gen . - f = open (os.path.join (os.environ.get('gendir', os.environ.get('srcdir', '.')), 'Makefile.gen'), 'w') - f.write ('#\n# This file is machine generated. All edits will be overwritten\n#\n') - output_subfrag (f, 'h') - output_subfrag (f, 'i') - output_subfrag (f, 'cc') - f.close () - -def output_ifile_include (dirname): - global do_sources - if do_sources: - f = open ('%s_generated.i' % (dirname,), 'w') - f.write ('//\n// This file is machine generated. All edits will be overwritten\n//\n') - files = name_dict.setdefault ('i', []) - files.sort () - f.write ('%{\n') - for file in files: - f.write ('#include <%s>\n' % (file[0:-1] + 'h',)) - f.write ('%}\n\n') - for file in files: - f.write ('%%include <%s>\n' % (file,)) - -def output_subfrag (f, ext): - files = name_dict.setdefault (ext, []) - files.sort () - f.write ("GENERATED_%s =" % (ext.upper ())) - for file in files: - f.write (" \\\n\t%s" % (file,)) - f.write ("\n\n") - -def extract_extension (template_name): - # template name is something like: GrFIRfilterXXX.h.t - # we return everything between the penultimate . and .t - mo = re.search (r'\.([a-z]+)\.t$', template_name) - if not mo: - raise ValueError, "Incorrectly formed template_name '%s'" % (template_name,) - return mo.group (1) - -def open_src (name, mode): - global srcdir - return open (os.path.join (srcdir, name), mode) - -def do_substitution (d, in_file, out_file): - def repl (match_obj): - key = match_obj.group (1) - # print key - return d[key] - - inp = in_file.read () - out = re.sub (r"@([a-zA-Z0-9_]+)@", repl, inp) - out_file.write (out) - - - -copyright = '''/* -*- c++ -*- */ -/* - * Copyright 2003,2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -''' - -def is_complex (code3): - if i_code (code3) == 'c' or o_code (code3) == 'c': - return '1' - else: - return '0' - - -def standard_dict (name, code3, package='gr'): - d = {} - d['NAME'] = name - d['NAME_IMPL'] = name+'_impl' - d['GUARD_NAME'] = 'INCLUDED_%s_%s_H' % (package.upper(), name.upper()) - d['GUARD_NAME_IMPL'] = 'INCLUDED_%s_%s_IMPL_H' % (package.upper(), name.upper()) - d['BASE_NAME'] = re.sub ('^' + package + '_', '', name) - d['SPTR_NAME'] = '%s_sptr' % name - d['WARNING'] = 'WARNING: this file is machine generated. Edits will be overwritten' - d['COPYRIGHT'] = copyright - d['TYPE'] = i_type (code3) - d['I_TYPE'] = i_type (code3) - d['O_TYPE'] = o_type (code3) - d['TAP_TYPE'] = tap_type (code3) - d['IS_COMPLEX'] = is_complex (code3) - return d - - -def standard_dict2 (name, code3, package): - d = {} - d['NAME'] = name - d['BASE_NAME'] = name - d['GUARD_NAME'] = 'INCLUDED_%s_%s_H' % (package.upper(), name.upper()) - d['WARNING'] = 'WARNING: this file is machine generated. Edits will be overwritten' - d['COPYRIGHT'] = copyright - d['TYPE'] = i_type (code3) - d['I_TYPE'] = i_type (code3) - d['O_TYPE'] = o_type (code3) - d['TAP_TYPE'] = tap_type (code3) - d['IS_COMPLEX'] = is_complex (code3) - return d - -def standard_impl_dict2 (name, code3, package): - d = {} - d['NAME'] = name - d['IMPL_NAME'] = name - d['BASE_NAME'] = name.rstrip("impl").rstrip("_") - d['GUARD_NAME'] = 'INCLUDED_%s_%s_H' % (package.upper(), name.upper()) - d['WARNING'] = 'WARNING: this file is machine generated. Edits will be overwritten' - d['COPYRIGHT'] = copyright - d['FIR_TYPE'] = "fir_filter_" + code3 - d['CFIR_TYPE'] = "fir_filter_" + code3[0:2] + 'c' - d['TYPE'] = i_type (code3) - d['I_TYPE'] = i_type (code3) - d['O_TYPE'] = o_type (code3) - d['TAP_TYPE'] = tap_type (code3) - d['IS_COMPLEX'] = is_complex (code3) - return d diff --git a/python/build_utils_codes.py b/python/build_utils_codes.py deleted file mode 100644 index 1c66b51..0000000 --- a/python/build_utils_codes.py +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright 2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# SPDX-License-Identifier: GPL-3.0-or-later -# - -def i_code (code3): - return code3[0] - -def o_code (code3): - if len (code3) >= 2: - return code3[1] - else: - return code3[0] - -def tap_code (code3): - if len (code3) >= 3: - return code3[2] - else: - return code3[0] - -def i_type (code3): - return char_to_type[i_code (code3)] - -def o_type (code3): - return char_to_type[o_code (code3)] - -def tap_type (code3): - return char_to_type[tap_code (code3)] - - -char_to_type = {} -char_to_type['s'] = 'short' -char_to_type['i'] = 'int' -char_to_type['f'] = 'float' -char_to_type['c'] = 'gr_complex' -char_to_type['b'] = 'unsigned char' diff --git a/python/csv_reader.py b/python/csv_reader.py index b9a33b9..6adf9db 100644 --- a/python/csv_reader.py +++ b/python/csv_reader.py @@ -82,7 +82,7 @@ def __init__(self, fname='', has_header=True, data_type='uint8', # setup logger logger_name = 'gr_log.' + self.to_basic_block().alias() - if logger_name in gr.logger_get_names(): + if logger_name in gr.logger_get_logger_names(): self.log = gr.logger(logger_name) else: self.log = gr.logger('log') diff --git a/python/csv_writer.py b/python/csv_writer.py index 074eca0..9cbb776 100644 --- a/python/csv_writer.py +++ b/python/csv_writer.py @@ -102,7 +102,7 @@ def __init__(self, fname='', add_metadata=False, metadata_format='', data_type=' # setup logger logger_name = 'gr_log.' + self.to_basic_block().alias() - if logger_name in gr.logger_get_names(): + if logger_name in gr.logger_get_logger_names(): self.log = gr.logger(logger_name) else: self.log = gr.logger('log') @@ -153,7 +153,7 @@ def __init__(self, fname='', add_metadata=False, metadata_format='', data_type=' self.set_msg_handler(self.message_port_name, self.message_handler) def message_handler(self, msg): - if not pmt.is_dict(msg): + if not pmt.is_pair(msg) and not pmt.is_dict(msg): return try: diff --git a/python/file_archiver.py b/python/file_archiver.py index c17dc2b..4d6133a 100644 --- a/python/file_archiver.py +++ b/python/file_archiver.py @@ -56,7 +56,7 @@ def __init__(self, output_path="/tmp", fname_format = "", archive = False): # setup logger logger_name = 'gr_log.' + self.to_basic_block().alias() - if logger_name in gr.logger_get_names(): + if logger_name in gr.logger_get_logger_names(): self.log = gr.logger(logger_name) else: self.log = gr.logger('log') diff --git a/python/file_monitor.py b/python/file_monitor.py index fd3a1fc..b3d88dd 100644 --- a/python/file_monitor.py +++ b/python/file_monitor.py @@ -43,7 +43,7 @@ def __init__(self, nfiles_max=10, output_path="/tmp", copy = False): # setup logger logger_name = 'gr_log.' + self.to_basic_block().alias() - if logger_name in gr.logger_get_names(): + if logger_name in gr.logger_get_logger_names(): self.log = gr.logger(logger_name) else: self.log = gr.logger('log') diff --git a/python/qa_block_buffer.py b/python/qa_block_buffer.py index b099790..8d0482b 100644 --- a/python/qa_block_buffer.py +++ b/python/qa_block_buffer.py @@ -8,10 +8,18 @@ # SPDX-License-Identifier: GPL-3.0-or-later # -import time from gnuradio import gr, gr_unittest from gnuradio import blocks, analog -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils +import time + class qa_block_buffer(gr_unittest.TestCase): @@ -72,4 +80,4 @@ def test_1(self): if __name__ == '__main__': - gr_unittest.run(qa_block_buffer, "qa_block_buffer.xml") + gr_unittest.run(qa_block_buffer) \ No newline at end of file diff --git a/python/qa_burst_power_detector.py b/python/qa_burst_power_detector.py index 2fac2fe..cd2c57b 100755 --- a/python/qa_burst_power_detector.py +++ b/python/qa_burst_power_detector.py @@ -10,7 +10,14 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils import time @@ -24,8 +31,8 @@ def tearDown(self): def test_001_instantiation(self): # data - src_data = (1 + 1j, 2 + 2j, 3 + 3j) - expected_result = () + src_data = [1 + 1j, 2 + 2j, 3 + 3j] + expected_result = [] # blocks src = blocks.vector_source_c(src_data) @@ -46,4 +53,4 @@ def test_001_instantiation(self): if __name__ == '__main__': - gr_unittest.run(qa_burst_power_detector, "qa_burst_power_detector.xml") + gr_unittest.run(qa_burst_power_detector) diff --git a/python/qa_complex_to_interleaved_short.py b/python/qa_complex_to_interleaved_short.py index 52e7137..534eb49 100755 --- a/python/qa_complex_to_interleaved_short.py +++ b/python/qa_complex_to_interleaved_short.py @@ -10,7 +10,15 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils + class qa_complex_to_interleaved_short (gr_unittest.TestCase): @@ -23,7 +31,7 @@ def tearDown(self): def test_no_scale(self): # data src_data = (1+1j,2+2j,3+3j) - expected_result = (1,1,2,2,3,3) + expected_result = [1,1,2,2,3,3] # blocks src = blocks.vector_source_c(src_data) @@ -44,7 +52,7 @@ def test_with_scale(self): # data src_data = (1+1j,2+2j,3+3j) scale = 2.0 - expected_result =tuple(i*scale for i in (1,1,2,2,3,3)) + expected_result = list(i*scale for i in [1,1,2,2,3,3]) # blocks src = blocks.vector_source_c(src_data) @@ -64,7 +72,7 @@ def test_with_scale(self): def test_vector(self): # data src_data = (1+2j,3+4j) - expected_result = (1,2,3,4) + expected_result = [1,2,3,4] # blocks src = blocks.vector_source_c(src_data) @@ -83,4 +91,4 @@ def test_vector(self): if __name__ == '__main__': - gr_unittest.run(qa_complex_to_interleaved_short, "qa_complex_to_interleaved_short.xml") + gr_unittest.run(qa_complex_to_interleaved_short) diff --git a/python/qa_compute_stats.py b/python/qa_compute_stats.py index e66c167..859fae9 100755 --- a/python/qa_compute_stats.py +++ b/python/qa_compute_stats.py @@ -10,12 +10,20 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils import pdu_utils import pmt import time import numpy as np + class qa_compute_stats(gr_unittest.TestCase): def setUp(self): diff --git a/python/qa_file_sink.py b/python/qa_file_sink.py index 7e56757..07cbc50 100755 --- a/python/qa_file_sink.py +++ b/python/qa_file_sink.py @@ -10,10 +10,18 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils import pdu_utils import time + class qa_file_sink(gr_unittest.TestCase): def setUp(self): diff --git a/python/qa_file_source.py b/python/qa_file_source.py index df0530f..b3af661 100755 --- a/python/qa_file_source.py +++ b/python/qa_file_source.py @@ -10,10 +10,18 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils import pdu_utils import time + class qa_file_source(gr_unittest.TestCase): def setUp(self): diff --git a/python/qa_interleaved_short_to_complex.py b/python/qa_interleaved_short_to_complex.py index 90411ac..43131b5 100755 --- a/python/qa_interleaved_short_to_complex.py +++ b/python/qa_interleaved_short_to_complex.py @@ -10,7 +10,15 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils + class qa_interleaved_short_to_complex(gr_unittest.TestCase): @@ -82,4 +90,4 @@ def test_vector(self): self.assertComplexTuplesAlmostEqual(expected_result, result_data, 5) if __name__ == '__main__': - gr_unittest.run(qa_interleaved_short_to_complex, "qa_interleaved_short_to_complex.xml") + gr_unittest.run(qa_interleaved_short_to_complex) diff --git a/python/qa_invert_tune.py b/python/qa_invert_tune.py index bee33e3..01a2749 100755 --- a/python/qa_invert_tune.py +++ b/python/qa_invert_tune.py @@ -10,11 +10,19 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils import pdu_utils import pmt import time + class qa_invert_tune(gr_unittest.TestCase): def setUp (self): diff --git a/python/qa_message_vector_file_sink.py b/python/qa_message_vector_file_sink.py index d986d37..e701706 100755 --- a/python/qa_message_vector_file_sink.py +++ b/python/qa_message_vector_file_sink.py @@ -10,7 +10,14 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils import pdu_utils import time diff --git a/python/qa_message_vector_raster_file_sink.py b/python/qa_message_vector_raster_file_sink.py index b789236..6186cb3 100755 --- a/python/qa_message_vector_raster_file_sink.py +++ b/python/qa_message_vector_raster_file_sink.py @@ -10,7 +10,14 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils import pdu_utils import time diff --git a/python/qa_sandia_tag_debug.py b/python/qa_sandia_tag_debug.py index 29ca48c..dcf87d6 100644 --- a/python/qa_sandia_tag_debug.py +++ b/python/qa_sandia_tag_debug.py @@ -9,7 +9,14 @@ from gnuradio import gr, gr_unittest, blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils import pmt import time @@ -300,4 +307,4 @@ def test_009_dual_tags_nostore(self): if __name__ == '__main__': - gr_unittest.run(qa_sandia_tag_debug, "qa_sandia_tag_debug.xml") + gr_unittest.run(qa_sandia_tag_debug) diff --git a/python/qa_stream_gate.py b/python/qa_stream_gate.py index 71b101f..e5106c6 100755 --- a/python/qa_stream_gate.py +++ b/python/qa_stream_gate.py @@ -10,7 +10,14 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils class qa_stream_gate(gr_unittest.TestCase): @@ -23,8 +30,8 @@ def tearDown(self): def test_001_flow(self): # data - src_data = (1, 1, 2, 2, 3, 3) - expected_result = (1, 1, 2, 2, 3, 3) + src_data = [1, 1, 2, 2, 3, 3] + expected_result = [1, 1, 2, 2, 3, 3] # blocks src = blocks.vector_source_f(src_data) @@ -43,8 +50,8 @@ def test_001_flow(self): def test_002_block(self): # data - src_data = (1, 1, 2, 2, 3, 3) - expected_result = () + src_data = [1, 1, 2, 2, 3, 3] + expected_result = [] # blocks src = blocks.vector_source_f(src_data) diff --git a/python/qa_tag_debug_file.py b/python/qa_tag_debug_file.py index ce1b073..fc6a6f2 100755 --- a/python/qa_tag_debug_file.py +++ b/python/qa_tag_debug_file.py @@ -10,7 +10,14 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils import pmt diff --git a/python/qa_tagged_bits_to_bytes.py b/python/qa_tagged_bits_to_bytes.py index 688d5d1..13c5228 100755 --- a/python/qa_tagged_bits_to_bytes.py +++ b/python/qa_tagged_bits_to_bytes.py @@ -10,7 +10,14 @@ from gnuradio import gr, gr_unittest from gnuradio import blocks -import sandia_utils_swig as sandia_utils +try: + import sandia_utils +except ImportError: + import os + import sys + dirname, filename = os.path.split(os.path.abspath(__file__)) + sys.path.append(os.path.join(dirname, "bindings")) + import sandia_utils import pmt import time @@ -28,7 +35,7 @@ def test_one_tag_aligned(self): src_data = (1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1) offset = 0 src_tag = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) - expected_result = (0xab, 0xcd) + expected_result = [0xab, 0xcd] # blocks src = blocks.vector_source_b(src_data, False, 1, [src_tag]) @@ -50,7 +57,7 @@ def test_one_tag_not_aligned(self): src_data = (0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1) offset = 2 src_tag = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) - expected_result = (0xab, 0xcd) + expected_result = [0xab, 0xcd] # blocks src = blocks.vector_source_b(src_data, False, 1, [src_tag]) @@ -74,7 +81,7 @@ def test_two_tags_first_aligned(self): src_tag1 = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) offset = 8 src_tag2 = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) - expected_result = (0xab, 0xcd) + expected_result = [0xab, 0xcd] # blocks src = blocks.vector_source_b(src_data, False, 1, [src_tag1, src_tag2]) @@ -98,7 +105,7 @@ def test_two_tags_not_aligned(self): src_tag1 = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) offset = 10 src_tag2 = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) - expected_result = (0xab, 0xcd) + expected_result = [0xab, 0xcd] # blocks src = blocks.vector_source_b(src_data, False, 1, [src_tag1, src_tag2]) @@ -122,7 +129,7 @@ def test_big_endian_two_tags_not_aligned(self): src_tag1 = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) offset = 10 src_tag2 = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) - expected_result = (0xab, 0xcd) + expected_result = [0xab, 0xcd] # blocks src = blocks.vector_source_b(src_data, False, 1, [src_tag1, src_tag2]) @@ -144,7 +151,7 @@ def test_vector_one_tag_not_aligned(self): src_data = (0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1) offset = 2 src_tag = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) - expected_result = (0xab, 0xcd, 0xab, 0xcd) + expected_result = [0xab, 0xcd, 0xab, 0xcd] # blocks src = blocks.vector_source_b(src_data, False, 1, [src_tag]) @@ -167,7 +174,7 @@ def test_big_vector_one_tag_not_aligned(self): src_data = (0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1) offset = 2 src_tag = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) - expected_result = () # vector is too big, should never get an output + expected_result = [] # vector is too big, should never get an output # blocks src = blocks.vector_source_b(src_data, False, 1, [src_tag]) @@ -192,7 +199,7 @@ def test_one_tag_not_bye_aligned(self): src_data = (0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1) offset = 2 src_tag = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) - expected_result = (0xab, 0xcd) + expected_result = [0xab, 0xcd] # blocks src = blocks.vector_source_b(src_data, False, 1, [src_tag]) @@ -217,7 +224,7 @@ def test_pad_left(self): src_data = (0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1) offset = 2 src_tag = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) - expected_result = (0x01, 0xab, 0xcd) + expected_result = [0x01, 0xab, 0xcd] # blocks src = blocks.vector_source_b(src_data, False, 1, [src_tag]) @@ -239,7 +246,7 @@ def test_pad_right(self): src_data = (0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1) offset = 2 src_tag = gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")]) - expected_result = (0x40, 0xab, 0xcd) + expected_result = [0x40, 0xab, 0xcd] # blocks src = blocks.vector_source_b(src_data, False, 1, [src_tag]) @@ -271,7 +278,7 @@ def test_rx_time_drop(self): for offset in offsets: tags.append(gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")])) - expected_result = (0x0,) * 5 + expected_result = [0x0] * 5 # blocks src = blocks.vector_source_b(src_data, False, 1, tags) @@ -307,7 +314,7 @@ def test_rx_time_pad_right(self): for offset in offsets: tags.append(gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")])) - expected_result = (0x0,) * 5 + expected_result = [0x0] * 5 # blocks src = blocks.vector_source_b(src_data, False, 1, tags) @@ -343,7 +350,7 @@ def test_rx_time_pad_left(self): for offset in offsets: tags.append(gr.tag_utils.python_to_tag([offset, pmt.intern("BURST"), pmt.from_uint64(0), pmt.intern("test_simple_source")])) - expected_result = (0x0,) * 5 + expected_result = [0x0] * 5 # blocks src = blocks.vector_source_b(src_data, False, 1, tags) diff --git a/python/rftap_encap.py b/python/rftap_encap.py index bdb3cf1..4950cc9 100644 --- a/python/rftap_encap.py +++ b/python/rftap_encap.py @@ -49,7 +49,7 @@ def __init__(self, encapsulation_from, custom_dlt, custom_dissector_name): # setup logger logger_name = 'gr_log.' + self.to_basic_block().alias() - if logger_name in gr.logger_get_names(): + if logger_name in gr.logger_get_logger_names(): self.log = gr.logger(logger_name) else: self.log = gr.logger('log') diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt deleted file mode 100644 index 4dffed8..0000000 --- a/swig/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2011 Free Software Foundation, Inc. -# -# This file was generated by gr_modtool, a tool from the GNU Radio framework -# This file is a part of gr-sandia_utils -# -# SPDX-License-Identifier: GPL-3.0-or-later - -######################################################################## -# Check if there is C++ code at all -######################################################################## -if(NOT sandia_utils_sources) - MESSAGE(STATUS "No C++ sources... skipping swig/") - return() -endif(NOT sandia_utils_sources) - -######################################################################## -# Include swig generation macros -######################################################################## -find_package(SWIG) -find_package(PythonLibs) -if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) - return() -endif() -include(GrSwig) -include(GrPython) - -######################################################################## -# Setup swig generation -######################################################################## -set(GR_SWIG_INCLUDE_DIRS $) -set(GR_SWIG_TARGET_DEPS gnuradio::runtime_swig) - -set(GR_SWIG_LIBRARIES gnuradio-sandia_utils) -######################################################################## -# Bluefile Libraries -######################################################################## -if(BLUEFILE_FOUND) - list(APPEND GR_SWIG_LIBRARIES bluefile bluefilecxx) - message(STATUS "Swig libs: ${GR_SWIG_LIBRARIES}") -endif(BLUEFILE_FOUND) - -set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/sandia_utils_swig_doc.i) -set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) - -GR_SWIG_MAKE(sandia_utils_swig sandia_utils_swig.i) - - - -######################################################################## -# Install the build swig module -######################################################################## -GR_SWIG_INSTALL(TARGETS sandia_utils_swig DESTINATION ${GR_PYTHON_DIR}/sandia_utils) - -######################################################################## -# Install swig .i files for development -######################################################################## -install( - FILES - sandia_utils_swig.i - ${CMAKE_CURRENT_BINARY_DIR}/sandia_utils_swig_doc.i - DESTINATION ${GR_INCLUDE_DIR}/sandia_utils/swig -) diff --git a/swig/sandia_utils_swig.i b/swig/sandia_utils_swig.i deleted file mode 100644 index d744837..0000000 --- a/swig/sandia_utils_swig.i +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- c++ -*- */ - -#define SANDIA_UTILS_API - -%include "gnuradio.i" // the common stuff - -//load generated python docstrings -%include "sandia_utils_swig_doc.i" - -%{ -#include "sandia_utils/block_buffer.h" -#include "sandia_utils/burst_power_detector.h" -#include "sandia_utils/interleaved_short_to_complex.h" -#include "sandia_utils/complex_to_interleaved_short.h" -#include "sandia_utils/file_sink.h" -#include "sandia_utils/constants.h" -#include "sandia_utils/invert_tune.h" -#include "sandia_utils/file_source.h" -#include "sandia_utils/message_vector_file_sink.h" -#include "sandia_utils/message_vector_raster_file_sink.h" -#include "sandia_utils/stream_gate.h" -#include "sandia_utils/tag_debug_file.h" -#include "sandia_utils/sandia_tag_debug.h" -#include "sandia_utils/tagged_bits_to_bytes.h" -#include "sandia_utils/compute_stats.h" -#include "sandia_utils/vita49_tcp_msg_source.h" -%} - -%include "sandia_utils/constants.h" - - -%include "sandia_utils/block_buffer.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, block_buffer); -%include "sandia_utils/burst_power_detector.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, burst_power_detector); -%include "sandia_utils/interleaved_short_to_complex.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, interleaved_short_to_complex); -%include "sandia_utils/complex_to_interleaved_short.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, complex_to_interleaved_short); -%include "sandia_utils/file_sink.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, file_sink); -%include "sandia_utils/invert_tune.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, invert_tune); -%include "sandia_utils/file_source.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, file_source); -%include "sandia_utils/message_vector_file_sink.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, message_vector_file_sink); -%include "sandia_utils/message_vector_raster_file_sink.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, message_vector_raster_file_sink); -%include "sandia_utils/tag_debug_file.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, tag_debug_file); -%include "sandia_utils/sandia_tag_debug.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, sandia_tag_debug); -%include "sandia_utils/tagged_bits_to_bytes.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, tagged_bits_to_bytes); - -// stream gate -%include "sandia_utils/stream_gate.h" -GR_SWIG_BLOCK_MAGIC2_TMPL(sandia_utils, stream_gate_b, stream_gate); -GR_SWIG_BLOCK_MAGIC2_TMPL(sandia_utils, stream_gate_s, stream_gate); -GR_SWIG_BLOCK_MAGIC2_TMPL(sandia_utils, stream_gate_i, stream_gate); -GR_SWIG_BLOCK_MAGIC2_TMPL(sandia_utils, stream_gate_f, stream_gate); -GR_SWIG_BLOCK_MAGIC2_TMPL(sandia_utils, stream_gate_c, stream_gate); -%include "sandia_utils/compute_stats.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, compute_stats); -%include "sandia_utils/vita49_tcp_msg_source.h" -GR_SWIG_BLOCK_MAGIC2(sandia_utils, vita49_tcp_msg_source);