2.0.4 • Published 10 months ago

@nextlvlup/ubx-parser v2.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@nextlvlup/ubx-parser

npm version npm downloads

A parser for the GNSS protocol ubx. Developed and tested with a ublox M9L GPS module.

This library was created based on the documentation provided by ublox. Interface Description Integration Manual

Usage

Install the package:

# ✨ Auto-detect (supports npm, yarn, pnpm, deno and bun)
npx nypm install @nextlvlup/ubx-parser
# npm
npm install @nextlvlup/ubx-parser
# pnpm
pnpm install @nextlvlup/ubx-parser

Basic Usage

import { createParser } from "@nextlvlup/ubx-parser";
import { UBX_NAV_PVT } from "@nextlvlup/ubx-parser/message";

const parser = createParser();

// callback with error and respective buffer
parser.hooks.hook("error", (err, buf) => console.log(err, buf));
// callback with packets as raw buffer
parser.hooks.hook("data", (data) => console.log(data));

// attach UBX-NAV-PVT Parser and listen for packets
// callback with fully typed UBX-NAV-PVT packets
parser.attach(UBX_NAV_PVT).hook((data) => console.log(data));

parser.parse(/** Input Buffer */);

TCP/IP Example

If you want to provide the GNSS data from a local Linux device via TCP you can do this with the following command: socat -d -d tcp-l:1234 file://dev/ttyS0,b460800,raw

This command starts a TCP server and serves as a gateway between the local serial port ttyS0 and the TCP client.

import { Socket } from "node:net";

import { createParser } from "@nextlvlup/ubx-parser";
import { UBX_NAV_PVT } from "@nextlvlup/ubx-parser/message";

const client = new Socket();
const parser = createParser();

// listen for UBX_NAV_PVT packets
parser.attach(UBX_NAV_PVT).hook((data) => console.log(data));

client.connect({ host: "localhost", port: 1234 });
client.on("data", (buffer) => parser.parse(buffer));

SerialPort Example

import { SerialPort } from "serialport";

import { createParser } from "@nextlvlup/ubx-parser";
import { UBX_NAV_PVT } from "@nextlvlup/ubx-parser/message";

const serialport = new SerialPort({ path: "/dev/ttyS0", baudRate: 460_800 });
const parser = createParser();

// listen for UBX_NAV_PVT packets
parser.attach(UBX_NAV_PVT).hook((data) => console.log(data));

port.on("data", (buffer) => parser.parse(buffer));

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Published under the MIT license. Made by community 💛


🤖 auto updated with automd

2.0.3

10 months ago

2.0.2

10 months ago

2.0.4

10 months ago

2.0.1

10 months ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

2.0.0

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago