New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@jbroll/nmea-simple

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jbroll/nmea-simple - npm Package Compare versions

Comparing version

to
3.3.4-rc.5

1

dist/prn-utils.d.ts
export declare function getTalkerSystemId(talkerId: string): number;
export declare function adjustPRN(prn: number, systemId: number): number;
export declare function validatePRN(prn: number, systemId: number): boolean;
export declare function getSystemName(systemId: number): string;

47

dist/prn-utils.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// Map talker IDs to system IDs
// Map talker IDs to system IDs according to uBlox NMEA 4.1 spec
function getTalkerSystemId(talkerId) {
switch (talkerId) {
case "GP": return 1; // GPS
case "GL": return 2; // GLONASS
case "GB": return 3; // BeiDou
case "GA": return 4; // Galileo
case "GL": return 2; // GLONASS (primary)
case "GA": return 3; // Galileo
case "GB": return 4; // BeiDou
case "GQ": return 5; // QZSS
case "GI": return 6; // NavIC/IRNSS
// case "GL": return 6; // GLONASS (secondary)
case "GI": return 7; // IRNSS/NavIC
default: return 0; // Unknown/Combined

@@ -16,11 +17,12 @@ }

exports.getTalkerSystemId = getTalkerSystemId;
// Apply system-specific PRN offset
// Apply system-specific PRN offset based on uBlox NMEA 4.1 spec
function adjustPRN(prn, systemId) {
switch (systemId) {
case 1: return prn; // GPS: no adjustment needed (1-32)
case 2: return prn; // GLONASS: no adjustment needed (65-96)
case 3: return prn + 200; // BeiDou: add 200 (201-235)
case 4: return prn + 100; // Galileo: add 100 (101-136)
case 2: // GLONASS (primary): no adjustment needed (65-96)
case 6: return prn; // GLONASS (secondary): no adjustment needed (65-96)
case 3: return prn + 100; // Galileo: add 100 (101-136)
case 4: return prn + 200; // BeiDou: add 200 (201-235)
case 5: return prn; // QZSS: no adjustment needed (193-197)
case 6: return prn + 400; // NavIC: add 400 (401-414)
case 7: return prn + 400; // IRNSS/NavIC: add 400 (401-414)
default: return prn; // Unknown: no adjustment

@@ -30,11 +32,12 @@ }

exports.adjustPRN = adjustPRN;
// Validate PRN is in correct range for system
// Validate PRN is in correct range for system according to uBlox NMEA 4.1
function validatePRN(prn, systemId) {
switch (systemId) {
case 1: return prn >= 1 && prn <= 32; // GPS
case 2: return prn >= 65 && prn <= 96; // GLONASS
case 3: return prn >= 201 && prn <= 235; // BeiDou
case 4: return prn >= 101 && prn <= 136; // Galileo
case 2: // GLONASS (primary)
case 6: return prn >= 65 && prn <= 96; // GLONASS (secondary)
case 3: return prn >= 101 && prn <= 136; // Galileo
case 4: return prn >= 201 && prn <= 235; // BeiDou
case 5: return prn >= 193 && prn <= 197; // QZSS
case 6: return prn >= 401 && prn <= 414; // NavIC
case 7: return prn >= 401 && prn <= 414; // IRNSS/NavIC
default: return true; // Unknown: accept any

@@ -44,1 +47,15 @@ }

exports.validatePRN = validatePRN;
// Get the name of the GNSS system for a given system ID
function getSystemName(systemId) {
switch (systemId) {
case 1: return "GPS";
case 2:
case 6: return "GLONASS";
case 3: return "Galileo";
case 4: return "BeiDou";
case 5: return "QZSS";
case 7: return "IRNSS/NavIC";
default: return "Unknown";
}
}
exports.getSystemName = getSystemName;

@@ -1,1 +0,4 @@

import "should";
export declare function getTalkerSystemId(talkerId: string): number;
export declare function adjustPRN(prn: number, systemId: number): number;
export declare function validatePRN(prn: number, systemId: number): boolean;
export declare function getSystemName(systemId: number): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("should");
var index_1 = require("../index");
describe("GSA", 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("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);
});
describe("parses different constellation packets", function () {
var packets = [
index_1.parseNmeaSentence("$GNGSA,A,3,28,26,04,09,16,27,31,08,,,,,1.33,0.74,1.10,1*08"),
index_1.parseNmeaSentence("$GNGSA,A,3,73,74,82,71,72,,,,,,,,1.33,0.74,1.10,2*0E"),
index_1.parseNmeaSentence("$GNGSA,A,3,14,24,25,35,33,,,,,,,,1.33,0.74,1.10,4*04")
];
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);
});
});
});
});
// Map talker IDs to system IDs according to uBlox NMEA 4.1 spec
function getTalkerSystemId(talkerId) {
switch (talkerId) {
case "GP": return 1; // GPS
case "GL": return 2; // GLONASS (primary)
case "GA": return 3; // Galileo
case "GB": return 4; // BeiDou
case "GQ": return 5; // QZSS
// case "GL": return 6; // GLONASS (secondary)
case "GI": return 7; // IRNSS/NavIC
default: return 0; // Unknown/Combined
}
}
exports.getTalkerSystemId = getTalkerSystemId;
// Apply system-specific PRN offset based on uBlox NMEA 4.1 spec
function adjustPRN(prn, systemId) {
switch (systemId) {
case 1: return prn; // GPS: no adjustment needed (1-32)
case 2: // GLONASS (primary): no adjustment needed (65-96)
case 6: return prn; // GLONASS (secondary): no adjustment needed (65-96)
case 3: return prn + 100; // Galileo: add 100 (101-136)
case 4: return prn + 200; // BeiDou: add 200 (201-235)
case 5: return prn; // QZSS: no adjustment needed (193-197)
case 7: return prn + 400; // IRNSS/NavIC: add 400 (401-414)
default: return prn; // Unknown: no adjustment
}
}
exports.adjustPRN = adjustPRN;
// Validate PRN is in correct range for system according to uBlox NMEA 4.1
function validatePRN(prn, systemId) {
switch (systemId) {
case 1: return prn >= 1 && prn <= 32; // GPS
case 2: // GLONASS (primary)
case 6: return prn >= 65 && prn <= 96; // GLONASS (secondary)
case 3: return prn >= 101 && prn <= 136; // Galileo
case 4: return prn >= 201 && prn <= 235; // BeiDou
case 5: return prn >= 193 && prn <= 197; // QZSS
case 7: return prn >= 401 && prn <= 414; // IRNSS/NavIC
default: return true; // Unknown: accept any
}
}
exports.validatePRN = validatePRN;
// Get the name of the GNSS system for a given system ID
function getSystemName(systemId) {
switch (systemId) {
case 1: return "GPS";
case 2:
case 6: return "GLONASS";
case 3: return "Galileo";
case 4: return "BeiDou";
case 5: return "QZSS";
case 7: return "IRNSS/NavIC";
default: return "Unknown";
}
}
exports.getSystemName = getSystemName;

