From 5c53f4841e68ec70ce49f5ee58e4300cbfd93646 Mon Sep 17 00:00:00 2001 From: A1337CBS <47105599+A1337CBS@users.noreply.github.com> Date: Tue, 31 Dec 2019 14:27:08 +0300 Subject: [PATCH 1/3] bugfix, if framesize>168 then data is cutoff when using odd length for LEN_FRAME --- gr-aistx/lib/Build_Frame_impl.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gr-aistx/lib/Build_Frame_impl.cc b/gr-aistx/lib/Build_Frame_impl.cc index 2eb640c..66d4058 100644 --- a/gr-aistx/lib/Build_Frame_impl.cc +++ b/gr-aistx/lib/Build_Frame_impl.cc @@ -424,6 +424,9 @@ namespace gr { //// frame generation ///// int LEN_FRAME = LEN_PREAMBLE + LEN_START*2 + LEN_STUFFED_PAYLOAD; + //Make len_frame even + while(LEN_FRAME%8 != 0) + LEN_FRAME++; char frame[LEN_FRAME]; unsigned char byte_frame[LEN_FRAME/8]; //PASTA memset (frame, 0x0, LEN_FRAME); From 91bc81b14a742aae25f21a322d35d4a94a3e6ffa Mon Sep 17 00:00:00 2001 From: Marcel Verpaalen Date: Mon, 11 May 2020 12:26:45 +0200 Subject: [PATCH 2/3] Add navigation status --- AIVDM_Encoder.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/AIVDM_Encoder.py b/AIVDM_Encoder.py index b688c47..984f85a 100755 --- a/AIVDM_Encoder.py +++ b/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)) From 7bdfb564c96ccaa502aecc11c9b21a40f5cf6819 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 18 Aug 2020 14:21:47 +0200 Subject: [PATCH 3/3] Fix checksum for checksums <10 leading zero is missing in case of checksums <10 --- unpacker.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpacker.pl b/unpacker.pl index 409e93c..68339a8 100644 --- a/unpacker.pl +++ b/unpacker.pl @@ -149,7 +149,7 @@ sub nmea_checksum # Ensure that $sum is two upper-case hex digits - $sum = sprintf ("%2X", $sum); + $sum = sprintf ("%02X", $sum); return $sum; }