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

Added DEVID decoder for Sierra Wireless AVL #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions lib/NMEA.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var MWV = require("./codes/MWV.js");
var DBT = require("./codes/DBT.js");
var HDG = require("./codes/HDG.js");
var VHW = require("./codes/VHW.js");
var DEVID = require("./codes/DEVID.js");
var Helper = require("./Helper.js");

/** NMEA module */
Expand Down Expand Up @@ -185,6 +186,8 @@ var NMEA = ( function() {
nmea.addParser(new GLL.Decoder("GPGLL"));
nmea.addParser(new HDG.Decoder("HCHDG"));
nmea.addParser(new VHW.Decoder("VWVHW"));
// non-standard decoders
nmea.addParser(new DEVID.Decoder("DEVID"));
// add the standard encoders
nmea.addEncoder(new GGA.Encoder("GPGGA"));
nmea.addEncoder(new RMC.Encoder("GPRMC"));
Expand Down
36 changes: 36 additions & 0 deletions lib/codes/DEVID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Sierra Wireless GX 440 Device ID Parser
// $DEVID,0x0000028A003D2A10*40

var Helper = require("../Helper.js");

exports.Decoder = function(id) {
this.id = id;
this.talker_type_id = "DEVID";
this.talker_type_desc = "Device ID";

this.parse = function(tokens) {
if(tokens.length < 2) {
throw new Error('DEVID: not enough tokens');
}

// trim whitespace
// some parsers may not want the tokens trimmed so the individual parser has to do it if applicable
var i;
for(i=0;i<tokens.length;++i) {
tokens[i] = tokens[i].trim();
}

// Remove 0x to match the device id from the status page
var deviceId = Helper.encodeValue(tokens[1]);
if(deviceId.length > 2){
deviceId = deviceId.substr(2);
}

return {
id : tokens[0].substr(1),
talker_type_id: this.talker_type_id,
talker_type_desc: this.talker_type_desc,
device:deviceId
};
};
};