Check for invalid speed values in Hydronav header.

Related to #206. If this is indeed what is causing the alerts,
we will change the logic so that it simply logs (or ignores)
invalid speeds rather than throwing.
This commit is contained in:
D. Berge
2022-05-02 13:09:43 +02:00
parent af6e419aab
commit 10883eb1a6

View File

@@ -97,6 +97,9 @@ function parse (buffer) {
// (we convert to metres per second)
(buf, ctx) => {
ctx.speed = Number(buf.subarray(s+80, s+80+6).toString('ascii'));
if (isNaN(ctx.speed)) {
throw NavHeaderError("Unparseable speed value: "+buf.subarray(s+80, s+80+6).toString('ascii'), buf);
}
const units = buf.subarray(s+86, s+86+2).toString('ascii');
switch (units.toUpperCase()) {
case "KT":