From 9a9026f3056da41fcf36e39687f2254ec7a4af79 Mon Sep 17 00:00:00 2001 From: Zach Hudson Date: Fri, 5 Jan 2018 09:43:07 -0800 Subject: [PATCH 01/12] Restructured files to be compatable with Pybombs --- gr-aistx/CMakeLists.txt => CMakeLists.txt | 0 gr-aistx/GPL => GPL | 0 README | 29 ++++++++++++------- {gr-aistx/apps => apps}/CMakeLists.txt | 0 .../Modules/CMakeParseArgumentsCopy.cmake | 0 .../cmake => cmake}/Modules/FindCppUnit.cmake | 0 .../Modules/FindGnuradioRuntime.cmake | 0 .../cmake => cmake}/Modules/GrMiscUtils.cmake | 0 .../cmake => cmake}/Modules/GrPlatform.cmake | 0 .../cmake => cmake}/Modules/GrPython.cmake | 0 .../cmake => cmake}/Modules/GrSwig.cmake | 0 .../cmake => cmake}/Modules/GrTest.cmake | 0 .../cmake => cmake}/cmake_uninstall.cmake.in | 0 {gr-aistx/docs => docs}/CMakeLists.txt | 0 {gr-aistx/docs => docs}/README.AISTX | 0 .../docs => docs}/doxygen/CMakeLists.txt | 0 {gr-aistx/docs => docs}/doxygen/Doxyfile.in | 0 .../doxygen/Doxyfile.swig_doc.in | 0 .../docs => docs}/doxygen/doxyxml/__init__.py | 0 .../docs => docs}/doxygen/doxyxml/base.py | 0 .../doxygen/doxyxml/doxyindex.py | 0 .../doxygen/doxyxml/generated/__init__.py | 0 .../doxygen/doxyxml/generated/compound.py | 0 .../doxyxml/generated/compoundsuper.py | 0 .../doxygen/doxyxml/generated/index.py | 0 .../doxygen/doxyxml/generated/indexsuper.py | 0 .../docs => docs}/doxygen/doxyxml/text.py | 0 .../doxygen/other/group_defs.dox | 0 .../docs => docs}/doxygen/other/main_page.dox | 0 {gr-aistx/docs => docs}/doxygen/swig_doc.py | 0 AIVDM_Encoder.py => examples/AIVDM_Encoder.py | 0 AiS_TX.grc => examples/AiS_TX.grc | 0 AiS_TX.py => examples/AiS_TX.py | 0 unpacker.c => examples/unpacker.c | 0 gr-aistx/README | 24 --------------- {gr-aistx/grc => grc}/AISTX_Build_Frame.xml | 0 {gr-aistx/grc => grc}/AISTX_DebugME.xml | 0 {gr-aistx/grc => grc}/AISTX_nrz_to_nrzi.xml | 0 {gr-aistx/grc => grc}/CMakeLists.txt | 0 .../include => include}/AISTX/Build_Frame.h | 0 .../include => include}/AISTX/CMakeLists.txt | 0 {gr-aistx/include => include}/AISTX/DebugME.h | 0 {gr-aistx/include => include}/AISTX/api.h | 0 .../include => include}/AISTX/nrz_to_nrzi.h | 0 {gr-aistx/lib => lib}/Build_Frame_impl.cc | 0 {gr-aistx/lib => lib}/Build_Frame_impl.h | 0 {gr-aistx/lib => lib}/CMakeLists.txt | 0 {gr-aistx/lib => lib}/DebugME_impl.cc | 0 {gr-aistx/lib => lib}/DebugME_impl.h | 0 {gr-aistx/lib => lib}/nrz_to_nrzi_impl.cc | 0 {gr-aistx/lib => lib}/nrz_to_nrzi_impl.h | 0 {gr-aistx/lib => lib}/qa_AISTX.cc | 0 {gr-aistx/lib => lib}/qa_AISTX.h | 0 {gr-aistx/lib => lib}/test_AISTX.cc | 0 {gr-aistx/python => python}/CMakeLists.txt | 0 {gr-aistx/python => python}/__init__.py | 0 {gr-aistx/python => python}/qa_Build_Frame.py | 0 {gr-aistx/python => python}/qa_DebugME.py | 0 {gr-aistx/python => python}/qa_nrz_to_nrzi.py | 0 {gr-aistx/swig => swig}/AISTX_swig.i | 0 {gr-aistx/swig => swig}/CMakeLists.txt | 0 61 files changed, 19 insertions(+), 34 deletions(-) rename gr-aistx/CMakeLists.txt => CMakeLists.txt (100%) rename gr-aistx/GPL => GPL (100%) rename {gr-aistx/apps => apps}/CMakeLists.txt (100%) rename {gr-aistx/cmake => cmake}/Modules/CMakeParseArgumentsCopy.cmake (100%) rename {gr-aistx/cmake => cmake}/Modules/FindCppUnit.cmake (100%) rename {gr-aistx/cmake => cmake}/Modules/FindGnuradioRuntime.cmake (100%) rename {gr-aistx/cmake => cmake}/Modules/GrMiscUtils.cmake (100%) rename {gr-aistx/cmake => cmake}/Modules/GrPlatform.cmake (100%) rename {gr-aistx/cmake => cmake}/Modules/GrPython.cmake (100%) rename {gr-aistx/cmake => cmake}/Modules/GrSwig.cmake (100%) rename {gr-aistx/cmake => cmake}/Modules/GrTest.cmake (100%) rename {gr-aistx/cmake => cmake}/cmake_uninstall.cmake.in (100%) rename {gr-aistx/docs => docs}/CMakeLists.txt (100%) rename {gr-aistx/docs => docs}/README.AISTX (100%) rename {gr-aistx/docs => docs}/doxygen/CMakeLists.txt (100%) rename {gr-aistx/docs => docs}/doxygen/Doxyfile.in (100%) rename {gr-aistx/docs => docs}/doxygen/Doxyfile.swig_doc.in (100%) rename {gr-aistx/docs => docs}/doxygen/doxyxml/__init__.py (100%) rename {gr-aistx/docs => docs}/doxygen/doxyxml/base.py (100%) rename {gr-aistx/docs => docs}/doxygen/doxyxml/doxyindex.py (100%) rename {gr-aistx/docs => docs}/doxygen/doxyxml/generated/__init__.py (100%) rename {gr-aistx/docs => docs}/doxygen/doxyxml/generated/compound.py (100%) rename {gr-aistx/docs => docs}/doxygen/doxyxml/generated/compoundsuper.py (100%) rename {gr-aistx/docs => docs}/doxygen/doxyxml/generated/index.py (100%) rename {gr-aistx/docs => docs}/doxygen/doxyxml/generated/indexsuper.py (100%) rename {gr-aistx/docs => docs}/doxygen/doxyxml/text.py (100%) rename {gr-aistx/docs => docs}/doxygen/other/group_defs.dox (100%) rename {gr-aistx/docs => docs}/doxygen/other/main_page.dox (100%) rename {gr-aistx/docs => docs}/doxygen/swig_doc.py (100%) rename AIVDM_Encoder.py => examples/AIVDM_Encoder.py (100%) rename AiS_TX.grc => examples/AiS_TX.grc (100%) rename AiS_TX.py => examples/AiS_TX.py (100%) rename unpacker.c => examples/unpacker.c (100%) delete mode 100644 gr-aistx/README rename {gr-aistx/grc => grc}/AISTX_Build_Frame.xml (100%) rename {gr-aistx/grc => grc}/AISTX_DebugME.xml (100%) rename {gr-aistx/grc => grc}/AISTX_nrz_to_nrzi.xml (100%) rename {gr-aistx/grc => grc}/CMakeLists.txt (100%) rename {gr-aistx/include => include}/AISTX/Build_Frame.h (100%) rename {gr-aistx/include => include}/AISTX/CMakeLists.txt (100%) rename {gr-aistx/include => include}/AISTX/DebugME.h (100%) rename {gr-aistx/include => include}/AISTX/api.h (100%) rename {gr-aistx/include => include}/AISTX/nrz_to_nrzi.h (100%) rename {gr-aistx/lib => lib}/Build_Frame_impl.cc (100%) rename {gr-aistx/lib => lib}/Build_Frame_impl.h (100%) rename {gr-aistx/lib => lib}/CMakeLists.txt (100%) rename {gr-aistx/lib => lib}/DebugME_impl.cc (100%) rename {gr-aistx/lib => lib}/DebugME_impl.h (100%) rename {gr-aistx/lib => lib}/nrz_to_nrzi_impl.cc (100%) rename {gr-aistx/lib => lib}/nrz_to_nrzi_impl.h (100%) rename {gr-aistx/lib => lib}/qa_AISTX.cc (100%) rename {gr-aistx/lib => lib}/qa_AISTX.h (100%) rename {gr-aistx/lib => lib}/test_AISTX.cc (100%) rename {gr-aistx/python => python}/CMakeLists.txt (100%) rename {gr-aistx/python => python}/__init__.py (100%) rename {gr-aistx/python => python}/qa_Build_Frame.py (100%) rename {gr-aistx/python => python}/qa_DebugME.py (100%) rename {gr-aistx/python => python}/qa_nrz_to_nrzi.py (100%) rename {gr-aistx/swig => swig}/AISTX_swig.i (100%) rename {gr-aistx/swig => swig}/CMakeLists.txt (100%) diff --git a/gr-aistx/CMakeLists.txt b/CMakeLists.txt similarity index 100% rename from gr-aistx/CMakeLists.txt rename to CMakeLists.txt diff --git a/gr-aistx/GPL b/GPL similarity index 100% rename from gr-aistx/GPL rename to GPL diff --git a/README b/README index 9f1e803..31fb5ec 100644 --- a/README +++ b/README @@ -1,15 +1,24 @@ -ais -=== -Thanks for downloading the AIS BlackToolkit! This directory contains: +This directory contains a custom block for GnuRadio we called AIS Frame Builder. +It is part of the AIS BlackToolkit. + +This block serves as generator of AIS frames and implements the full AIS stack. +It is composed of three main components covering respectively the +application/presentation layers, the link layer and the physical layer, +as defined in the protocol specification for AIS. -The AIS transmitter in form of GRC graph a1e4b54db83fb895a3c94493126bb318 AiS_TX.grc -The AIS transmitter in form of script kiddie script 52540b46f316ee460f4684a262132d36 AiS_TX.py -An AIVDM encoder supporting the main message types 056ac09822b342da296617ba7b4055dd AIVDM_Encoder.py -The AIS Frame Builder block for GnuRadio gr-aistx -A NMEA encoder (binary to ASCII) 2534dc06c21fe53f45bd2abab96bb6a7 unpacker.c +Install as described in the official out-of-tree documentation, i.e.: -Remember to install GnuRadio and gr-aistx first. A short description is included in each file's header. +$ mkdir build +$ cd build +$ cmake ../ +$ make +$ sudo make install -Good luck! +Copyright 2013-2014 -- Embyte & Pastus + +This program 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 2 +of the License, or (at your option) any later version. diff --git a/gr-aistx/apps/CMakeLists.txt b/apps/CMakeLists.txt similarity index 100% rename from gr-aistx/apps/CMakeLists.txt rename to apps/CMakeLists.txt diff --git a/gr-aistx/cmake/Modules/CMakeParseArgumentsCopy.cmake b/cmake/Modules/CMakeParseArgumentsCopy.cmake similarity index 100% rename from gr-aistx/cmake/Modules/CMakeParseArgumentsCopy.cmake rename to cmake/Modules/CMakeParseArgumentsCopy.cmake diff --git a/gr-aistx/cmake/Modules/FindCppUnit.cmake b/cmake/Modules/FindCppUnit.cmake similarity index 100% rename from gr-aistx/cmake/Modules/FindCppUnit.cmake rename to cmake/Modules/FindCppUnit.cmake diff --git a/gr-aistx/cmake/Modules/FindGnuradioRuntime.cmake b/cmake/Modules/FindGnuradioRuntime.cmake similarity index 100% rename from gr-aistx/cmake/Modules/FindGnuradioRuntime.cmake rename to cmake/Modules/FindGnuradioRuntime.cmake diff --git a/gr-aistx/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake similarity index 100% rename from gr-aistx/cmake/Modules/GrMiscUtils.cmake rename to cmake/Modules/GrMiscUtils.cmake diff --git a/gr-aistx/cmake/Modules/GrPlatform.cmake b/cmake/Modules/GrPlatform.cmake similarity index 100% rename from gr-aistx/cmake/Modules/GrPlatform.cmake rename to cmake/Modules/GrPlatform.cmake diff --git a/gr-aistx/cmake/Modules/GrPython.cmake b/cmake/Modules/GrPython.cmake similarity index 100% rename from gr-aistx/cmake/Modules/GrPython.cmake rename to cmake/Modules/GrPython.cmake diff --git a/gr-aistx/cmake/Modules/GrSwig.cmake b/cmake/Modules/GrSwig.cmake similarity index 100% rename from gr-aistx/cmake/Modules/GrSwig.cmake rename to cmake/Modules/GrSwig.cmake diff --git a/gr-aistx/cmake/Modules/GrTest.cmake b/cmake/Modules/GrTest.cmake similarity index 100% rename from gr-aistx/cmake/Modules/GrTest.cmake rename to cmake/Modules/GrTest.cmake diff --git a/gr-aistx/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in similarity index 100% rename from gr-aistx/cmake/cmake_uninstall.cmake.in rename to cmake/cmake_uninstall.cmake.in diff --git a/gr-aistx/docs/CMakeLists.txt b/docs/CMakeLists.txt similarity index 100% rename from gr-aistx/docs/CMakeLists.txt rename to docs/CMakeLists.txt diff --git a/gr-aistx/docs/README.AISTX b/docs/README.AISTX similarity index 100% rename from gr-aistx/docs/README.AISTX rename to docs/README.AISTX diff --git a/gr-aistx/docs/doxygen/CMakeLists.txt b/docs/doxygen/CMakeLists.txt similarity index 100% rename from gr-aistx/docs/doxygen/CMakeLists.txt rename to docs/doxygen/CMakeLists.txt diff --git a/gr-aistx/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in similarity index 100% rename from gr-aistx/docs/doxygen/Doxyfile.in rename to docs/doxygen/Doxyfile.in diff --git a/gr-aistx/docs/doxygen/Doxyfile.swig_doc.in b/docs/doxygen/Doxyfile.swig_doc.in similarity index 100% rename from gr-aistx/docs/doxygen/Doxyfile.swig_doc.in rename to docs/doxygen/Doxyfile.swig_doc.in diff --git a/gr-aistx/docs/doxygen/doxyxml/__init__.py b/docs/doxygen/doxyxml/__init__.py similarity index 100% rename from gr-aistx/docs/doxygen/doxyxml/__init__.py rename to docs/doxygen/doxyxml/__init__.py diff --git a/gr-aistx/docs/doxygen/doxyxml/base.py b/docs/doxygen/doxyxml/base.py similarity index 100% rename from gr-aistx/docs/doxygen/doxyxml/base.py rename to docs/doxygen/doxyxml/base.py diff --git a/gr-aistx/docs/doxygen/doxyxml/doxyindex.py b/docs/doxygen/doxyxml/doxyindex.py similarity index 100% rename from gr-aistx/docs/doxygen/doxyxml/doxyindex.py rename to docs/doxygen/doxyxml/doxyindex.py diff --git a/gr-aistx/docs/doxygen/doxyxml/generated/__init__.py b/docs/doxygen/doxyxml/generated/__init__.py similarity index 100% rename from gr-aistx/docs/doxygen/doxyxml/generated/__init__.py rename to docs/doxygen/doxyxml/generated/__init__.py diff --git a/gr-aistx/docs/doxygen/doxyxml/generated/compound.py b/docs/doxygen/doxyxml/generated/compound.py similarity index 100% rename from gr-aistx/docs/doxygen/doxyxml/generated/compound.py rename to docs/doxygen/doxyxml/generated/compound.py diff --git a/gr-aistx/docs/doxygen/doxyxml/generated/compoundsuper.py b/docs/doxygen/doxyxml/generated/compoundsuper.py similarity index 100% rename from gr-aistx/docs/doxygen/doxyxml/generated/compoundsuper.py rename to docs/doxygen/doxyxml/generated/compoundsuper.py diff --git a/gr-aistx/docs/doxygen/doxyxml/generated/index.py b/docs/doxygen/doxyxml/generated/index.py similarity index 100% rename from gr-aistx/docs/doxygen/doxyxml/generated/index.py rename to docs/doxygen/doxyxml/generated/index.py diff --git a/gr-aistx/docs/doxygen/doxyxml/generated/indexsuper.py b/docs/doxygen/doxyxml/generated/indexsuper.py similarity index 100% rename from gr-aistx/docs/doxygen/doxyxml/generated/indexsuper.py rename to docs/doxygen/doxyxml/generated/indexsuper.py diff --git a/gr-aistx/docs/doxygen/doxyxml/text.py b/docs/doxygen/doxyxml/text.py similarity index 100% rename from gr-aistx/docs/doxygen/doxyxml/text.py rename to docs/doxygen/doxyxml/text.py diff --git a/gr-aistx/docs/doxygen/other/group_defs.dox b/docs/doxygen/other/group_defs.dox similarity index 100% rename from gr-aistx/docs/doxygen/other/group_defs.dox rename to docs/doxygen/other/group_defs.dox diff --git a/gr-aistx/docs/doxygen/other/main_page.dox b/docs/doxygen/other/main_page.dox similarity index 100% rename from gr-aistx/docs/doxygen/other/main_page.dox rename to docs/doxygen/other/main_page.dox diff --git a/gr-aistx/docs/doxygen/swig_doc.py b/docs/doxygen/swig_doc.py similarity index 100% rename from gr-aistx/docs/doxygen/swig_doc.py rename to docs/doxygen/swig_doc.py diff --git a/AIVDM_Encoder.py b/examples/AIVDM_Encoder.py similarity index 100% rename from AIVDM_Encoder.py rename to examples/AIVDM_Encoder.py diff --git a/AiS_TX.grc b/examples/AiS_TX.grc similarity index 100% rename from AiS_TX.grc rename to examples/AiS_TX.grc diff --git a/AiS_TX.py b/examples/AiS_TX.py similarity index 100% rename from AiS_TX.py rename to examples/AiS_TX.py diff --git a/unpacker.c b/examples/unpacker.c similarity index 100% rename from unpacker.c rename to examples/unpacker.c diff --git a/gr-aistx/README b/gr-aistx/README deleted file mode 100644 index 31fb5ec..0000000 --- a/gr-aistx/README +++ /dev/null @@ -1,24 +0,0 @@ - -This directory contains a custom block for GnuRadio we called AIS Frame Builder. -It is part of the AIS BlackToolkit. - -This block serves as generator of AIS frames and implements the full AIS stack. -It is composed of three main components covering respectively the -application/presentation layers, the link layer and the physical layer, -as defined in the protocol specification for AIS. - -Install as described in the official out-of-tree documentation, i.e.: - -$ mkdir build -$ cd build -$ cmake ../ -$ make -$ sudo make install - -Copyright 2013-2014 -- Embyte & Pastus - -This program 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 2 -of the License, or (at your option) any later version. - diff --git a/gr-aistx/grc/AISTX_Build_Frame.xml b/grc/AISTX_Build_Frame.xml similarity index 100% rename from gr-aistx/grc/AISTX_Build_Frame.xml rename to grc/AISTX_Build_Frame.xml diff --git a/gr-aistx/grc/AISTX_DebugME.xml b/grc/AISTX_DebugME.xml similarity index 100% rename from gr-aistx/grc/AISTX_DebugME.xml rename to grc/AISTX_DebugME.xml diff --git a/gr-aistx/grc/AISTX_nrz_to_nrzi.xml b/grc/AISTX_nrz_to_nrzi.xml similarity index 100% rename from gr-aistx/grc/AISTX_nrz_to_nrzi.xml rename to grc/AISTX_nrz_to_nrzi.xml diff --git a/gr-aistx/grc/CMakeLists.txt b/grc/CMakeLists.txt similarity index 100% rename from gr-aistx/grc/CMakeLists.txt rename to grc/CMakeLists.txt diff --git a/gr-aistx/include/AISTX/Build_Frame.h b/include/AISTX/Build_Frame.h similarity index 100% rename from gr-aistx/include/AISTX/Build_Frame.h rename to include/AISTX/Build_Frame.h diff --git a/gr-aistx/include/AISTX/CMakeLists.txt b/include/AISTX/CMakeLists.txt similarity index 100% rename from gr-aistx/include/AISTX/CMakeLists.txt rename to include/AISTX/CMakeLists.txt diff --git a/gr-aistx/include/AISTX/DebugME.h b/include/AISTX/DebugME.h similarity index 100% rename from gr-aistx/include/AISTX/DebugME.h rename to include/AISTX/DebugME.h diff --git a/gr-aistx/include/AISTX/api.h b/include/AISTX/api.h similarity index 100% rename from gr-aistx/include/AISTX/api.h rename to include/AISTX/api.h diff --git a/gr-aistx/include/AISTX/nrz_to_nrzi.h b/include/AISTX/nrz_to_nrzi.h similarity index 100% rename from gr-aistx/include/AISTX/nrz_to_nrzi.h rename to include/AISTX/nrz_to_nrzi.h diff --git a/gr-aistx/lib/Build_Frame_impl.cc b/lib/Build_Frame_impl.cc similarity index 100% rename from gr-aistx/lib/Build_Frame_impl.cc rename to lib/Build_Frame_impl.cc diff --git a/gr-aistx/lib/Build_Frame_impl.h b/lib/Build_Frame_impl.h similarity index 100% rename from gr-aistx/lib/Build_Frame_impl.h rename to lib/Build_Frame_impl.h diff --git a/gr-aistx/lib/CMakeLists.txt b/lib/CMakeLists.txt similarity index 100% rename from gr-aistx/lib/CMakeLists.txt rename to lib/CMakeLists.txt diff --git a/gr-aistx/lib/DebugME_impl.cc b/lib/DebugME_impl.cc similarity index 100% rename from gr-aistx/lib/DebugME_impl.cc rename to lib/DebugME_impl.cc diff --git a/gr-aistx/lib/DebugME_impl.h b/lib/DebugME_impl.h similarity index 100% rename from gr-aistx/lib/DebugME_impl.h rename to lib/DebugME_impl.h diff --git a/gr-aistx/lib/nrz_to_nrzi_impl.cc b/lib/nrz_to_nrzi_impl.cc similarity index 100% rename from gr-aistx/lib/nrz_to_nrzi_impl.cc rename to lib/nrz_to_nrzi_impl.cc diff --git a/gr-aistx/lib/nrz_to_nrzi_impl.h b/lib/nrz_to_nrzi_impl.h similarity index 100% rename from gr-aistx/lib/nrz_to_nrzi_impl.h rename to lib/nrz_to_nrzi_impl.h diff --git a/gr-aistx/lib/qa_AISTX.cc b/lib/qa_AISTX.cc similarity index 100% rename from gr-aistx/lib/qa_AISTX.cc rename to lib/qa_AISTX.cc diff --git a/gr-aistx/lib/qa_AISTX.h b/lib/qa_AISTX.h similarity index 100% rename from gr-aistx/lib/qa_AISTX.h rename to lib/qa_AISTX.h diff --git a/gr-aistx/lib/test_AISTX.cc b/lib/test_AISTX.cc similarity index 100% rename from gr-aistx/lib/test_AISTX.cc rename to lib/test_AISTX.cc diff --git a/gr-aistx/python/CMakeLists.txt b/python/CMakeLists.txt similarity index 100% rename from gr-aistx/python/CMakeLists.txt rename to python/CMakeLists.txt diff --git a/gr-aistx/python/__init__.py b/python/__init__.py similarity index 100% rename from gr-aistx/python/__init__.py rename to python/__init__.py diff --git a/gr-aistx/python/qa_Build_Frame.py b/python/qa_Build_Frame.py similarity index 100% rename from gr-aistx/python/qa_Build_Frame.py rename to python/qa_Build_Frame.py diff --git a/gr-aistx/python/qa_DebugME.py b/python/qa_DebugME.py similarity index 100% rename from gr-aistx/python/qa_DebugME.py rename to python/qa_DebugME.py diff --git a/gr-aistx/python/qa_nrz_to_nrzi.py b/python/qa_nrz_to_nrzi.py similarity index 100% rename from gr-aistx/python/qa_nrz_to_nrzi.py rename to python/qa_nrz_to_nrzi.py diff --git a/gr-aistx/swig/AISTX_swig.i b/swig/AISTX_swig.i similarity index 100% rename from gr-aistx/swig/AISTX_swig.i rename to swig/AISTX_swig.i diff --git a/gr-aistx/swig/CMakeLists.txt b/swig/CMakeLists.txt similarity index 100% rename from gr-aistx/swig/CMakeLists.txt rename to swig/CMakeLists.txt From 6fefc0e90c7189ce78eaf211b3d2b625fed9a268 Mon Sep 17 00:00:00 2001 From: bmagistro Date: Wed, 7 Oct 2020 17:20:32 -0400 Subject: [PATCH 02/12] port aistx to ver 3.8 --- .gitignore | 5 + CMakeLists.txt | 124 ++++++++--- apps/CMakeLists.txt | 3 +- cmake/Modules/AISTXConfig.cmake | 31 +++ cmake/Modules/CMakeParseArgumentsCopy.cmake | 2 +- cmake/Modules/FindGnuradioRuntime.cmake | 35 --- cmake/Modules/GrMiscUtils.cmake | 210 ------------------ cmake/Modules/GrPlatform.cmake | 46 ---- cmake/Modules/GrPython.cmake | 227 ------------------- cmake/Modules/GrSwig.cmake | 229 -------------------- cmake/Modules/GrTest.cmake | 133 ------------ cmake/Modules/targetConfig.cmake.in | 26 +++ docs/CMakeLists.txt | 3 +- grc/AISTX_Build_Frame.block.yml | 33 +++ grc/AISTX_Build_Frame.xml | 47 ---- grc/AISTX_DebugME.block.yml | 24 ++ grc/AISTX_DebugME.xml | 32 --- grc/AISTX_nrz_to_nrzi.block.yml | 19 ++ grc/AISTX_nrz_to_nrzi.xml | 15 -- grc/CMakeLists.txt | 11 +- include/AISTX/CMakeLists.txt | 3 +- lib/CMakeLists.txt | 33 ++- python/CMakeLists.txt | 3 +- python/__init__.py | 4 +- swig/CMakeLists.txt | 14 +- 25 files changed, 284 insertions(+), 1028 deletions(-) create mode 100644 .gitignore create mode 100644 cmake/Modules/AISTXConfig.cmake delete mode 100644 cmake/Modules/FindGnuradioRuntime.cmake delete mode 100644 cmake/Modules/GrMiscUtils.cmake delete mode 100644 cmake/Modules/GrPlatform.cmake delete mode 100644 cmake/Modules/GrPython.cmake delete mode 100644 cmake/Modules/GrSwig.cmake delete mode 100644 cmake/Modules/GrTest.cmake create mode 100644 cmake/Modules/targetConfig.cmake.in create mode 100644 grc/AISTX_Build_Frame.block.yml delete mode 100644 grc/AISTX_Build_Frame.xml create mode 100644 grc/AISTX_DebugME.block.yml delete mode 100644 grc/AISTX_DebugME.xml create mode 100644 grc/AISTX_nrz_to_nrzi.block.yml delete mode 100644 grc/AISTX_nrz_to_nrzi.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..04d7b50 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# editors +[._]*.sw[a-p] + +# build dirs +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 102755b..f887cad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011,2012,2014,2016,2018 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-AISTX # # 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 @@ -17,47 +18,75 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. - ######################################################################## # Project setup ######################################################################## -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 3.8) +include(GNUInstallDirs) project(gr-AISTX CXX C) enable_testing() -#select the release build type by default to get optimization flags +# Install to PyBOMBS target prefix if defined +if(DEFINED ENV{PYBOMBS_PREFIX}) + set(CMAKE_INSTALL_PREFIX $ENV{PYBOMBS_PREFIX}) + message(STATUS "PyBOMBS installed GNU Radio. Setting CMAKE_INSTALL_PREFIX to $ENV{PYBOMBS_PREFIX}") +endif() + +# Select the release build type by default to get optimization flags if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") message(STATUS "Build type not specified: defaulting to release.") endif(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "") -list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) +# Make sure our local CMake Modules path comes first +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules) + +# Set the version information here +set(VERSION_MAJOR 1) +set(VERSION_API 0) +set(VERSION_ABI 0) +set(VERSION_PATCH git) + +cmake_policy(SET CMP0011 NEW) + +# Enable generation of compile_commands.json for code completion engines +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) ######################################################################## # Compiler specific setup ######################################################################## -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR + CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + AND NOT WIN32) #http://gcc.gnu.org/wiki/Visibility add_definitions(-fvisibility=hidden) endif() +IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + SET(CMAKE_CXX_STANDARD 11) +ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(CMAKE_CXX_STANDARD 11) +ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + SET(CMAKE_CXX_STANDARD 11) +ELSE() + message(WARNING "C++ standard could not be set because compiler is not GNU, Clang or MSVC.") +ENDIF() + +IF(CMAKE_C_COMPILER_ID STREQUAL "GNU") + SET(CMAKE_C_STANDARD 11) +ELSEIF(CMAKE_C_COMPILER_ID MATCHES "Clang") + SET(CMAKE_C_STANDARD 11) +ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + SET(CMAKE_C_STANDARD 11) +ELSE() + message(WARNING "C standard could not be set because compiler is not GNU, Clang or MSVC.") +ENDIF() + ######################################################################## # Find boost ######################################################################## -if(UNIX AND EXISTS "/usr/lib64") - list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix -endif(UNIX AND EXISTS "/usr/lib64") -set(Boost_ADDITIONAL_VERSIONS - "1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39" - "1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" - "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49" - "1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54" - "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" - "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" - "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" -) -find_package(Boost "1.35" COMPONENTS filesystem system) +find_package(Boost "1.65" COMPONENTS filesystem system program_options regex thread) if(NOT Boost_FOUND) message(FATAL_ERROR "Boost required to compile AISTX") @@ -66,7 +95,15 @@ endif() ######################################################################## # Install directories ######################################################################## +find_package(Gnuradio "3.8" COMPONENTS fft filter blocks REQUIRED) +include(GrVersion) + include(GrPlatform) #define LIB_SUFFIX + +if(NOT CMAKE_MODULES_DIR) + set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake) +endif(NOT CMAKE_MODULES_DIR) + set(GR_RUNTIME_DIR bin) set(GR_LIBRARY_DIR lib${LIB_SUFFIX}) set(GR_INCLUDE_DIR include/AISTX) @@ -80,25 +117,31 @@ set(GR_LIBEXEC_DIR libexec) set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME}) set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) +######################################################################## +# On Apple only, set install name and use rpath correctly, if not already set +######################################################################## +if(APPLE) + if(NOT CMAKE_INSTALL_NAME_DIR) + set(CMAKE_INSTALL_NAME_DIR + ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE + PATH "Library Install Name Destination Directory" FORCE) + endif(NOT CMAKE_INSTALL_NAME_DIR) + if(NOT CMAKE_INSTALL_RPATH) + set(CMAKE_INSTALL_RPATH + ${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR} CACHE + PATH "Library Install RPath" FORCE) + endif(NOT CMAKE_INSTALL_RPATH) + if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) + set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE + BOOL "Do Build Using Library Install RPath" FORCE) + endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH) +endif(APPLE) + ######################################################################## # Find gnuradio build dependencies ######################################################################## -find_package(GnuradioRuntime) find_package(CppUnit) -# To run a more advanced search for GNU Radio and it's components and -# versions, use the following. Add any components required to the list -# of GR_REQUIRED_COMPONENTS (in all caps) and change "version" to the -# minimum API compatible version required. -# -# set(GR_REQUIRED_COMPONENTS CORE BLOCKS FILTER ...) -# find_package(Gnuradio "version") - - -if(NOT GNURADIO_RUNTIME_FOUND) - message(FATAL_ERROR "GnuRadio Runtime required to compile AISTX") -endif() - if(NOT CPPUNIT_FOUND) message(FATAL_ERROR "CppUnit required to compile AISTX") endif() @@ -136,13 +179,22 @@ add_custom_target(uninstall ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake ) + ######################################################################## # Add subdirectories ######################################################################## add_subdirectory(include/AISTX) add_subdirectory(lib) +add_subdirectory(apps) +add_subdirectory(docs) add_subdirectory(swig) add_subdirectory(python) add_subdirectory(grc) -add_subdirectory(apps) -add_subdirectory(docs) + +######################################################################## +# Install cmake search helper for this library +######################################################################## + +install(FILES cmake/Modules/AISTXConfig.cmake + DESTINATION ${CMAKE_MODULES_DIR}/AISTX +) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index c837d77..575ab26 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-AISTX # # 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 diff --git a/cmake/Modules/AISTXConfig.cmake b/cmake/Modules/AISTXConfig.cmake new file mode 100644 index 0000000..b51773a --- /dev/null +++ b/cmake/Modules/AISTXConfig.cmake @@ -0,0 +1,31 @@ +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PC_AISTX AISTX) + +FIND_PATH( + AISTX_INCLUDE_DIRS + NAMES AISTX/api.h + HINTS $ENV{AISTX_DIR}/include + ${PC_AISTX_INCLUDEDIR} + PATHS ${CMAKE_INSTALL_PREFIX}/include + /usr/local/include + /usr/include +) + +FIND_LIBRARY( + AISTX_LIBRARIES + NAMES gnuradio-AISTX + HINTS $ENV{AISTX_DIR}/lib + ${PC_AISTX_LIBDIR} + PATHS ${CMAKE_INSTALL_PREFIX}/lib + ${CMAKE_INSTALL_PREFIX}/lib64 + /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 + ) + +include("${CMAKE_CURRENT_LIST_DIR}/AISTXTarget.cmake") + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(AISTX DEFAULT_MSG AISTX_LIBRARIES AISTX_INCLUDE_DIRS) +MARK_AS_ADVANCED(AISTX_LIBRARIES AISTX_INCLUDE_DIRS) diff --git a/cmake/Modules/CMakeParseArgumentsCopy.cmake b/cmake/Modules/CMakeParseArgumentsCopy.cmake index 7ce4c49..66016cb 100644 --- a/cmake/Modules/CMakeParseArgumentsCopy.cmake +++ b/cmake/Modules/CMakeParseArgumentsCopy.cmake @@ -58,7 +58,7 @@ # the new option. # E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in # MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would -# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. +# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefore. #============================================================================= # Copyright 2010 Alexander Neundorf diff --git a/cmake/Modules/FindGnuradioRuntime.cmake b/cmake/Modules/FindGnuradioRuntime.cmake deleted file mode 100644 index 2833fb1..0000000 --- a/cmake/Modules/FindGnuradioRuntime.cmake +++ /dev/null @@ -1,35 +0,0 @@ -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_GNURADIO_RUNTIME gnuradio-runtime) - -if(PC_GNURADIO_RUNTIME_FOUND) - # look for include files - FIND_PATH( - GNURADIO_RUNTIME_INCLUDE_DIRS - NAMES gnuradio/top_block.h - HINTS $ENV{GNURADIO_RUNTIME_DIR}/include - ${PC_GNURADIO_RUNTIME_INCLUDE_DIRS} - ${CMAKE_INSTALL_PREFIX}/include - PATHS /usr/local/include - /usr/include - ) - - # look for libs - FIND_LIBRARY( - GNURADIO_RUNTIME_LIBRARIES - NAMES gnuradio-runtime - HINTS $ENV{GNURADIO_RUNTIME_DIR}/lib - ${PC_GNURADIO_RUNTIME_LIBDIR} - ${CMAKE_INSTALL_PREFIX}/lib/ - ${CMAKE_INSTALL_PREFIX}/lib64/ - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 - ) - - set(GNURADIO_RUNTIME_FOUND ${PC_GNURADIO_RUNTIME_FOUND}) -endif(PC_GNURADIO_RUNTIME_FOUND) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_RUNTIME DEFAULT_MSG GNURADIO_RUNTIME_LIBRARIES GNURADIO_RUNTIME_INCLUDE_DIRS) -MARK_AS_ADVANCED(GNURADIO_RUNTIME_LIBRARIES GNURADIO_RUNTIME_INCLUDE_DIRS) diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake deleted file mode 100644 index 9331d5d..0000000 --- a/cmake/Modules/GrMiscUtils.cmake +++ /dev/null @@ -1,210 +0,0 @@ -# Copyright 2010-2011 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. - -if(DEFINED __INCLUDED_GR_MISC_UTILS_CMAKE) - return() -endif() -set(__INCLUDED_GR_MISC_UTILS_CMAKE TRUE) - -######################################################################## -# Set global variable macro. -# Used for subdirectories to export settings. -# Example: include and library paths. -######################################################################## -function(GR_SET_GLOBAL var) - set(${var} ${ARGN} CACHE INTERNAL "" FORCE) -endfunction(GR_SET_GLOBAL) - -######################################################################## -# Set the pre-processor definition if the condition is true. -# - def the pre-processor definition to set and condition name -######################################################################## -function(GR_ADD_COND_DEF def) - if(${def}) - add_definitions(-D${def}) - endif(${def}) -endfunction(GR_ADD_COND_DEF) - -######################################################################## -# Check for a header and conditionally set a compile define. -# - hdr the relative path to the header file -# - def the pre-processor definition to set -######################################################################## -function(GR_CHECK_HDR_N_DEF hdr def) - include(CheckIncludeFileCXX) - CHECK_INCLUDE_FILE_CXX(${hdr} ${def}) - GR_ADD_COND_DEF(${def}) -endfunction(GR_CHECK_HDR_N_DEF) - -######################################################################## -# Include subdirectory macro. -# Sets the CMake directory variables, -# includes the subdirectory CMakeLists.txt, -# resets the CMake directory variables. -# -# This macro includes subdirectories rather than adding them -# so that the subdirectory can affect variables in the level above. -# This provides a work-around for the lack of convenience libraries. -# This way a subdirectory can append to the list of library sources. -######################################################################## -macro(GR_INCLUDE_SUBDIRECTORY subdir) - #insert the current directories on the front of the list - list(INSERT _cmake_source_dirs 0 ${CMAKE_CURRENT_SOURCE_DIR}) - list(INSERT _cmake_binary_dirs 0 ${CMAKE_CURRENT_BINARY_DIR}) - - #set the current directories to the names of the subdirs - set(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}) - set(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${subdir}) - - #include the subdirectory CMakeLists to run it - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - include(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt) - - #reset the value of the current directories - list(GET _cmake_source_dirs 0 CMAKE_CURRENT_SOURCE_DIR) - list(GET _cmake_binary_dirs 0 CMAKE_CURRENT_BINARY_DIR) - - #pop the subdir names of the front of the list - list(REMOVE_AT _cmake_source_dirs 0) - list(REMOVE_AT _cmake_binary_dirs 0) -endmacro(GR_INCLUDE_SUBDIRECTORY) - -######################################################################## -# Check if a compiler flag works and conditionally set a compile define. -# - flag the compiler flag to check for -# - have the variable to set with result -######################################################################## -macro(GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE flag have) - include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG(${flag} ${have}) - if(${have}) - add_definitions(${flag}) - endif(${have}) -endmacro(GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE) - -######################################################################## -# Generates the .la libtool file -# This appears to generate libtool files that cannot be used by auto*. -# Usage GR_LIBTOOL(TARGET [target] DESTINATION [dest]) -# Notice: there is not COMPONENT option, these will not get distributed. -######################################################################## -function(GR_LIBTOOL) - if(NOT DEFINED GENERATE_LIBTOOL) - set(GENERATE_LIBTOOL OFF) #disabled by default - endif() - - if(GENERATE_LIBTOOL) - include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(GR_LIBTOOL "" "TARGET;DESTINATION" "" ${ARGN}) - - find_program(LIBTOOL libtool) - if(LIBTOOL) - include(CMakeMacroLibtoolFile) - CREATE_LIBTOOL_FILE(${GR_LIBTOOL_TARGET} /${GR_LIBTOOL_DESTINATION}) - endif(LIBTOOL) - endif(GENERATE_LIBTOOL) - -endfunction(GR_LIBTOOL) - -######################################################################## -# Do standard things to the library target -# - set target properties -# - make install rules -# Also handle gnuradio custom naming conventions w/ extras mode. -######################################################################## -function(GR_LIBRARY_FOO target) - #parse the arguments for component names - include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(GR_LIBRARY "" "RUNTIME_COMPONENT;DEVEL_COMPONENT" "" ${ARGN}) - - #set additional target properties - set_target_properties(${target} PROPERTIES SOVERSION ${LIBVER}) - - #install the generated files like so... - install(TARGETS ${target} - LIBRARY DESTINATION ${GR_LIBRARY_DIR} COMPONENT ${GR_LIBRARY_RUNTIME_COMPONENT} # .so/.dylib file - ARCHIVE DESTINATION ${GR_LIBRARY_DIR} COMPONENT ${GR_LIBRARY_DEVEL_COMPONENT} # .lib file - RUNTIME DESTINATION ${GR_RUNTIME_DIR} COMPONENT ${GR_LIBRARY_RUNTIME_COMPONENT} # .dll file - ) - - #extras mode enabled automatically on linux - if(NOT DEFINED LIBRARY_EXTRAS) - set(LIBRARY_EXTRAS ${LINUX}) - endif() - - #special extras mode to enable alternative naming conventions - if(LIBRARY_EXTRAS) - - #create .la file before changing props - GR_LIBTOOL(TARGET ${target} DESTINATION ${GR_LIBRARY_DIR}) - - #give the library a special name with ultra-zero soversion - set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_NAME ${target}-${LIBVER} SOVERSION "0.0.0") - set(target_name lib${target}-${LIBVER}.so.0.0.0) - - #custom command to generate symlinks - add_custom_command( - TARGET ${target} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E create_symlink ${target_name} ${CMAKE_CURRENT_BINARY_DIR}/lib${target}.so - COMMAND ${CMAKE_COMMAND} -E create_symlink ${target_name} ${CMAKE_CURRENT_BINARY_DIR}/lib${target}-${LIBVER}.so.0 - COMMAND ${CMAKE_COMMAND} -E touch ${target_name} #so the symlinks point to something valid so cmake 2.6 will install - ) - - #and install the extra symlinks - install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/lib${target}.so - ${CMAKE_CURRENT_BINARY_DIR}/lib${target}-${LIBVER}.so.0 - DESTINATION ${GR_LIBRARY_DIR} COMPONENT ${GR_LIBRARY_RUNTIME_COMPONENT} - ) - - endif(LIBRARY_EXTRAS) -endfunction(GR_LIBRARY_FOO) - -######################################################################## -# Create a dummy custom command that depends on other targets. -# Usage: -# GR_GEN_TARGET_DEPS(unique_name target_deps ...) -# ADD_CUSTOM_COMMAND( ${target_deps}) -# -# Custom command cant depend on targets, but can depend on executables, -# and executables can depend on targets. So this is the process: -######################################################################## -function(GR_GEN_TARGET_DEPS name var) - file( - WRITE ${CMAKE_CURRENT_BINARY_DIR}/${name}.cpp.in - "int main(void){return 0;}\n" - ) - execute_process( - COMMAND ${CMAKE_COMMAND} -E copy_if_different - ${CMAKE_CURRENT_BINARY_DIR}/${name}.cpp.in - ${CMAKE_CURRENT_BINARY_DIR}/${name}.cpp - ) - add_executable(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name}.cpp) - if(ARGN) - add_dependencies(${name} ${ARGN}) - endif(ARGN) - - if(CMAKE_CROSSCOMPILING) - set(${var} "DEPENDS;${name}" PARENT_SCOPE) #cant call command when cross - else() - set(${var} "DEPENDS;${name};COMMAND;${name}" PARENT_SCOPE) - endif() -endfunction(GR_GEN_TARGET_DEPS) diff --git a/cmake/Modules/GrPlatform.cmake b/cmake/Modules/GrPlatform.cmake deleted file mode 100644 index a2e4f3b..0000000 --- a/cmake/Modules/GrPlatform.cmake +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 2011 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. - -if(DEFINED __INCLUDED_GR_PLATFORM_CMAKE) - return() -endif() -set(__INCLUDED_GR_PLATFORM_CMAKE TRUE) - -######################################################################## -# Setup additional defines for OS types -######################################################################## -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(LINUX TRUE) -endif() - -if(LINUX AND EXISTS "/etc/debian_version") - set(DEBIAN TRUE) -endif() - -if(LINUX AND EXISTS "/etc/redhat-release") - set(REDHAT TRUE) -endif() - -######################################################################## -# when the library suffix should be 64 (applies to redhat linux family) -######################################################################## -if(NOT DEFINED LIB_SUFFIX AND REDHAT AND CMAKE_SYSTEM_PROCESSOR MATCHES "64$") - set(LIB_SUFFIX 64) -endif() -set(LIB_SUFFIX ${LIB_SUFFIX} CACHE STRING "lib directory suffix") diff --git a/cmake/Modules/GrPython.cmake b/cmake/Modules/GrPython.cmake deleted file mode 100644 index efdddf3..0000000 --- a/cmake/Modules/GrPython.cmake +++ /dev/null @@ -1,227 +0,0 @@ -# Copyright 2010-2011 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. - -if(DEFINED __INCLUDED_GR_PYTHON_CMAKE) - return() -endif() -set(__INCLUDED_GR_PYTHON_CMAKE TRUE) - -######################################################################## -# Setup the python interpreter: -# This allows the user to specify a specific interpreter, -# or finds the interpreter via the built-in cmake module. -######################################################################## -#this allows the user to override PYTHON_EXECUTABLE -if(PYTHON_EXECUTABLE) - - set(PYTHONINTERP_FOUND TRUE) - -#otherwise if not set, try to automatically find it -else(PYTHON_EXECUTABLE) - - #use the built-in find script - find_package(PythonInterp) - - #and if that fails use the find program routine - if(NOT PYTHONINTERP_FOUND) - find_program(PYTHON_EXECUTABLE NAMES python python2.7 python2.6 python2.5) - if(PYTHON_EXECUTABLE) - set(PYTHONINTERP_FOUND TRUE) - endif(PYTHON_EXECUTABLE) - endif(NOT PYTHONINTERP_FOUND) - -endif(PYTHON_EXECUTABLE) - -#make the path to the executable appear in the cmake gui -set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") - -#make sure we can use -B with python (introduced in 2.6) -if(PYTHON_EXECUTABLE) - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -B -c "" - OUTPUT_QUIET ERROR_QUIET - RESULT_VARIABLE PYTHON_HAS_DASH_B_RESULT - ) - if(PYTHON_HAS_DASH_B_RESULT EQUAL 0) - set(PYTHON_DASH_B "-B") - endif() -endif(PYTHON_EXECUTABLE) - -######################################################################## -# Check for the existence of a python module: -# - desc a string description of the check -# - mod the name of the module to import -# - cmd an additional command to run -# - have the result variable to set -######################################################################## -macro(GR_PYTHON_CHECK_MODULE desc mod cmd have) - message(STATUS "") - message(STATUS "Python checking for ${desc}") - execute_process( - COMMAND ${PYTHON_EXECUTABLE} -c " -######################################### -try: import ${mod} -except: exit(-1) -try: assert ${cmd} -except: exit(-1) -#########################################" - RESULT_VARIABLE ${have} - ) - if(${have} EQUAL 0) - message(STATUS "Python checking for ${desc} - found") - set(${have} TRUE) - else(${have} EQUAL 0) - message(STATUS "Python checking for ${desc} - not found") - set(${have} FALSE) - endif(${have} EQUAL 0) -endmacro(GR_PYTHON_CHECK_MODULE) - -######################################################################## -# Sets the python installation directory GR_PYTHON_DIR -######################################################################## -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c " -from distutils import sysconfig -print sysconfig.get_python_lib(plat_specific=True, prefix='') -" OUTPUT_VARIABLE GR_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE -) -file(TO_CMAKE_PATH ${GR_PYTHON_DIR} GR_PYTHON_DIR) - -######################################################################## -# Create an always-built target with a unique name -# Usage: GR_UNIQUE_TARGET( ) -######################################################################## -function(GR_UNIQUE_TARGET desc) - file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib -unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5] -print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))" - OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE) - add_custom_target(${_target} ALL DEPENDS ${ARGN}) -endfunction(GR_UNIQUE_TARGET) - -######################################################################## -# Install python sources (also builds and installs byte-compiled python) -######################################################################## -function(GR_PYTHON_INSTALL) - include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(GR_PYTHON_INSTALL "" "DESTINATION;COMPONENT" "FILES;PROGRAMS" ${ARGN}) - - #################################################################### - if(GR_PYTHON_INSTALL_FILES) - #################################################################### - install(${ARGN}) #installs regular python files - - #create a list of all generated files - unset(pysrcfiles) - unset(pycfiles) - unset(pyofiles) - foreach(pyfile ${GR_PYTHON_INSTALL_FILES}) - get_filename_component(pyfile ${pyfile} ABSOLUTE) - list(APPEND pysrcfiles ${pyfile}) - - #determine if this file is in the source or binary directory - file(RELATIVE_PATH source_rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${pyfile}) - string(LENGTH "${source_rel_path}" source_rel_path_len) - file(RELATIVE_PATH binary_rel_path ${CMAKE_CURRENT_BINARY_DIR} ${pyfile}) - string(LENGTH "${binary_rel_path}" binary_rel_path_len) - - #and set the generated path appropriately - if(${source_rel_path_len} GREATER ${binary_rel_path_len}) - set(pygenfile ${CMAKE_CURRENT_BINARY_DIR}/${binary_rel_path}) - else() - set(pygenfile ${CMAKE_CURRENT_BINARY_DIR}/${source_rel_path}) - endif() - list(APPEND pycfiles ${pygenfile}c) - list(APPEND pyofiles ${pygenfile}o) - - #ensure generation path exists - get_filename_component(pygen_path ${pygenfile} PATH) - file(MAKE_DIRECTORY ${pygen_path}) - - endforeach(pyfile) - - #the command to generate the pyc files - add_custom_command( - DEPENDS ${pysrcfiles} OUTPUT ${pycfiles} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/python_compile_helper.py ${pysrcfiles} ${pycfiles} - ) - - #the command to generate the pyo files - add_custom_command( - DEPENDS ${pysrcfiles} OUTPUT ${pyofiles} - COMMAND ${PYTHON_EXECUTABLE} -O ${CMAKE_BINARY_DIR}/python_compile_helper.py ${pysrcfiles} ${pyofiles} - ) - - #create install rule and add generated files to target list - set(python_install_gen_targets ${pycfiles} ${pyofiles}) - install(FILES ${python_install_gen_targets} - DESTINATION ${GR_PYTHON_INSTALL_DESTINATION} - COMPONENT ${GR_PYTHON_INSTALL_COMPONENT} - ) - - - #################################################################### - elseif(GR_PYTHON_INSTALL_PROGRAMS) - #################################################################### - file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native) - - foreach(pyfile ${GR_PYTHON_INSTALL_PROGRAMS}) - get_filename_component(pyfile_name ${pyfile} NAME) - get_filename_component(pyfile ${pyfile} ABSOLUTE) - string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pyexefile "${pyfile}.exe") - list(APPEND python_install_gen_targets ${pyexefile}) - - get_filename_component(pyexefile_path ${pyexefile} PATH) - file(MAKE_DIRECTORY ${pyexefile_path}) - - add_custom_command( - OUTPUT ${pyexefile} DEPENDS ${pyfile} - COMMAND ${PYTHON_EXECUTABLE} -c - \"open('${pyexefile}', 'w').write('\#!${pyexe_native}\\n'+open('${pyfile}').read())\" - COMMENT "Shebangin ${pyfile_name}" - ) - - #on windows, python files need an extension to execute - get_filename_component(pyfile_ext ${pyfile} EXT) - if(WIN32 AND NOT pyfile_ext) - set(pyfile_name "${pyfile_name}.py") - endif() - - install(PROGRAMS ${pyexefile} RENAME ${pyfile_name} - DESTINATION ${GR_PYTHON_INSTALL_DESTINATION} - COMPONENT ${GR_PYTHON_INSTALL_COMPONENT} - ) - endforeach(pyfile) - - endif() - - GR_UNIQUE_TARGET("pygen" ${python_install_gen_targets}) - -endfunction(GR_PYTHON_INSTALL) - -######################################################################## -# Write the python helper script that generates byte code files -######################################################################## -file(WRITE ${CMAKE_BINARY_DIR}/python_compile_helper.py " -import sys, py_compile -files = sys.argv[1:] -srcs, gens = files[:len(files)/2], files[len(files)/2:] -for src, gen in zip(srcs, gens): - py_compile.compile(file=src, cfile=gen, doraise=True) -") diff --git a/cmake/Modules/GrSwig.cmake b/cmake/Modules/GrSwig.cmake deleted file mode 100644 index 6ba5ee3..0000000 --- a/cmake/Modules/GrSwig.cmake +++ /dev/null @@ -1,229 +0,0 @@ -# Copyright 2010-2011 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. - -if(DEFINED __INCLUDED_GR_SWIG_CMAKE) - return() -endif() -set(__INCLUDED_GR_SWIG_CMAKE TRUE) - -include(GrPython) - -######################################################################## -# Builds a swig documentation file to be generated into python docstrings -# Usage: GR_SWIG_MAKE_DOCS(output_file input_path input_path....) -# -# Set the following variable to specify extra dependent targets: -# - GR_SWIG_DOCS_SOURCE_DEPS -# - GR_SWIG_DOCS_TARGET_DEPS -######################################################################## -function(GR_SWIG_MAKE_DOCS output_file) - find_package(Doxygen) - if(DOXYGEN_FOUND) - - #setup the input files variable list, quote formated - set(input_files) - unset(INPUT_PATHS) - foreach(input_path ${ARGN}) - if (IS_DIRECTORY ${input_path}) #when input path is a directory - file(GLOB input_path_h_files ${input_path}/*.h) - else() #otherwise its just a file, no glob - set(input_path_h_files ${input_path}) - endif() - list(APPEND input_files ${input_path_h_files}) - set(INPUT_PATHS "${INPUT_PATHS} \"${input_path}\"") - endforeach(input_path) - - #determine the output directory - get_filename_component(name ${output_file} NAME_WE) - get_filename_component(OUTPUT_DIRECTORY ${output_file} PATH) - set(OUTPUT_DIRECTORY ${OUTPUT_DIRECTORY}/${name}_swig_docs) - make_directory(${OUTPUT_DIRECTORY}) - - #generate the Doxyfile used by doxygen - configure_file( - ${CMAKE_SOURCE_DIR}/docs/doxygen/Doxyfile.swig_doc.in - ${OUTPUT_DIRECTORY}/Doxyfile - @ONLY) - - #Create a dummy custom command that depends on other targets - include(GrMiscUtils) - GR_GEN_TARGET_DEPS(_${name}_tag tag_deps ${GR_SWIG_DOCS_TARGET_DEPS}) - - #call doxygen on the Doxyfile + input headers - add_custom_command( - OUTPUT ${OUTPUT_DIRECTORY}/xml/index.xml - DEPENDS ${input_files} ${GR_SWIG_DOCS_SOURCE_DEPS} ${tag_deps} - COMMAND ${DOXYGEN_EXECUTABLE} ${OUTPUT_DIRECTORY}/Doxyfile - COMMENT "Generating doxygen xml for ${name} docs" - ) - - #call the swig_doc script on the xml files - add_custom_command( - OUTPUT ${output_file} - DEPENDS ${input_files} ${OUTPUT_DIRECTORY}/xml/index.xml - COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} - ${CMAKE_SOURCE_DIR}/docs/doxygen/swig_doc.py - ${OUTPUT_DIRECTORY}/xml - ${output_file} - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs/doxygen - ) - - else(DOXYGEN_FOUND) - file(WRITE ${output_file} "\n") #no doxygen -> empty file - endif(DOXYGEN_FOUND) -endfunction(GR_SWIG_MAKE_DOCS) - -######################################################################## -# Build a swig target for the common gnuradio use case. Usage: -# GR_SWIG_MAKE(target ifile ifile ifile...) -# -# Set the following variables before calling: -# - GR_SWIG_FLAGS -# - GR_SWIG_INCLUDE_DIRS -# - GR_SWIG_LIBRARIES -# - GR_SWIG_SOURCE_DEPS -# - GR_SWIG_TARGET_DEPS -# - GR_SWIG_DOC_FILE -# - GR_SWIG_DOC_DIRS -######################################################################## -macro(GR_SWIG_MAKE name) - set(ifiles ${ARGN}) - - #do swig doc generation if specified - if (GR_SWIG_DOC_FILE) - set(GR_SWIG_DOCS_SOURCE_DEPS ${GR_SWIG_SOURCE_DEPS}) - set(GR_SWIG_DOCS_TAREGT_DEPS ${GR_SWIG_TARGET_DEPS}) - GR_SWIG_MAKE_DOCS(${GR_SWIG_DOC_FILE} ${GR_SWIG_DOC_DIRS}) - list(APPEND GR_SWIG_SOURCE_DEPS ${GR_SWIG_DOC_FILE}) - endif() - - #append additional include directories - find_package(PythonLibs) - list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH}) #deprecated name (now dirs) - list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}) - - #determine include dependencies for swig file - execute_process( - COMMAND ${PYTHON_EXECUTABLE} - ${CMAKE_BINARY_DIR}/get_swig_deps.py - "${ifiles}" "${GR_SWIG_INCLUDE_DIRS}" - OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE SWIG_MODULE_${name}_EXTRA_DEPS - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) - - #Create a dummy custom command that depends on other targets - include(GrMiscUtils) - GR_GEN_TARGET_DEPS(_${name}_swig_tag tag_deps ${GR_SWIG_TARGET_DEPS}) - set(tag_file ${CMAKE_CURRENT_BINARY_DIR}/${name}.tag) - add_custom_command( - OUTPUT ${tag_file} - DEPENDS ${GR_SWIG_SOURCE_DEPS} ${tag_deps} - COMMAND ${CMAKE_COMMAND} -E touch ${tag_file} - ) - - #append the specified include directories - include_directories(${GR_SWIG_INCLUDE_DIRS}) - list(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${tag_file}) - - #setup the swig flags with flags and include directories - set(CMAKE_SWIG_FLAGS -fvirtual -modern -keyword -w511 -module ${name} ${GR_SWIG_FLAGS}) - foreach(dir ${GR_SWIG_INCLUDE_DIRS}) - list(APPEND CMAKE_SWIG_FLAGS "-I${dir}") - endforeach(dir) - - #set the C++ property on the swig .i file so it builds - set_source_files_properties(${ifiles} PROPERTIES CPLUSPLUS ON) - - #setup the actual swig library target to be built - include(UseSWIG) - SWIG_ADD_MODULE(${name} python ${ifiles}) - SWIG_LINK_LIBRARIES(${name} ${PYTHON_LIBRARIES} ${GR_SWIG_LIBRARIES}) - -endmacro(GR_SWIG_MAKE) - -######################################################################## -# Install swig targets generated by GR_SWIG_MAKE. Usage: -# GR_SWIG_INSTALL( -# TARGETS target target target... -# [DESTINATION destination] -# [COMPONENT component] -# ) -######################################################################## -macro(GR_SWIG_INSTALL) - - include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(GR_SWIG_INSTALL "" "DESTINATION;COMPONENT" "TARGETS" ${ARGN}) - - foreach(name ${GR_SWIG_INSTALL_TARGETS}) - install(TARGETS ${SWIG_MODULE_${name}_REAL_NAME} - DESTINATION ${GR_SWIG_INSTALL_DESTINATION} - COMPONENT ${GR_SWIG_INSTALL_COMPONENT} - ) - - include(GrPython) - GR_PYTHON_INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.py - DESTINATION ${GR_SWIG_INSTALL_DESTINATION} - COMPONENT ${GR_SWIG_INSTALL_COMPONENT} - ) - - GR_LIBTOOL( - TARGET ${SWIG_MODULE_${name}_REAL_NAME} - DESTINATION ${GR_SWIG_INSTALL_DESTINATION} - ) - - endforeach(name) - -endmacro(GR_SWIG_INSTALL) - -######################################################################## -# Generate a python file that can determine swig dependencies. -# Used by the make macro above to determine extra dependencies. -# When you build C++, CMake figures out the header dependencies. -# This code essentially performs that logic for swig includes. -######################################################################## -file(WRITE ${CMAKE_BINARY_DIR}/get_swig_deps.py " - -import os, sys, re - -include_matcher = re.compile('[#|%]include\\s*[<|\"](.*)[>|\"]') -include_dirs = sys.argv[2].split(';') - -def get_swig_incs(file_path): - file_contents = open(file_path, 'r').read() - return include_matcher.findall(file_contents, re.MULTILINE) - -def get_swig_deps(file_path, level): - deps = [file_path] - if level == 0: return deps - for inc_file in get_swig_incs(file_path): - for inc_dir in include_dirs: - inc_path = os.path.join(inc_dir, inc_file) - if not os.path.exists(inc_path): continue - deps.extend(get_swig_deps(inc_path, level-1)) - return deps - -if __name__ == '__main__': - ifiles = sys.argv[1].split(';') - deps = sum([get_swig_deps(ifile, 3) for ifile in ifiles], []) - #sys.stderr.write(';'.join(set(deps)) + '\\n\\n') - print(';'.join(set(deps))) -") diff --git a/cmake/Modules/GrTest.cmake b/cmake/Modules/GrTest.cmake deleted file mode 100644 index 6174c03..0000000 --- a/cmake/Modules/GrTest.cmake +++ /dev/null @@ -1,133 +0,0 @@ -# Copyright 2010-2011 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. - -if(DEFINED __INCLUDED_GR_TEST_CMAKE) - return() -endif() -set(__INCLUDED_GR_TEST_CMAKE TRUE) - -######################################################################## -# Add a unit test and setup the environment for a unit test. -# Takes the same arguments as the ADD_TEST function. -# -# Before calling set the following variables: -# GR_TEST_TARGET_DEPS - built targets for the library path -# GR_TEST_LIBRARY_DIRS - directories for the library path -# GR_TEST_PYTHON_DIRS - directories for the python path -######################################################################## -function(GR_ADD_TEST test_name) - - if(WIN32) - #Ensure that the build exe also appears in the PATH. - list(APPEND GR_TEST_TARGET_DEPS ${ARGN}) - - #In the land of windows, all libraries must be in the PATH. - #Since the dependent libraries are not yet installed, - #we must manually set them in the PATH to run tests. - #The following appends the path of a target dependency. - foreach(target ${GR_TEST_TARGET_DEPS}) - get_target_property(location ${target} LOCATION) - if(location) - get_filename_component(path ${location} PATH) - string(REGEX REPLACE "\\$\\(.*\\)" ${CMAKE_BUILD_TYPE} path ${path}) - list(APPEND GR_TEST_LIBRARY_DIRS ${path}) - endif(location) - endforeach(target) - - #SWIG generates the python library files into a subdirectory. - #Therefore, we must append this subdirectory into PYTHONPATH. - #Only do this for the python directories matching the following: - foreach(pydir ${GR_TEST_PYTHON_DIRS}) - get_filename_component(name ${pydir} NAME) - if(name MATCHES "^(swig|lib|src)$") - list(APPEND GR_TEST_PYTHON_DIRS ${pydir}/${CMAKE_BUILD_TYPE}) - endif() - endforeach(pydir) - endif(WIN32) - - file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} srcdir) - file(TO_NATIVE_PATH "${GR_TEST_LIBRARY_DIRS}" libpath) #ok to use on dir list? - file(TO_NATIVE_PATH "${GR_TEST_PYTHON_DIRS}" pypath) #ok to use on dir list? - - set(environs "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}") - - #http://www.cmake.org/pipermail/cmake/2009-May/029464.html - #Replaced this add test + set environs code with the shell script generation. - #Its nicer to be able to manually run the shell script to diagnose problems. - #ADD_TEST(${ARGV}) - #SET_TESTS_PROPERTIES(${test_name} PROPERTIES ENVIRONMENT "${environs}") - - if(UNIX) - set(binpath "${CMAKE_CURRENT_BINARY_DIR}:$PATH") - #set both LD and DYLD paths to cover multiple UNIX OS library paths - list(APPEND libpath "$LD_LIBRARY_PATH" "$DYLD_LIBRARY_PATH") - list(APPEND pypath "$PYTHONPATH") - - #replace list separator with the path separator - string(REPLACE ";" ":" libpath "${libpath}") - string(REPLACE ";" ":" pypath "${pypath}") - list(APPEND environs "PATH=${binpath}" "LD_LIBRARY_PATH=${libpath}" "DYLD_LIBRARY_PATH=${libpath}" "PYTHONPATH=${pypath}") - - #generate a bat file that sets the environment and runs the test - find_program(SHELL sh) - set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh) - file(WRITE ${sh_file} "#!${SHELL}\n") - #each line sets an environment variable - foreach(environ ${environs}) - file(APPEND ${sh_file} "export ${environ}\n") - endforeach(environ) - #load the command to run with its arguments - foreach(arg ${ARGN}) - file(APPEND ${sh_file} "${arg} ") - endforeach(arg) - file(APPEND ${sh_file} "\n") - - #make the shell file executable - execute_process(COMMAND chmod +x ${sh_file}) - - add_test(${test_name} ${SHELL} ${sh_file}) - - endif(UNIX) - - if(WIN32) - list(APPEND libpath ${DLL_PATHS} "%PATH%") - list(APPEND pypath "%PYTHONPATH%") - - #replace list separator with the path separator (escaped) - string(REPLACE ";" "\\;" libpath "${libpath}") - string(REPLACE ";" "\\;" pypath "${pypath}") - list(APPEND environs "PATH=${libpath}" "PYTHONPATH=${pypath}") - - #generate a bat file that sets the environment and runs the test - set(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat) - file(WRITE ${bat_file} "@echo off\n") - #each line sets an environment variable - foreach(environ ${environs}) - file(APPEND ${bat_file} "SET ${environ}\n") - endforeach(environ) - #load the command to run with its arguments - foreach(arg ${ARGN}) - file(APPEND ${bat_file} "${arg} ") - endforeach(arg) - file(APPEND ${bat_file} "\n") - - add_test(${test_name} ${bat_file}) - endif(WIN32) - -endfunction(GR_ADD_TEST) diff --git a/cmake/Modules/targetConfig.cmake.in b/cmake/Modules/targetConfig.cmake.in new file mode 100644 index 0000000..79e4a28 --- /dev/null +++ b/cmake/Modules/targetConfig.cmake.in @@ -0,0 +1,26 @@ +# Copyright 2018 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. + +include(CMakeFindDependencyMacro) + +set(target_deps "@TARGET_DEPENDENCIES@") +foreach(dep IN LISTS target_deps) + find_dependency(${dep}) +endforeach() +include("${CMAKE_CURRENT_LIST_DIR}/@TARGET@Targets.cmake") diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index f16fbf6..6d1a556 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-AISTX # # 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 diff --git a/grc/AISTX_Build_Frame.block.yml b/grc/AISTX_Build_Frame.block.yml new file mode 100644 index 0000000..d2ba012 --- /dev/null +++ b/grc/AISTX_Build_Frame.block.yml @@ -0,0 +1,33 @@ +# auto-generated by grc.converter + +id: AISTX_Build_Frame +label: AIS Frame Builder +category: AISTX + +parameters: +- id: sentence + label: Sentence + dtype: string + default: '010010000011101011110111001110011000100000000000000000100000001011001000001011000101000110100010010100001101011001111011000011111111111011100101110011100000000000000110' +- id: repeat + label: Repeat + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] +- id: enable_NRZI + label: Enable_NRZI_Conversion + dtype: enum + default: 'True' + options: ['True', 'False'] + option_labels: ['Yes', 'No'] + +outputs: +- domain: stream + dtype: byte + +templates: + imports: import AISTX + make: AISTX.Build_Frame(${sentence}, ${repeat}, ${enable_NRZI}) + +file_format: 1 diff --git a/grc/AISTX_Build_Frame.xml b/grc/AISTX_Build_Frame.xml deleted file mode 100644 index 61f7198..0000000 --- a/grc/AISTX_Build_Frame.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - AIS Frame Builder - AISTX_Build_Frame - AISTX - import AISTX - AISTX.Build_Frame($sentence, $repeat, $enable_NRZI) - - Sentence - sentence - 010010000011101011110111001110011000100000000000000000100000001011001000001011000101000110100010010100001101011001111011000011111111111011100101110011100000000000000110 - string - - - Repeat - repeat - True - enum - - - - - Enable_NRZI_Conversion - enable_NRZI - True - enum - - - - - - out - byte - - diff --git a/grc/AISTX_DebugME.block.yml b/grc/AISTX_DebugME.block.yml new file mode 100644 index 0000000..3450bcf --- /dev/null +++ b/grc/AISTX_DebugME.block.yml @@ -0,0 +1,24 @@ +# auto-generated by grc.converter + +id: AISTX_DebugME +label: DebugME +category: AISTX + +parameters: +- id: type + label: Input Type + dtype: enum + options: [complex, float, byte] + option_attributes: + size: [gr.sizeof_gr_complex, gr.sizeof_float, gr.sizeof_char] + hide: part + +inputs: +- domain: stream + dtype: ${ type } + +templates: + imports: import AISTX + make: AISTX.DebugME(${type.size}) + +file_format: 1 diff --git a/grc/AISTX_DebugME.xml b/grc/AISTX_DebugME.xml deleted file mode 100644 index 9dcdc31..0000000 --- a/grc/AISTX_DebugME.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - DebugME - AISTX_DebugME - AISTX - import AISTX - AISTX.DebugME($type.size) - - Input Type - type - enum - - - - - - in - $type - - diff --git a/grc/AISTX_nrz_to_nrzi.block.yml b/grc/AISTX_nrz_to_nrzi.block.yml new file mode 100644 index 0000000..438dcc2 --- /dev/null +++ b/grc/AISTX_nrz_to_nrzi.block.yml @@ -0,0 +1,19 @@ +# auto-generated by grc.converter + +id: AISTX_nrz_to_nrzi +label: Nrz to nrzi +category: AISTX + +inputs: +- domain: stream + dtype: byte + +outputs: +- domain: stream + dtype: byte + +templates: + imports: import AISTX + make: AISTX.nrz_to_nrzi() + +file_format: 1 diff --git a/grc/AISTX_nrz_to_nrzi.xml b/grc/AISTX_nrz_to_nrzi.xml deleted file mode 100644 index d2191bb..0000000 --- a/grc/AISTX_nrz_to_nrzi.xml +++ /dev/null @@ -1,15 +0,0 @@ - - Nrz to nrzi - AISTX_nrz_to_nrzi - AISTX - import AISTX - AISTX.nrz_to_nrzi() - - in - byte - - - out - byte - - diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index 2ae27c1..f408dfa 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-AISTX # # 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 @@ -16,8 +17,10 @@ # 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. + install(FILES - AISTX_nrz_to_nrzi.xml - AISTX_Build_Frame.xml - AISTX_DebugME.xml DESTINATION share/gnuradio/grc/blocks + AISTX_nrz_to_nrzi.block.yml + AISTX_Build_Frame.block.yml + AISTX_DebugME.block.yml + DESTINATION share/gnuradio/grc/blocks ) diff --git a/include/AISTX/CMakeLists.txt b/include/AISTX/CMakeLists.txt index 257680e..563cfc8 100644 --- a/include/AISTX/CMakeLists.txt +++ b/include/AISTX/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011,2012 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-AISTX # # 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 diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 64a6e1c..d95a6b0 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,6 +1,7 @@ -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011,2012,2016,2018,2019 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-AISTX # # 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 @@ -27,21 +28,45 @@ link_directories(${Boost_LIBRARY_DIRS}) list(APPEND AISTX_sources nrz_to_nrzi_impl.cc Build_Frame_impl.cc - DebugME_impl.cc ) + DebugME_impl.cc +) + +set(AISTX_sources "${AISTX_sources}" PARENT_SCOPE) +if(NOT AISTX_sources) + MESSAGE(STATUS "No C++ sources... skipping lib/") + return() +endif(NOT AISTX_sources) add_library(gnuradio-AISTX SHARED ${AISTX_sources}) -target_link_libraries(gnuradio-AISTX ${Boost_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES}) +target_link_libraries(gnuradio-AISTX gnuradio::gnuradio-runtime ${Boost_LIBRARIES}) +target_include_directories(gnuradio-AISTX + PUBLIC $ + PUBLIC $ + ) set_target_properties(gnuradio-AISTX PROPERTIES DEFINE_SYMBOL "gnuradio_AISTX_EXPORTS") +if(APPLE) + set_target_properties(gnuradio-AISTX PROPERTIES + INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" + ) +endif(APPLE) + ######################################################################## # Install built library files ######################################################################## +include(GrMiscUtils) install(TARGETS gnuradio-AISTX LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file RUNTIME DESTINATION bin # .dll file ) +######################################################################## +# Print summary +######################################################################## +message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}") +message(STATUS "Building for version: ${VERSION} / ${LIBVER}") + ######################################################################## # Build and register unit test ######################################################################## diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index b79d4bf..a7532fd 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,6 +1,7 @@ # Copyright 2011 Free Software Foundation, Inc. # -# This file is part of GNU Radio +# This file was generated by gr_modtool, a tool from the GNU Radio framework +# This file is a part of gr-AISTX # # 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 diff --git a/python/__init__.py b/python/__init__.py index c1d8e3f..3872a70 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -31,9 +31,9 @@ from dl import RTLD_GLOBAL as _RTLD_GLOBAL except ImportError: try: - from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL + from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL except ImportError: - pass + pass if _RTLD_GLOBAL != 0: _dlopenflags = sys.getdlopenflags() diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index 0a80154..822e3ac 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -17,6 +17,14 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. +######################################################################## +# Check if there is C++ code at all +######################################################################## +if(NOT AISTX_sources) + MESSAGE(STATUS "No C++ sources... skipping swig/") + return() +endif(NOT AISTX_sources) + ######################################################################## # Include swig generation macros ######################################################################## @@ -31,11 +39,11 @@ include(GrPython) ######################################################################## # Setup swig generation ######################################################################## -foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/swig) -endforeach(incdir) +set(GR_SWIG_INCLUDE_DIRS $) +set(GR_SWIG_TARGET_DEPS gnuradio::runtime_swig) set(GR_SWIG_LIBRARIES gnuradio-AISTX) + set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/AISTX_swig_doc.i) set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../include) From 49b49cd4a8225c80b13be5699ba0d55627feedcb Mon Sep 17 00:00:00 2001 From: bmagistro Date: Mon, 12 Oct 2020 21:13:20 -0400 Subject: [PATCH 03/12] restructure/move files in root so that repository can be used with pybombs --- {examples => apps}/AIVDM_Encoder.py | 7 +- apps/AIVDM_pre.pl | 571 ++++++++++++++++++++++++++++ {examples => apps}/AiS_TX.py | 0 {examples => apps}/unpacker.c | 0 apps/unpacker.pl | 227 +++++++++++ 5 files changed, 802 insertions(+), 3 deletions(-) rename {examples => apps}/AIVDM_Encoder.py (97%) create mode 100644 apps/AIVDM_pre.pl rename {examples => apps}/AiS_TX.py (100%) rename {examples => apps}/unpacker.c (100%) create mode 100644 apps/unpacker.pl diff --git a/examples/AIVDM_Encoder.py b/apps/AIVDM_Encoder.py similarity index 97% rename from examples/AIVDM_Encoder.py rename to apps/AIVDM_Encoder.py index b688c47..984f85a 100755 --- a/examples/AIVDM_Encoder.py +++ b/apps/AIVDM_Encoder.py @@ -37,11 +37,11 @@ def compute_long_lat22 (__long, __lat): _lat = '{0:b}'.format(int(round(__lat*600)) & 0b11111111111111111).rjust(17,'0') return (_long, _lat) -def encode_1(__mmsi, __speed, __long, __lat, __course, __ts): +def encode_1(__mmsi, __status,__speed, __long, __lat, __course, __ts): _type = '{0:b}'.format(1).rjust(6,'0') # 18 _repeat = "00" # repeat (directive to an AIS transceiver that this message should be rebroadcast.) _mmsi = '{0:b}'.format(__mmsi).rjust(30,'0') # 30 bits (247320162) - _status = '{0:b}'.format(15).rjust(4,'0') # status not defined + _status = '{0:b}'.format(__status).rjust(4,'0') # navigation status e.g. 0=Under way using engine, 1-At anchor, 5=Moored, 8=Sailing,15=undefined _rot = '{0:b}'.format(128).rjust(8,'0') # rate of turn not defined _speed = '{0:b}'.format(int(round(__speed*10))).rjust(10,'0') # Speed over ground is in 0.1-knot resolution from 0 to 102 knots. value 1023 indicates speed is not available, value 1022 indicates 102.2 knots or higher. @@ -268,6 +268,7 @@ def main(): 970010000 for SART device""", default=247320162) parser.add_option("--speed", help="18. Speed (knot), default = 0.1", default=0.1) + parser.add_option("--status", help="1. Navigation Status, default = 15 (undefined)", default=15) parser.add_option("--long", help="18. Longitude, default = 9.72357833333333", default=9.72357833333333) parser.add_option("--lat", help="18. Latitude, default = 45.6910166666667", default=45.6910166666667) parser.add_option("--course", help="18. Course, default = 83.4", default=83.4) @@ -309,7 +310,7 @@ def main(): payload = "" if options.type == "1": - payload = encode_1(int(options.mmsi), float(options.speed), float(options.long), float(options.lat), float(options.course), int(options.ts)) + payload = encode_1(int(options.mmsi),int(options.status), float(options.speed), float(options.long), float(options.lat), float(options.course), int(options.ts)) elif options.type == "4": payload = encode_4(int(options.mmsi), float(options.speed), float(options.long), float(options.lat), float(options.course), int(options.ts)) diff --git a/apps/AIVDM_pre.pl b/apps/AIVDM_pre.pl new file mode 100644 index 0000000..90b6e1c --- /dev/null +++ b/apps/AIVDM_pre.pl @@ -0,0 +1,571 @@ +#!/usr/bin/perl + +# Program AIVDM_pre + +# This is a preprocessor for the AIS BlackToolkit. It is designed to provide a simple +# user interface allowing users to automatically generate comamnds for use with the +# AIVDM_Encoder.py program + +# AIVDM_Encoder prepares an output string that can be used by the unpacker.pl (or unpacker.c) +# program or transmitted using AiS_TX. This program, then, can create either form of the +# command lines below: + +# ./AIVDM_Encoder.py --type=1 --vsize=30x10 | xargs -IA ./unpacker.pl A 1 A +# ./AIVDM_Encoder.py --type=1 --vsize=30x10 | xargs -IX ./AiS_TX.py --payload=X --channel=A + +# See also "AIVDM/AIVDO protocol decoding" page at http://catb.org/gpsd/AIVDM.html + +# (c) Gary C. Kessler, 2018 + +$build_date = "09/09/2018"; +$version = "0.9"; + +$type = menu (); + +if ($type eq "X") + { + print "Goodbye!\n\n"; + exit; + }; + +# Initialize command string output. All commands include the --type parameter + +$command = "./AIVDM_Encoder.py --type=" . $type . " "; + +# Step through the supported parameters and ask for values for those parameters supported by the +# requested message type; provide default value. If default selected, do not add to command string output + +print "\nSee The 'AIVDM/AIVDO protocol decoding' page at http://catb.org/gpsd/AIVDM.html\n"; +print "for additional information on selecting parameter values.\n"; + +##### +# All messages contain an MMSI. +# The Maritime Mobile Service Identity (MMSI) is a 9 decimal digit number +# NOTE: The Encoder default value is not a real ship but indicates an Italian vessel + +do + { + print "\nEnter MMSI (9 decimal digits); Encoder default = 247320162 (vessel)\nor 970010000 (SART device): "; + chomp ($mmsi = ); + } + until (verify_numeric_string ($mmsi,9) || $mmsi eq ""); + +if ($mmsi ne "") + { $command .= "--mmsi=" . $mmsi . " "; } + +##### +# The SART_MSG parameter is used only in message type 14 +# The Search and Rescue Transponder (SART) message can be from 1-161 characters in length + +if ($type == 14) + { + do + { + print "\nEnter SART message (1-161 characters); Encoder default = 'SART ACTIVE':\n"; + chomp ($sart_msg = ); + } + until (length ($sart_msg) <= 161); + + if ($sart_msg ne "") + { $command .= "--sart_msg='" . $sart_msg . "' "; } + } + +##### +# Position parameters (latitude, longitude) are used in message types 1, 4, & 18 +# The Encoder default value is on Via Pizzo Formico near Piazza Madonna delle Nevi, Seriate, Bergamo, Italy + +if ($type == 1 || $type == 4 || $type == 18) + { + do + { + print "\nEnter latitude (-90 to 90); Encoder default = 45.6910166666667: "; + chomp ($lat = ); + } + until (($lat >= -90 && $lat <= 90) || $lat eq ""); + + if ($lat ne "") + { $command .= "--lat='" . $lat . "' "; } + + do + { + print "\nEnter longitude (-180 to 180); Encoder default = 9.72357833333333: "; + chomp ($long = ); + } + until (($long >= -180 && $long <= 180) || $long eq ""); + + if ($long ne "") + { $command .= "--long='" . $long . "' "; } + } + +##### +# Course, speed, and timestamp parameters are used in message types 1 & 18 + +if ($type == 1 || $type == 18) + { + do + { + print "\nEnter speed, in knots in 0.1 kn resolution (0-102; 1022 = 102.2 kn or higher;\n1023 = speed not available); Encoder default = 0.1: "; + chomp ($speed = ); + } + until (($speed >= 0 && $speed <= 102) || $speed == 1022 || $speed == 1023 || $speed eq ""); + + if ($speed ne "") + { $command .= "--speed=" . $speed . " "; } + + do + { + print "\nEnter course (1 to 360; 3600 = data not available); Encoder default = 83.4: "; + chomp ($course = ); + } + until (($course >= 1 && $course <= 360) || $course == 3600 || $course eq ""); + + if ($course ne "") + { $command .= "--course=" . $course . " "; } + + do + { + print "\nEnter UTC timestamp, in seconds (0-59; 60 = time stamp not available;\n"; + print "61 = positioning system is in manual input mode;\n62 = positioning system operates in estimated (dead reckoning) mode,\n"; + print "63 = positioning system is inoperative); Encoder default = 38: "; + chomp ($ts = ); + } + until (($ts >= 0 && $ts <= 63) || $ts eq ""); + + if ($ts ne "") + { $command .= "--ts=" . int($ts+0.5) . " "; } + } + +##### +# Fixed Access Time Division Multiple Access (FATDMA) parameters are used in message type 20 +# It has been difficult to get exact meaning and values, but I am allowing values based upon the field sizes. +# See also https://fccid.io/UYW-4230002/User-Manual/User-manual-2545256.html + +if ($type == 20) + { + do + { + print "\nEnter FATDMA reserved offset number (0-4095); Encoder default = 0: "; + chomp ($fatdmaoffset = ); + } + until (($fatdmaoffset >= 0 && $fatdmaoffset <= 4095) || $fatdmaoffset eq ""); + + if ($fatdmaoffset ne "") + { $command .= "--fatdmaoffset=" . int($fatdmaoffset) . " "; } + + do + { + print "\nEnter FATDMA number of reserved slots (0-15); Encoder default = 0: "; + chomp ($fatdmaslots = ); + } + until (($fatdmaslots >= 0 && $fatdmaslots <= 15) || $fatdmaslots eq ""); + + if ($fatdmaslots ne "") + { $command .= "--fatdmaslots=" . int($fatdmaslots) . " "; } + + do + { + print "\nEnter FATDMA timeout, in minutes (0-7); Encoder default = 0: "; + chomp ($fatdmatimeout = ); + } + until (($fatdmatimeout >= 0 && $fatdmatimeout <= 7) || $fatdmatimeouts eq ""); + + if ($fatdmatimeout ne "") + { $command .= "--fatdmatimeout=" . int($fatdmatimeout) . " "; } + + do + { + print "\nEnter FATDMA repeat increment (0-2047); Encoder default = 0: "; + chomp ($fatdmaincrement = ); + } + until (($fatdmaincrement >= 0 && $fatdmaincrement <= 2047) || $fatdmaincrement eq ""); + + if ($fatdmaincrement ne "") + { $command .= "--fatdmaincrement=" . int($fatdmaincrement) . " "; } + } + +##### +# Aids-to-Navigation (AtoN) parameters are used in message 21. + +if ($type == 21) + { + do + { + print "\nEnter 0 if this is a real AtoN at indicated position; 1 if this is a\nvirtual AtoN simulated by nearby AIS station; Encoder default = 0: "; + chomp ($v_AtoN = ); + } + until ($v_AtoN == 0 || $v_AtoN == 1 || $v_AtoN eq ""); + + if ($v_AtoN) + { $command .= "--v_AtoN" . " "; } + + do + { + print "\nEnter type of navigational aid (0-31) from the following list:\n"; + print " 0. AIS Default; type of AtoN not specified\n"; + print " 1. Reference point\n"; + print " 2. RACON (radar transponder marking a navigation hazard)\n"; + print " 3. Fixed structure off shore, such as oil platforms, wind farms, rigs.\n"; + print " 4. Spare, Reserved for future use 5. Light, without sectors\n"; + print " 6. Light, with sectors 7. Leading Light Front\n"; + print " 8. Leading Light Rear 9. Beacon, Cardinal N\n"; + print " 10. Beacon, Cardinal E 11. Beacon, Cardinal S\n"; + print " 12. Beacon, Cardinal W 13. Beacon, Port hand\n"; + print " 14. Beacon, Starboard hand\n"; + print " 15. Beacon, Preferred Channel port hand\n"; + print " 16. Beacon, Preferred Channel starboard hand\n"; + print " 17. Beacon, Isolated danger 18. Beacon, Safe water\n"; + print " 19. Beacon, Special mark 20. Cardinal Mark N\n"; + print " 21. Cardinal Mark E 22. Cardinal Mark S\n"; + print " 23. Cardinal Mark W 24. Port hand Mark\n"; + print " 25. Starboard hand Mark 26. Preferred Channel Port hand\n"; + print " 27. Preferred Channel Starboard hand\n"; + print " 28. Isolated danger 29. Safe Water\n"; + print " 30. Special Mark 31. Light Vessel / LANBY / Rigs\n"; + print " Encoder default = 1: "; + chomp ($aid_type = ); + } + until (($aid_type >= 0 && $aid_type <= 31) || $aid_type eq ""); + + if ($aid_type ne "") + { $command .= "--aid_type=" . int($aid_type) . " "; } + + do + { + print "\nEnter AtoN name (1-20 characters); Encoder default = '@@@@@@@@@@@@@@@@@@@@':\n"; + chomp ($aid_name = ); + $aid_name = uc($aid_name) + } + until (length ($aid_name) <= 20); + + if ($aid_name ne "") + { $command .= "--aid_name='" . $aid_name . "' "; } + } + +##### +# Channel management parameters apply only to message type 22 +# These parameters specify the frequency for AIS channels A and B based upon the +# ITU frequency designators + +if ($type == 22) + { + do + { + print "\nEnter AIS Channel A channel number, from ITU-R Rec. M.1084;\nEncoder default = 2087 (87B = 161.975 MHz): "; + chomp ($channel_a = ); + } + until ($channel_a >= 0 || $channel_a eq ""); + + if ($channel_a ne "") + { $command .= "--channel_a=" . int($channel_a) . " "; } + + do + { + print "\nEnter AIS Channel B channel number, from ITU-R Rec. M.1084;\nEncoder default = 2088 (88B = 162.025 MHz): "; + chomp ($channel_b = ); + } + until ($channel_b >= 0 || $channel_b eq ""); + + if ($channel_b ne "") + { $command .= "--channel_b=" . int($channel_b) . " "; } + } + +##### +# AIS coverage region parameters are used in message types 22 & 23 +# These parameters define the rectagular AIS jurisdication area by specifying the northeast corner lat and long, +# and the southwest corner lat and long. + +if ($type == 22 || $type == 23) + { + do + { + print "\nEnter northeast corner's latitude of AIS rectangular jurisdiction (-90 to 90);\nEncoder default = 45.8: "; + chomp ($ne_lat = ); + } + until (($ne_lat >= -90 && $ne_lat <= 90) || $ne_lat eq ""); + + if ($ne_lat ne "") + { $command .= "--ne_lat='" . $ne_lat . "' "; } + + do + { + print "\nEnter northeast corner's longitude (-180 to 180); Encoder default = 9.9: "; + chomp ($ne_lon = ); + } + until (($ne_lon >= -180 && $ne_lon <= 180) || $ne_lon eq ""); + + if ($ne_lon ne "") + { $command .= "--ne_lon='" . $ne_lon . "' "; } + + do + { + print "\nEnter southwest corner's latitude of AIS rectangular jurisdiction (-90 to 90);\nEncoder default = 45.5: "; + chomp ($sw_lat = ); + } + until (($sw_lat >= -90 && $sw_lat <= 90) || $sw_lat eq ""); + + if ($sw_lat ne "") + { $command .= "--sw_lat='" . $sw_lat . "' "; } + + do + { + print "\nEnter southwest corner's longitude (-180 to 180); Encoder default = 9.5: "; + chomp ($sw_lon = ); + } + until (($sw_lon >= -180 && $sw_lon <= 180) || $sw_lon eq ""); + + if ($sw_lon ne "") + { $command .= "--sw_lon='" . $sw_lon . "' "; } + } + +##### +# The report interval and quiet time parameters are only used in message type 23 + +if ($type == 23) + { + do + { + print "\nEnter station reporting interval (0-15) from the following list:\n"; + print " 0. As given by the autonomous mode 1. 10 Minutes\n"; + print " 2. 6 Minutes 3. 3 Minutes 4. 1 minute\n"; + print " 5. 30 seconds 6. 15 Seconds 7. 10 Seconds\n"; + print " 8. 5 Seconds 9. Next Shorter Reporting Interval\n"; + print " 10. Next Longer Reporting Interval\n"; + print " 11-15. Reserved for future use\n"; + print " Encoder default = 1: "; + chomp ($interval = ); + } + until (($interval >= 0 && $interval <= 15) || $interval eq ""); + + if ($interval ne "") + { $command .= "--interval=" . int($interval) . " "; } + +do + { + print "\nEnter station quiet time, in minutes (1-15; 0 = none); Encoder default = 15:\n"; + chomp ($quiet = ); + } + until (($quiet >= 0 && $quiet <= 15) || $quiet eq ""); + + if ($quiet ne "") + { $command .= "--quiet=" . int($quiet) . " "; } + } + +##### +# Message type 24 has a Part A format and Part B format. First find the part... + +if ($type == 24) + { + do + { + print "\nEnter Static Data Report part number (A or B); Encoder default = A: "; + chomp ($part = ); + $part = uc($part); + } + until ($part eq "A" || $part eq "B" || $part eq ""); + + $part24 = $part; + if ($part eq "") + { $part24 = "A"; } + else + { $command .= "--part=" . $part . " "; } + } + +##### +# Message type 24, Part A format... + +if ($type == 24 && $part24 eq "A") + { + do + { + print "\nEnter vessel name (1-20 characters); Encoder default = NaN:\n"; + chomp ($vname = ); + $vname = uc($vname) + } + until (length ($vname) <= 20); + + if ($vname ne "") + { $command .= "--vname='" . $vname . "' "; } + } + +##### +# Vessel callsign and type are part of message type 24, Part B format... + +if ($type == 24 && $part24 eq "B") + { + do + { + print "\nEnter vessel call sign (1-7 characters); Encoder default = KC9CAF:\n"; + chomp ($callsign = ); + $callsign = uc($callsign) + } + until (length ($callsign) <= 7); + + if ($callsign ne "") + { $command .= "--callsign=" . $callsign . " "; } + } + + do + { + print "\nEnter vessel type (0-99) from the following list:\n"; + print " 0. Not available, AIS default 1-19. Reserved\n"; + print " 20-29. Wing in ground (WIG)\n"; + print " 30. Fishing 31. Towing\n"; + print " 32. Towing: length exceeds 200m or breadth exceeds 25m\n"; + print " 33. Dredging or underwater ops 34. Diving ops\n"; + print " 35. Military ops 36. Sailing\n"; + print " 37. Pleasure Craft 38-39. reserved\n"; + print " 40-49. High speed craft (HSC) 50. Pilot Vessel\n"; + print " 51. Search and Rescue vessel 52. Tug\n"; + print " 53. Port Tender 54. Anti-pollution equipment\n"; + print " 55. Law Enforcement 56-57. spare\n"; + print " 58. Medical Transport 59. Noncombatant ship\n"; + print " 60-69. Passenger ship 70-79. Cargo\n"; + print " 80-89. Tanker 90-99. Other ship type\n"; + print " Encoder default = 60: "; + chomp ($vtype = ); + } + until (($vtype >= 0 && $vtype <= 99) || $vtype eq ""); + + if ($vtype ne "") + { $command .= "--vtype=" . int($vtype) . " "; } + +##### +# Vessel size are part of message type 21 or type 24, Part B format... + +if ($type == 21 || ($type == 24 && $part24 eq "B")) + { + do + { + print "\nEnter vessel length, in meters (even number, 0-1022); Encoder default = 90:\n"; + chomp ($vsize_len = ); + $vsize_len = int($vsize_len); + } + until (($vsize_len >= 0 && $vsize_len <= 1022 & $vsize_len % 2 == 0) || $vsize_len eq ""); + + do + { + print "\nEnter vessel beam, in meters (even number, 0-126); Encoder default = 14:\n"; + chomp ($vsize_beam = ); + $vsize_beam = int($vsize_beam); + } + until (($vsize_beam >= 0 && $vsize_beam <= 126 && $vsize_beam % 2 == 0) || $vsize_beam eq ""); + + if ($vsize_len ne "" || $vsize_beam ne "") + { $command .= "--vsize=" . $vsize_len . "x" . $vsize_beam . " "; } + } + +# Now get parameters for the final part of the command string to output +# First determine whether to output as a comamnd to run the Unpacker or for AiS_TX + +do + { + print "\nSet command for unpacker (U) or AiS_TX (A) [default = U]: "; + chomp ($out = ); + $out = uc ($out); + } + until ($out eq "U" || $out eq "A" || $out eq ""); +if ($out eq "") { $out = "U"; } + +# If directing string to the Unpacker, indicate whether we want to create a complete NMEA sentence + +if ($out eq "U") + { + do + { + print "\nCreate NMEA sentance? (Y/N) [default = Y]: "; + chomp ($nmea = ); + $nmea = uc ($nmea); + } + until ($nmea eq "Y" || $nmea eq "N" || $nmea eq ""); + if ($nmea eq "") { $nmea = "Y"; } + + if ($nmea eq "Y") + { $nmea_enable = 1; } + else + { $nmea_enable = 0; } + } + +# Select AIS channel A or B + +do + { + print "\nEnter AIS channel (A/B) [default = A]: "; + chomp ($channel = ); + $channel = uc ($channel); + } + until ($channel eq "A" || $channel eq "B" || $channel eq ""); +if ($channel eq "") { $channel = "A"; } + +if ($out eq "U") + { $command .= "| xargs -IX ./unpacker.pl X " . $nmea_enable . " " . $channel; } + else + { $command .= "| xargs -IX ./AiS_TX.py --payload=X --channel=" . $channel;} + +print "\n$command\n\n"; + +# ******************************************************** +# ***** SUBROUTINE BLOCKS ***** +# ******************************************************** + +# ******************************************************** +# menu +# ******************************************************** + +# Main menu subroutine. Determine message type. + +sub menu # () + { + my $opt; + +# Show the main menu options... + + do + { + print "\033[2J"; # Clear the screen + print "\033[0;0H"; # Place cursor at 0,0 (upper left-hand corner) + print " AIVDM Preprocessor (Build: $build_date Version: $version)\n\n"; + print " MENU\n\n"; + print " Type 1: Position Report Class A\n"; + print " Type 4: Base Station Report\n"; + print " Type 14: Safety-Related Broadcast Message\n"; + print " Type 18: Standard Class B CS Position Report\n"; + print " Type 20: Data Link Management Message\n"; + print " Type 21: Aid-to-Navigation Report\n"; + print " Type 22: Channel Management\n"; + print " Type 23: Group Assignment Command\n"; + print " Type 24: Static Data Report\n"; + print "\n"; + print " X. Exit\n\n"; + print "Enter message type (1, 4, 14, 18, 20-24) or 'X' to halt: "; + chomp ($opt = ); + $opt = uc ($opt); + } + until ($opt == 1 || $opt == 4 || $opt == 14 || $opt == 18 || ($opt >= 20 && $opt <= 24) || $opt eq "X"); + + return ($opt); + } + +# ******************************************************** +# verify_numeric_string +# ******************************************************** + +# Verify that a numeric string of len $len is the proper length and actually all digits + +sub verify_numeric_string # ($num_str, $str_len) + { + my ($i,$ok,$tyui); + my ($num_str, $str_len); $num_str = $_[0]; $str_len = $_[1]; + + if (length ($num_str) != $str_len) + { return 0; } + + for ($i=0; $i<$str_len; $i++) + { + $tyui = substr ($num_str,$i,1); + if ($tyui lt "0" || $tyui gt "9") + { return 0; } + } + + return 1; + } + diff --git a/examples/AiS_TX.py b/apps/AiS_TX.py similarity index 100% rename from examples/AiS_TX.py rename to apps/AiS_TX.py diff --git a/examples/unpacker.c b/apps/unpacker.c similarity index 100% rename from examples/unpacker.c rename to apps/unpacker.c diff --git a/apps/unpacker.pl b/apps/unpacker.pl new file mode 100644 index 0000000..68339a8 --- /dev/null +++ b/apps/unpacker.pl @@ -0,0 +1,227 @@ +#!/usr/bin/perl -w + +# ============= FROM UNPACKER.C ==================== +# This source code is part of the AIS BlackToolkit. +# Unpacker.c allows you to build a NMEA sentece out of its payload. Normally used in combination with AIVDM_Encoder. + +# Copyright 2013-2014 -- Embyte & Pastus + +# This program 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 2 +# of the License, or (at your option) any later version. +# ================================================== + +# This is a Perl version of the C code in the AIS BlackToolkit distribution +# (c) Gary C. Kessler, 2018 +# Version -- 09/06/2018 (v0.1) + +# Usage example: +# $ ./AIVDM_Encoder.py --type=1 --vsize=30x10 | xargs -IX ./unpacker.pl X 1 A + +# The command above: +# 1) Runs AIVDM_encoder with whatever parameters and creates a binary string output +# 2) xargs takes the binary string and assigns it to "X" +# 3) Run unpacker with three arguments: +# X is the binary string output from AIVDM_Encoder +# 1 is the enable_nmea value (1 = ON, else OFF) +# A is the AIS channel (should be either A or B) + +# Parse command line + +if (parsecommandline ()) + { exit 1; }; + +$strlen = length ($in_string); + +# Error checking. Ensure that string is a multiple of 6 bits and composed of 0s and 1s; NMEA value is 0 or 1; and +# Channel is A or B + +if ($strlen % 6 != 0) + { + print "Input length not an even multiple of 6...\n"; + exit; + } + +for ($i=0; $i<$strlen; $i++) + { + $tyui = substr ($in_string, $i, 1); + if ($tyui ne "0" && $tyui ne "1") + { + print "Input contains non-binary value... $tyui\n"; + exit; + } + } + +if ($enable_nmea ne "0" && $enable_nmea ne "1") + { + print "Enable NMEA value not 0 or 1... $enable_nmea\n"; + exit; + } + +if ($channel ne "A" && $channel ne "B") + { + print "Channel must be A or B... $channel\n"; + exit; + } + + +print "NMEA value: $enable_nmea Channel: $channel\n"; +print "Input: $in_string\n"; +print "Armored ASCII: "; + +# Manipulate $in_string from binary to the NMEA 6-bit "armored" ASCII + +for ($i=0; $i<$strlen/6; $i++) + { + +# One character = 6 bits, so get the 6-bit block + + $in_buffer [$i] = substr ($in_string, $i*6, 6); + +# Convert the 6 binary bits to an integer value + + $in_buffer [$i] = convert ($in_buffer [$i], 6); + +# Now convert the value to an ASCII character + + if ($in_buffer [$i] > 39) + { $in_buffer [$i] += 8; } + $in_buffer [$i] += 48; + + $in_buffer [$i] = chr ($in_buffer [$i]); + + print $in_buffer [$i]; + } + +print "\n\n"; + +# Prepare AIS Message +# If enable_nmea = 1, then prepare NMEA header +# Next part is the ASCII string +# If enable_nmea=1, add compute and add checksum + +$AIS_message = ""; + +if ($enable_nmea == 1) + { $AIS_message = "!AIVDM,1,1,," . $channel . ","; } + +for ($i=0; $i<$strlen/6; $i++) + { $AIS_message = $AIS_message . $in_buffer [$i]; } + +if ($enable_nmea == 1) + { + $AIS_message = $AIS_message . ",0"; + $checksum = nmea_checksum ($AIS_message); + $AIS_message = $AIS_message . "*" . $checksum; + } + +print "AIS Message: $AIS_message\n\n"; + + +# ******************************************************** +# ***** SUBROUTINE BLOCKS ***** +# ******************************************************** + +# ******************************************************** +# nmea_checksum +# ******************************************************** + +sub nmea_checksum + +# The NMEA checksum is computed on the entire sentence including the AIVDM/AIVDO tag but excluding the leading "!" +# The checksum is merely a bybe-by-byte XOR of the sentence + +{ +my ($sentence, $char, $i, $n, $len, $sum); + +$sentence = $_[0]; +$len = length ($sentence); +$sum = 0; + +if (substr ($sentence,0,1) eq "!") + { $n = 1; } + else + { $n = 0; } + +for ($i=$n; $i<$len; $i++) + { $sum ^= ord (substr ($sentence,$i,1)); } + +# Ensure that $sum is two upper-case hex digits + + $sum = sprintf ("%02X", $sum); + return $sum; +} + +# ******************************************************** +# convert +# ******************************************************** + +sub convert +{ +my ($j, $sum); +my ($str, $n); + +$str = $_[0]; $n = $_[1]; +$sum=0; + +for ($j=0; $j<$n; $j++) + { + if (substr ($str,$j,1) == 1) { $sum += 2 ** ($n-$j-1); } + } + +return $sum; +} + +# ******************************************************** +# help_text +# ******************************************************** + +# Display the help file + +sub help_text +{ +print<< "EOT"; +Program usage: unpacker S N C + + where: S is the input string (an even multiple of 6 bits in length + composed of 0s and 1s) + N is 1 to output an NMEA sentence or 0 + C is the broadcast channel (A or B) +EOT +return; +} + +# ******************************************************** +# parsecommandline +# ******************************************************** + +# Parse command line for file name, if present. Query +# user for any missing information + +# Return $state = 1 to indicate that the program should stop +# immediately (switch -h) + +sub parsecommandline +{ +my $state = 0; + +# Parse command line switches ($ARGV array of length $#ARGV) + +if ($#ARGV == 2) + { + $in_string = $ARGV[0]; + $enable_nmea = $ARGV[1]; + $channel = $ARGV[2]; + } + else + { + help_text(); + $state = 1; + } + +return $state; +} + + + From e5b53d7a4c09080c3557f810064b3a5cec08e0ae Mon Sep 17 00:00:00 2001 From: bmagistro Date: Sat, 6 Feb 2021 16:09:47 -0500 Subject: [PATCH 04/12] remove/move duplicated/missed app files --- AIVDM_pre.pl | 571 --------------------------------------------------- unpacker.pl | 227 -------------------- 2 files changed, 798 deletions(-) delete mode 100644 AIVDM_pre.pl delete mode 100644 unpacker.pl diff --git a/AIVDM_pre.pl b/AIVDM_pre.pl deleted file mode 100644 index 90b6e1c..0000000 --- a/AIVDM_pre.pl +++ /dev/null @@ -1,571 +0,0 @@ -#!/usr/bin/perl - -# Program AIVDM_pre - -# This is a preprocessor for the AIS BlackToolkit. It is designed to provide a simple -# user interface allowing users to automatically generate comamnds for use with the -# AIVDM_Encoder.py program - -# AIVDM_Encoder prepares an output string that can be used by the unpacker.pl (or unpacker.c) -# program or transmitted using AiS_TX. This program, then, can create either form of the -# command lines below: - -# ./AIVDM_Encoder.py --type=1 --vsize=30x10 | xargs -IA ./unpacker.pl A 1 A -# ./AIVDM_Encoder.py --type=1 --vsize=30x10 | xargs -IX ./AiS_TX.py --payload=X --channel=A - -# See also "AIVDM/AIVDO protocol decoding" page at http://catb.org/gpsd/AIVDM.html - -# (c) Gary C. Kessler, 2018 - -$build_date = "09/09/2018"; -$version = "0.9"; - -$type = menu (); - -if ($type eq "X") - { - print "Goodbye!\n\n"; - exit; - }; - -# Initialize command string output. All commands include the --type parameter - -$command = "./AIVDM_Encoder.py --type=" . $type . " "; - -# Step through the supported parameters and ask for values for those parameters supported by the -# requested message type; provide default value. If default selected, do not add to command string output - -print "\nSee The 'AIVDM/AIVDO protocol decoding' page at http://catb.org/gpsd/AIVDM.html\n"; -print "for additional information on selecting parameter values.\n"; - -##### -# All messages contain an MMSI. -# The Maritime Mobile Service Identity (MMSI) is a 9 decimal digit number -# NOTE: The Encoder default value is not a real ship but indicates an Italian vessel - -do - { - print "\nEnter MMSI (9 decimal digits); Encoder default = 247320162 (vessel)\nor 970010000 (SART device): "; - chomp ($mmsi = ); - } - until (verify_numeric_string ($mmsi,9) || $mmsi eq ""); - -if ($mmsi ne "") - { $command .= "--mmsi=" . $mmsi . " "; } - -##### -# The SART_MSG parameter is used only in message type 14 -# The Search and Rescue Transponder (SART) message can be from 1-161 characters in length - -if ($type == 14) - { - do - { - print "\nEnter SART message (1-161 characters); Encoder default = 'SART ACTIVE':\n"; - chomp ($sart_msg = ); - } - until (length ($sart_msg) <= 161); - - if ($sart_msg ne "") - { $command .= "--sart_msg='" . $sart_msg . "' "; } - } - -##### -# Position parameters (latitude, longitude) are used in message types 1, 4, & 18 -# The Encoder default value is on Via Pizzo Formico near Piazza Madonna delle Nevi, Seriate, Bergamo, Italy - -if ($type == 1 || $type == 4 || $type == 18) - { - do - { - print "\nEnter latitude (-90 to 90); Encoder default = 45.6910166666667: "; - chomp ($lat = ); - } - until (($lat >= -90 && $lat <= 90) || $lat eq ""); - - if ($lat ne "") - { $command .= "--lat='" . $lat . "' "; } - - do - { - print "\nEnter longitude (-180 to 180); Encoder default = 9.72357833333333: "; - chomp ($long = ); - } - until (($long >= -180 && $long <= 180) || $long eq ""); - - if ($long ne "") - { $command .= "--long='" . $long . "' "; } - } - -##### -# Course, speed, and timestamp parameters are used in message types 1 & 18 - -if ($type == 1 || $type == 18) - { - do - { - print "\nEnter speed, in knots in 0.1 kn resolution (0-102; 1022 = 102.2 kn or higher;\n1023 = speed not available); Encoder default = 0.1: "; - chomp ($speed = ); - } - until (($speed >= 0 && $speed <= 102) || $speed == 1022 || $speed == 1023 || $speed eq ""); - - if ($speed ne "") - { $command .= "--speed=" . $speed . " "; } - - do - { - print "\nEnter course (1 to 360; 3600 = data not available); Encoder default = 83.4: "; - chomp ($course = ); - } - until (($course >= 1 && $course <= 360) || $course == 3600 || $course eq ""); - - if ($course ne "") - { $command .= "--course=" . $course . " "; } - - do - { - print "\nEnter UTC timestamp, in seconds (0-59; 60 = time stamp not available;\n"; - print "61 = positioning system is in manual input mode;\n62 = positioning system operates in estimated (dead reckoning) mode,\n"; - print "63 = positioning system is inoperative); Encoder default = 38: "; - chomp ($ts = ); - } - until (($ts >= 0 && $ts <= 63) || $ts eq ""); - - if ($ts ne "") - { $command .= "--ts=" . int($ts+0.5) . " "; } - } - -##### -# Fixed Access Time Division Multiple Access (FATDMA) parameters are used in message type 20 -# It has been difficult to get exact meaning and values, but I am allowing values based upon the field sizes. -# See also https://fccid.io/UYW-4230002/User-Manual/User-manual-2545256.html - -if ($type == 20) - { - do - { - print "\nEnter FATDMA reserved offset number (0-4095); Encoder default = 0: "; - chomp ($fatdmaoffset = ); - } - until (($fatdmaoffset >= 0 && $fatdmaoffset <= 4095) || $fatdmaoffset eq ""); - - if ($fatdmaoffset ne "") - { $command .= "--fatdmaoffset=" . int($fatdmaoffset) . " "; } - - do - { - print "\nEnter FATDMA number of reserved slots (0-15); Encoder default = 0: "; - chomp ($fatdmaslots = ); - } - until (($fatdmaslots >= 0 && $fatdmaslots <= 15) || $fatdmaslots eq ""); - - if ($fatdmaslots ne "") - { $command .= "--fatdmaslots=" . int($fatdmaslots) . " "; } - - do - { - print "\nEnter FATDMA timeout, in minutes (0-7); Encoder default = 0: "; - chomp ($fatdmatimeout = ); - } - until (($fatdmatimeout >= 0 && $fatdmatimeout <= 7) || $fatdmatimeouts eq ""); - - if ($fatdmatimeout ne "") - { $command .= "--fatdmatimeout=" . int($fatdmatimeout) . " "; } - - do - { - print "\nEnter FATDMA repeat increment (0-2047); Encoder default = 0: "; - chomp ($fatdmaincrement = ); - } - until (($fatdmaincrement >= 0 && $fatdmaincrement <= 2047) || $fatdmaincrement eq ""); - - if ($fatdmaincrement ne "") - { $command .= "--fatdmaincrement=" . int($fatdmaincrement) . " "; } - } - -##### -# Aids-to-Navigation (AtoN) parameters are used in message 21. - -if ($type == 21) - { - do - { - print "\nEnter 0 if this is a real AtoN at indicated position; 1 if this is a\nvirtual AtoN simulated by nearby AIS station; Encoder default = 0: "; - chomp ($v_AtoN = ); - } - until ($v_AtoN == 0 || $v_AtoN == 1 || $v_AtoN eq ""); - - if ($v_AtoN) - { $command .= "--v_AtoN" . " "; } - - do - { - print "\nEnter type of navigational aid (0-31) from the following list:\n"; - print " 0. AIS Default; type of AtoN not specified\n"; - print " 1. Reference point\n"; - print " 2. RACON (radar transponder marking a navigation hazard)\n"; - print " 3. Fixed structure off shore, such as oil platforms, wind farms, rigs.\n"; - print " 4. Spare, Reserved for future use 5. Light, without sectors\n"; - print " 6. Light, with sectors 7. Leading Light Front\n"; - print " 8. Leading Light Rear 9. Beacon, Cardinal N\n"; - print " 10. Beacon, Cardinal E 11. Beacon, Cardinal S\n"; - print " 12. Beacon, Cardinal W 13. Beacon, Port hand\n"; - print " 14. Beacon, Starboard hand\n"; - print " 15. Beacon, Preferred Channel port hand\n"; - print " 16. Beacon, Preferred Channel starboard hand\n"; - print " 17. Beacon, Isolated danger 18. Beacon, Safe water\n"; - print " 19. Beacon, Special mark 20. Cardinal Mark N\n"; - print " 21. Cardinal Mark E 22. Cardinal Mark S\n"; - print " 23. Cardinal Mark W 24. Port hand Mark\n"; - print " 25. Starboard hand Mark 26. Preferred Channel Port hand\n"; - print " 27. Preferred Channel Starboard hand\n"; - print " 28. Isolated danger 29. Safe Water\n"; - print " 30. Special Mark 31. Light Vessel / LANBY / Rigs\n"; - print " Encoder default = 1: "; - chomp ($aid_type = ); - } - until (($aid_type >= 0 && $aid_type <= 31) || $aid_type eq ""); - - if ($aid_type ne "") - { $command .= "--aid_type=" . int($aid_type) . " "; } - - do - { - print "\nEnter AtoN name (1-20 characters); Encoder default = '@@@@@@@@@@@@@@@@@@@@':\n"; - chomp ($aid_name = ); - $aid_name = uc($aid_name) - } - until (length ($aid_name) <= 20); - - if ($aid_name ne "") - { $command .= "--aid_name='" . $aid_name . "' "; } - } - -##### -# Channel management parameters apply only to message type 22 -# These parameters specify the frequency for AIS channels A and B based upon the -# ITU frequency designators - -if ($type == 22) - { - do - { - print "\nEnter AIS Channel A channel number, from ITU-R Rec. M.1084;\nEncoder default = 2087 (87B = 161.975 MHz): "; - chomp ($channel_a = ); - } - until ($channel_a >= 0 || $channel_a eq ""); - - if ($channel_a ne "") - { $command .= "--channel_a=" . int($channel_a) . " "; } - - do - { - print "\nEnter AIS Channel B channel number, from ITU-R Rec. M.1084;\nEncoder default = 2088 (88B = 162.025 MHz): "; - chomp ($channel_b = ); - } - until ($channel_b >= 0 || $channel_b eq ""); - - if ($channel_b ne "") - { $command .= "--channel_b=" . int($channel_b) . " "; } - } - -##### -# AIS coverage region parameters are used in message types 22 & 23 -# These parameters define the rectagular AIS jurisdication area by specifying the northeast corner lat and long, -# and the southwest corner lat and long. - -if ($type == 22 || $type == 23) - { - do - { - print "\nEnter northeast corner's latitude of AIS rectangular jurisdiction (-90 to 90);\nEncoder default = 45.8: "; - chomp ($ne_lat = ); - } - until (($ne_lat >= -90 && $ne_lat <= 90) || $ne_lat eq ""); - - if ($ne_lat ne "") - { $command .= "--ne_lat='" . $ne_lat . "' "; } - - do - { - print "\nEnter northeast corner's longitude (-180 to 180); Encoder default = 9.9: "; - chomp ($ne_lon = ); - } - until (($ne_lon >= -180 && $ne_lon <= 180) || $ne_lon eq ""); - - if ($ne_lon ne "") - { $command .= "--ne_lon='" . $ne_lon . "' "; } - - do - { - print "\nEnter southwest corner's latitude of AIS rectangular jurisdiction (-90 to 90);\nEncoder default = 45.5: "; - chomp ($sw_lat = ); - } - until (($sw_lat >= -90 && $sw_lat <= 90) || $sw_lat eq ""); - - if ($sw_lat ne "") - { $command .= "--sw_lat='" . $sw_lat . "' "; } - - do - { - print "\nEnter southwest corner's longitude (-180 to 180); Encoder default = 9.5: "; - chomp ($sw_lon = ); - } - until (($sw_lon >= -180 && $sw_lon <= 180) || $sw_lon eq ""); - - if ($sw_lon ne "") - { $command .= "--sw_lon='" . $sw_lon . "' "; } - } - -##### -# The report interval and quiet time parameters are only used in message type 23 - -if ($type == 23) - { - do - { - print "\nEnter station reporting interval (0-15) from the following list:\n"; - print " 0. As given by the autonomous mode 1. 10 Minutes\n"; - print " 2. 6 Minutes 3. 3 Minutes 4. 1 minute\n"; - print " 5. 30 seconds 6. 15 Seconds 7. 10 Seconds\n"; - print " 8. 5 Seconds 9. Next Shorter Reporting Interval\n"; - print " 10. Next Longer Reporting Interval\n"; - print " 11-15. Reserved for future use\n"; - print " Encoder default = 1: "; - chomp ($interval = ); - } - until (($interval >= 0 && $interval <= 15) || $interval eq ""); - - if ($interval ne "") - { $command .= "--interval=" . int($interval) . " "; } - -do - { - print "\nEnter station quiet time, in minutes (1-15; 0 = none); Encoder default = 15:\n"; - chomp ($quiet = ); - } - until (($quiet >= 0 && $quiet <= 15) || $quiet eq ""); - - if ($quiet ne "") - { $command .= "--quiet=" . int($quiet) . " "; } - } - -##### -# Message type 24 has a Part A format and Part B format. First find the part... - -if ($type == 24) - { - do - { - print "\nEnter Static Data Report part number (A or B); Encoder default = A: "; - chomp ($part = ); - $part = uc($part); - } - until ($part eq "A" || $part eq "B" || $part eq ""); - - $part24 = $part; - if ($part eq "") - { $part24 = "A"; } - else - { $command .= "--part=" . $part . " "; } - } - -##### -# Message type 24, Part A format... - -if ($type == 24 && $part24 eq "A") - { - do - { - print "\nEnter vessel name (1-20 characters); Encoder default = NaN:\n"; - chomp ($vname = ); - $vname = uc($vname) - } - until (length ($vname) <= 20); - - if ($vname ne "") - { $command .= "--vname='" . $vname . "' "; } - } - -##### -# Vessel callsign and type are part of message type 24, Part B format... - -if ($type == 24 && $part24 eq "B") - { - do - { - print "\nEnter vessel call sign (1-7 characters); Encoder default = KC9CAF:\n"; - chomp ($callsign = ); - $callsign = uc($callsign) - } - until (length ($callsign) <= 7); - - if ($callsign ne "") - { $command .= "--callsign=" . $callsign . " "; } - } - - do - { - print "\nEnter vessel type (0-99) from the following list:\n"; - print " 0. Not available, AIS default 1-19. Reserved\n"; - print " 20-29. Wing in ground (WIG)\n"; - print " 30. Fishing 31. Towing\n"; - print " 32. Towing: length exceeds 200m or breadth exceeds 25m\n"; - print " 33. Dredging or underwater ops 34. Diving ops\n"; - print " 35. Military ops 36. Sailing\n"; - print " 37. Pleasure Craft 38-39. reserved\n"; - print " 40-49. High speed craft (HSC) 50. Pilot Vessel\n"; - print " 51. Search and Rescue vessel 52. Tug\n"; - print " 53. Port Tender 54. Anti-pollution equipment\n"; - print " 55. Law Enforcement 56-57. spare\n"; - print " 58. Medical Transport 59. Noncombatant ship\n"; - print " 60-69. Passenger ship 70-79. Cargo\n"; - print " 80-89. Tanker 90-99. Other ship type\n"; - print " Encoder default = 60: "; - chomp ($vtype = ); - } - until (($vtype >= 0 && $vtype <= 99) || $vtype eq ""); - - if ($vtype ne "") - { $command .= "--vtype=" . int($vtype) . " "; } - -##### -# Vessel size are part of message type 21 or type 24, Part B format... - -if ($type == 21 || ($type == 24 && $part24 eq "B")) - { - do - { - print "\nEnter vessel length, in meters (even number, 0-1022); Encoder default = 90:\n"; - chomp ($vsize_len = ); - $vsize_len = int($vsize_len); - } - until (($vsize_len >= 0 && $vsize_len <= 1022 & $vsize_len % 2 == 0) || $vsize_len eq ""); - - do - { - print "\nEnter vessel beam, in meters (even number, 0-126); Encoder default = 14:\n"; - chomp ($vsize_beam = ); - $vsize_beam = int($vsize_beam); - } - until (($vsize_beam >= 0 && $vsize_beam <= 126 && $vsize_beam % 2 == 0) || $vsize_beam eq ""); - - if ($vsize_len ne "" || $vsize_beam ne "") - { $command .= "--vsize=" . $vsize_len . "x" . $vsize_beam . " "; } - } - -# Now get parameters for the final part of the command string to output -# First determine whether to output as a comamnd to run the Unpacker or for AiS_TX - -do - { - print "\nSet command for unpacker (U) or AiS_TX (A) [default = U]: "; - chomp ($out = ); - $out = uc ($out); - } - until ($out eq "U" || $out eq "A" || $out eq ""); -if ($out eq "") { $out = "U"; } - -# If directing string to the Unpacker, indicate whether we want to create a complete NMEA sentence - -if ($out eq "U") - { - do - { - print "\nCreate NMEA sentance? (Y/N) [default = Y]: "; - chomp ($nmea = ); - $nmea = uc ($nmea); - } - until ($nmea eq "Y" || $nmea eq "N" || $nmea eq ""); - if ($nmea eq "") { $nmea = "Y"; } - - if ($nmea eq "Y") - { $nmea_enable = 1; } - else - { $nmea_enable = 0; } - } - -# Select AIS channel A or B - -do - { - print "\nEnter AIS channel (A/B) [default = A]: "; - chomp ($channel = ); - $channel = uc ($channel); - } - until ($channel eq "A" || $channel eq "B" || $channel eq ""); -if ($channel eq "") { $channel = "A"; } - -if ($out eq "U") - { $command .= "| xargs -IX ./unpacker.pl X " . $nmea_enable . " " . $channel; } - else - { $command .= "| xargs -IX ./AiS_TX.py --payload=X --channel=" . $channel;} - -print "\n$command\n\n"; - -# ******************************************************** -# ***** SUBROUTINE BLOCKS ***** -# ******************************************************** - -# ******************************************************** -# menu -# ******************************************************** - -# Main menu subroutine. Determine message type. - -sub menu # () - { - my $opt; - -# Show the main menu options... - - do - { - print "\033[2J"; # Clear the screen - print "\033[0;0H"; # Place cursor at 0,0 (upper left-hand corner) - print " AIVDM Preprocessor (Build: $build_date Version: $version)\n\n"; - print " MENU\n\n"; - print " Type 1: Position Report Class A\n"; - print " Type 4: Base Station Report\n"; - print " Type 14: Safety-Related Broadcast Message\n"; - print " Type 18: Standard Class B CS Position Report\n"; - print " Type 20: Data Link Management Message\n"; - print " Type 21: Aid-to-Navigation Report\n"; - print " Type 22: Channel Management\n"; - print " Type 23: Group Assignment Command\n"; - print " Type 24: Static Data Report\n"; - print "\n"; - print " X. Exit\n\n"; - print "Enter message type (1, 4, 14, 18, 20-24) or 'X' to halt: "; - chomp ($opt = ); - $opt = uc ($opt); - } - until ($opt == 1 || $opt == 4 || $opt == 14 || $opt == 18 || ($opt >= 20 && $opt <= 24) || $opt eq "X"); - - return ($opt); - } - -# ******************************************************** -# verify_numeric_string -# ******************************************************** - -# Verify that a numeric string of len $len is the proper length and actually all digits - -sub verify_numeric_string # ($num_str, $str_len) - { - my ($i,$ok,$tyui); - my ($num_str, $str_len); $num_str = $_[0]; $str_len = $_[1]; - - if (length ($num_str) != $str_len) - { return 0; } - - for ($i=0; $i<$str_len; $i++) - { - $tyui = substr ($num_str,$i,1); - if ($tyui lt "0" || $tyui gt "9") - { return 0; } - } - - return 1; - } - diff --git a/unpacker.pl b/unpacker.pl deleted file mode 100644 index 409e93c..0000000 --- a/unpacker.pl +++ /dev/null @@ -1,227 +0,0 @@ -#!/usr/bin/perl -w - -# ============= FROM UNPACKER.C ==================== -# This source code is part of the AIS BlackToolkit. -# Unpacker.c allows you to build a NMEA sentece out of its payload. Normally used in combination with AIVDM_Encoder. - -# Copyright 2013-2014 -- Embyte & Pastus - -# This program 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 2 -# of the License, or (at your option) any later version. -# ================================================== - -# This is a Perl version of the C code in the AIS BlackToolkit distribution -# (c) Gary C. Kessler, 2018 -# Version -- 09/06/2018 (v0.1) - -# Usage example: -# $ ./AIVDM_Encoder.py --type=1 --vsize=30x10 | xargs -IX ./unpacker.pl X 1 A - -# The command above: -# 1) Runs AIVDM_encoder with whatever parameters and creates a binary string output -# 2) xargs takes the binary string and assigns it to "X" -# 3) Run unpacker with three arguments: -# X is the binary string output from AIVDM_Encoder -# 1 is the enable_nmea value (1 = ON, else OFF) -# A is the AIS channel (should be either A or B) - -# Parse command line - -if (parsecommandline ()) - { exit 1; }; - -$strlen = length ($in_string); - -# Error checking. Ensure that string is a multiple of 6 bits and composed of 0s and 1s; NMEA value is 0 or 1; and -# Channel is A or B - -if ($strlen % 6 != 0) - { - print "Input length not an even multiple of 6...\n"; - exit; - } - -for ($i=0; $i<$strlen; $i++) - { - $tyui = substr ($in_string, $i, 1); - if ($tyui ne "0" && $tyui ne "1") - { - print "Input contains non-binary value... $tyui\n"; - exit; - } - } - -if ($enable_nmea ne "0" && $enable_nmea ne "1") - { - print "Enable NMEA value not 0 or 1... $enable_nmea\n"; - exit; - } - -if ($channel ne "A" && $channel ne "B") - { - print "Channel must be A or B... $channel\n"; - exit; - } - - -print "NMEA value: $enable_nmea Channel: $channel\n"; -print "Input: $in_string\n"; -print "Armored ASCII: "; - -# Manipulate $in_string from binary to the NMEA 6-bit "armored" ASCII - -for ($i=0; $i<$strlen/6; $i++) - { - -# One character = 6 bits, so get the 6-bit block - - $in_buffer [$i] = substr ($in_string, $i*6, 6); - -# Convert the 6 binary bits to an integer value - - $in_buffer [$i] = convert ($in_buffer [$i], 6); - -# Now convert the value to an ASCII character - - if ($in_buffer [$i] > 39) - { $in_buffer [$i] += 8; } - $in_buffer [$i] += 48; - - $in_buffer [$i] = chr ($in_buffer [$i]); - - print $in_buffer [$i]; - } - -print "\n\n"; - -# Prepare AIS Message -# If enable_nmea = 1, then prepare NMEA header -# Next part is the ASCII string -# If enable_nmea=1, add compute and add checksum - -$AIS_message = ""; - -if ($enable_nmea == 1) - { $AIS_message = "!AIVDM,1,1,," . $channel . ","; } - -for ($i=0; $i<$strlen/6; $i++) - { $AIS_message = $AIS_message . $in_buffer [$i]; } - -if ($enable_nmea == 1) - { - $AIS_message = $AIS_message . ",0"; - $checksum = nmea_checksum ($AIS_message); - $AIS_message = $AIS_message . "*" . $checksum; - } - -print "AIS Message: $AIS_message\n\n"; - - -# ******************************************************** -# ***** SUBROUTINE BLOCKS ***** -# ******************************************************** - -# ******************************************************** -# nmea_checksum -# ******************************************************** - -sub nmea_checksum - -# The NMEA checksum is computed on the entire sentence including the AIVDM/AIVDO tag but excluding the leading "!" -# The checksum is merely a bybe-by-byte XOR of the sentence - -{ -my ($sentence, $char, $i, $n, $len, $sum); - -$sentence = $_[0]; -$len = length ($sentence); -$sum = 0; - -if (substr ($sentence,0,1) eq "!") - { $n = 1; } - else - { $n = 0; } - -for ($i=$n; $i<$len; $i++) - { $sum ^= ord (substr ($sentence,$i,1)); } - -# Ensure that $sum is two upper-case hex digits - - $sum = sprintf ("%2X", $sum); - return $sum; -} - -# ******************************************************** -# convert -# ******************************************************** - -sub convert -{ -my ($j, $sum); -my ($str, $n); - -$str = $_[0]; $n = $_[1]; -$sum=0; - -for ($j=0; $j<$n; $j++) - { - if (substr ($str,$j,1) == 1) { $sum += 2 ** ($n-$j-1); } - } - -return $sum; -} - -# ******************************************************** -# help_text -# ******************************************************** - -# Display the help file - -sub help_text -{ -print<< "EOT"; -Program usage: unpacker S N C - - where: S is the input string (an even multiple of 6 bits in length - composed of 0s and 1s) - N is 1 to output an NMEA sentence or 0 - C is the broadcast channel (A or B) -EOT -return; -} - -# ******************************************************** -# parsecommandline -# ******************************************************** - -# Parse command line for file name, if present. Query -# user for any missing information - -# Return $state = 1 to indicate that the program should stop -# immediately (switch -h) - -sub parsecommandline -{ -my $state = 0; - -# Parse command line switches ($ARGV array of length $#ARGV) - -if ($#ARGV == 2) - { - $in_string = $ARGV[0]; - $enable_nmea = $ARGV[1]; - $channel = $ARGV[2]; - } - else - { - help_text(); - $state = 1; - } - -return $state; -} - - - From d572be4a0f008c7cdd4da05eecdb23eee6ed2bb9 Mon Sep 17 00:00:00 2001 From: bmagistro Date: Sat, 6 Feb 2021 19:31:18 -0500 Subject: [PATCH 05/12] fix repeat function --- lib/Build_Frame_impl.cc | 20 ++++++++++++-------- lib/Build_Frame_impl.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/Build_Frame_impl.cc b/lib/Build_Frame_impl.cc index 2eb640c..07e59e5 100644 --- a/lib/Build_Frame_impl.cc +++ b/lib/Build_Frame_impl.cc @@ -57,6 +57,7 @@ namespace gr { gr::io_signature::make(0, 0, 0), gr::io_signature::make(1, 1, sizeof(unsigned char))), d_repeat(repeat), + d_repeat_cnt(0), d_enable_NRZI(enable_NRZI) { unsigned short REMAINDER_TO_EIGHT, PADDING_TO_EIGHT; // to pad the payload to a multiple of 8 @@ -133,7 +134,7 @@ namespace gr { return buffer; } - // staffing function + // stuffing function int Build_Frame_impl::stuff (const char *in, char *out, int l_in) { int i=0, j=0, consecutives=0, l_out=0; @@ -346,6 +347,14 @@ namespace gr { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { + // sleep at the start, if we stop too quickly after the send, the send doesn't seem to happen + usleep(100000); + + // if not set to repeat and we've sent a message we can exit + if (!d_repeat && d_repeat_cnt > 0) { + return WORK_DONE; + } + unsigned char *out = (unsigned char *) output_items[0]; // B3co>HP00 P ;8 ;56 RD =Is3 w sU kP06 CRC @@ -453,13 +462,8 @@ namespace gr { } - - // some sleep here -// int r = (int) rand() % 1000; -// usleep(1000*r); // -6 - //sleep(1); - usleep(100000); - + d_repeat_cnt++; + // Tell runtime system how many output items we produced. return noutput_items; } diff --git a/lib/Build_Frame_impl.h b/lib/Build_Frame_impl.h index 6a6648f..5206ed5 100644 --- a/lib/Build_Frame_impl.h +++ b/lib/Build_Frame_impl.h @@ -32,6 +32,7 @@ namespace gr { { private: bool d_repeat; + unsigned long d_repeat_cnt; bool d_enable_NRZI; //char * d_sentence; char *payload; // [the 01 rapresentation of the sentence as taken from input] From 05d28fc08718c7f093ff619158cb9e69a1c36cc8 Mon Sep 17 00:00:00 2001 From: bmagistro Date: Sat, 13 Feb 2021 21:21:23 -0500 Subject: [PATCH 06/12] add option for building tests; gr3.8 migrated to boost utf and some embedded platforms may not include cppunit by default --- CMakeLists.txt | 13 +++++-------- lib/CMakeLists.txt | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f887cad..9ff10b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,11 @@ cmake_minimum_required(VERSION 3.8) include(GNUInstallDirs) project(gr-AISTX CXX C) -enable_testing() + +option(ENABLE_TESTING "Enable/Build tests" OFF) +if(ENABLE_TESTING) + enable_testing() +endif(ENABLE_TESTING) # Install to PyBOMBS target prefix if defined if(DEFINED ENV{PYBOMBS_PREFIX}) @@ -140,11 +144,6 @@ endif(APPLE) ######################################################################## # Find gnuradio build dependencies ######################################################################## -find_package(CppUnit) - -if(NOT CPPUNIT_FOUND) - message(FATAL_ERROR "CppUnit required to compile AISTX") -endif() ######################################################################## # Setup the include and linker paths @@ -152,14 +151,12 @@ endif() include_directories( ${CMAKE_SOURCE_DIR}/include ${Boost_INCLUDE_DIRS} - ${CPPUNIT_INCLUDE_DIRS} ${GNURADIO_RUNTIME_INCLUDE_DIRS} ${GNURADIO_RUNTIME_INCLUDE_DIRS}/gnuradio/swig ) link_directories( ${Boost_LIBRARY_DIRS} - ${CPPUNIT_LIBRARY_DIRS} ${GNURADIO_RUNTIME_LIBRARY_DIRS} ) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d95a6b0..3f18136 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -70,23 +70,34 @@ message(STATUS "Building for version: ${VERSION} / ${LIBVER}") ######################################################################## # Build and register unit test ######################################################################## -include(GrTest) +if(ENABLE_TESTING) +message("asdf: ${ENABLE_TESTING}") + find_package(CppUnit) -include_directories(${CPPUNIT_INCLUDE_DIRS}) + if(NOT CPPUNIT_FOUND) + message(FATAL_ERROR "CppUnit required to compile AISTX") + endif() -list(APPEND test_AISTX_sources - ${CMAKE_CURRENT_SOURCE_DIR}/test_AISTX.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_AISTX.cc -) + include(GrTest) + + list(APPEND test_AISTX_sources + ${CMAKE_CURRENT_SOURCE_DIR}/test_AISTX.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_AISTX.cc + ) -add_executable(test-AISTX ${test_AISTX_sources}) + add_executable(test-AISTX ${test_AISTX_sources}) -target_link_libraries( - test-AISTX - ${GNURADIO_RUNTIME_LIBRARIES} - ${Boost_LIBRARIES} - ${CPPUNIT_LIBRARIES} - gnuradio-AISTX -) + target_include_directories(test-AISTX + PUBLIC ${CPPUNIT_INCLUDE_DIRS} + ) + + target_link_libraries( + test-AISTX + ${GNURADIO_RUNTIME_LIBRARIES} + ${Boost_LIBRARIES} + ${CPPUNIT_LIBRARIES} + gnuradio-AISTX + ) -GR_ADD_TEST(test_AISTX test-AISTX) + GR_ADD_TEST(test_AISTX test-AISTX) +endif(ENABLE_TESTING) From b3f1d4f8279f2c8c66c97a4e9393a8ea879d5216 Mon Sep 17 00:00:00 2001 From: bmagistro Date: Sun, 14 Feb 2021 18:35:29 -0500 Subject: [PATCH 07/12] make tests optional in cmake; cmake gr module install cleanup --- CMakeLists.txt | 37 +----------------------------------- include/AISTX/CMakeLists.txt | 3 ++- lib/CMakeLists.txt | 12 ++---------- python/CMakeLists.txt | 14 ++++++++------ python/__init__.py | 27 ++++---------------------- swig/CMakeLists.txt | 7 ++----- 6 files changed, 19 insertions(+), 81 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ff10b0..d887ac5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,6 @@ # Project setup ######################################################################## cmake_minimum_required(VERSION 3.8) -include(GNUInstallDirs) project(gr-AISTX CXX C) option(ENABLE_TESTING "Enable/Build tests" OFF) @@ -87,15 +86,6 @@ ELSE() message(WARNING "C standard could not be set because compiler is not GNU, Clang or MSVC.") ENDIF() -######################################################################## -# Find boost -######################################################################## -find_package(Boost "1.65" COMPONENTS filesystem system program_options regex thread) - -if(NOT Boost_FOUND) - message(FATAL_ERROR "Boost required to compile AISTX") -endif() - ######################################################################## # Install directories ######################################################################## @@ -108,18 +98,12 @@ if(NOT CMAKE_MODULES_DIR) set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake) endif(NOT CMAKE_MODULES_DIR) -set(GR_RUNTIME_DIR bin) -set(GR_LIBRARY_DIR lib${LIB_SUFFIX}) set(GR_INCLUDE_DIR include/AISTX) -set(GR_DATA_DIR share) +set(GR_CMAKE_DIR ${CMAKE_MODULES_DIR}/AISTX) set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME}) -set(GR_DOC_DIR ${GR_DATA_DIR}/doc) set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME}) -set(GR_CONF_DIR etc) set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d) -set(GR_LIBEXEC_DIR libexec) set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME}) -set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) ######################################################################## # On Apple only, set install name and use rpath correctly, if not already set @@ -145,25 +129,6 @@ endif(APPLE) # Find gnuradio build dependencies ######################################################################## -######################################################################## -# Setup the include and linker paths -######################################################################## -include_directories( - ${CMAKE_SOURCE_DIR}/include - ${Boost_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${GNURADIO_RUNTIME_INCLUDE_DIRS}/gnuradio/swig -) - -link_directories( - ${Boost_LIBRARY_DIRS} - ${GNURADIO_RUNTIME_LIBRARY_DIRS} -) - -# Set component parameters -set(GR_AISTX_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE INTERNAL "" FORCE) -set(GR_AISTX_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/swig CACHE INTERNAL "" FORCE) - ######################################################################## # Create uninstall target ######################################################################## diff --git a/include/AISTX/CMakeLists.txt b/include/AISTX/CMakeLists.txt index 563cfc8..cbba99f 100644 --- a/include/AISTX/CMakeLists.txt +++ b/include/AISTX/CMakeLists.txt @@ -25,5 +25,6 @@ install(FILES api.h nrz_to_nrzi.h Build_Frame.h - DebugME.h DESTINATION include/AISTX + DebugME.h + DESTINATION include/AISTX ) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 3f18136..d262281 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -23,8 +23,6 @@ ######################################################################## include(GrPlatform) #define LIB_SUFFIX -include_directories(${Boost_INCLUDE_DIR}) -link_directories(${Boost_LIBRARY_DIRS}) list(APPEND AISTX_sources nrz_to_nrzi_impl.cc Build_Frame_impl.cc @@ -38,7 +36,7 @@ if(NOT AISTX_sources) endif(NOT AISTX_sources) add_library(gnuradio-AISTX SHARED ${AISTX_sources}) -target_link_libraries(gnuradio-AISTX gnuradio::gnuradio-runtime ${Boost_LIBRARIES}) +target_link_libraries(gnuradio-AISTX gnuradio::gnuradio-runtime) target_include_directories(gnuradio-AISTX PUBLIC $ PUBLIC $ @@ -55,11 +53,7 @@ endif(APPLE) # Install built library files ######################################################################## include(GrMiscUtils) -install(TARGETS gnuradio-AISTX - LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file - ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file - RUNTIME DESTINATION bin # .dll file -) +GR_LIBRARY_FOO(gnuradio-AISTX) ######################################################################## # Print summary @@ -71,7 +65,6 @@ message(STATUS "Building for version: ${VERSION} / ${LIBVER}") # Build and register unit test ######################################################################## if(ENABLE_TESTING) -message("asdf: ${ENABLE_TESTING}") find_package(CppUnit) if(NOT CPPUNIT_FOUND) @@ -94,7 +87,6 @@ message("asdf: ${ENABLE_TESTING}") target_link_libraries( test-AISTX ${GNURADIO_RUNTIME_LIBRARIES} - ${Boost_LIBRARIES} ${CPPUNIT_LIBRARIES} gnuradio-AISTX ) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index a7532fd..fd3b1ad 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -38,10 +38,12 @@ GR_PYTHON_INSTALL( ######################################################################## # Handle the unit tests ######################################################################## -include(GrTest) +if(ENABLE_TESTING) + include(GrTest) -set(GR_TEST_TARGET_DEPS gnuradio-AISTX) -set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig) -GR_ADD_TEST(qa_nrz_to_nrzi ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_nrz_to_nrzi.py) -GR_ADD_TEST(qa_Build_Frame ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_Build_Frame.py) -GR_ADD_TEST(qa_DebugME ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_DebugME.py) + set(GR_TEST_TARGET_DEPS gnuradio-AISTX) + set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/swig) + GR_ADD_TEST(qa_nrz_to_nrzi ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_nrz_to_nrzi.py) + GR_ADD_TEST(qa_Build_Frame ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_Build_Frame.py) + GR_ADD_TEST(qa_DebugME ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/qa_DebugME.py) +endif(ENABLE_TESTING) diff --git a/python/__init__.py b/python/__init__.py index 3872a70..46f0e46 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -23,32 +23,13 @@ description here (python/__init__.py). ''' -# ---------------------------------------------------------------- -# Temporary workaround for ticket:181 (swig+python problem) -import sys -_RTLD_GLOBAL = 0 +# import swig generated symbols into the satellites namespace +# this would fail if we are being imported from the build dir try: - from dl import RTLD_GLOBAL as _RTLD_GLOBAL + from .AISTX_swig import * except ImportError: - try: - from DLFCN import RTLD_GLOBAL as _RTLD_GLOBAL - except ImportError: - pass - -if _RTLD_GLOBAL != 0: - _dlopenflags = sys.getdlopenflags() - sys.setdlopenflags(_dlopenflags|_RTLD_GLOBAL) -# ---------------------------------------------------------------- - - -# import swig generated symbols into the AISTX namespace -from AISTX_swig import * + from AISTX_swig import * # import any pure python here # -# ---------------------------------------------------------------- -# Tail of workaround -if _RTLD_GLOBAL != 0: - sys.setdlopenflags(_dlopenflags) # Restore original flags -# ---------------------------------------------------------------- diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index 822e3ac..2da2d31 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -28,11 +28,8 @@ endif(NOT AISTX_sources) ######################################################################## # Include swig generation macros ######################################################################## -find_package(SWIG) -find_package(PythonLibs) -if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) - return() -endif() +find_package(SWIG REQUIRED) +find_package(PythonLibs REQUIRED) include(GrSwig) include(GrPython) From c06f5fdbef6570755e0e5e63949e8868fd667770 Mon Sep 17 00:00:00 2001 From: bmagistro Date: Mon, 8 Feb 2021 12:53:18 -0500 Subject: [PATCH 08/12] convert frame builder support input, previous functionality is obtained by combining with message strobe --- examples/aistx_msg.grc | 900 ++++++++++++++++++++++++++++++++ grc/AISTX_Build_Frame.block.yml | 15 +- include/AISTX/Build_Frame.h | 6 +- lib/Build_Frame_impl.cc | 171 ++++-- lib/Build_Frame_impl.h | 17 +- 5 files changed, 1043 insertions(+), 66 deletions(-) create mode 100644 examples/aistx_msg.grc diff --git a/examples/aistx_msg.grc b/examples/aistx_msg.grc new file mode 100644 index 0000000..113b6fc --- /dev/null +++ b/examples/aistx_msg.grc @@ -0,0 +1,900 @@ +options: + parameters: + author: '' + category: '[GRC Hier Blocks]' + cmake_opt: '' + comment: '' + copyright: '' + description: '' + gen_cmake: 'On' + gen_linking: dynamic + generate_options: no_gui + hier_block_src_path: '.:' + id: aistx_msg + max_nouts: '0' + output_language: python + placement: (0,0) + qt_qss_theme: '' + realtime_scheduling: '' + run: 'True' + run_command: '{python} -u {filename}' + run_options: run + sizing_mode: fixed + thread_safe_setters: '' + title: aistx_msg + window_size: '' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [8, 12.0] + rotation: 0 + state: enabled + +blocks: +- name: bit_rate + id: variable + parameters: + comment: '' + value: '9600' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [281, 82] + rotation: 0 + state: enabled +- name: samp_rate + id: variable + parameters: + comment: '' + value: '1000000' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [282, 15] + rotation: 0 + state: enabled +- name: AISTX_Build_Frame_0 + id: AISTX_Build_Frame + parameters: + affinity: '' + alias: '' + comment: '' + enable_NRZI: 'True' + maxoutbuf: '0' + minoutbuf: '0' + repeat: 'True' + tag: packet_len + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [152, 364] + rotation: 0 + state: enabled +- name: analog_sig_source_x_0 + id: analog_sig_source_x + parameters: + affinity: '' + alias: '' + amp: '1' + comment: '' + freq: '-25000' + maxoutbuf: '0' + minoutbuf: '0' + offset: '0' + phase: '0' + samp_rate: samp_rate + type: complex + waveform: analog.GR_SIN_WAVE + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [459, 207] + rotation: 0 + state: enabled +- name: analog_sig_source_x_1 + id: analog_sig_source_x + parameters: + affinity: '' + alias: '' + amp: '1' + comment: '' + freq: '25000' + maxoutbuf: '0' + minoutbuf: '0' + offset: '0' + phase: '0' + samp_rate: samp_rate + type: complex + waveform: analog.GR_SIN_WAVE + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [459, 477] + rotation: 0 + state: enabled +- name: blocks_add_xx_0 + id: blocks_add_xx + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + num_inputs: '2' + type: complex + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [1105, 368] + rotation: 0 + state: enabled +- name: blocks_message_debug_0 + id: blocks_message_debug + parameters: + affinity: '' + alias: '' + comment: '' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [154, 567] + rotation: 0 + state: disabled +- name: blocks_message_strobe_0 + id: blocks_message_strobe + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + msg: pmt.intern("010010000011101011110111001110011000100000000000000000100000001011001000001011000101000110100010010100001101011001111011000011111111111011100101110011100000000000000110") + period: '10000' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [153, 482] + rotation: 180 + state: enabled +- name: blocks_multiply_const_vxx_0 + id: blocks_multiply_const_vxx + parameters: + affinity: '' + alias: '' + comment: '' + const: '.45' + maxoutbuf: '0' + minoutbuf: '0' + type: complex + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [893, 317] + rotation: 0 + state: enabled +- name: blocks_multiply_const_vxx_1 + id: blocks_multiply_const_vxx + parameters: + affinity: '' + alias: '' + comment: '' + const: '0.9' + maxoutbuf: '0' + minoutbuf: '0' + type: complex + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [893, 205] + rotation: 0 + state: enabled +- name: blocks_multiply_const_vxx_2 + id: blocks_multiply_const_vxx + parameters: + affinity: '' + alias: '' + comment: '' + const: '.45' + maxoutbuf: '0' + minoutbuf: '0' + type: complex + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [893, 445] + rotation: 0 + state: enabled +- name: blocks_multiply_const_vxx_3 + id: blocks_multiply_const_vxx + parameters: + affinity: '' + alias: '' + comment: '' + const: '0.9' + maxoutbuf: '0' + minoutbuf: '0' + type: complex + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [893, 557] + rotation: 0 + state: enabled +- name: blocks_multiply_xx_0 + id: blocks_multiply_xx + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + num_inputs: '2' + type: complex + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [733, 251] + rotation: 0 + state: enabled +- name: blocks_multiply_xx_1 + id: blocks_multiply_xx + parameters: + affinity: '' + alias: '' + comment: '' + maxoutbuf: '0' + minoutbuf: '0' + num_inputs: '2' + type: complex + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [733, 489] + rotation: 0 + state: enabled +- name: blocks_selector_0 + id: blocks_selector + parameters: + affinity: '' + alias: '' + comment: '' + enabled: 'True' + input_index: '1' + maxoutbuf: '0' + minoutbuf: '0' + num_inputs: '3' + num_outputs: '1' + output_index: '0' + showports: 'True' + type: complex + vlen: '1' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [1243, 352] + rotation: 0 + state: enabled +- name: blocks_socket_pdu_0 + id: blocks_socket_pdu + parameters: + affinity: '' + alias: '' + comment: '' + host: 0.0.0.0 + maxoutbuf: '0' + minoutbuf: '0' + mtu: '1472' + port: '23201' + tcp_no_delay: 'False' + type: UDP_SERVER + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [153, 237] + rotation: 180 + state: disabled +- name: digital_gmsk_mod_0 + id: digital_gmsk_mod + parameters: + affinity: '' + alias: '' + bt: '0.4' + comment: '' + log: 'False' + maxoutbuf: '0' + minoutbuf: '0' + samples_per_symbol: int(samp_rate/bit_rate) + verbose: 'False' + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [482, 372] + rotation: 0 + state: enabled +- name: osmosdr_sink_0 + id: osmosdr_sink + parameters: + affinity: '' + alias: '' + ant0: '' + ant1: '' + ant10: '' + ant11: '' + ant12: '' + ant13: '' + ant14: '' + ant15: '' + ant16: '' + ant17: '' + ant18: '' + ant19: '' + ant2: '' + ant20: '' + ant21: '' + ant22: '' + ant23: '' + ant24: '' + ant25: '' + ant26: '' + ant27: '' + ant28: '' + ant29: '' + ant3: '' + ant30: '' + ant31: '' + ant4: '' + ant5: '' + ant6: '' + ant7: '' + ant8: '' + ant9: '' + args: bladerf=0,biastee=0 + bb_gain0: '20' + bb_gain1: '20' + bb_gain10: '20' + bb_gain11: '20' + bb_gain12: '20' + bb_gain13: '20' + bb_gain14: '20' + bb_gain15: '20' + bb_gain16: '20' + bb_gain17: '20' + bb_gain18: '20' + bb_gain19: '20' + bb_gain2: '20' + bb_gain20: '20' + bb_gain21: '20' + bb_gain22: '20' + bb_gain23: '20' + bb_gain24: '20' + bb_gain25: '20' + bb_gain26: '20' + bb_gain27: '20' + bb_gain28: '20' + bb_gain29: '20' + bb_gain3: '20' + bb_gain30: '20' + bb_gain31: '20' + bb_gain4: '20' + bb_gain5: '20' + bb_gain6: '20' + bb_gain7: '20' + bb_gain8: '20' + bb_gain9: '20' + bw0: '0' + bw1: '0' + bw10: '0' + bw11: '0' + bw12: '0' + bw13: '0' + bw14: '0' + bw15: '0' + bw16: '0' + bw17: '0' + bw18: '0' + bw19: '0' + bw2: '0' + bw20: '0' + bw21: '0' + bw22: '0' + bw23: '0' + bw24: '0' + bw25: '0' + bw26: '0' + bw27: '0' + bw28: '0' + bw29: '0' + bw3: '0' + bw30: '0' + bw31: '0' + bw4: '0' + bw5: '0' + bw6: '0' + bw7: '0' + bw8: '0' + bw9: '0' + clock_source0: '' + clock_source1: '' + clock_source2: '' + clock_source3: '' + clock_source4: '' + clock_source5: '' + clock_source6: '' + clock_source7: '' + comment: '' + corr0: '0' + corr1: '0' + corr10: '0' + corr11: '0' + corr12: '0' + corr13: '0' + corr14: '0' + corr15: '0' + corr16: '0' + corr17: '0' + corr18: '0' + corr19: '0' + corr2: '0' + corr20: '0' + corr21: '0' + corr22: '0' + corr23: '0' + corr24: '0' + corr25: '0' + corr26: '0' + corr27: '0' + corr28: '0' + corr29: '0' + corr3: '0' + corr30: '0' + corr31: '0' + corr4: '0' + corr5: '0' + corr6: '0' + corr7: '0' + corr8: '0' + corr9: '0' + freq0: '162000000' + freq1: 100e6 + freq10: 100e6 + freq11: 100e6 + freq12: 100e6 + freq13: 100e6 + freq14: 100e6 + freq15: 100e6 + freq16: 100e6 + freq17: 100e6 + freq18: 100e6 + freq19: 100e6 + freq2: 100e6 + freq20: 100e6 + freq21: 100e6 + freq22: 100e6 + freq23: 100e6 + freq24: 100e6 + freq25: 100e6 + freq26: 100e6 + freq27: 100e6 + freq28: 100e6 + freq29: 100e6 + freq3: 100e6 + freq30: 100e6 + freq31: 100e6 + freq4: 100e6 + freq5: 100e6 + freq6: 100e6 + freq7: 100e6 + freq8: 100e6 + freq9: 100e6 + gain0: '10' + gain1: '10' + gain10: '10' + gain11: '10' + gain12: '10' + gain13: '10' + gain14: '10' + gain15: '10' + gain16: '10' + gain17: '10' + gain18: '10' + gain19: '10' + gain2: '10' + gain20: '10' + gain21: '10' + gain22: '10' + gain23: '10' + gain24: '10' + gain25: '10' + gain26: '10' + gain27: '10' + gain28: '10' + gain29: '10' + gain3: '10' + gain30: '10' + gain31: '10' + gain4: '10' + gain5: '10' + gain6: '10' + gain7: '10' + gain8: '10' + gain9: '10' + if_gain0: '20' + if_gain1: '20' + if_gain10: '20' + if_gain11: '20' + if_gain12: '20' + if_gain13: '20' + if_gain14: '20' + if_gain15: '20' + if_gain16: '20' + if_gain17: '20' + if_gain18: '20' + if_gain19: '20' + if_gain2: '20' + if_gain20: '20' + if_gain21: '20' + if_gain22: '20' + if_gain23: '20' + if_gain24: '20' + if_gain25: '20' + if_gain26: '20' + if_gain27: '20' + if_gain28: '20' + if_gain29: '20' + if_gain3: '20' + if_gain30: '20' + if_gain31: '20' + if_gain4: '20' + if_gain5: '20' + if_gain6: '20' + if_gain7: '20' + if_gain8: '20' + if_gain9: '20' + maxoutbuf: '0' + minoutbuf: '0' + nchan: '1' + num_mboards: '1' + sample_rate: samp_rate + sync: sync + time_source0: '' + time_source1: '' + time_source2: '' + time_source3: '' + time_source4: '' + time_source5: '' + time_source6: '' + time_source7: '' + type: fc32 + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [1527, 121] + rotation: 0 + state: enabled +- name: uhd_usrp_sink_0 + id: uhd_usrp_sink + parameters: + affinity: '' + alias: '' + ant0: TX/RX + ant1: TX/RX + ant10: TX/RX + ant11: TX/RX + ant12: TX/RX + ant13: TX/RX + ant14: TX/RX + ant15: TX/RX + ant16: TX/RX + ant17: TX/RX + ant18: TX/RX + ant19: TX/RX + ant2: TX/RX + ant20: TX/RX + ant21: TX/RX + ant22: TX/RX + ant23: TX/RX + ant24: TX/RX + ant25: TX/RX + ant26: TX/RX + ant27: TX/RX + ant28: TX/RX + ant29: TX/RX + ant3: TX/RX + ant30: TX/RX + ant31: TX/RX + ant4: TX/RX + ant5: TX/RX + ant6: TX/RX + ant7: TX/RX + ant8: TX/RX + ant9: TX/RX + bw0: '500000' + bw1: '0' + bw10: '0' + bw11: '0' + bw12: '0' + bw13: '0' + bw14: '0' + bw15: '0' + bw16: '0' + bw17: '0' + bw18: '0' + bw19: '0' + bw2: '0' + bw20: '0' + bw21: '0' + bw22: '0' + bw23: '0' + bw24: '0' + bw25: '0' + bw26: '0' + bw27: '0' + bw28: '0' + bw29: '0' + bw3: '0' + bw30: '0' + bw31: '0' + bw4: '0' + bw5: '0' + bw6: '0' + bw7: '0' + bw8: '0' + bw9: '0' + center_freq0: '162000000' + center_freq1: '0' + center_freq10: '0' + center_freq11: '0' + center_freq12: '0' + center_freq13: '0' + center_freq14: '0' + center_freq15: '0' + center_freq16: '0' + center_freq17: '0' + center_freq18: '0' + center_freq19: '0' + center_freq2: '0' + center_freq20: '0' + center_freq21: '0' + center_freq22: '0' + center_freq23: '0' + center_freq24: '0' + center_freq25: '0' + center_freq26: '0' + center_freq27: '0' + center_freq28: '0' + center_freq29: '0' + center_freq3: '0' + center_freq30: '0' + center_freq31: '0' + center_freq4: '0' + center_freq5: '0' + center_freq6: '0' + center_freq7: '0' + center_freq8: '0' + center_freq9: '0' + clock_rate: 0e0 + clock_source0: '' + clock_source1: '' + clock_source2: '' + clock_source3: '' + clock_source4: '' + clock_source5: '' + clock_source6: '' + clock_source7: '' + comment: '' + dev_addr: '""' + dev_args: '""' + gain0: '0' + gain1: '0' + gain10: '0' + gain11: '0' + gain12: '0' + gain13: '0' + gain14: '0' + gain15: '0' + gain16: '0' + gain17: '0' + gain18: '0' + gain19: '0' + gain2: '0' + gain20: '0' + gain21: '0' + gain22: '0' + gain23: '0' + gain24: '0' + gain25: '0' + gain26: '0' + gain27: '0' + gain28: '0' + gain29: '0' + gain3: '0' + gain30: '0' + gain31: '0' + gain4: '0' + gain5: '0' + gain6: '0' + gain7: '0' + gain8: '0' + gain9: '0' + len_tag_name: '' + lo_export0: 'False' + lo_export1: 'False' + lo_export10: 'False' + lo_export11: 'False' + lo_export12: 'False' + lo_export13: 'False' + lo_export14: 'False' + lo_export15: 'False' + lo_export16: 'False' + lo_export17: 'False' + lo_export18: 'False' + lo_export19: 'False' + lo_export2: 'False' + lo_export20: 'False' + lo_export21: 'False' + lo_export22: 'False' + lo_export23: 'False' + lo_export24: 'False' + lo_export25: 'False' + lo_export26: 'False' + lo_export27: 'False' + lo_export28: 'False' + lo_export29: 'False' + lo_export3: 'False' + lo_export30: 'False' + lo_export31: 'False' + lo_export4: 'False' + lo_export5: 'False' + lo_export6: 'False' + lo_export7: 'False' + lo_export8: 'False' + lo_export9: 'False' + lo_source0: internal + lo_source1: internal + lo_source10: internal + lo_source11: internal + lo_source12: internal + lo_source13: internal + lo_source14: internal + lo_source15: internal + lo_source16: internal + lo_source17: internal + lo_source18: internal + lo_source19: internal + lo_source2: internal + lo_source20: internal + lo_source21: internal + lo_source22: internal + lo_source23: internal + lo_source24: internal + lo_source25: internal + lo_source26: internal + lo_source27: internal + lo_source28: internal + lo_source29: internal + lo_source3: internal + lo_source30: internal + lo_source31: internal + lo_source4: internal + lo_source5: internal + lo_source6: internal + lo_source7: internal + lo_source8: internal + lo_source9: internal + maxoutbuf: '0' + minoutbuf: '0' + nchan: '1' + norm_gain0: 'False' + norm_gain1: 'False' + norm_gain10: 'False' + norm_gain11: 'False' + norm_gain12: 'False' + norm_gain13: 'False' + norm_gain14: 'False' + norm_gain15: 'False' + norm_gain16: 'False' + norm_gain17: 'False' + norm_gain18: 'False' + norm_gain19: 'False' + norm_gain2: 'False' + norm_gain20: 'False' + norm_gain21: 'False' + norm_gain22: 'False' + norm_gain23: 'False' + norm_gain24: 'False' + norm_gain25: 'False' + norm_gain26: 'False' + norm_gain27: 'False' + norm_gain28: 'False' + norm_gain29: 'False' + norm_gain3: 'False' + norm_gain30: 'False' + norm_gain31: 'False' + norm_gain4: 'False' + norm_gain5: 'False' + norm_gain6: 'False' + norm_gain7: 'False' + norm_gain8: 'False' + norm_gain9: 'False' + num_mboards: '1' + otw: '' + samp_rate: samp_rate + sd_spec0: '' + sd_spec1: '' + sd_spec2: '' + sd_spec3: '' + sd_spec4: '' + sd_spec5: '' + sd_spec6: '' + sd_spec7: '' + show_lo_controls: 'False' + stream_args: '' + stream_chans: '[]' + sync: sync + time_source0: '' + time_source1: '' + time_source2: '' + time_source3: '' + time_source4: '' + time_source5: '' + time_source6: '' + time_source7: '' + type: fc32 + states: + bus_sink: false + bus_source: false + bus_structure: null + coordinate: [1528, 332] + rotation: 0 + state: disabled + +connections: +- [AISTX_Build_Frame_0, '0', digital_gmsk_mod_0, '0'] +- [analog_sig_source_x_0, '0', blocks_multiply_xx_0, '0'] +- [analog_sig_source_x_1, '0', blocks_multiply_xx_1, '1'] +- [blocks_add_xx_0, '0', blocks_selector_0, '1'] +- [blocks_message_strobe_0, strobe, AISTX_Build_Frame_0, sentence] +- [blocks_message_strobe_0, strobe, blocks_message_debug_0, print] +- [blocks_multiply_const_vxx_0, '0', blocks_add_xx_0, '0'] +- [blocks_multiply_const_vxx_1, '0', blocks_selector_0, '0'] +- [blocks_multiply_const_vxx_2, '0', blocks_add_xx_0, '1'] +- [blocks_multiply_const_vxx_3, '0', blocks_selector_0, '2'] +- [blocks_multiply_xx_0, '0', blocks_multiply_const_vxx_0, '0'] +- [blocks_multiply_xx_0, '0', blocks_multiply_const_vxx_1, '0'] +- [blocks_multiply_xx_1, '0', blocks_multiply_const_vxx_2, '0'] +- [blocks_multiply_xx_1, '0', blocks_multiply_const_vxx_3, '0'] +- [blocks_selector_0, '0', osmosdr_sink_0, '0'] +- [blocks_selector_0, '0', uhd_usrp_sink_0, '0'] +- [blocks_socket_pdu_0, pdus, AISTX_Build_Frame_0, sentence] +- [blocks_socket_pdu_0, pdus, blocks_message_debug_0, print] +- [digital_gmsk_mod_0, '0', blocks_multiply_xx_0, '1'] +- [digital_gmsk_mod_0, '0', blocks_multiply_xx_1, '0'] + +metadata: + file_format: 1 diff --git a/grc/AISTX_Build_Frame.block.yml b/grc/AISTX_Build_Frame.block.yml index d2ba012..2983e27 100644 --- a/grc/AISTX_Build_Frame.block.yml +++ b/grc/AISTX_Build_Frame.block.yml @@ -5,10 +5,6 @@ label: AIS Frame Builder category: AISTX parameters: -- id: sentence - label: Sentence - dtype: string - default: '010010000011101011110111001110011000100000000000000000100000001011001000001011000101000110100010010100001101011001111011000011111111111011100101110011100000000000000110' - id: repeat label: Repeat dtype: enum @@ -21,6 +17,15 @@ parameters: default: 'True' options: ['True', 'False'] option_labels: ['Yes', 'No'] +- id: tag + label: Length tag name + dtype: string + default: packet_len + +inputs: +- domain: message + id: sentence + optional: true outputs: - domain: stream @@ -28,6 +33,6 @@ outputs: templates: imports: import AISTX - make: AISTX.Build_Frame(${sentence}, ${repeat}, ${enable_NRZI}) + make: AISTX.Build_Frame(${repeat}, ${enable_NRZI}, ${tag}) file_format: 1 diff --git a/include/AISTX/Build_Frame.h b/include/AISTX/Build_Frame.h index 003a562..d3672f9 100644 --- a/include/AISTX/Build_Frame.h +++ b/include/AISTX/Build_Frame.h @@ -23,7 +23,7 @@ #define INCLUDED_AISTX_BUILD_FRAME_H #include -#include +#include namespace gr { namespace AISTX { @@ -33,7 +33,7 @@ namespace gr { * \ingroup AISTX * */ - class AISTX_API Build_Frame : virtual public gr::sync_block + class AISTX_API Build_Frame : virtual public gr::tagged_stream_block { public: typedef boost::shared_ptr sptr; @@ -50,7 +50,7 @@ namespace gr { * 6. NRZI conversion (enabled by default) * */ - static sptr make(const char *sentence, bool repeat, bool enable_NRZI); + static sptr make(bool repeat, bool enable_NRZI, const std::string& lengthtagname = "packet_len"); }; } // namespace AISTX diff --git a/lib/Build_Frame_impl.cc b/lib/Build_Frame_impl.cc index 07e59e5..507c68b 100644 --- a/lib/Build_Frame_impl.cc +++ b/lib/Build_Frame_impl.cc @@ -22,12 +22,15 @@ #include "config.h" #endif +#include +#include #include #include "Build_Frame_impl.h" #include #include #include +#include #define LEN_PREAMBLE 24 #define LEN_START 8 @@ -43,63 +46,27 @@ namespace gr { namespace AISTX { Build_Frame::sptr - Build_Frame::make(const char *sentence, bool repeat, bool enable_NRZI) + Build_Frame::make(bool repeat, bool enable_NRZI, const std::string& tsb_tag_key) { return gnuradio::get_initial_sptr - (new Build_Frame_impl(sentence, repeat, enable_NRZI)); + (new Build_Frame_impl(repeat, enable_NRZI, tsb_tag_key)); } /* * The private constructor */ - Build_Frame_impl::Build_Frame_impl(const char *sentence, bool repeat, bool enable_NRZI) - : gr::sync_block("Build_Frame", + Build_Frame_impl::Build_Frame_impl(bool repeat, bool enable_NRZI, const std::string& tsb_tag_key) + : gr::tagged_stream_block("Build_Frame", gr::io_signature::make(0, 0, 0), - gr::io_signature::make(1, 1, sizeof(unsigned char))), + gr::io_signature::make(1, 1, sizeof(unsigned char)), + tsb_tag_key), d_repeat(repeat), d_repeat_cnt(0), - d_enable_NRZI(enable_NRZI) + d_enable_NRZI(enable_NRZI), + d_itemsize(sizeof(unsigned char)), + d_curr_len(0) { - unsigned short REMAINDER_TO_EIGHT, PADDING_TO_EIGHT; // to pad the payload to a multiple of 8 - - LEN_PAYLOAD = strlen(sentence); - if (LEN_PAYLOAD>168) - printf ("Frame padding disabled. Multiple packets.\n"); - - // IMPORTANT - REMAINDER_TO_EIGHT = LEN_PAYLOAD%8; - if (REMAINDER_TO_EIGHT==0) { - payload = (char *) malloc(LEN_PAYLOAD + LEN_CRC); - // nb. It comes in in ASCII - for (int i=0; i0){ - - PADDING_TO_EIGHT = 8-REMAINDER_TO_EIGHT; - payload = (char *) malloc(LEN_PAYLOAD + PADDING_TO_EIGHT + LEN_CRC); - - for (int i=0; i(sym_str.c_str())); + d_curr_len = sym_str.length(); + } + else { + throw std::runtime_error("received a message type that hasn't been implemented"); + } + } + + return d_curr_len; + } + + int Build_Frame_impl::work(int noutput_items, + gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items) { + // some direct copies in here from `pdu to tagged stream block` too // sleep at the start, if we stop too quickly after the send, the send doesn't seem to happen usleep(100000); @@ -355,7 +351,75 @@ namespace gr { return WORK_DONE; } - unsigned char *out = (unsigned char *) output_items[0]; + char* out = (char*) output_items[0]; + + if (d_curr_len == 0) { + return 0; + } + + // work() should only be called if the current PDU fits entirely + // into the output buffer. + assert(noutput_items >= 0 && (unsigned int)noutput_items >= d_curr_len); + + // Copy vector output + size_t nout = d_curr_len; + size_t io(0); + const uint8_t* ptr = (const uint8_t*)uniform_vector_elements(d_curr_vect, io); + memcpy(out, ptr, d_curr_len * d_itemsize); + + // at this point we have the `sentence` stored in `out` and length in `nout`. + //printf("len: %ld; val: %s\n", nout, out); + // printf("buf len: %ld; in lenL %ld\n", noutput_items, ninput_items); + // TODO get a better understanding of noutput_items, set at 32768, but not entirely sure where/how + // had been under the impression this would be based on the calc length function but + // it does not seem related. going off the 32k, our output should always fit.. + + //char* d_sentence; + const char* sentence = out; + char* payload; // [the 01 rapresentation of the sentence as taken from input] + unsigned short LEN_SENTENCE; + unsigned short LEN_PAYLOAD; + + unsigned short REMAINDER_TO_EIGHT, PADDING_TO_EIGHT; // to pad the payload to a multiple of 8 + + LEN_PAYLOAD = strlen(sentence); + if (LEN_PAYLOAD>168) + printf ("Frame padding disabled. Multiple packets.\n"); + + // IMPORTANT + REMAINDER_TO_EIGHT = LEN_PAYLOAD%8; + if (REMAINDER_TO_EIGHT==0) { + payload = (char *) malloc(LEN_PAYLOAD + LEN_CRC); + // nb. It comes in in ASCII + for (int i=0; i0){ + + PADDING_TO_EIGHT = 8-REMAINDER_TO_EIGHT; + payload = (char *) malloc(LEN_PAYLOAD + PADDING_TO_EIGHT + LEN_CRC); + + for (int i=0; iHP00 P ;8 ;56 RD =Is3 w sU kP06 CRC // 010010000011101011110111001110011000100000000000000000 100000 001011001000 001011000101000110 100010010100 001101011001111011000011 111111 111011100101 110011100000000000000110 0011000010001111 @@ -463,6 +527,11 @@ namespace gr { } d_repeat_cnt++; + // Reset state + d_curr_len = 0; + + //return nout; + // Tell runtime system how many output items we produced. return noutput_items; diff --git a/lib/Build_Frame_impl.h b/lib/Build_Frame_impl.h index 5206ed5..6cdc12a 100644 --- a/lib/Build_Frame_impl.h +++ b/lib/Build_Frame_impl.h @@ -34,13 +34,13 @@ namespace gr { bool d_repeat; unsigned long d_repeat_cnt; bool d_enable_NRZI; - //char * d_sentence; - char *payload; // [the 01 rapresentation of the sentence as taken from input] - unsigned short LEN_SENTENCE; - unsigned short LEN_PAYLOAD; + size_t d_itemsize; + pmt::pmt_t d_curr_meta; + pmt::pmt_t d_curr_vect; + size_t d_curr_len; public: - Build_Frame_impl(const char *sentence, bool repeat, bool enable_NRZI); + Build_Frame_impl(bool repeat, bool enable_NRZI, const std::string& lengthtagname = "packet_len"); ~Build_Frame_impl(); void dump_buffer(const char *b, int buffer_size); @@ -53,10 +53,13 @@ namespace gr { void compute_crc(char *buffer, char *ret, unsigned int len); void byte_packing(char *input_frame, unsigned char *out_byte, unsigned int len); + int calculate_output_stream_length(const gr_vector_int& ninput_items); + // Where all the action really happens int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items); }; } // namespace AISTX From 78a616fb8e06576043f21a94ec74541c9d1cf70b Mon Sep 17 00:00:00 2001 From: bmagistro Date: Mon, 8 Feb 2021 13:34:01 -0500 Subject: [PATCH 09/12] add formatting files from gnuradio project --- .clang-format | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ .clang-tidy | 10 +++++ .gitattributes | 17 ++++++++ 3 files changed, 131 insertions(+) create mode 100644 .clang-format create mode 100644 .clang-tidy create mode 100644 .gitattributes diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..3e4ddd4 --- /dev/null +++ b/.clang-format @@ -0,0 +1,104 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: true +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: false +BinPackParameters: false +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: true + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 90 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeCategories: + - Regex: '^"(gnuradio)/' + Priority: 1 + - Regex: '^<(gnuradio)/' + Priority: 2 + - Regex: '^<(boost)/' + Priority: 98 + - Regex: '^<[a-z]*>$' + Priority: 99 + - Regex: '^".*"$' + Priority: 0 + - Regex: '.*' + Priority: 10 + +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 8 +UseTab: Never diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..6e66eb2 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,10 @@ +--- +Checks: '-*,misc-throw-by-value-catch-by-reference,misc-static-assert,readability-container-size-empty,modernize-use-override,modernize-make-unique,modernize-deprecated-headers,misc-unused-using-decls,misc-redundant-expression' +# Not in here: modernize-use-emplace, since that basically broke all things it touched +WarningsAsErrors: '' +HeaderFilterRegex: '\.(cc|c|cpp|h|hpp)$' +AnalyzeTemporaryDtors: false +FormatStyle: file +CheckOptions: +... + diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..afdc846 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# +# The following turn off LF->CRLF conversion for some files on Windows. +# these conversions cause syntax errors on MinGW/MSYS. They should not +# have any effect on non-Windows systems or on Cygwin. Any files that +# required svn:eof-style=lf under subversion should be included here. +# +*.m4 -crlf +*.ac -crlf +*.scm -crlf +# +# In GNURadio 3.9, pybind11 compares hash values of headers and source +# files against knowns values. Conversion of values to CRLF on checkout +# break those checks so keep LF values when files are subject to said checks +# +*.h text eol=lf +*.c text eol=lf +*.cc text eol=lf From b4ba8805404b588a2c4df701a6e9a673f1eaab0a Mon Sep 17 00:00:00 2001 From: bmagistro Date: Mon, 8 Feb 2021 13:34:58 -0500 Subject: [PATCH 10/12] apply clang-format to '*\.[ch](c|pp)?$' files --- apps/unpacker.c | 93 ++-- include/AISTX/Build_Frame.h | 60 +-- include/AISTX/DebugME.h | 46 +- include/AISTX/api.h | 4 +- include/AISTX/nrz_to_nrzi.h | 46 +- lib/Build_Frame_impl.cc | 975 ++++++++++++++++++------------------ lib/Build_Frame_impl.h | 71 +-- lib/DebugME_impl.cc | 122 +++-- lib/DebugME_impl.h | 41 +- lib/nrz_to_nrzi_impl.cc | 141 +++--- lib/nrz_to_nrzi_impl.h | 41 +- lib/qa_AISTX.cc | 7 +- lib/qa_AISTX.h | 6 +- lib/test_AISTX.cc | 19 +- 14 files changed, 838 insertions(+), 834 deletions(-) diff --git a/apps/unpacker.c b/apps/unpacker.c index 9d0e14b..ae2a102 100644 --- a/apps/unpacker.c +++ b/apps/unpacker.c @@ -1,8 +1,9 @@ /* This source code is part of the AIS BlackToolkit. -Unpacker.c allows you to build a NMEA sentece out of its payload. Normally used in combination with AIVDM_Encoder. - +Unpacker.c allows you to build a NMEA sentece out of its payload. Normally used in +combination with AIVDM_Encoder. + Copyright 2013-2014 -- Embyte & Pastus This program is free software; you can redistribute it and/or @@ -10,25 +11,25 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -Usage example: +Usage example: $ ./AIVDM_Encoder.py --type=1 --vsize=30x10 | xargs -IA ./unpacker A 1 A */ -#include #include #include -#include -#include #include +#include +#include +#include -unsigned long unpack(char *buffer, int start, int length) +unsigned long unpack(char* buffer, int start, int length) { unsigned long ret = 0; - for(int i = start; i < (start+length); i++) { - ret <<= 1; - ret |= (buffer[i] & 0x01); + for (int i = start; i < (start + length); i++) { + ret <<= 1; + ret |= (buffer[i] & 0x01); } return ret; } @@ -37,50 +38,56 @@ char nmea_checksum(std::string buffer) { unsigned int i = 0; char sum = 0x00; - if(buffer[0] == '!') i++; - for(; i < buffer.length(); i++) sum ^= buffer[i]; + if (buffer[0] == '!') + i++; + for (; i < buffer.length(); i++) + sum ^= buffer[i]; return sum; } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) +{ + + + if (argc < 4) { + std::cout << "\nUsage: ./unpacker binary_string enable_nmea channel\n"; + std::cout << "\nenable_nmea = 1 for full NMEA sentence, otherwise only payload " + "is printed\n"; + std::cout << "channel = A/B\n\n"; + return 0; + } + + int i; + char asciidata[255]; + int len = strlen(argv[1]); - if (argc<4) { - std::cout << "\nUsage: ./unpacker binary_string enable_nmea channel\n"; - std::cout << "\nenable_nmea = 1 for full NMEA sentence, otherwise only payload is printed\n"; - std::cout << "channel = A/B\n\n"; - return 0; - } + int enable_nmea = (int)*argv[2] - 48; + char channel = *argv[3]; + std::ostringstream d_payload; + d_payload.str(""); - int i; - char asciidata[255]; + for (i = 0; i < len / 6; i++) { + asciidata[i] = unpack(argv[1], i * 6, 6); + if (asciidata[i] > 39) + asciidata[i] += 8; + asciidata[i] += 48; + } - int len = strlen(argv[1]); - - int enable_nmea = (int) *argv[2] - 48; - char channel = *argv[3]; - std::ostringstream d_payload; - d_payload.str(""); - - for(i = 0; i < len/6; i++) { - asciidata[i] = unpack(argv[1], i*6, 6); - if(asciidata[i] > 39) asciidata[i] += 8; - asciidata[i] += 48; - } + if (enable_nmea) + d_payload << "!AIVDM,1,1,," << channel << ","; - if (enable_nmea) - d_payload << "!AIVDM,1,1,," << channel << ","; + for (int i = 0; i < len / 6; i++) + d_payload << asciidata[i]; - for(int i = 0; i < len/6; i++) - d_payload << asciidata[i]; - if (enable_nmea) { - d_payload << ",0"; //number of bits to fill out 6-bit boundary - char checksum = nmea_checksum(std::string(d_payload.str())); - d_payload << "*" << std::setw(2) << std::setfill('0') << std::hex << std::uppercase << int(checksum); + d_payload << ",0"; // number of bits to fill out 6-bit boundary + char checksum = nmea_checksum(std::string(d_payload.str())); + d_payload << "*" << std::setw(2) << std::setfill('0') << std::hex + << std::uppercase << int(checksum); } - std::cout << std::string(d_payload.str()) << std::endl; - return 1; + std::cout << std::string(d_payload.str()) << std::endl; + return 1; } diff --git a/include/AISTX/Build_Frame.h b/include/AISTX/Build_Frame.h index d3672f9..95538ca 100644 --- a/include/AISTX/Build_Frame.h +++ b/include/AISTX/Build_Frame.h @@ -1,17 +1,17 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2013 <+YOU OR YOUR COMPANY+>. - * + * * This 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. - * + * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -22,39 +22,39 @@ #ifndef INCLUDED_AISTX_BUILD_FRAME_H #define INCLUDED_AISTX_BUILD_FRAME_H -#include #include +#include namespace gr { - namespace AISTX { +namespace AISTX { + +/*! + * \brief Builds AIS Frame + * \ingroup AISTX + * + */ +class AISTX_API Build_Frame : virtual public gr::tagged_stream_block +{ +public: + typedef boost::shared_ptr sptr; /*! - * \brief Builds AIS Frame - * \ingroup AISTX + * \brief Builds an AIS Frame of 256 bytes. + * + * This module does, in order: + * 1. Payload (NMEA sentence) encoding (6 bits per ASCII) + * 2. CRC generation [16] + * 3. Reverse bit order (payload + crc) + * 4. Stuffing (payload + crc) + * 5. Headers (Preamble [24], Start [8], Trailer [8], 0x00 Padding) + * 6. NRZI conversion (enabled by default) * */ - class AISTX_API Build_Frame : virtual public gr::tagged_stream_block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Builds an AIS Frame of 256 bytes. - * - * This module does, in order: - * 1. Payload (NMEA sentence) encoding (6 bits per ASCII) - * 2. CRC generation [16] - * 3. Reverse bit order (payload + crc) - * 4. Stuffing (payload + crc) - * 5. Headers (Preamble [24], Start [8], Trailer [8], 0x00 Padding) - * 6. NRZI conversion (enabled by default) - * - */ - static sptr make(bool repeat, bool enable_NRZI, const std::string& lengthtagname = "packet_len"); - }; - - } // namespace AISTX + static sptr + make(bool repeat, bool enable_NRZI, const std::string& lengthtagname = "packet_len"); +}; + +} // namespace AISTX } // namespace gr #endif /* INCLUDED_AISTX_BUILD_FRAME_H */ - diff --git a/include/AISTX/DebugME.h b/include/AISTX/DebugME.h index 310c57d..0abc7bf 100644 --- a/include/AISTX/DebugME.h +++ b/include/AISTX/DebugME.h @@ -1,17 +1,17 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2013 <+YOU OR YOUR COMPANY+>. - * + * * This 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. - * + * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -22,34 +22,32 @@ #ifndef INCLUDED_AISTX_DEBUGME_H #define INCLUDED_AISTX_DEBUGME_H -#include #include - +#include namespace gr { - namespace AISTX { +namespace AISTX { + +/*! + * \brief Print the incoming BYTE sequence + * \ingroup AISTX + * + */ +class AISTX_API DebugME : virtual public gr::block +{ +public: + typedef boost::shared_ptr sptr; /*! - * \brief Print the incoming BYTE sequence - * \ingroup AISTX + * \brief Print the incoming BYTE sequence as sequence of HEXs * + * Goes through the incoming sequence (const char *in) and prints it in HEXs */ - class AISTX_API DebugME : virtual public gr::block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Print the incoming BYTE sequence as sequence of HEXs - * - * Goes through the incoming sequence (const char *in) and prints it in HEXs - */ - static sptr make(size_t itemsize); - }; - - } // namespace AISTX + static sptr make(size_t itemsize); +}; + +} // namespace AISTX } // namespace gr #endif /* INCLUDED_AISTX_DEBUGME_H */ - diff --git a/include/AISTX/api.h b/include/AISTX/api.h index 40308fd..0b4f8b1 100644 --- a/include/AISTX/api.h +++ b/include/AISTX/api.h @@ -25,9 +25,9 @@ #include #ifdef gnuradio_AISTX_EXPORTS -# define AISTX_API __GR_ATTR_EXPORT +#define AISTX_API __GR_ATTR_EXPORT #else -# define AISTX_API __GR_ATTR_IMPORT +#define AISTX_API __GR_ATTR_IMPORT #endif #endif /* INCLUDED_AISTX_API_H */ diff --git a/include/AISTX/nrz_to_nrzi.h b/include/AISTX/nrz_to_nrzi.h index 571fc26..437d396 100644 --- a/include/AISTX/nrz_to_nrzi.h +++ b/include/AISTX/nrz_to_nrzi.h @@ -1,17 +1,17 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2013 <+YOU OR YOUR COMPANY+>. - * + * * This 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. - * + * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -22,33 +22,33 @@ #ifndef INCLUDED_AISTX_NRZ_TO_NRZI_H #define INCLUDED_AISTX_NRZ_TO_NRZI_H -#include #include +#include namespace gr { - namespace AISTX { +namespace AISTX { + +/*! + * \brief Convert from NRZ to NRZI + * \ingroup AISTX + * + */ +class AISTX_API nrz_to_nrzi : virtual public gr::block +{ +public: + typedef boost::shared_ptr sptr; /*! * \brief Convert from NRZ to NRZI - * \ingroup AISTX + * + * Convert a BYTE sequence from NRZ to NRZI. Note: This is also implemented in the + * Build_Frame component. * */ - class AISTX_API nrz_to_nrzi : virtual public gr::block - { - public: - typedef boost::shared_ptr sptr; - - /*! - * \brief Convert from NRZ to NRZI - * - * Convert a BYTE sequence from NRZ to NRZI. Note: This is also implemented in the Build_Frame component. - * - */ - static sptr make(); - }; - - } // namespace AISTX + static sptr make(); +}; + +} // namespace AISTX } // namespace gr #endif /* INCLUDED_AISTX_NRZ_TO_NRZI_H */ - diff --git a/lib/Build_Frame_impl.cc b/lib/Build_Frame_impl.cc index 507c68b..ad3f29f 100644 --- a/lib/Build_Frame_impl.cc +++ b/lib/Build_Frame_impl.cc @@ -1,17 +1,17 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2013 <+YOU OR YOUR COMPANY+>. - * + * * This 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. - * + * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -22,13 +22,13 @@ #include "config.h" #endif -#include +#include "Build_Frame_impl.h" #include #include -#include "Build_Frame_impl.h" +#include -#include -#include +#include +#include #include #include @@ -37,506 +37,525 @@ #define LEN_CRC 16 #define LEN_FRAME_MAX 256 -#define PREAMBLE_MARK 101010101010101010101010 (24 bits) -#define START_MARK 01111110 (8 bits) +#define PREAMBLE_MARK 101010101010101010101010(24 bits) +#define START_MARK 01111110(8 bits) #define DEBUG 0 namespace gr { - namespace AISTX { +namespace AISTX { + +Build_Frame::sptr +Build_Frame::make(bool repeat, bool enable_NRZI, const std::string& tsb_tag_key) +{ + return gnuradio::get_initial_sptr( + new Build_Frame_impl(repeat, enable_NRZI, tsb_tag_key)); +} + +/* + * The private constructor + */ +Build_Frame_impl::Build_Frame_impl(bool repeat, + bool enable_NRZI, + const std::string& tsb_tag_key) + : gr::tagged_stream_block("Build_Frame", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(1, 1, sizeof(unsigned char)), + tsb_tag_key), + d_repeat(repeat), + d_repeat_cnt(0), + d_enable_NRZI(enable_NRZI), + d_itemsize(sizeof(unsigned char)), + d_curr_len(0) +{ + message_port_register_in(pmt::mp("sentence")); +} + +/* + * Our virtual destructor. + */ +Build_Frame_impl::~Build_Frame_impl() {} + + +void Build_Frame_impl::dump_buffer(const char* b, int buffer_size) +{ + int k = 0; + for (; k < buffer_size; k++) + printf("%d", b[k]); + printf("\n"); +} + +// buffer must have length >= sizeof(int) + 1 +// Write to the buffer backwards so that the binary representation +// is in the correct order i.e. the LSB is on the far right +// instead of the far left of the printed string +char* Build_Frame_impl::int2bin(int a, char* buffer, int buf_size) +{ + buffer += (buf_size - 1); + + for (int i = 31; i >= 0; i--) { + *buffer-- = (a & 1) + '0'; + + a >>= 1; + } - Build_Frame::sptr - Build_Frame::make(bool repeat, bool enable_NRZI, const std::string& tsb_tag_key) - { - return gnuradio::get_initial_sptr - (new Build_Frame_impl(repeat, enable_NRZI, tsb_tag_key)); + return buffer; +} + +// stuffing function +int Build_Frame_impl::stuff(const char* in, char* out, int l_in) +{ + int i = 0, j = 0, consecutives = 0, l_out = 0; + + while (i < l_in) { + + if (in[i] & 0x01) + consecutives++; + else + consecutives = 0; + + out[j++] = in[i++]; + l_out++; + + if (consecutives == 5) { + out[j++] = 0x0; + l_out++; + consecutives = 0; + } } + return l_out; +} + +void Build_Frame_impl::pack(int orig_ascii, char* ret, int bits_per_byte) +{ + // go down to fit in 6 bits + int ascii = orig_ascii - 48; + if (ascii > 39) + ascii -= 8; + + /* if (DEBUG)*/ + /* printf ("\nAscii: orig=%d scaled=%d\n", orig_ascii, ascii);*/ + + char binary[6]; + int y = 0; + + if (ascii == 0) + memset(binary, 0x0, 6); + else + while (ascii != 1) { + if (ascii % 2 == 0) + binary[y] = 0x0; + else if (ascii % 2 == 1) + binary[y] = 0x1; + ascii /= 2; + y++; + } - /* - * The private constructor - */ - Build_Frame_impl::Build_Frame_impl(bool repeat, bool enable_NRZI, const std::string& tsb_tag_key) - : gr::tagged_stream_block("Build_Frame", - gr::io_signature::make(0, 0, 0), - gr::io_signature::make(1, 1, sizeof(unsigned char)), - tsb_tag_key), - d_repeat(repeat), - d_repeat_cnt(0), - d_enable_NRZI(enable_NRZI), - d_itemsize(sizeof(unsigned char)), - d_curr_len(0) - { - message_port_register_in(pmt::mp("sentence")); + if (ascii == 1) { + binary[y] = 0x1; + y++; } - /* - * Our virtual destructor. - */ - Build_Frame_impl::~Build_Frame_impl() - { + if (y < 6) { // fill in space + for (; y < 6; y++) + binary[y] = 0x0; } + for (y = 0; y < 6; y++) // reverse*/ + ret[y] = binary[5 - y]; + ret[y] = '\0'; + + /* if (DEBUG)*/ + /* printf("Binary = %s, Ret = %s\n", binary, ret );*/ +} + +void Build_Frame_impl::nrz_to_nrzi(char* data, int length) +{ + unsigned short d_prev_nrzi_bit = 0; + unsigned short nrz_bit, nrzi_bit; + + for (int i = 0; i < length; i++) { + nrz_bit = data[i]; - void Build_Frame_impl::dump_buffer(const char *b, int buffer_size) - { - int k = 0; - for(; k < buffer_size; k++) - printf("%d", b[k]); - printf("\n"); - } - - // buffer must have length >= sizeof(int) + 1 - // Write to the buffer backwards so that the binary representation - // is in the correct order i.e. the LSB is on the far right - // instead of the far left of the printed string - char * Build_Frame_impl::int2bin(int a, char *buffer, int buf_size) { - buffer += (buf_size - 1); - - for (int i = 31; i >= 0; i--) { - *buffer-- = (a & 1) + '0'; - - a >>= 1; - } - - return buffer; - } - - // stuffing function - int Build_Frame_impl::stuff (const char *in, char *out, int l_in) - { - int i=0, j=0, consecutives=0, l_out=0; - - while(i 39) - ascii -= 8; - - /* if (DEBUG)*/ - /* printf ("\nAscii: orig=%d scaled=%d\n", orig_ascii, ascii);*/ - - char binary[6]; - int y = 0; - - if (ascii==0) - memset (binary, 0x0, 6); - else - while (ascii!=1) { - if (ascii % 2 == 0) - binary[y] = 0x0; - else if (ascii % 2 == 1) - binary[y] = 0x1; - ascii /= 2; - y++; - } - - if (ascii==1) { - binary[y] = 0x1; - y++; - } - - if(y < 6) { // fill in space - for(; y < 6; y++) - binary[y] = 0x0; - } - - for(y = 0; y < 6; y++) // reverse*/ - ret[y] = binary[5 - y]; - ret[y]='\0'; - - /* if (DEBUG)*/ - /* printf("Binary = %s, Ret = %s\n", binary, ret );*/ - - } - - void Build_Frame_impl::nrz_to_nrzi(char *data, int length) - { - unsigned short d_prev_nrzi_bit = 0; - unsigned short nrz_bit, nrzi_bit; - - for (int i = 0; i < length; i++) - { - nrz_bit = data[i]; - - if(nrz_bit == 0) - { - nrzi_bit = d_prev_nrzi_bit ^ 1; - } - else - { - nrzi_bit = d_prev_nrzi_bit; - } - - data[i] = nrzi_bit; - d_prev_nrzi_bit = nrzi_bit; + if (nrz_bit == 0) { + nrzi_bit = d_prev_nrzi_bit ^ 1; + } else { + nrzi_bit = d_prev_nrzi_bit; } - } - - void Build_Frame_impl::reverse_bit_order(char *data, int length) - { - int tmp = 0; - for(int i = 0; i < length/8; i++) { - for(int j = 0; j < 4; j++) { - tmp = data[i*8 + j]; - data[i*8 + j] = data[i*8 + 7-j]; - data[i*8 + 7-j] = tmp; - } - } - } - - unsigned long Build_Frame_impl::unpack(char *buffer, int start, int length) - { - unsigned long ret = 0; - for(int i = start; i < (start+length); i++) { - ret <<= 1; - ret |= (buffer[i] & 0x01); - } - return ret; - } - - void Build_Frame_impl::compute_crc(char *buffer, char *ret, unsigned int len) // Calculates CRC-checksum from unpacked data - { - static const unsigned short crc_itu16_table[] = - { - 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, - 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7, - 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E, - 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876, - 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD, - 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5, - 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C, - 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974, - 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB, - 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3, - 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A, - 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72, - 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9, - 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1, - 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738, - 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70, - 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7, - 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF, - 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036, - 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E, - 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5, - 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD, - 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134, - 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C, - 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3, - 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB, - 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232, - 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A, - 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1, - 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9, - 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330, - 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78 - }; - - int crc=0xffff; - int i = 0; - char temp[8]; - int datalen = len/8; - -// // go to char (this can be optimized) -// printf ("INPUT:"); -// for(int j=0;j> 8) ^ crc_itu16_table[(crc ^ data[i]) & 0xFF]; - - crc=(crc & 0xFFFF)^0xFFFF; -// printf("%X\n", crc); - - int2bin(crc, ret, 16); -// printf ("CRC ASCII1 = %s\n", ret); - //dump_buffer(ret, 16); - - reverse_bit_order (ret, 16); //revert crc bit in byte - - int2bin(crc, ret, 16); - strncpy(temp,ret+8,8); //swap the two crc byte - strncpy(ret+8,ret,8); - strncpy(ret,temp,8); - - // back to binary - for(int j=0;j<16;j++) - ret[j]=ret[j]-0x30; - -// if (DEBUG) { -// printf("CRC 2=\n"); -// dump_buffer(ret,16); -// } + + data[i] = nrzi_bit; + d_prev_nrzi_bit = nrzi_bit; + } } - void Build_Frame_impl::byte_packing(char *input_frame, unsigned char *out_byte, unsigned int len) { - for (int i = 0; i < len/8; i++) { - char tmp[8]; - memcpy(tmp, &input_frame[i*8], 8); - out_byte[i] = tmp[0]*128+tmp[1]*64+tmp[2]*32+tmp[3]*16+tmp[4]*8+tmp[5]*4+tmp[6]*2+tmp[7]; - - //out_byte[i] = input_frame[i*8]*128+input_frame[i*8+1]*64+input_frame[i*8+2]*32+input_frame[i*8+3]*16+input_frame[i*8+4]*8+input_frame[i*8+5]*4+input_frame[i*8+6]*2+input_frame[i*8+7]; -// printf ("%X", out_byte[i]); - } -// printf("\n"); - } - - int Build_Frame_impl::calculate_output_stream_length(const gr_vector_int& ninput_items) { - // straight copy from `pdu to tagged stream block` - if (d_curr_len == 0) { +void Build_Frame_impl::reverse_bit_order(char* data, int length) +{ + int tmp = 0; + for (int i = 0; i < length / 8; i++) { + for (int j = 0; j < 4; j++) { + tmp = data[i * 8 + j]; + data[i * 8 + j] = data[i * 8 + 7 - j]; + data[i * 8 + 7 - j] = tmp; + } + } +} + +unsigned long Build_Frame_impl::unpack(char* buffer, int start, int length) +{ + unsigned long ret = 0; + for (int i = start; i < (start + length); i++) { + ret <<= 1; + ret |= (buffer[i] & 0x01); + } + return ret; +} + +void Build_Frame_impl::compute_crc( + char* buffer, + char* ret, + unsigned int len) // Calculates CRC-checksum from unpacked data +{ + // clang-format off + static const unsigned short crc_itu16_table[] = { + 0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF, + 0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7, + 0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E, + 0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876, + 0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD, + 0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5, + 0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C, + 0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974, + 0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB, + 0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3, + 0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A, + 0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72, + 0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9, + 0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1, + 0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738, + 0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70, + 0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7, + 0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF, + 0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036, + 0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E, + 0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5, + 0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD, + 0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134, + 0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C, + 0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3, + 0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB, + 0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232, + 0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A, + 0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1, + 0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9, + 0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330, + 0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78 + }; + // clang-format on + + int crc = 0xffff; + int i = 0; + char temp[8]; + int datalen = len / 8; + + // // go to char (this can be optimized) + // printf ("INPUT:"); + // for(int j=0;j> 8) ^ crc_itu16_table[(crc ^ data[i]) & 0xFF]; + + crc = (crc & 0xFFFF) ^ 0xFFFF; + // printf("%X\n", crc); + + int2bin(crc, ret, 16); + // printf ("CRC ASCII1 = %s\n", ret); + // dump_buffer(ret, 16); + + reverse_bit_order(ret, 16); // revert crc bit in byte + + int2bin(crc, ret, 16); + strncpy(temp, ret + 8, 8); // swap the two crc byte + strncpy(ret + 8, ret, 8); + strncpy(ret, temp, 8); + + // back to binary + for (int j = 0; j < 16; j++) + ret[j] = ret[j] - 0x30; + + // if (DEBUG) { + // printf("CRC 2=\n"); + // dump_buffer(ret,16); + // } +} + +void Build_Frame_impl::byte_packing(char* input_frame, + unsigned char* out_byte, + unsigned int len) +{ + for (int i = 0; i < len / 8; i++) { + char tmp[8]; + memcpy(tmp, &input_frame[i * 8], 8); + out_byte[i] = tmp[0] * 128 + tmp[1] * 64 + tmp[2] * 32 + tmp[3] * 16 + + tmp[4] * 8 + tmp[5] * 4 + tmp[6] * 2 + tmp[7]; + + // out_byte[i] = + // input_frame[i*8]*128+input_frame[i*8+1]*64+input_frame[i*8+2]*32+input_frame[i*8+3]*16+input_frame[i*8+4]*8+input_frame[i*8+5]*4+input_frame[i*8+6]*2+input_frame[i*8+7]; + // printf ("%X", out_byte[i]); + } + // printf("\n"); +} + +int Build_Frame_impl::calculate_output_stream_length(const gr_vector_int& ninput_items) +{ + // straight copy from `pdu to tagged stream block` + if (d_curr_len == 0) { pmt::pmt_t msg(delete_head_nowait(pmt::mp("sentence"))); if (msg.get() == NULL) { - return 0; + return 0; } if (pmt::is_pair(msg)) { - d_curr_meta = pmt::car(msg); - d_curr_vect = pmt::cdr(msg); - // do not assume the length of PMT is in items (e.g.: from socket_pdu) - d_curr_len = pmt::blob_length(d_curr_vect) / d_itemsize; + d_curr_meta = pmt::car(msg); + d_curr_vect = pmt::cdr(msg); + // do not assume the length of PMT is in items (e.g.: from socket_pdu) + d_curr_len = pmt::blob_length(d_curr_vect) / d_itemsize; + } else if (pmt::is_symbol(msg)) { + // transform a symbol to a uniform vector + const std::string sym_str = symbol_to_string(msg); + d_curr_vect = pmt::init_u8vector( + sym_str.length(), reinterpret_cast(sym_str.c_str())); + d_curr_len = sym_str.length(); + } else { + throw std::runtime_error( + "received a message type that hasn't been implemented"); } - else if (pmt::is_symbol(msg)) { - // transform a symbol to a uniform vector - const std::string sym_str = symbol_to_string(msg); - d_curr_vect = pmt::init_u8vector(sym_str.length(), reinterpret_cast(sym_str.c_str())); - d_curr_len = sym_str.length(); - } - else { - throw std::runtime_error("received a message type that hasn't been implemented"); - } - } + } + + return d_curr_len; +} - return d_curr_len; +int Build_Frame_impl::work(int noutput_items, + gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items) +{ + // some direct copies in here from `pdu to tagged stream block` too + // sleep at the start, if we stop too quickly after the send, the send doesn't seem to + // happen + usleep(100000); + + // if not set to repeat and we've sent a message we can exit + if (!d_repeat && d_repeat_cnt > 0) { + return WORK_DONE; } - int Build_Frame_impl::work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) - { - // some direct copies in here from `pdu to tagged stream block` too - // sleep at the start, if we stop too quickly after the send, the send doesn't seem to happen - usleep(100000); - - // if not set to repeat and we've sent a message we can exit - if (!d_repeat && d_repeat_cnt > 0) { - return WORK_DONE; - } + char* out = (char*)output_items[0]; - char* out = (char*) output_items[0]; + if (d_curr_len == 0) { + return 0; + } - if (d_curr_len == 0) { - return 0; - } + // work() should only be called if the current PDU fits entirely + // into the output buffer. + assert(noutput_items >= 0 && (unsigned int)noutput_items >= d_curr_len); + + // Copy vector output + size_t nout = d_curr_len; + size_t io(0); + const uint8_t* ptr = (const uint8_t*)uniform_vector_elements(d_curr_vect, io); + memcpy(out, ptr, d_curr_len * d_itemsize); + + // at this point we have the `sentence` stored in `out` and length in `nout`. + // printf("len: %ld; val: %s\n", nout, out); + // printf("buf len: %ld; in lenL %ld\n", noutput_items, ninput_items); + // TODO get a better understanding of noutput_items, set at 32768, but not entirely + // sure where/how had been under the impression this would be based on the + // calc length function but it does not seem related. + // going off the 32k, our output should always fit.. + + // char* d_sentence; + const char* sentence = out; + char* payload; // [the 01 rapresentation of the sentence as taken from input] + unsigned short LEN_SENTENCE; + unsigned short LEN_PAYLOAD; + + unsigned short REMAINDER_TO_EIGHT, + PADDING_TO_EIGHT; // to pad the payload to a multiple of 8 + + LEN_PAYLOAD = strlen(sentence); + if (LEN_PAYLOAD > 168) + printf("Frame padding disabled. Multiple packets.\n"); + + // IMPORTANT + REMAINDER_TO_EIGHT = LEN_PAYLOAD % 8; + if (REMAINDER_TO_EIGHT == 0) { + payload = (char*)malloc(LEN_PAYLOAD + LEN_CRC); + // nb. It comes in in ASCII + for (int i = 0; i < LEN_PAYLOAD; i++) + payload[i] = sentence[i] - 48; + } else if (REMAINDER_TO_EIGHT > 0) { + + PADDING_TO_EIGHT = 8 - REMAINDER_TO_EIGHT; + payload = (char*)malloc(LEN_PAYLOAD + PADDING_TO_EIGHT + LEN_CRC); + + for (int i = 0; i < LEN_PAYLOAD; i++) + payload[i] = sentence[i] - 48; + + printf("Detected a payload which is *not* multiple of 8 (%d bits). Padding with " + "%d bits to %d\n", + LEN_PAYLOAD, + PADDING_TO_EIGHT, + LEN_PAYLOAD + PADDING_TO_EIGHT); + memset(payload + LEN_PAYLOAD, 0x0, PADDING_TO_EIGHT); + + LEN_PAYLOAD += PADDING_TO_EIGHT; // update PAYLOAD LENGHT + } - // work() should only be called if the current PDU fits entirely - // into the output buffer. - assert(noutput_items >= 0 && (unsigned int)noutput_items >= d_curr_len); + dump_buffer(payload, LEN_PAYLOAD); - // Copy vector output - size_t nout = d_curr_len; - size_t io(0); - const uint8_t* ptr = (const uint8_t*)uniform_vector_elements(d_curr_vect, io); - memcpy(out, ptr, d_curr_len * d_itemsize); + // crc + char crc[16]; // 2 gnuradio bytes of CRC + char input_crc[LEN_PAYLOAD]; + memcpy(input_crc, payload, LEN_PAYLOAD); + compute_crc(input_crc, crc, LEN_PAYLOAD); + memcpy(payload + LEN_PAYLOAD, crc, LEN_CRC); + + // reverse + reverse_bit_order(payload, LEN_PAYLOAD + LEN_CRC); + + + // clang-format off + // B3co>HP00 P ;8 ;56 RD =Is3 w sU kP06 CRC + // 010010000011101011110111001110011000100000000000000000 100000 001011001000 001011000101000110 100010010100 001101011001111011000011 111111 111011100101 110011100000000000000110 0011000010001111 + // clang-format on - // at this point we have the `sentence` stored in `out` and length in `nout`. - //printf("len: %ld; val: %s\n", nout, out); - // printf("buf len: %ld; in lenL %ld\n", noutput_items, ninput_items); - // TODO get a better understanding of noutput_items, set at 32768, but not entirely sure where/how - // had been under the impression this would be based on the calc length function but - // it does not seem related. going off the 32k, our output should always fit.. + // printf("\nENCODING:\t%s\n", sentence); + // printf("LEN_SENTENCE:\t%d\n", LEN_SENTENCE); printf("LEN_PAYLOAD:\t%d\n", + // LEN_PAYLOAD); printf("LEN_CRC:\t%d\n", LEN_CRC); - //char* d_sentence; - const char* sentence = out; - char* payload; // [the 01 rapresentation of the sentence as taken from input] - unsigned short LEN_SENTENCE; - unsigned short LEN_PAYLOAD; - - unsigned short REMAINDER_TO_EIGHT, PADDING_TO_EIGHT; // to pad the payload to a multiple of 8 - - LEN_PAYLOAD = strlen(sentence); - if (LEN_PAYLOAD>168) - printf ("Frame padding disabled. Multiple packets.\n"); - - // IMPORTANT - REMAINDER_TO_EIGHT = LEN_PAYLOAD%8; - if (REMAINDER_TO_EIGHT==0) { - payload = (char *) malloc(LEN_PAYLOAD + LEN_CRC); - // nb. It comes in in ASCII - for (int i=0; i0){ - - PADDING_TO_EIGHT = 8-REMAINDER_TO_EIGHT; - payload = (char *) malloc(LEN_PAYLOAD + PADDING_TO_EIGHT + LEN_CRC); - - for (int i=0; iHP00 P ;8 ;56 RD =Is3 w sU kP06 CRC -// 010010000011101011110111001110011000100000000000000000 100000 001011001000 001011000101000110 100010010100 001101011001111011000011 111111 111011100101 110011100000000000000110 0011000010001111 -// printf("\nENCODING:\t%s\n", sentence); -// printf("LEN_SENTENCE:\t%d\n", LEN_SENTENCE); -// printf("LEN_PAYLOAD:\t%d\n", LEN_PAYLOAD); -// printf("LEN_CRC:\t%d\n", LEN_CRC); - -// // payload encoding -// char buffer[6]; - -// for (int i=0; i %s \n", strlen(payload), i+1, sentence[i], payload); -// } - - -// // crc -// char crc[16]; // 2 gnuradio bytes of CRC -// char input_crc[LEN_PAYLOAD]; -// memcpy (input_crc, payload, LEN_PAYLOAD); -// compute_crc (input_crc, crc, LEN_PAYLOAD); -// memcpy (payload+LEN_PAYLOAD, crc, LEN_CRC); - - // reverse bits (payload + crc) -// reverse_bit_order (payload, LEN_PAYLOAD+LEN_CRC); -//// printf("Dump buffer after reverse + crc= "); -//// dump_buffer(payload, LEN_PAYLOAD+LEN_CRC); - - // stuffing (payload + crc) - if (LEN_PAYLOAD<=168) { - - char stuffed_payload[LEN_FRAME_MAX]; - int LEN_STUFFED_PAYLOAD = stuff (payload, stuffed_payload, LEN_PAYLOAD+LEN_CRC); - - //// frame generation ///// - char frame[LEN_FRAME_MAX]; - unsigned char byte_frame[LEN_FRAME_MAX/8]; //PASTA - memset (frame, 0x0, LEN_FRAME_MAX); - - // headers - memcpy (frame, "\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0", LEN_PREAMBLE); - memcpy (frame+LEN_PREAMBLE, "\0\1\1\1\1\1\1\0", LEN_START); - // payload + crc - memcpy (frame+LEN_PREAMBLE+LEN_START, stuffed_payload, LEN_STUFFED_PAYLOAD); - // trailer - memcpy (frame+LEN_PREAMBLE+LEN_START+LEN_STUFFED_PAYLOAD, "\0\1\1\1\1\1\1\0", 8); - - // padding - int LEN_PADDING = LEN_FRAME_MAX-(LEN_PREAMBLE+LEN_START+LEN_STUFFED_PAYLOAD+LEN_START); - memset (frame+LEN_PREAMBLE+LEN_START+LEN_STUFFED_PAYLOAD+LEN_START, 0x0, LEN_PADDING); - int len_frame_real = LEN_FRAME_MAX; // 256 - - // NRZI Conversion - nrz_to_nrzi (frame, len_frame_real); - printf ("Sent Frame (NRZI enabled) = "); - - dump_buffer(frame, len_frame_real); - - // Binary conversion (to use with GMSK mod's byte_to_symb - byte_packing(frame, byte_frame, len_frame_real); - - // output - memcpy (out, byte_frame, len_frame_real/8); - noutput_items = len_frame_real/8; - - - } - else { - - char stuffed_payload[1024]; - int LEN_STUFFED_PAYLOAD = stuff (payload, stuffed_payload, LEN_PAYLOAD+LEN_CRC); - - //// frame generation ///// - int LEN_FRAME = LEN_PREAMBLE + LEN_START*2 + LEN_STUFFED_PAYLOAD; - char frame[LEN_FRAME]; - unsigned char byte_frame[LEN_FRAME/8]; //PASTA - memset (frame, 0x0, LEN_FRAME); - - // headers - memcpy (frame, "\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0", LEN_PREAMBLE); - memcpy (frame+LEN_PREAMBLE, "\0\1\1\1\1\1\1\0", LEN_START); - // payload + crc - memcpy (frame+LEN_PREAMBLE+LEN_START, stuffed_payload, LEN_STUFFED_PAYLOAD); - // trailer - memcpy (frame+LEN_PREAMBLE+LEN_START+LEN_STUFFED_PAYLOAD, "\0\1\1\1\1\1\1\0", 8); - - int len_frame_real = LEN_FRAME; - - // NRZI Conversion - nrz_to_nrzi (frame, len_frame_real); - printf ("Sent Frame (NRZI enabled) = "); - - dump_buffer(frame, len_frame_real); - - // Binary conversion (to use with GMSK mod's byte_to_symb - byte_packing(frame, byte_frame, len_frame_real); - - // output - memcpy (out, byte_frame, len_frame_real/8); - noutput_items = len_frame_real/8; - - } - - d_repeat_cnt++; - // Reset state - d_curr_len = 0; - - //return nout; - - - // Tell runtime system how many output items we produced. - return noutput_items; + // // payload encoding + // char buffer[6]; + + // for (int i=0; i %s \n", strlen(payload), i+1, sentence[i], payload); + // } + + + // // crc + // char crc[16]; // 2 gnuradio bytes of CRC + // char input_crc[LEN_PAYLOAD]; + // memcpy (input_crc, payload, LEN_PAYLOAD); + // compute_crc (input_crc, crc, LEN_PAYLOAD); + // memcpy (payload+LEN_PAYLOAD, crc, LEN_CRC); + + // reverse bits (payload + crc) + // reverse_bit_order (payload, LEN_PAYLOAD+LEN_CRC); + //// printf("Dump buffer after reverse + crc= "); + //// dump_buffer(payload, LEN_PAYLOAD+LEN_CRC); + + // stuffing (payload + crc) + if (LEN_PAYLOAD <= 168) { + + char stuffed_payload[LEN_FRAME_MAX]; + int LEN_STUFFED_PAYLOAD = stuff(payload, stuffed_payload, LEN_PAYLOAD + LEN_CRC); + + //// frame generation ///// + char frame[LEN_FRAME_MAX]; + unsigned char byte_frame[LEN_FRAME_MAX / 8]; // PASTA + memset(frame, 0x0, LEN_FRAME_MAX); + + // headers + memcpy(frame, "\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0", LEN_PREAMBLE); + memcpy(frame + LEN_PREAMBLE, "\0\1\1\1\1\1\1\0", LEN_START); + // payload + crc + memcpy(frame + LEN_PREAMBLE + LEN_START, stuffed_payload, LEN_STUFFED_PAYLOAD); + // trailer + memcpy(frame + LEN_PREAMBLE + LEN_START + LEN_STUFFED_PAYLOAD, + "\0\1\1\1\1\1\1\0", + 8); + + // padding + int LEN_PADDING = + LEN_FRAME_MAX - (LEN_PREAMBLE + LEN_START + LEN_STUFFED_PAYLOAD + LEN_START); + memset(frame + LEN_PREAMBLE + LEN_START + LEN_STUFFED_PAYLOAD + LEN_START, + 0x0, + LEN_PADDING); + int len_frame_real = LEN_FRAME_MAX; // 256 + + // NRZI Conversion + nrz_to_nrzi(frame, len_frame_real); + printf("Sent Frame (NRZI enabled) = "); + + dump_buffer(frame, len_frame_real); + + // Binary conversion (to use with GMSK mod's byte_to_symb + byte_packing(frame, byte_frame, len_frame_real); + + // output + memcpy(out, byte_frame, len_frame_real / 8); + noutput_items = len_frame_real / 8; + + + } else { + + char stuffed_payload[1024]; + int LEN_STUFFED_PAYLOAD = stuff(payload, stuffed_payload, LEN_PAYLOAD + LEN_CRC); + + //// frame generation ///// + int LEN_FRAME = LEN_PREAMBLE + LEN_START * 2 + LEN_STUFFED_PAYLOAD; + char frame[LEN_FRAME]; + unsigned char byte_frame[LEN_FRAME / 8]; // PASTA + memset(frame, 0x0, LEN_FRAME); + + // headers + memcpy(frame, "\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0\1\0", LEN_PREAMBLE); + memcpy(frame + LEN_PREAMBLE, "\0\1\1\1\1\1\1\0", LEN_START); + // payload + crc + memcpy(frame + LEN_PREAMBLE + LEN_START, stuffed_payload, LEN_STUFFED_PAYLOAD); + // trailer + memcpy(frame + LEN_PREAMBLE + LEN_START + LEN_STUFFED_PAYLOAD, + "\0\1\1\1\1\1\1\0", + 8); + + int len_frame_real = LEN_FRAME; + + // NRZI Conversion + nrz_to_nrzi(frame, len_frame_real); + printf("Sent Frame (NRZI enabled) = "); + + dump_buffer(frame, len_frame_real); + + // Binary conversion (to use with GMSK mod's byte_to_symb + byte_packing(frame, byte_frame, len_frame_real); + + // output + memcpy(out, byte_frame, len_frame_real / 8); + noutput_items = len_frame_real / 8; } - } /* namespace AISTX */ -} /* namespace gr */ + d_repeat_cnt++; + // Reset state + d_curr_len = 0; + + // return nout; + + // Tell runtime system how many output items we produced. + return noutput_items; +} + +} /* namespace AISTX */ +} /* namespace gr */ diff --git a/lib/Build_Frame_impl.h b/lib/Build_Frame_impl.h index 6cdc12a..7a982c6 100644 --- a/lib/Build_Frame_impl.h +++ b/lib/Build_Frame_impl.h @@ -1,23 +1,23 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2013 <+YOU OR YOUR COMPANY+>. - * + * * This 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. - * + * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ - + #ifndef INCLUDED_AISTX_BUILD_FRAME_IMPL_H #define INCLUDED_AISTX_BUILD_FRAME_IMPL_H @@ -26,44 +26,45 @@ #define __VERSION 0.3 namespace gr { - namespace AISTX { +namespace AISTX { - class Build_Frame_impl : public Build_Frame - { - private: - bool d_repeat; - unsigned long d_repeat_cnt; - bool d_enable_NRZI; - size_t d_itemsize; +class Build_Frame_impl : public Build_Frame +{ +private: + bool d_repeat; + unsigned long d_repeat_cnt; + bool d_enable_NRZI; + size_t d_itemsize; pmt::pmt_t d_curr_meta; pmt::pmt_t d_curr_vect; size_t d_curr_len; - - public: - Build_Frame_impl(bool repeat, bool enable_NRZI, const std::string& lengthtagname = "packet_len"); - ~Build_Frame_impl(); - void dump_buffer(const char *b, int buffer_size); - char * int2bin(int a, char *buffer, int buf_size); - int stuff (const char *in, char *out, int l_in); - void pack (int orig_ascii, char *ret, int bits_per_byte); - void nrz_to_nrzi(char *data, int length); - void reverse_bit_order(char *data, int length); - unsigned long unpack(char *buffer, int start, int length); - void compute_crc(char *buffer, char *ret, unsigned int len); - void byte_packing(char *input_frame, unsigned char *out_byte, unsigned int len); +public: + Build_Frame_impl(bool repeat, + bool enable_NRZI, + const std::string& lengthtagname = "packet_len"); + ~Build_Frame_impl(); + + void dump_buffer(const char* b, int buffer_size); + char* int2bin(int a, char* buffer, int buf_size); + int stuff(const char* in, char* out, int l_in); + void pack(int orig_ascii, char* ret, int bits_per_byte); + void nrz_to_nrzi(char* data, int length); + void reverse_bit_order(char* data, int length); + unsigned long unpack(char* buffer, int start, int length); + void compute_crc(char* buffer, char* ret, unsigned int len); + void byte_packing(char* input_frame, unsigned char* out_byte, unsigned int len); - int calculate_output_stream_length(const gr_vector_int& ninput_items); + int calculate_output_stream_length(const gr_vector_int& ninput_items); - // Where all the action really happens - int work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); - }; + // Where all the action really happens + int work(int noutput_items, + gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items); +}; - } // namespace AISTX +} // namespace AISTX } // namespace gr #endif /* INCLUDED_AISTX_BUILD_FRAME_IMPL_H */ - diff --git a/lib/DebugME_impl.cc b/lib/DebugME_impl.cc index 3d0681c..4ad35e1 100644 --- a/lib/DebugME_impl.cc +++ b/lib/DebugME_impl.cc @@ -1,17 +1,17 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2013 <+YOU OR YOUR COMPANY+>. - * + * * This 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. - * + * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -22,77 +22,71 @@ #include "config.h" #endif -#include #include "DebugME_impl.h" +#include #include namespace gr { - namespace AISTX { +namespace AISTX { - DebugME::sptr - DebugME::make(size_t itemsize) - { - return gnuradio::get_initial_sptr - (new DebugME_impl(itemsize)); - } +DebugME::sptr DebugME::make(size_t itemsize) +{ + return gnuradio::get_initial_sptr(new DebugME_impl(itemsize)); +} - /* - * The private constructor - */ - DebugME_impl::DebugME_impl(size_t itemsize) - : gr::block("DebugME", - gr::io_signature::make(1, 1, itemsize), - gr::io_signature::make(0, 0, 0)), - d_itemsize(itemsize) - {} +/* + * The private constructor + */ +DebugME_impl::DebugME_impl(size_t itemsize) + : gr::block("DebugME", + gr::io_signature::make(1, 1, itemsize), + gr::io_signature::make(0, 0, 0)), + d_itemsize(itemsize) +{ +} - /* - * Our virtual destructor. - */ - DebugME_impl::~DebugME_impl() - { - } +/* + * Our virtual destructor. + */ +DebugME_impl::~DebugME_impl() {} - void - DebugME_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) - { - /* <+forecast+> e.g. ninput_items_required[0] = noutput_items */ - } +void DebugME_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required) +{ + /* <+forecast+> e.g. ninput_items_required[0] = noutput_items */ +} + +int DebugME_impl::general_work(int noutput_items, + gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items) +{ - int - DebugME_impl::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) - { + // char / byte + if (d_itemsize == 1) { + const unsigned char* in = (const unsigned char*)input_items[0]; + for (int i = 0; i < ninput_items[0]; ++i) + printf("\\x%.2X", in[i]); + } + // float + else if (d_itemsize == 4) { + const float* in = (const float*)input_items[0]; + for (int i = 0; i < ninput_items[0]; ++i) + printf("\\%.0f", in[i]); + } + // complex + else + printf("Complexes not supported yet!"); - // char / byte - if (d_itemsize == 1) { - const unsigned char *in = (const unsigned char *) input_items[0]; - for(int i = 0; i - // Tell runtime system how many input items we consumed on - // each input stream. - consume_each (noutput_items); + // Do <+signal processing+> + // Tell runtime system how many input items we consumed on + // each input stream. + consume_each(noutput_items); - // Tell runtime system how many output items we produced. - return 0; - } + // Tell runtime system how many output items we produced. + return 0; +} - } /* namespace AISTX */ +} /* namespace AISTX */ } /* namespace gr */ - diff --git a/lib/DebugME_impl.h b/lib/DebugME_impl.h index ae973cb..0e70bf6 100644 --- a/lib/DebugME_impl.h +++ b/lib/DebugME_impl.h @@ -1,17 +1,17 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2013 <+YOU OR YOUR COMPANY+>. - * + * * This 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. - * + * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -24,28 +24,27 @@ #include namespace gr { - namespace AISTX { +namespace AISTX { - class DebugME_impl : public DebugME - { - private: - size_t d_itemsize; +class DebugME_impl : public DebugME +{ +private: + size_t d_itemsize; - public: - DebugME_impl(size_t itemsize); - ~DebugME_impl(); +public: + DebugME_impl(size_t itemsize); + ~DebugME_impl(); - // Where all the action really happens - void forecast (int noutput_items, gr_vector_int &ninput_items_required); + // Where all the action really happens + void forecast(int noutput_items, gr_vector_int& ninput_items_required); - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - }; + int general_work(int noutput_items, + gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items); +}; - } // namespace AISTX +} // namespace AISTX } // namespace gr #endif /* INCLUDED_AISTX_DEBUGME_IMPL_H */ - diff --git a/lib/nrz_to_nrzi_impl.cc b/lib/nrz_to_nrzi_impl.cc index 93934dc..7efa3e6 100644 --- a/lib/nrz_to_nrzi_impl.cc +++ b/lib/nrz_to_nrzi_impl.cc @@ -1,17 +1,17 @@ /* -*- c++ -*- */ -/* +/* * Copyright 2013 <+YOU OR YOUR COMPANY+>. - * + * * This 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. - * + * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -22,87 +22,76 @@ #include "config.h" #endif -#include #include "nrz_to_nrzi_impl.h" +#include #include namespace gr { - namespace AISTX { - - nrz_to_nrzi::sptr - nrz_to_nrzi::make() - { - return gnuradio::get_initial_sptr - (new nrz_to_nrzi_impl()); - } - - /* - * The private constructor - */ - nrz_to_nrzi_impl::nrz_to_nrzi_impl() - : gr::block("nrz_to_nrzi", - gr::io_signature::make(1, 1, sizeof(unsigned char)), - gr::io_signature::make(1, 1, sizeof(unsigned char))) - {} - - /* - * Our virtual destructor. - */ - nrz_to_nrzi_impl::~nrz_to_nrzi_impl() - { - } - - void - nrz_to_nrzi_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) - { - /* <+forecast+> e.g. ninput_items_required[0] = noutput_items */ - } +namespace AISTX { - int - nrz_to_nrzi_impl::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) - { - const unsigned char *in = (const unsigned char *) input_items[0]; - unsigned char *out = (unsigned char *) output_items[0]; - unsigned char nrzi_bit; - unsigned char nrz_bit; - unsigned char d_prev_nrzi_bit = 0; - - for(int i = 0;i e.g. ninput_items_required[0] = noutput_items */ +} + +int nrz_to_nrzi_impl::general_work(int noutput_items, + gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items) +{ + const unsigned char* in = (const unsigned char*)input_items[0]; + unsigned char* out = (unsigned char*)output_items[0]; + unsigned char nrzi_bit; + unsigned char nrz_bit; + unsigned char d_prev_nrzi_bit = 0; + + for (int i = 0; i < noutput_items; ++i) + printf("%d", in[i]); + printf("\n"); + + for (int i = 0; i < noutput_items; i++) { + nrz_bit = in[i]; + + if (nrz_bit == 0) { + nrzi_bit = d_prev_nrzi_bit ^ 1; + } else { + nrzi_bit = d_prev_nrzi_bit; } + out[i] = nrzi_bit; + d_prev_nrzi_bit = nrzi_bit; + } - for(int i = 0;i. - * + * * This 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. - * + * * This software 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 this software; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, @@ -24,28 +24,27 @@ #include namespace gr { - namespace AISTX { +namespace AISTX { - class nrz_to_nrzi_impl : public nrz_to_nrzi - { - private: - // Nothing to declare in this block. +class nrz_to_nrzi_impl : public nrz_to_nrzi +{ +private: + // Nothing to declare in this block. - public: - nrz_to_nrzi_impl(); - ~nrz_to_nrzi_impl(); +public: + nrz_to_nrzi_impl(); + ~nrz_to_nrzi_impl(); - // Where all the action really happens - void forecast (int noutput_items, gr_vector_int &ninput_items_required); + // Where all the action really happens + void forecast(int noutput_items, gr_vector_int& ninput_items_required); - int general_work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - }; + int general_work(int noutput_items, + gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items); +}; - } // namespace AISTX +} // namespace AISTX } // namespace gr #endif /* INCLUDED_AISTX_NRZ_TO_NRZI_IMPL_H */ - diff --git a/lib/qa_AISTX.cc b/lib/qa_AISTX.cc index 1a101f1..c5b3aa2 100644 --- a/lib/qa_AISTX.cc +++ b/lib/qa_AISTX.cc @@ -27,10 +27,9 @@ #include "qa_AISTX.h" -CppUnit::TestSuite * -qa_AISTX::suite() +CppUnit::TestSuite* qa_AISTX::suite() { - CppUnit::TestSuite *s = new CppUnit::TestSuite("AISTX"); + CppUnit::TestSuite* s = new CppUnit::TestSuite("AISTX"); - return s; + return s; } diff --git a/lib/qa_AISTX.h b/lib/qa_AISTX.h index 8d23882..ba4270a 100644 --- a/lib/qa_AISTX.h +++ b/lib/qa_AISTX.h @@ -30,9 +30,9 @@ class __GR_ATTR_EXPORT qa_AISTX { - public: - //! return suite of tests for all of gr-filter directory - static CppUnit::TestSuite *suite(); +public: + //! return suite of tests for all of gr-filter directory + static CppUnit::TestSuite* suite(); }; #endif /* _QA_AISTX_H_ */ diff --git a/lib/test_AISTX.cc b/lib/test_AISTX.cc index 0546257..a4ff5d4 100644 --- a/lib/test_AISTX.cc +++ b/lib/test_AISTX.cc @@ -23,21 +23,20 @@ #include #include -#include #include "qa_AISTX.h" +#include #include -int -main (int argc, char **argv) +int main(int argc, char** argv) { - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(get_unittest_path("AISTX.xml").c_str()); - CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(get_unittest_path("AISTX.xml").c_str()); + CppUnit::XmlOutputter* xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); - runner.addTest(qa_AISTX::suite()); - runner.setOutputter(xmlout); + runner.addTest(qa_AISTX::suite()); + runner.setOutputter(xmlout); - bool was_successful = runner.run("", false); + bool was_successful = runner.run("", false); - return was_successful ? 0 : 1; + return was_successful ? 0 : 1; } From 24d893590b3d5482b01269c4959f9d67a9a0ab3e Mon Sep 17 00:00:00 2001 From: bmagistro Date: Mon, 8 Feb 2021 14:17:51 -0500 Subject: [PATCH 11/12] run and address clang-tidy items --- lib/Build_Frame_impl.cc | 11 +++-------- lib/Build_Frame_impl.h | 6 +++--- lib/DebugME_impl.cc | 7 +------ lib/DebugME_impl.h | 6 +++--- lib/nrz_to_nrzi_impl.cc | 7 +------ lib/nrz_to_nrzi_impl.h | 6 +++--- 6 files changed, 14 insertions(+), 29 deletions(-) diff --git a/lib/Build_Frame_impl.cc b/lib/Build_Frame_impl.cc index ad3f29f..5ca351e 100644 --- a/lib/Build_Frame_impl.cc +++ b/lib/Build_Frame_impl.cc @@ -27,9 +27,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #define LEN_PREAMBLE 24 @@ -71,11 +71,6 @@ Build_Frame_impl::Build_Frame_impl(bool repeat, message_port_register_in(pmt::mp("sentence")); } -/* - * Our virtual destructor. - */ -Build_Frame_impl::~Build_Frame_impl() {} - void Build_Frame_impl::dump_buffer(const char* b, int buffer_size) { diff --git a/lib/Build_Frame_impl.h b/lib/Build_Frame_impl.h index 7a982c6..ccb2c45 100644 --- a/lib/Build_Frame_impl.h +++ b/lib/Build_Frame_impl.h @@ -43,7 +43,7 @@ class Build_Frame_impl : public Build_Frame Build_Frame_impl(bool repeat, bool enable_NRZI, const std::string& lengthtagname = "packet_len"); - ~Build_Frame_impl(); + ~Build_Frame_impl() override = default; void dump_buffer(const char* b, int buffer_size); char* int2bin(int a, char* buffer, int buf_size); @@ -55,13 +55,13 @@ class Build_Frame_impl : public Build_Frame void compute_crc(char* buffer, char* ret, unsigned int len); void byte_packing(char* input_frame, unsigned char* out_byte, unsigned int len); - int calculate_output_stream_length(const gr_vector_int& ninput_items); + int calculate_output_stream_length(const gr_vector_int& ninput_items) override; // Where all the action really happens int work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); + gr_vector_void_star& output_items) override; }; } // namespace AISTX diff --git a/lib/DebugME_impl.cc b/lib/DebugME_impl.cc index 4ad35e1..a7365f4 100644 --- a/lib/DebugME_impl.cc +++ b/lib/DebugME_impl.cc @@ -24,7 +24,7 @@ #include "DebugME_impl.h" #include -#include +#include namespace gr { namespace AISTX { @@ -45,11 +45,6 @@ DebugME_impl::DebugME_impl(size_t itemsize) { } -/* - * Our virtual destructor. - */ -DebugME_impl::~DebugME_impl() {} - void DebugME_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required) { /* <+forecast+> e.g. ninput_items_required[0] = noutput_items */ diff --git a/lib/DebugME_impl.h b/lib/DebugME_impl.h index 0e70bf6..29ac581 100644 --- a/lib/DebugME_impl.h +++ b/lib/DebugME_impl.h @@ -33,15 +33,15 @@ class DebugME_impl : public DebugME public: DebugME_impl(size_t itemsize); - ~DebugME_impl(); + ~DebugME_impl() override = default; // Where all the action really happens - void forecast(int noutput_items, gr_vector_int& ninput_items_required); + void forecast(int noutput_items, gr_vector_int& ninput_items_required) override; int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); + gr_vector_void_star& output_items) override; }; } // namespace AISTX diff --git a/lib/nrz_to_nrzi_impl.cc b/lib/nrz_to_nrzi_impl.cc index 7efa3e6..9b01f65 100644 --- a/lib/nrz_to_nrzi_impl.cc +++ b/lib/nrz_to_nrzi_impl.cc @@ -24,7 +24,7 @@ #include "nrz_to_nrzi_impl.h" #include -#include +#include namespace gr { namespace AISTX { @@ -44,11 +44,6 @@ nrz_to_nrzi_impl::nrz_to_nrzi_impl() { } -/* - * Our virtual destructor. - */ -nrz_to_nrzi_impl::~nrz_to_nrzi_impl() {} - void nrz_to_nrzi_impl::forecast(int noutput_items, gr_vector_int& ninput_items_required) { /* <+forecast+> e.g. ninput_items_required[0] = noutput_items */ diff --git a/lib/nrz_to_nrzi_impl.h b/lib/nrz_to_nrzi_impl.h index 6a0534f..6382972 100644 --- a/lib/nrz_to_nrzi_impl.h +++ b/lib/nrz_to_nrzi_impl.h @@ -33,15 +33,15 @@ class nrz_to_nrzi_impl : public nrz_to_nrzi public: nrz_to_nrzi_impl(); - ~nrz_to_nrzi_impl(); + ~nrz_to_nrzi_impl() override = default; // Where all the action really happens - void forecast(int noutput_items, gr_vector_int& ninput_items_required); + void forecast(int noutput_items, gr_vector_int& ninput_items_required) override; int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items); + gr_vector_void_star& output_items) override; }; } // namespace AISTX From b715a2a0baae9bb2e981380423bfc124c2453fa7 Mon Sep 17 00:00:00 2001 From: bmagistro Date: Sun, 14 Feb 2021 21:04:29 -0500 Subject: [PATCH 12/12] remove existing ais_tx grc & py files, deprecated since they use wx gui --- apps/AiS_TX.py | 135 ----- examples/AiS_TX.grc | 1369 ------------------------------------------- 2 files changed, 1504 deletions(-) delete mode 100755 apps/AiS_TX.py delete mode 100644 examples/AiS_TX.grc diff --git a/apps/AiS_TX.py b/apps/AiS_TX.py deleted file mode 100755 index 5ea5deb..0000000 --- a/apps/AiS_TX.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python -# -# This script is part of the AIS BlackToolkit. -# AiS_TX.py implements a software-based AIS transmitter accordingly to specifications (ITU-R M.1371-4). -# -# A fully functional GnuRadio installation is required, including our AIS Frame Builder block, namely gr-aistx. -# -# Tested on: -# GnuRadio 3.6.5.1 -# Debian 7.1.0 wheezy -# GNU C++ version 4.7.3; Boost_104900 -# UHD_003.005.003-0-unknown -# Ettus USRP B100 Version 2) -# -# Copyright 2013-2014 -- Embyte & Pastus -# -# This program 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 2 -# of the License, or (at your option) any later version. -# -# Usage example: -# $ ./AIVDM_Encoder.py --type=1 --mmsi=970010000 --lat=45.6910 --long=9.7235 | xargs -IX ./AiS_TX.py --payload=X --channel=A -# - -from gnuradio import blocks -from gnuradio import digital -from gnuradio import eng_notation -from gnuradio import gr -from gnuradio import uhd -from gnuradio.eng_option import eng_option -from gnuradio.gr import firdes -from grc_gnuradio import wxgui as grc_wxgui -from optparse import OptionParser -import AISTX -import time -import wx - -class top_block(grc_wxgui.top_block_gui): - - def __init__(self, p, c, pw, ff, sr, br): - grc_wxgui.top_block_gui.__init__(self, title="Top Block") - _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" - self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) - - ################################################## - # Variables - ################################################## - self.samp_rate = samp_rate = sr - self.channel_select = channel_select = c - self.bit_rate = bit_rate = br - - ################################################## - # Blocks - ################################################## - self.uhd_usrp_sink_0 = uhd.usrp_sink( - device_addr="", - stream_args=uhd.stream_args( - cpu_format="fc32", - channels=range(1), - ), - ) - self.uhd_usrp_sink_0.set_samp_rate(samp_rate) - self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request_t(161975000+50000*c,ff), 0) - self.uhd_usrp_sink_0.set_gain(-10, 0) - self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) - self.digital_gmsk_mod_0 = digital.gmsk_mod( - samples_per_symbol=int(samp_rate/bit_rate), - bt=0.4, - verbose=False, - log=False, - ) - self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.9, )) - self.AISTX_Build_Frame_0 = AISTX.Build_Frame(p, False, True) - - ################################################## - # Connections - ################################################## - self.connect((self.AISTX_Build_Frame_0, 0), (self.digital_gmsk_mod_0, 0)) - self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) - self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) - - - def get_samp_rate(self): - return self.samp_rate - - def set_samp_rate(self, samp_rate): - self.samp_rate = samp_rate - self.uhd_usrp_sink_0.set_samp_rate(self.samp_rate) - - def get_channel_select(self): - return self.channel_select - - def set_channel_select(self, channel_select): - self.channel_select = channel_select - self.analog_sig_source_x_0.set_frequency(-25000+50000*self.channel_select) - - def get_bit_rate(self): - return self.bit_rate - - def set_bit_rate(self, bit_rate): - self.bit_rate = bit_rate - -if __name__ == '__main__': - - desc="""GnuRadio-Based AIS Transmitter. Copyright Embyte & Pastus 2013-2014.""" - - parser = OptionParser(option_class=eng_option, usage="%prog: [options]", description=desc) - - parser.add_option("--payload", help="""Specify the message payload to transmit - (e.g., crafted via AIVDM_Encoder)""") - parser.add_option("--channel", help="""Specify the AIS channel: - - A: 161.975Mhz (87B) - - B: 162.025Mhz (88B)""") - parser.add_option("--power", help="""Specify the transmisson power, between -12dB and +12dB (default is -10dB)""", type="int", default = -10) - parser.add_option("--filter_frequency", help="""Specify the filter frequency (default is 19MHz)""", type="int", default = 19000000) - parser.add_option("--sampling_rate", help="""Specify the sampling rate (default is 326.531KHz)""", type="int", default = 326531) - parser.add_option("--bit_rate", help="""Specify the bit rate (default is 9600 baud)""", type="int", default = 9600) - - (options, args) = parser.parse_args() - - if not options.payload: - parser.error("Payload not specified: -h for help.") - - if not options.channel: - parser.error("Channel not specified: -h for help.") - - if options.channel!="A" and options.channel!="B": - parser.error("Channel accepts value A or B: -h for help") - - channel_ID = 0 if options.channel=="A" else 1 - - tb = top_block(p=options.payload, c=channel_ID, pw=options.power, ff=options.filter_frequency, sr=options.sampling_rate, br=options.bit_rate) - tb.Run(True) - diff --git a/examples/AiS_TX.grc b/examples/AiS_TX.grc deleted file mode 100644 index a4cbe0c..0000000 --- a/examples/AiS_TX.grc +++ /dev/null @@ -1,1369 +0,0 @@ - - - Fri Nov 14 14:27:09 2014 - - options - - id - top_block - - - _enabled - True - - - title - - - - author - - - - description - - - - window_size - 1280, 1024 - - - generate_options - wx_gui - - - category - Custom - - - run_options - prompt - - - run - True - - - max_nouts - 0 - - - realtime_scheduling - - - - _coordinate - (-1, 0) - - - _rotation - 0 - - - - analog_sig_source_x - - id - analog_sig_source_x_0 - - - _enabled - True - - - type - complex - - - samp_rate - samp_rate - - - waveform - analog.GR_SIN_WAVE - - - freq - -25000 - - - amp - 1 - - - offset - 0 - - - _coordinate - (253, 184) - - - _rotation - 0 - - - - blks2_selector - - id - blks2_selector_0 - - - _enabled - True - - - type - complex - - - num_inputs - 3 - - - num_outputs - 1 - - - input_index - channel_select - - - output_index - 0 - - - vlen - 1 - - - _coordinate - (953, 164) - - - _rotation - 0 - - - - variable - - id - samp_rate - - - _enabled - True - - - value - 326531 - - - _coordinate - (173, 0) - - - _rotation - 0 - - - - variable - - id - bit_rate - - - _enabled - True - - - value - 9600 - - - _coordinate - (281, -1) - - - _rotation - 0 - - - - digital_gmsk_mod - - id - digital_gmsk_mod_0 - - - _enabled - True - - - samples_per_symbol - int(samp_rate/bit_rate) - - - bt - 0.4 - - - verbose - False - - - log - False - - - _coordinate - (254, 103) - - - _rotation - 0 - - - - blocks_multiply_xx - - id - blocks_multiply_xx_0 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (464, 148) - - - _rotation - 0 - - - - blocks_multiply_const_vxx - - id - blocks_multiply_const_vxx_0_1 - - - _enabled - True - - - type - complex - - - const - 0.9 - - - vlen - 1 - - - _coordinate - (681, 160) - - - _rotation - 0 - - - - blocks_multiply_const_vxx - - id - blocks_multiply_const_vxx_0_1_0 - - - _enabled - True - - - type - complex - - - const - 0.9 - - - vlen - 1 - - - _coordinate - (697, 376) - - - _rotation - 0 - - - - blocks_add_xx - - id - blocks_add_xx_0 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (803, 212) - - - _rotation - 0 - - - - blocks_multiply_const_vxx - - id - blocks_multiply_const_vxx_0 - - - _enabled - True - - - type - complex - - - const - 0.45 - - - vlen - 1 - - - _coordinate - (611, 208) - - - _rotation - 0 - - - - blocks_multiply_const_vxx - - id - blocks_multiply_const_vxx_0_0 - - - _enabled - True - - - type - complex - - - const - 0.45 - - - vlen - 1 - - - _coordinate - (605, 301) - - - _rotation - 0 - - - - blocks_multiply_xx - - id - blocks_multiply_xx_0_0 - - - _enabled - True - - - type - complex - - - num_inputs - 2 - - - vlen - 1 - - - _coordinate - (458, 364) - - - _rotation - 0 - - - - digital_gmsk_mod - - id - digital_gmsk_mod_0_0 - - - _enabled - True - - - samples_per_symbol - int(samp_rate/bit_rate) - - - bt - 0.4 - - - verbose - False - - - log - False - - - _coordinate - (249, 321) - - - _rotation - 0 - - - - analog_sig_source_x - - id - analog_sig_source_x_0_0 - - - _enabled - True - - - type - complex - - - samp_rate - samp_rate - - - waveform - analog.GR_SIN_WAVE - - - freq - 25000 - - - amp - 1 - - - offset - 0 - - - _coordinate - (250, 401) - - - _rotation - 0 - - - - variable - - id - channel_select - - - _enabled - True - - - value - 2 - - - _coordinate - (368, -1) - - - _rotation - 0 - - - - uhd_usrp_sink - - id - uhd_usrp_sink_0 - - - _enabled - True - - - type - fc32 - - - otw - - - - stream_args - - - - dev_addr - - - - sync - - - - clock_rate - 0.0 - - - num_mboards - 1 - - - clock_source0 - - - - time_source0 - - - - sd_spec0 - - - - clock_source1 - - - - time_source1 - gpsdo - - - sd_spec1 - - - - clock_source2 - - - - time_source2 - - - - sd_spec2 - - - - clock_source3 - - - - time_source3 - - - - sd_spec3 - - - - clock_source4 - - - - time_source4 - - - - sd_spec4 - - - - clock_source5 - - - - time_source5 - - - - sd_spec5 - - - - clock_source6 - - - - time_source6 - - - - sd_spec6 - - - - clock_source7 - - - - time_source7 - - - - sd_spec7 - - - - nchan - 1 - - - samp_rate - samp_rate - - - center_freq0 - uhd.tune_request_t(162000000, 19000000) - - - gain0 - 0 - - - ant0 - TX/RX - - - bw0 - 0 - - - center_freq1 - 0 - - - gain1 - 0 - - - ant1 - - - - bw1 - 0 - - - center_freq2 - 0 - - - gain2 - 0 - - - ant2 - - - - bw2 - 0 - - - center_freq3 - 0 - - - gain3 - 0 - - - ant3 - - - - bw3 - 0 - - - center_freq4 - 0 - - - gain4 - 0 - - - ant4 - - - - bw4 - 0 - - - center_freq5 - 0 - - - gain5 - 0 - - - ant5 - - - - bw5 - 0 - - - center_freq6 - 0 - - - gain6 - 0 - - - ant6 - - - - bw6 - 0 - - - center_freq7 - 0 - - - gain7 - 0 - - - ant7 - - - - bw7 - 0 - - - center_freq8 - 0 - - - gain8 - 0 - - - ant8 - - - - bw8 - 0 - - - center_freq9 - 0 - - - gain9 - 0 - - - ant9 - - - - bw9 - 0 - - - center_freq10 - 0 - - - gain10 - 0 - - - ant10 - - - - bw10 - 0 - - - center_freq11 - 0 - - - gain11 - 0 - - - ant11 - - - - bw11 - 0 - - - center_freq12 - 0 - - - gain12 - 0 - - - ant12 - - - - bw12 - 0 - - - center_freq13 - 0 - - - gain13 - 0 - - - ant13 - - - - bw13 - 0 - - - center_freq14 - 0 - - - gain14 - 0 - - - ant14 - - - - bw14 - 0 - - - center_freq15 - 0 - - - gain15 - 0 - - - ant15 - - - - bw15 - 0 - - - center_freq16 - 0 - - - gain16 - 0 - - - ant16 - - - - bw16 - 0 - - - center_freq17 - 0 - - - gain17 - 0 - - - ant17 - - - - bw17 - 0 - - - center_freq18 - 0 - - - gain18 - 0 - - - ant18 - - - - bw18 - 0 - - - center_freq19 - 0 - - - gain19 - 0 - - - ant19 - - - - bw19 - 0 - - - center_freq20 - 0 - - - gain20 - 0 - - - ant20 - - - - bw20 - 0 - - - center_freq21 - 0 - - - gain21 - 0 - - - ant21 - - - - bw21 - 0 - - - center_freq22 - 0 - - - gain22 - 0 - - - ant22 - - - - bw22 - 0 - - - center_freq23 - 0 - - - gain23 - 0 - - - ant23 - - - - bw23 - 0 - - - center_freq24 - 0 - - - gain24 - 0 - - - ant24 - - - - bw24 - 0 - - - center_freq25 - 0 - - - gain25 - 0 - - - ant25 - - - - bw25 - 0 - - - center_freq26 - 0 - - - gain26 - 0 - - - ant26 - - - - bw26 - 0 - - - center_freq27 - 0 - - - gain27 - 0 - - - ant27 - - - - bw27 - 0 - - - center_freq28 - 0 - - - gain28 - 0 - - - ant28 - - - - bw28 - 0 - - - center_freq29 - 0 - - - gain29 - 0 - - - ant29 - - - - bw29 - 0 - - - center_freq30 - 0 - - - gain30 - 0 - - - ant30 - - - - bw30 - 0 - - - center_freq31 - 0 - - - gain31 - 0 - - - ant31 - - - - bw31 - 0 - - - _coordinate - (932, 305) - - - _rotation - 0 - - - - AISTX_Build_Frame - - id - AISTX_Build_Frame_0 - - - _enabled - True - - - sentence - 000100000001101100011001110111011011110000000000000000000000011000111100111100100000101100100000101101000110011010001010010100010000000001000000000000000000000000000000 - - - repeat - True - - - enable_NRZI - True - - - _coordinate - (0, 97) - - - _rotation - 0 - - - - AISTX_Build_Frame - - id - AISTX_Build_Frame_1 - - - _enabled - True - - - sentence - 010100000001101100011001110111011011110000000000000001011110000000000000 - - - repeat - True - - - enable_NRZI - True - - - _coordinate - (1, 317) - - - _rotation - 0 - - - - digital_gmsk_mod_0 - blocks_multiply_xx_0 - 0 - 0 - - - analog_sig_source_x_0 - blocks_multiply_xx_0 - 0 - 1 - - - analog_sig_source_x_0_0 - blocks_multiply_xx_0_0 - 0 - 1 - - - digital_gmsk_mod_0_0 - blocks_multiply_xx_0_0 - 0 - 0 - - - blocks_multiply_xx_0_0 - blocks_multiply_const_vxx_0_0 - 0 - 0 - - - blocks_multiply_xx_0 - blocks_multiply_const_vxx_0_1 - 0 - 0 - - - blocks_multiply_xx_0 - blocks_multiply_const_vxx_0 - 0 - 0 - - - blks2_selector_0 - uhd_usrp_sink_0 - 0 - 0 - - - blocks_add_xx_0 - blks2_selector_0 - 0 - 2 - - - blocks_multiply_const_vxx_0_1 - blks2_selector_0 - 0 - 0 - - - blocks_multiply_const_vxx_0_1_0 - blks2_selector_0 - 0 - 1 - - - blocks_multiply_xx_0_0 - blocks_multiply_const_vxx_0_1_0 - 0 - 0 - - - blocks_multiply_const_vxx_0 - blocks_add_xx_0 - 0 - 0 - - - blocks_multiply_const_vxx_0_0 - blocks_add_xx_0 - 0 - 1 - - - AISTX_Build_Frame_0 - digital_gmsk_mod_0 - 0 - 0 - - - AISTX_Build_Frame_1 - digital_gmsk_mod_0_0 - 0 - 0 - -