@@ -142,2 +142,20 @@ "use strict";

});
// Added test for secondary GLONASS
it("handles secondary GLONASS correctly", function () {
var sentence = helpers_1.appendChecksumFooter("$GLGSV,1,1,04,88,45,123,41,89,67,321,42,,,,,,,,,6");
var packet = index_1.parseNmeaSentence(sentence);
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(2);
packet.satellites[0].should.deepEqual({
prnNumber: 88,
elevationDegrees: 45,
azimuthTrue: 123,
SNRdB: 41
});
packet.satellites[1].should.deepEqual({
prnNumber: 89,
elevationDegrees: 67,
azimuthTrue: 321,
SNRdB: 42
});
});
});
{
"name": "@jbroll/nmea-simple",
"version": "3.3.4-rc.4",
"version": "3.3.4-rc.5",
"homepage": "https://github.com/jbroll/nmea-simple",

@@ -5,0 +5,0 @@ "description": "NMEA 0183 sentence parser and encoder",

@@ -1,10 +0,11 @@

// Map talker IDs to system IDs
// Map talker IDs to system IDs according to uBlox NMEA 4.1 spec
export function getTalkerSystemId(talkerId: string): number {
switch (talkerId) {
case "GP": return 1; // GPS
case "GL": return 2; // GLONASS
case "GB": return 3; // BeiDou
case "GA": return 4; // Galileo
case "GL": return 2; // GLONASS (primary)
case "GA": return 3; // Galileo
case "GB": return 4; // BeiDou
case "GQ": return 5; // QZSS
case "GI": return 6; // NavIC/IRNSS
// case "GL": return 6; // GLONASS (secondary)
case "GI": return 7; // IRNSS/NavIC
default: return 0; // Unknown/Combined

@@ -14,11 +15,12 @@ }

// Apply system-specific PRN offset
// Apply system-specific PRN offset based on uBlox NMEA 4.1 spec
export function adjustPRN(prn: number, systemId: number): number {
switch (systemId) {
case 1: return prn; // GPS: no adjustment needed (1-32)
case 2: return prn; // GLONASS: no adjustment needed (65-96)
case 3: return prn + 200; // BeiDou: add 200 (201-235)
case 4: return prn + 100; // Galileo: add 100 (101-136)
case 2: // GLONASS (primary): no adjustment needed (65-96)
case 6: return prn; // GLONASS (secondary): no adjustment needed (65-96)
case 3: return prn + 100; // Galileo: add 100 (101-136)
case 4: return prn + 200; // BeiDou: add 200 (201-235)
case 5: return prn; // QZSS: no adjustment needed (193-197)
case 6: return prn + 400; // NavIC: add 400 (401-414)
case 7: return prn + 400; // IRNSS/NavIC: add 400 (401-414)
default: return prn; // Unknown: no adjustment

@@ -28,14 +30,28 @@ }

// Validate PRN is in correct range for system
// Validate PRN is in correct range for system according to uBlox NMEA 4.1
export function validatePRN(prn: number, systemId: number): boolean {
switch (systemId) {
case 1: return prn >= 1 && prn <= 32; // GPS
case 2: return prn >= 65 && prn <= 96; // GLONASS
case 3: return prn >= 201 && prn <= 235; // BeiDou
case 4: return prn >= 101 && prn <= 136; // Galileo
case 5: return prn >= 193 && prn <= 197; // QZSS
case 6: return prn >= 401 && prn <= 414; // NavIC
default: return true; // Unknown: accept any
case 1: return prn >= 1 && prn <= 32; // GPS
case 2: // GLONASS (primary)
case 6: return prn >= 65 && prn <= 96; // GLONASS (secondary)
case 3: return prn >= 101 && prn <= 136; // Galileo
case 4: return prn >= 201 && prn <= 235; // BeiDou
case 5: return prn >= 193 && prn <= 197; // QZSS
case 7: return prn >= 401 && prn <= 414; // IRNSS/NavIC
default: return true; // Unknown: accept any
}
}
// Get the name of the GNSS system for a given system ID
export function getSystemName(systemId: number): string {
switch (systemId) {
case 1: return "GPS";
case 2:
case 6: return "GLONASS";
case 3: return "Galileo";
case 4: return "BeiDou";
case 5: return "QZSS";
case 7: return "IRNSS/NavIC";
default: return "Unknown";
}
}

@@ -1,54 +0,56 @@

import "should";
import { parseNmeaSentence, GSVPacket } from "../index";
// Map talker IDs to system IDs according to uBlox NMEA 4.1 spec
export function getTalkerSystemId(talkerId: string): number {
switch (talkerId) {
case "GP": return 1; // GPS
case "GL": return 2; // GLONASS (primary)
case "GA": return 3; // Galileo
case "GB": return 4; // BeiDou
case "GQ": return 5; // QZSS
// case "GL": return 6; // GLONASS (secondary)
case "GI": return 7; // IRNSS/NavIC
default: return 0; // Unknown/Combined
}
}
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;
// Apply system-specific PRN offset based on uBlox NMEA 4.1 spec
export function adjustPRN(prn: number, systemId: number): number {
switch (systemId) {
case 1: return prn; // GPS: no adjustment needed (1-32)
case 2: // GLONASS (primary): no adjustment needed (65-96)
case 6: return prn; // GLONASS (secondary): no adjustment needed (65-96)
case 3: return prn + 100; // Galileo: add 100 (101-136)
case 4: return prn + 200; // BeiDou: add 200 (201-235)
case 5: return prn; // QZSS: no adjustment needed (193-197)
case 7: return prn + 400; // IRNSS/NavIC: add 400 (401-414)
default: return prn; // Unknown: no adjustment
}
}
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);
});
// Validate PRN is in correct range for system according to uBlox NMEA 4.1
export function validatePRN(prn: number, systemId: number): boolean {
switch (systemId) {
case 1: return prn >= 1 && prn <= 32; // GPS
case 2: // GLONASS (primary)
case 6: return prn >= 65 && prn <= 96; // GLONASS (secondary)
case 3: return prn >= 101 && prn <= 136; // Galileo
case 4: return prn >= 201 && prn <= 235; // BeiDou
case 5: return prn >= 193 && prn <= 197; // QZSS
case 7: return prn >= 401 && prn <= 414; // IRNSS/NavIC
default: return true; // Unknown: accept any
}
}
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[];
// Get the name of the GNSS system for a given system ID
export function getSystemName(systemId: number): string {
switch (systemId) {
case 1: return "GPS";
case 2:
case 6: return "GLONASS";
case 3: return "Galileo";
case 4: return "BeiDou";
case 5: return "QZSS";
case 7: return "IRNSS/NavIC";
default: return "Unknown";
}
}
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)
});
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)
});
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)
});
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);
});
});
});
});

@@ -152,4 +152,23 @@ import "should";

});
// Added test for secondary GLONASS
it("handles secondary GLONASS correctly", (): void => {
const sentence = appendChecksumFooter("$GLGSV,1,1,04,88,45,123,41,89,67,321,42,,,,,,,,,6");
const packet = parseNmeaSentence(sentence) as GSVPacket;
packet.satellites.should.be.instanceof(Array).and.have.lengthOf(2);
packet.satellites[0].should.deepEqual({
prnNumber: 88, // Secondary GLONASS PRN (no offset)
elevationDegrees: 45,
azimuthTrue: 123,
SNRdB: 41
});
packet.satellites[1].should.deepEqual({
prnNumber: 89,
elevationDegrees: 67,
azimuthTrue: 321,
SNRdB: 42
});
});
});