Skip to content

Commit

Permalink
Tread Heading events with undefined Reference as True
Browse files Browse the repository at this point in the history
Source is a yacht with a Cetrek 340 Chartnav, a 730 Pilot, and a 930580
Magnetic compass, feeding into Cetrek 2900 instruments.
  • Loading branch information
stefanor committed Dec 11, 2022
1 parent e8e2239 commit aab929d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pgns/127250.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ module.exports = [
node: 'navigation.headingTrue',
filter: function (n2k) {
return (
n2k.fields['Reference'] === 'True' &&
typeof n2k.fields['Heading'] !== 'undefined'
typeof n2k.fields['Heading'] !== 'undefined' && (
n2k.fields['Reference'] === 'True' ||
typeof n2k.fields['Reference'] === 'undefined'
)
)
}
},
Expand Down
13 changes: 13 additions & 0 deletions test/127250_heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,17 @@ describe('127250 Heading', function () {
)
// tree.should.be.validSignalKVesselIgnoringIdentity
})

it('Cetrek sentence converts', function () {
var tree = require('./testMapper').toNested(
JSON.parse(
'{"canId":233902663,"prio":3,"src":71,"dst":255,"pgn":127250,"timestamp":"2022-12-11T14:48:31.783Z","fields":{"Heading":6.2657},"description":"Vessel Heading"}'
)
)
tree.should.have.with.nested.property(
'navigation.headingTrue.value',
6.2657
)
tree.should.be.validSignalKVesselIgnoringIdentity
})
})

0 comments on commit aab929d

Please sign in to comment.