extended-nmea
Version:
A TypeScript library for parsing NMEA0183-like sentences with support for custom and proprietary sentences.
35 lines • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProprietarySentence = void 0;
const ChecksumSentence_1 = require("./ChecksumSentence");
const NmeaSentence_1 = require("./NmeaSentence");
const SentenceType_1 = require("../SentenceType");
class ProprietarySentence extends ChecksumSentence_1.ChecksumSentence {
/**
* Create a NMEA0183 "proprietary sentence" from a string and an optional talker id length.
*
* @param data The line to interpret as an NMEA0183 proprietary sentence. Can be an existing NMEA sentence.
* @param manufacturerId The manufacturer id in this sentence. Usually three characters.
* @param prefix The prefix to use when validating the sentence. The prefix will be prepended to the manufacturer id.
* This means by default for manufacturer id "GRMC" the prefix "$PGRMC" will be used for validation.
* @param suffix The suffix to use when validating the sentence.
*/
constructor(data, manufacturerId, prefix = ProprietarySentence.Prefix, suffix = NmeaSentence_1.NmeaSentence.Suffix) {
super(data, SentenceType_1.SentenceType.Proprietary, prefix + manufacturerId, suffix);
this.manufacturerId = manufacturerId;
}
/**
* Returns all characters between "$P" + the manufacturer id and "<CR><LF>".
*/
get dataNoFixtures() {
// Need to add prefix.length + 1 so the first "," is also cut away.
// This means "$PTEST,123,456<CR><LF>" becomes "123,456".
return this.raw.slice(this.prefix.length + 1, -this.suffix.length);
}
}
exports.ProprietarySentence = ProprietarySentence;
/**
* Each proprietary NMEA0183 sentence starts with "$P".
*/
ProprietarySentence.Prefix = "$P";
//# sourceMappingURL=ProprietarySentence.js.map