Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# editors
[._]*.sw[a-p]

# build dirs
build/
124 changes: 88 additions & 36 deletions gr-aistx/CMakeLists.txt → CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
Expand All @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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
)
File renamed without changes.
20 changes: 17 additions & 3 deletions README
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@

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
Expand All @@ -9,8 +15,16 @@ The AIS Frame Builder block for GnuRadio c8b7018386f64dd725fde119f406
A NMEA encoder (binary to ASCII) (C version) 2534dc06c21fe53f45bd2abab96bb6a7 unpacker.c
A NMEA encoder (Perl version by Gary C. Kessler) 52ab60db06525f2230bb4de3ee61a34b unpacker.pl

$ mkdir build
$ cd build
$ cmake ../
$ make
$ sudo make install

Remember to install GnuRadio and gr-aistx first. A short description is included in each file's header.
Copyright 2013-2014 -- Embyte & Pastus

Good luck!
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.

7 changes: 4 additions & 3 deletions AIVDM_Encoder.py → apps/AIVDM_Encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
Loading