@jbroll/nmea-simple
Advanced tools
Comparing version
@@ -30,13 +30,11 @@ /* | ||
import { parseFloatSafe, parseIntSafe } from "../helpers"; | ||
import { adjustPRN } from "../prn-utils"; | ||
import { initStubFields, PacketStub } from "./PacketStub"; | ||
export const sentenceId: "GSA" = "GSA"; | ||
export const sentenceName = "Active satellites and dilution of precision"; | ||
export type ThreeDFixType = "unknown" | "none" | "2D" | "3D"; | ||
const ThreeDFixTypes: ThreeDFixType[] = [ "unknown", "none", "2D", "3D" ]; | ||
export interface GSAPacket extends PacketStub<typeof sentenceId> { | ||
@@ -49,12 +47,14 @@ selectionMode: "automatic" | "manual"; | ||
VDOP: number; | ||
systemId: number; | ||
} | ||
export function decodeSentence(stub: PacketStub, fields: string[]): GSAPacket { | ||
const sats: number[] = []; | ||
const systemId = fields.length > 18 ? parseIntSafe(fields[18]) : 0; | ||
for (let i = 3; i < 15; i++) { | ||
if (fields[i]) { | ||
sats.push(+fields[i]); | ||
const rawPrn = parseIntSafe(fields[i]); | ||
if (rawPrn > 0) { | ||
sats.push(adjustPRN(rawPrn, systemId)); | ||
} | ||
} | ||
@@ -70,5 +70,5 @@ } | ||
HDOP: parseFloatSafe(fields[16]), | ||
VDOP: parseFloatSafe(fields[17]), | ||
systemId: fields.length > 18 ? parseInt(fields[18], 10) : 0 | ||
VDOP: parseFloatSafe(fields[17]) | ||
}; | ||
} | ||
@@ -46,2 +46,3 @@ /* | ||
import { parseIntSafe } from "../helpers"; | ||
import { adjustPRN, getTalkerSystemId } from "../prn-utils"; | ||
import { initStubFields, PacketStub } from "./PacketStub"; | ||
@@ -64,3 +65,2 @@ | ||
satellites: Satellite[]; | ||
signalId: string; | ||
} | ||
@@ -72,2 +72,3 @@ | ||
const sats: Satellite[] = []; | ||
const systemId = getTalkerSystemId(stub.talkerId || ""); | ||
@@ -79,6 +80,7 @@ // Process satellite records | ||
// Only add satellites with valid PRN numbers | ||
const prn = parseIntSafe(fields[offset]); | ||
if (prn > 0) { | ||
const rawPrn = parseIntSafe(fields[offset]); | ||
if (rawPrn > 0) { | ||
const adjustedPrn = adjustPRN(rawPrn, systemId); | ||
sats.push({ | ||
prnNumber: prn, | ||
prnNumber: adjustedPrn, | ||
elevationDegrees: parseIntSafe(fields[offset + 1]), | ||
@@ -101,6 +103,5 @@ azimuthTrue: parseIntSafe(fields[offset + 2]), | ||
satellitesInView: parseIntSafe(fields[3]), | ||
satellites: sats, | ||
signalId | ||
satellites: sats | ||
}; | ||
} | ||
@@ -12,4 +12,3 @@ import { PacketStub } from "./PacketStub"; | ||
VDOP: number; | ||
systemId: number; | ||
} | ||
export declare function decodeSentence(stub: PacketStub, fields: string[]): GSAPacket; |
@@ -42,2 +42,3 @@ "use strict"; | ||
var helpers_1 = require("../helpers"); | ||
var prn_utils_1 = require("../prn-utils"); | ||
var PacketStub_1 = require("./PacketStub"); | ||
@@ -49,9 +50,13 @@ exports.sentenceId = "GSA"; | ||
var sats = []; | ||
var systemId = fields.length > 18 ? helpers_1.parseIntSafe(fields[18]) : 0; | ||
for (var i = 3; i < 15; i++) { | ||
if (fields[i]) { | ||
sats.push(+fields[i]); | ||
var rawPrn = helpers_1.parseIntSafe(fields[i]); | ||
if (rawPrn > 0) { | ||
sats.push(prn_utils_1.adjustPRN(rawPrn, systemId)); | ||
} | ||
} | ||
} | ||
return __assign(__assign({}, PacketStub_1.initStubFields(stub, exports.sentenceId, exports.sentenceName)), { selectionMode: fields[1] === "A" ? "automatic" : "manual", fixMode: ThreeDFixTypes[helpers_1.parseIntSafe(fields[2])], satellites: sats, PDOP: helpers_1.parseFloatSafe(fields[15]), HDOP: helpers_1.parseFloatSafe(fields[16]), VDOP: helpers_1.parseFloatSafe(fields[17]), systemId: fields.length > 18 ? parseInt(fields[18], 10) : 0 }); | ||
return __assign(__assign({}, PacketStub_1.initStubFields(stub, exports.sentenceId, exports.sentenceName)), { selectionMode: fields[1] === "A" ? "automatic" : "manual", fixMode: ThreeDFixTypes[helpers_1.parseIntSafe(fields[2])], satellites: sats, PDOP: helpers_1.parseFloatSafe(fields[15]), HDOP: helpers_1.parseFloatSafe(fields[16]), VDOP: helpers_1.parseFloatSafe(fields[17]) }); | ||
} | ||
exports.decodeSentence = decodeSentence; |
@@ -15,4 +15,3 @@ import { PacketStub } from "./PacketStub"; | ||
satellites: Satellite[]; | ||
signalId: string; | ||
} | ||
export declare function decodeSentence(stub: PacketStub, fields: string[]): GSVPacket; |
@@ -58,2 +58,3 @@ "use strict"; | ||
var helpers_1 = require("../helpers"); | ||
var prn_utils_1 = require("../prn-utils"); | ||
var PacketStub_1 = require("./PacketStub"); | ||
@@ -66,2 +67,3 @@ exports.sentenceId = "GSV"; | ||
var sats = []; | ||
var systemId = prn_utils_1.getTalkerSystemId(stub.talkerId || ""); | ||
// Process satellite records | ||
@@ -71,6 +73,7 @@ for (var i = 0; i < numRecords; i++) { | ||
// Only add satellites with valid PRN numbers | ||
var prn = helpers_1.parseIntSafe(fields[offset]); | ||
if (prn > 0) { | ||
var rawPrn = helpers_1.parseIntSafe(fields[offset]); | ||
if (rawPrn > 0) { | ||
var adjustedPrn = prn_utils_1.adjustPRN(rawPrn, systemId); | ||
sats.push({ | ||
prnNumber: prn, | ||
prnNumber: adjustedPrn, | ||
elevationDegrees: helpers_1.parseIntSafe(fields[offset + 1]), | ||
@@ -86,4 +89,4 @@ azimuthTrue: helpers_1.parseIntSafe(fields[offset + 2]), | ||
var signalId = fields.length > expectedSatelliteFields ? fields[fields.length - 1] : "0"; | ||
return __assign(__assign({}, PacketStub_1.initStubFields(stub, exports.sentenceId, exports.sentenceName)), { numberOfMessages: helpers_1.parseIntSafe(fields[1]), messageNumber: helpers_1.parseIntSafe(fields[2]), satellitesInView: helpers_1.parseIntSafe(fields[3]), satellites: sats, signalId: signalId }); | ||
return __assign(__assign({}, PacketStub_1.initStubFields(stub, exports.sentenceId, exports.sentenceName)), { numberOfMessages: helpers_1.parseIntSafe(fields[1]), messageNumber: helpers_1.parseIntSafe(fields[2]), satellitesInView: helpers_1.parseIntSafe(fields[3]), satellites: sats }); | ||
} | ||
exports.decodeSentence = decodeSentence; |
@@ -6,16 +6,15 @@ "use strict"; | ||
describe("GSA", function () { | ||
it("parser", function () { | ||
it("parses basic packet without system ID", function () { | ||
var packet = index_1.parseNmeaSentence("$GPGSA,A,3,12,05,25,29,,,,,,,,,9.4,7.6,5.6*37"); | ||
packet.should.have.property("sentenceId", "GSA"); | ||
packet.should.have.property("sentenceName", "Active satellites and dilution of precision"); | ||
packet.should.have.property("talkerId", "GP"); | ||
packet.should.have.property("selectionMode", "automatic"); | ||
packet.should.have.property("fixMode", "3D"); | ||
packet.should.have.property("satellites", [12, 5, 25, 29]); | ||
packet.should.have.property("satellites").with.lengthOf(4); | ||
packet.satellites.should.containDeep([12, 5, 25, 29]); // GPS PRNs (no offset needed) | ||
packet.should.have.property("PDOP", 9.4); | ||
packet.should.have.property("HDOP", 7.6); | ||
packet.should.have.property("VDOP", 5.6); | ||
packet.should.have.property("systemId", 0); // Default system ID when not provided | ||
}); | ||
it("parses different system IDs", function () { | ||
describe("parses different constellation packets", function () { | ||
var packets = [ | ||
@@ -26,21 +25,25 @@ index_1.parseNmeaSentence("$GNGSA,A,3,28,26,04,09,16,27,31,08,,,,,1.33,0.74,1.10,1*08"), | ||
]; | ||
// GPS constellation | ||
packets[0].should.have.property("systemId", 1); | ||
packets[0].should.have.property("satellites").with.lengthOf(8); | ||
packets[0].satellites.should.containDeep([28, 26, 4, 9, 16, 27, 31, 8]); | ||
// GLONASS constellation | ||
packets[1].should.have.property("systemId", 2); | ||
packets[1].should.have.property("satellites").with.lengthOf(5); | ||
packets[1].satellites.should.containDeep([73, 74, 82, 71, 72]); | ||
// Galileo constellation | ||
packets[2].should.have.property("systemId", 4); | ||
packets[2].should.have.property("satellites").with.lengthOf(5); | ||
packets[2].satellites.should.containDeep([14, 24, 25, 35, 33]); | ||
// All packets should have the same DOP values | ||
packets.forEach(function (packet) { | ||
packet.should.have.property("PDOP", 1.33); | ||
packet.should.have.property("HDOP", 0.74); | ||
packet.should.have.property("VDOP", 1.10); | ||
it("handles GPS constellation correctly", function () { | ||
var gps = packets[0]; | ||
gps.should.have.property("satellites").with.lengthOf(8); | ||
gps.satellites.should.containDeep([28, 26, 4, 9, 16, 27, 31, 8]); // GPS PRNs (no offset) | ||
}); | ||
it("handles GLONASS constellation correctly", function () { | ||
var glonass = packets[1]; | ||
glonass.should.have.property("satellites").with.lengthOf(5); | ||
glonass.satellites.should.containDeep([73, 74, 82, 71, 72]); // GLONASS PRNs (no offset) | ||
}); | ||
it("handles Galileo constellation correctly", function () { | ||
var galileo = packets[2]; | ||
galileo.should.have.property("satellites").with.lengthOf(5); | ||
galileo.satellites.should.containDeep([114, 124, 125, 135, 133]); // Galileo PRNs (+100) | ||
}); | ||
it("maintains consistent DOP values", function () { | ||
packets.forEach(function (packet) { | ||
packet.should.have.property("PDOP", 1.33); | ||
packet.should.have.property("HDOP", 0.74); | ||
packet.should.have.property("VDOP", 1.10); | ||
}); | ||
}); | ||
}); | ||
}); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("should"); | ||
var helpers_1 = require("../helpers"); | ||
var index_1 = require("../index"); | ||
describe("GSV", function () { | ||
it("parses first sentence", function () { | ||
var packet = index_1.parseNmeaSentence("$GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74 $GPGSV,3,2,11,14,25,170,00,16,57,208,39,18,67,296,40,19,40,246,00*2D"); | ||
it("parses GPS satellites correctly", function () { | ||
var packet = index_1.parseNmeaSentence("$GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74"); | ||
packet.should.have.property("sentenceId", "GSV"); | ||
packet.should.have.property("sentenceName", "Satellites in view"); | ||
packet.should.have.property("talkerId", "GP"); | ||
@@ -14,6 +14,2 @@ packet.should.have.property("numberOfMessages", 3); | ||
packet.should.have.property("satellitesInView", 11); | ||
packet.should.have.property("satellites"); | ||
if (packet.sentenceId !== "GSV") { | ||
return; | ||
} | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(4); | ||
@@ -45,34 +41,104 @@ packet.satellites[0].should.deepEqual({ | ||
}); | ||
it("parses next sentence", function () { | ||
var packet = index_1.parseNmeaSentence("$GPGSV,3,3,11,14,25,170,00,16,57,208,39,18,67,296,40*49"); | ||
it("parses Galileo satellites correctly", function () { | ||
var sentence = helpers_1.appendChecksumFooter("$GAGSV,3,1,09,02,15,208,35,03,71,344,32,08,41,147,33,11,25,233,34"); | ||
var packet = index_1.parseNmeaSentence(sentence); | ||
packet.should.have.property("sentenceId", "GSV"); | ||
packet.should.have.property("sentenceName", "Satellites in view"); | ||
packet.should.have.property("talkerId", "GP"); | ||
packet.should.have.property("talkerId", "GA"); | ||
packet.should.have.property("numberOfMessages", 3); | ||
packet.should.have.property("messageNumber", 3); | ||
packet.should.have.property("satellitesInView", 11); | ||
packet.should.have.property("satellites"); | ||
if (packet.sentenceId !== "GSV") { | ||
return; | ||
} | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(3); | ||
packet.should.have.property("messageNumber", 1); | ||
packet.should.have.property("satellitesInView", 9); | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(4); | ||
packet.satellites[0].should.deepEqual({ | ||
prnNumber: 14, | ||
prnNumber: 102, | ||
elevationDegrees: 15, | ||
azimuthTrue: 208, | ||
SNRdB: 35 | ||
}); | ||
packet.satellites[1].should.deepEqual({ | ||
prnNumber: 103, | ||
elevationDegrees: 71, | ||
azimuthTrue: 344, | ||
SNRdB: 32 | ||
}); | ||
packet.satellites[2].should.deepEqual({ | ||
prnNumber: 108, | ||
elevationDegrees: 41, | ||
azimuthTrue: 147, | ||
SNRdB: 33 | ||
}); | ||
packet.satellites[3].should.deepEqual({ | ||
prnNumber: 111, | ||
elevationDegrees: 25, | ||
azimuthTrue: 170, | ||
SNRdB: 0 | ||
azimuthTrue: 233, | ||
SNRdB: 34 | ||
}); | ||
}); | ||
it("parses GLONASS satellites correctly", function () { | ||
var sentence = helpers_1.appendChecksumFooter("$GLGSV,2,1,08,73,42,069,43,74,35,124,42,84,81,197,39,85,27,309,41"); | ||
var packet = index_1.parseNmeaSentence(sentence); | ||
packet.should.have.property("sentenceId", "GSV"); | ||
packet.should.have.property("talkerId", "GL"); | ||
packet.should.have.property("numberOfMessages", 2); | ||
packet.should.have.property("messageNumber", 1); | ||
packet.should.have.property("satellitesInView", 8); | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(4); | ||
packet.satellites[0].should.deepEqual({ | ||
prnNumber: 73, | ||
elevationDegrees: 42, | ||
azimuthTrue: 69, | ||
SNRdB: 43 | ||
}); | ||
packet.satellites[1].should.deepEqual({ | ||
prnNumber: 16, | ||
elevationDegrees: 57, | ||
azimuthTrue: 208, | ||
prnNumber: 74, | ||
elevationDegrees: 35, | ||
azimuthTrue: 124, | ||
SNRdB: 42 | ||
}); | ||
packet.satellites[2].should.deepEqual({ | ||
prnNumber: 84, | ||
elevationDegrees: 81, | ||
azimuthTrue: 197, | ||
SNRdB: 39 | ||
}); | ||
packet.satellites[3].should.deepEqual({ | ||
prnNumber: 85, | ||
elevationDegrees: 27, | ||
azimuthTrue: 309, | ||
SNRdB: 41 | ||
}); | ||
}); | ||
it("parses BeiDou satellites correctly", function () { | ||
var sentence = helpers_1.appendChecksumFooter("$GBGSV,2,1,05,03,42,069,43,04,35,124,42,07,81,197,39,09,27,309,41"); | ||
var packet = index_1.parseNmeaSentence(sentence); | ||
packet.should.have.property("sentenceId", "GSV"); | ||
packet.should.have.property("talkerId", "GB"); | ||
packet.should.have.property("numberOfMessages", 2); | ||
packet.should.have.property("messageNumber", 1); | ||
packet.should.have.property("satellitesInView", 5); | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(4); | ||
packet.satellites[0].should.deepEqual({ | ||
prnNumber: 203, | ||
elevationDegrees: 42, | ||
azimuthTrue: 69, | ||
SNRdB: 43 | ||
}); | ||
packet.satellites[1].should.deepEqual({ | ||
prnNumber: 204, | ||
elevationDegrees: 35, | ||
azimuthTrue: 124, | ||
SNRdB: 42 | ||
}); | ||
packet.satellites[2].should.deepEqual({ | ||
prnNumber: 18, | ||
elevationDegrees: 67, | ||
azimuthTrue: 296, | ||
SNRdB: 40 | ||
prnNumber: 207, | ||
elevationDegrees: 81, | ||
azimuthTrue: 197, | ||
SNRdB: 39 | ||
}); | ||
packet.satellites[3].should.deepEqual({ | ||
prnNumber: 209, | ||
elevationDegrees: 27, | ||
azimuthTrue: 309, | ||
SNRdB: 41 | ||
}); | ||
}); | ||
}); |
{ | ||
"name": "@jbroll/nmea-simple", | ||
"version": "3.3.4-rc.0", | ||
"version": "3.3.4-rc.1", | ||
"homepage": "https://github.com/jbroll/nmea-simple", | ||
@@ -5,0 +5,0 @@ "description": "NMEA 0183 sentence parser and encoder", |
import "should"; | ||
import { parseNmeaSentence, GSVPacket } from "../index"; | ||
import { parseNmeaSentence, GSAPacket } from "../index"; | ||
describe("GSA", (): void => { | ||
it("parses basic packet without system ID", (): void => { | ||
const packet = parseNmeaSentence("$GPGSA,A,3,12,05,25,29,,,,,,,,,9.4,7.6,5.6*37") as GSVPacket; | ||
it("parser", (): void => { | ||
const packet = parseNmeaSentence("$GPGSA,A,3,12,05,25,29,,,,,,,,,9.4,7.6,5.6*37"); | ||
packet.should.have.property("sentenceId", "GSA"); | ||
packet.should.have.property("sentenceName", "Active satellites and dilution of precision"); | ||
packet.should.have.property("talkerId", "GP"); | ||
packet.should.have.property("selectionMode", "automatic"); | ||
packet.should.have.property("fixMode", "3D"); | ||
packet.should.have.property("satellites", [ 12, 5, 25, 29 ]); | ||
packet.should.have.property("PDOP", 9.4); | ||
packet.should.have.property("HDOP", 7.6); | ||
packet.should.have.property("VDOP", 5.6); | ||
packet.should.have.property("systemId", 0); // Default system ID when not provided | ||
packet.should.have.property("sentenceId", "GSA"); | ||
packet.should.have.property("talkerId", "GP"); | ||
packet.should.have.property("selectionMode", "automatic"); | ||
packet.should.have.property("fixMode", "3D"); | ||
packet.should.have.property("satellites").with.lengthOf(4); | ||
packet.satellites.should.containDeep([12, 5, 25, 29]); // GPS PRNs (no offset needed) | ||
packet.should.have.property("PDOP", 9.4); | ||
packet.should.have.property("HDOP", 7.6); | ||
packet.should.have.property("VDOP", 5.6); | ||
}); | ||
it("parses different system IDs", (): void => { | ||
const packets = [ | ||
parseNmeaSentence("$GNGSA,A,3,28,26,04,09,16,27,31,08,,,,,1.33,0.74,1.10,1*08"), | ||
parseNmeaSentence("$GNGSA,A,3,73,74,82,71,72,,,,,,,,1.33,0.74,1.10,2*0E"), | ||
parseNmeaSentence("$GNGSA,A,3,14,24,25,35,33,,,,,,,,1.33,0.74,1.10,4*04") | ||
] as GSAPacket[]; | ||
describe("parses different constellation packets", (): void => { | ||
const packets = [ | ||
parseNmeaSentence("$GNGSA,A,3,28,26,04,09,16,27,31,08,,,,,1.33,0.74,1.10,1*08"), | ||
parseNmeaSentence("$GNGSA,A,3,73,74,82,71,72,,,,,,,,1.33,0.74,1.10,2*0E"), | ||
parseNmeaSentence("$GNGSA,A,3,14,24,25,35,33,,,,,,,,1.33,0.74,1.10,4*04") | ||
] as GSVPacket[]; | ||
// GPS constellation | ||
packets[0].should.have.property("systemId", 1); | ||
packets[0].should.have.property("satellites").with.lengthOf(8); | ||
packets[0].satellites.should.containDeep([28, 26, 4, 9, 16, 27, 31, 8]); | ||
it("handles GPS constellation correctly", (): void => { | ||
const gps = packets[0]; | ||
gps.should.have.property("satellites").with.lengthOf(8); | ||
gps.satellites.should.containDeep([28, 26, 4, 9, 16, 27, 31, 8]); // GPS PRNs (no offset) | ||
}); | ||
// GLONASS constellation | ||
packets[1].should.have.property("systemId", 2); | ||
packets[1].should.have.property("satellites").with.lengthOf(5); | ||
packets[1].satellites.should.containDeep([73, 74, 82, 71, 72]); | ||
it("handles GLONASS constellation correctly", (): void => { | ||
const glonass = packets[1]; | ||
glonass.should.have.property("satellites").with.lengthOf(5); | ||
glonass.satellites.should.containDeep([73, 74, 82, 71, 72]); // GLONASS PRNs (no offset) | ||
}); | ||
// Galileo constellation | ||
packets[2].should.have.property("systemId", 4); | ||
packets[2].should.have.property("satellites").with.lengthOf(5); | ||
packets[2].satellites.should.containDeep([14, 24, 25, 35, 33]); | ||
it("handles Galileo constellation correctly", (): void => { | ||
const galileo = packets[2]; | ||
galileo.should.have.property("satellites").with.lengthOf(5); | ||
galileo.satellites.should.containDeep([114, 124, 125, 135, 133]); // Galileo PRNs (+100) | ||
}); | ||
// All packets should have the same DOP values | ||
packets.forEach((packet) => { | ||
packet.should.have.property("PDOP", 1.33); | ||
packet.should.have.property("HDOP", 0.74); | ||
packet.should.have.property("VDOP", 1.10); | ||
}); | ||
it("maintains consistent DOP values", (): void => { | ||
packets.forEach((packet) => { | ||
packet.should.have.property("PDOP", 1.33); | ||
packet.should.have.property("HDOP", 0.74); | ||
packet.should.have.property("VDOP", 1.10); | ||
}); | ||
}); | ||
}); | ||
}); | ||
import "should"; | ||
import { appendChecksumFooter } from "../helpers"; | ||
import { parseNmeaSentence, GSVPacket } from "../index"; | ||
import { parseNmeaSentence } from "../index"; | ||
describe("GSV", (): void => { | ||
it("parses GPS satellites correctly", (): void => { | ||
const packet = parseNmeaSentence("$GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74") as GSVPacket; | ||
packet.should.have.property("sentenceId", "GSV"); | ||
packet.should.have.property("talkerId", "GP"); | ||
packet.should.have.property("numberOfMessages", 3); | ||
packet.should.have.property("messageNumber", 1); | ||
packet.should.have.property("satellitesInView", 11); | ||
describe("GSV", (): void => { | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(4); | ||
packet.satellites[0].should.deepEqual({ | ||
prnNumber: 3, // GPS PRN (no offset) | ||
elevationDegrees: 3, | ||
azimuthTrue: 111, | ||
SNRdB: 0 | ||
}); | ||
packet.satellites[1].should.deepEqual({ | ||
prnNumber: 4, | ||
elevationDegrees: 15, | ||
azimuthTrue: 270, | ||
SNRdB: 0 | ||
}); | ||
packet.satellites[2].should.deepEqual({ | ||
prnNumber: 6, | ||
elevationDegrees: 1, | ||
azimuthTrue: 10, | ||
SNRdB: 0 | ||
}); | ||
packet.satellites[3].should.deepEqual({ | ||
prnNumber: 13, | ||
elevationDegrees: 6, | ||
azimuthTrue: 292, | ||
SNRdB: 0 | ||
}); | ||
}); | ||
it("parses first sentence", (): void => { | ||
const packet = parseNmeaSentence("$GPGSV,3,1,11,03,03,111,00,04,15,270,00,06,01,010,00,13,06,292,00*74 $GPGSV,3,2,11,14,25,170,00,16,57,208,39,18,67,296,40,19,40,246,00*2D"); | ||
packet.should.have.property("sentenceId", "GSV"); | ||
packet.should.have.property("sentenceName", "Satellites in view"); | ||
packet.should.have.property("talkerId", "GP"); | ||
packet.should.have.property("numberOfMessages", 3); | ||
packet.should.have.property("messageNumber", 1); | ||
packet.should.have.property("satellitesInView", 11); | ||
packet.should.have.property("satellites"); | ||
it("parses Galileo satellites correctly", (): void => { | ||
const sentence = appendChecksumFooter("$GAGSV,3,1,09,02,15,208,35,03,71,344,32,08,41,147,33,11,25,233,34"); | ||
const packet = parseNmeaSentence(sentence) as GSVPacket; | ||
if (packet.sentenceId !== "GSV") { return; } | ||
packet.should.have.property("sentenceId", "GSV"); | ||
packet.should.have.property("talkerId", "GA"); | ||
packet.should.have.property("numberOfMessages", 3); | ||
packet.should.have.property("messageNumber", 1); | ||
packet.should.have.property("satellitesInView", 9); | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(4); | ||
packet.satellites[0].should.deepEqual({ | ||
prnNumber: 3, | ||
elevationDegrees: 3, | ||
azimuthTrue: 111, | ||
SNRdB: 0 | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(4); | ||
packet.satellites[0].should.deepEqual({ | ||
prnNumber: 102, // Galileo PRN (offset by +100) | ||
elevationDegrees: 15, | ||
azimuthTrue: 208, | ||
SNRdB: 35 | ||
}); | ||
packet.satellites[1].should.deepEqual({ | ||
prnNumber: 103, // Galileo PRN (offset by +100) | ||
elevationDegrees: 71, | ||
azimuthTrue: 344, | ||
SNRdB: 32 | ||
}); | ||
packet.satellites[2].should.deepEqual({ | ||
prnNumber: 108, // Galileo PRN (offset by +100) | ||
elevationDegrees: 41, | ||
azimuthTrue: 147, | ||
SNRdB: 33 | ||
}); | ||
packet.satellites[3].should.deepEqual({ | ||
prnNumber: 111, // Galileo PRN (offset by +100) | ||
elevationDegrees: 25, | ||
azimuthTrue: 233, | ||
SNRdB: 34 | ||
}); | ||
}); | ||
packet.satellites[1].should.deepEqual({ | ||
prnNumber: 4, | ||
elevationDegrees: 15, | ||
azimuthTrue: 270, | ||
SNRdB: 0 | ||
it("parses GLONASS satellites correctly", (): void => { | ||
const sentence = appendChecksumFooter("$GLGSV,2,1,08,73,42,069,43,74,35,124,42,84,81,197,39,85,27,309,41"); | ||
const packet = parseNmeaSentence(sentence) as GSVPacket; | ||
packet.should.have.property("sentenceId", "GSV"); | ||
packet.should.have.property("talkerId", "GL"); | ||
packet.should.have.property("numberOfMessages", 2); | ||
packet.should.have.property("messageNumber", 1); | ||
packet.should.have.property("satellitesInView", 8); | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(4); | ||
packet.satellites[0].should.deepEqual({ | ||
prnNumber: 73, // GLONASS PRN (no offset) | ||
elevationDegrees: 42, | ||
azimuthTrue: 69, | ||
SNRdB: 43 | ||
}); | ||
packet.satellites[1].should.deepEqual({ | ||
prnNumber: 74, // GLONASS PRN (no offset) | ||
elevationDegrees: 35, | ||
azimuthTrue: 124, | ||
SNRdB: 42 | ||
}); | ||
packet.satellites[2].should.deepEqual({ | ||
prnNumber: 84, | ||
elevationDegrees: 81, | ||
azimuthTrue: 197, | ||
SNRdB: 39 | ||
}); | ||
packet.satellites[3].should.deepEqual({ | ||
prnNumber: 85, | ||
elevationDegrees: 27, | ||
azimuthTrue: 309, | ||
SNRdB: 41 | ||
}); | ||
}); | ||
packet.satellites[2].should.deepEqual({ | ||
prnNumber: 6, | ||
elevationDegrees: 1, | ||
azimuthTrue: 10, | ||
SNRdB: 0 | ||
}); | ||
packet.satellites[3].should.deepEqual({ | ||
prnNumber: 13, | ||
elevationDegrees: 6, | ||
azimuthTrue: 292, | ||
SNRdB: 0 | ||
}); | ||
}); | ||
it("parses next sentence", (): void => { | ||
const packet = parseNmeaSentence("$GPGSV,3,3,11,14,25,170,00,16,57,208,39,18,67,296,40*49"); | ||
it("parses BeiDou satellites correctly", (): void => { | ||
const sentence = appendChecksumFooter("$GBGSV,2,1,05,03,42,069,43,04,35,124,42,07,81,197,39,09,27,309,41"); | ||
const packet = parseNmeaSentence(sentence) as GSVPacket; | ||
packet.should.have.property("sentenceId", "GSV"); | ||
packet.should.have.property("sentenceName", "Satellites in view"); | ||
packet.should.have.property("talkerId", "GP"); | ||
packet.should.have.property("numberOfMessages", 3); | ||
packet.should.have.property("messageNumber", 3); | ||
packet.should.have.property("satellitesInView", 11); | ||
packet.should.have.property("satellites"); | ||
packet.should.have.property("sentenceId", "GSV"); | ||
packet.should.have.property("talkerId", "GB"); | ||
packet.should.have.property("numberOfMessages", 2); | ||
packet.should.have.property("messageNumber", 1); | ||
packet.should.have.property("satellitesInView", 5); | ||
if (packet.sentenceId !== "GSV") { return; } | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(3); | ||
packet.satellites[0].should.deepEqual({ | ||
prnNumber: 14, | ||
elevationDegrees: 25, | ||
azimuthTrue: 170, | ||
SNRdB: 0 | ||
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(4); | ||
packet.satellites[0].should.deepEqual({ | ||
prnNumber: 203, // BeiDou PRN (offset by +200) | ||
elevationDegrees: 42, | ||
azimuthTrue: 69, | ||
SNRdB: 43 | ||
}); | ||
packet.satellites[1].should.deepEqual({ | ||
prnNumber: 204, // BeiDou PRN (offset by +200) | ||
elevationDegrees: 35, | ||
azimuthTrue: 124, | ||
SNRdB: 42 | ||
}); | ||
packet.satellites[2].should.deepEqual({ | ||
prnNumber: 207, | ||
elevationDegrees: 81, | ||
azimuthTrue: 197, | ||
SNRdB: 39 | ||
}); | ||
packet.satellites[3].should.deepEqual({ | ||
prnNumber: 209, | ||
elevationDegrees: 27, | ||
azimuthTrue: 309, | ||
SNRdB: 41 | ||
}); | ||
}); | ||
packet.satellites[1].should.deepEqual({ | ||
prnNumber: 16, | ||
elevationDegrees: 57, | ||
azimuthTrue: 208, | ||
SNRdB: 39 | ||
}); | ||
packet.satellites[2].should.deepEqual({ | ||
prnNumber: 18, | ||
elevationDegrees: 67, | ||
azimuthTrue: 296, | ||
SNRdB: 40 | ||
}); | ||
}); | ||
}); | ||
}); | ||
222793
4.78%160
1.91%5425
4.47%