Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: timestamp should be in iso format when parsing $PCDIN sentences #14

Merged
merged 4 commits into from
Apr 19, 2018
Merged
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
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