Skip to content

Commit

Permalink
Bugfix/12 timestamp should be in iso format when parsing $PCDIN sente…
Browse files Browse the repository at this point in the history
…nces (#14)

fix: timestamp should be in iso format when parsing $PCDIN sentences
  • Loading branch information
sarfata authored and sbender9 committed Apr 19, 2018
1 parent 28ef60a commit 93026b1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 1 addition & 1 deletion lib/fromPgn.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class Parser extends EventEmitter {
// $PCDIN,01F119,00000000,0F,2AAF00D1067414FF*59

pgn.pgn = parseInt(split[1], 16)
pgn.timestamp = parseInt(split[2], 16)
pgn.timestamp = new Date(parseInt(split[2], 16)).toISOString()
pgn.src = parseInt(split[3], 16)
pgn.dst = 255
pgn.prio = 0
Expand Down
2 changes: 1 addition & 1 deletion test/pgns/129285.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test/pgns/130306-pcdin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = [{
"expected": {
// Note: analyzer produces timestamp in local time (not UTC) but this seems incorrect.
//"timestamp":"1969-12-31-16:00:00,3",
"timestamp":"1970-01-01T00:00:00.003Z",
"prio":0,"src":1,"dst":255,"pgn":130306,"description":"Wind Data",
"fields":{"SID":0,"Wind Speed":2.23,"Wind Angle":0.0966, "Reference":"Apparent"}
},
"input": "$PCDIN,01FD02,00000003,01,00DF00C603FAFFFF*20"
}]
10 changes: 7 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ describe('from pgn test data converts', function () {
fromPgn.on('pgn', (pgn) => {
try {
//console.log(JSON.stringify(data.expected))
delete pgn.timestamp
delete data.expected.timestamp

pgn.should.jsonEqual(data.expected)
done()
Expand Down Expand Up @@ -72,7 +70,13 @@ describe('to pgn test data converts', function () {
done()
return
}


if (test.input.startsWith("$PCDIN")) {
// PASS - No conversion to PCDIN available at the moment.
done()
return
}

var data = toPgn(test.expected)
var str = toActisenseSerialFormat(test.expected.pgn, data)

Expand Down

0 comments on commit 93026b1

Please sign in to comment.