Skip to content
Closed
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
8 changes: 7 additions & 1 deletion lib/toPgn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')) ||
Expand Down
2 changes: 1 addition & 1 deletion test/pgns/129794.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]
2 changes: 1 addition & 1 deletion test/pgns/129809.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]
2 changes: 1 addition & 1 deletion test/pgns/129810.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
]