Skip to content

Commit

Permalink
fix: only the first pair of repeating fields in a 126720 pgn are read (
Browse files Browse the repository at this point in the history
  • Loading branch information
sbender9 authored Sep 25, 2023
1 parent 86102d4 commit 2f9854e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/fromPgn.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ class Parser extends EventEmitter {
})
}

const RepeatingFields = pgnData.RepeatingFieldSet1Size ? pgnData.RepeatingFieldSet1Size : 0

trace(`${pgn.pgn} ${len} ${pgnData.Length} ${RepeatingFields} ${couldBeMulti}`)
trace(`${pgn.pgn} ${len} ${pgnData.Length} ${couldBeMulti}`)
if ( coalesced || len > 0x8 || (this.format == FORMAT_COALESCED && !this.mixedFormat) ) {
this.format = FORMAT_COALESCED
if ( sourceString ) {
Expand Down Expand Up @@ -203,6 +201,8 @@ class Parser extends EventEmitter {
pgn.input = [ sourceString ]
}

let RepeatingFields = pgnData.RepeatingFieldSet1Size ? pgnData.RepeatingFieldSet1Size : 0

pgn.fields = {}
try {
var fields = pgnData.Fields
Expand Down Expand Up @@ -245,6 +245,7 @@ class Parser extends EventEmitter {
if ( value == null ) {
value = pgnData.Fields[i].Match
}
RepeatingFields = pgnData.RepeatingFieldSet1Size ? pgnData.RepeatingFieldSet1Size : 0
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/pgns/130824.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [{
"expected": {"timestamp":"2016-02-28T19:57:03.931Z","prio":2,"src":24,"dst":255,"pgn":130824,"description":"Maretron: Annunciator","fields":{"Manufacturer Code":"Maretron","Industry Code":"Marine Industry","Field 4":0,"Field 5":0,"Reserved1":null,"list":[]}},
"expected": {"timestamp":"2016-02-28T19:57:03.931Z","prio":2,"src":24,"dst":255,"pgn":130824,"description":"Maretron: Annunciator","fields":{"Manufacturer Code":"Maretron","Industry Code":"Marine Industry","Field 4":0,"Field 5":0,"Reserved1":null,"Field 6": null, "Field 7": null, "Field 8": null}},
"input": "2016-02-28T19:57:03.931Z,2,130824,24,255,9,89,98,00,00,ff,ff,ff,ff,ff"
}]

0 comments on commit 2f9854e

Please sign in to comment.