diff --git a/lib/toPgn.ts b/lib/toPgn.ts index be7ba2b..6233e66 100644 --- a/lib/toPgn.ts +++ b/lib/toPgn.ts @@ -551,9 +551,15 @@ fieldTypeWriters['BITLOOKUP'] = (pgn, field, value, bs) => { } } +// PGNs that carry AIS text. AIS pads its fixed-length text fields with '@' +// (ITU-R M.1371, Annex 8), and receivers strip that padding. Filling with 0xff +// instead leaves the fill bytes visible on some chart plotters, which render +// them as trailing spaces after the vessel name. +const AIS_STRING_PGNS = [129040, 129794, 129809, 129810] + fieldTypeWriters['STRING_FIX'] = (pgn, field, value, bs) => { if (field.BitLength !== undefined) { - let fill = 0xff + let fill = AIS_STRING_PGNS.includes(pgn) ? 0x40 : 0xff if ( (pgn === 129810 && (field.Name === 'Vendor ID' || field.Name === 'Callsign')) || diff --git a/test/pgns/129794.js b/test/pgns/129794.js index d64dc11..c5ea58c 100644 --- a/test/pgns/129794.js +++ b/test/pgns/129794.js @@ -32,6 +32,6 @@ module.exports = [ } }, input: - '2017-04-15T14:58:37.235Z,6,129794,43,255,75,05,4a,ac,e4,15,00,00,00,00,57,44,44,39,31,37,31,41,54,4c,41,4e,54,49,43,20,43,4f,41,53,54,ff,ff,ff,ff,ff,ff,34,2c,01,46,00,00,00,5a,00,b7,44,00,e6,df,0c,a4,01,42,41,4c,54,49,4d,4f,52,45,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,84,e1' + '2017-04-15T14:58:37.235Z,6,129794,43,255,75,05,4a,ac,e4,15,00,00,00,00,57,44,44,39,31,37,31,41,54,4c,41,4e,54,49,43,20,43,4f,41,53,54,40,40,40,40,40,40,34,2c,01,46,00,00,00,5a,00,b7,44,00,e6,df,0c,a4,01,42,41,4c,54,49,4d,4f,52,45,40,40,40,40,40,40,40,40,40,40,40,84,e1' } ] diff --git a/test/pgns/129809.js b/test/pgns/129809.js index c627fa6..9c1d39d 100644 --- a/test/pgns/129809.js +++ b/test/pgns/129809.js @@ -18,6 +18,6 @@ module.exports = [ description: 'AIS Class B static data (msg 24 Part A)' }, input: - '2019-04-15T15:16:46.572Z,6,129809,43,255,27,18,78,48,28,14,57,49,4c,48,45,4c,4d,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,ff,02,ff' + '2019-04-15T15:16:46.572Z,6,129809,43,255,27,18,78,48,28,14,57,49,4c,48,45,4c,4d,40,40,40,40,40,40,40,40,40,40,40,40,40,02,ff' } ] diff --git a/test/pgns/129810.js b/test/pgns/129810.js index e43bc8b..931fd68 100644 --- a/test/pgns/129810.js +++ b/test/pgns/129810.js @@ -27,6 +27,6 @@ module.exports = [ description: 'AIS Class B static data (msg 24 Part B)' }, input: - '2023-07-22T13:41:17.102Z,6,129810,43,255,35,18,b5,59,29,14,25,47,41,52,4d,49,4e,ff,40,40,40,40,40,40,40,8c,00,0e,01,fa,00,3c,00,b6,59,29,14,20,01,ff' + '2023-07-22T13:41:17.102Z,6,129810,43,255,35,18,b5,59,29,14,25,47,41,52,4d,49,4e,40,40,40,40,40,40,40,40,8c,00,0e,01,fa,00,3c,00,b6,59,29,14,20,01,ff' } ]