diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/lib/fromPgn.js b/lib/fromPgn.js index f4a090d..f349e69 100644 --- a/lib/fromPgn.js +++ b/lib/fromPgn.js @@ -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 diff --git a/test/pgns/129285.js b/test/pgns/129285.js index cdeaed6..fac286a 100644 --- a/test/pgns/129285.js +++ b/test/pgns/129285.js @@ -1,4 +1,4 @@ module.exports = [{ - "expected": {"timestamp":"2017-04-15T14:57:58.470Z","prio":6,"src":3,"dst":255,"pgn":129285,"description":"Navigation - Route/WP Information","fields":{"Start RPS#":1,"nItems":3,"Database ID":0,"Route ID":0,"Supplementary Route/WP data available":1,"Route Name":"Route","list":[{"WP ID":1,"WP Name":"ORIGIN","WP Latitude":39.0763753,"WP Longitude":-76.4780091},{"WP ID":2,"WP Name":"Waypoint 165","WP Latitude":39.0554743,"WP Longitude":-76.4316303},{"WP ID":3,"WP Name":"Waypoint 166","WP Latitude":39.0545567,"WP Longitude":-76.4221445}]}}, + "expected": {"timestamp":"2018-01-26T20:06:39.369Z","prio":6,"src":3,"dst":255,"pgn":129285,"description":"Navigation - Route/WP Information","fields":{"Start RPS#":1,"nItems":3,"Database ID":0,"Route ID":0,"Supplementary Route/WP data available":1,"Route Name":"Route","list":[{"WP ID":1,"WP Name":"ORIGIN","WP Latitude":39.0763753,"WP Longitude":-76.4780091},{"WP ID":2,"WP Name":"Waypoint 165","WP Latitude":39.0554743,"WP Longitude":-76.4316303},{"WP ID":3,"WP Name":"Waypoint 166","WP Latitude":39.0545567,"WP Longitude":-76.4221445}]}}, "input": "2018-01-26T20:06:39.369Z,6,129285,3,255,83,01,00,03,00,00,00,00,00,f7,02,52,6f,75,74,65,01,ff,01,00,02,4f,52,49,47,49,4e,01,e9,94,4a,17,c5,61,6a,d2,02,00,02,57,61,79,70,6f,69,6e,74,20,31,36,35,01,77,64,47,17,71,75,71,d2,03,00,02,57,61,79,70,6f,69,6e,74,20,31,36,36,01,9f,40,47,17,fb,e7,72,d2" }] diff --git a/test/pgns/130306-pcdin.js b/test/pgns/130306-pcdin.js new file mode 100644 index 0000000..5112053 --- /dev/null +++ b/test/pgns/130306-pcdin.js @@ -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" +}] diff --git a/test/test.js b/test/test.js index 3e89932..2257c21 100644 --- a/test/test.js +++ b/test/test.js @@ -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() @@ -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)