From 9a9026f3056da41fcf36e39687f2254ec7a4af79 Mon Sep 17 00:00:00 2001 From: Zach Hudson Date: Fri, 5 Jan 2018 09:43:07 -0800 Subject: [PATCH 1/3] 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 2/3] 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 3/3] 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; +} + + +