npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@beyond-vision/node-mavlink

v0.1.4

Published

A library for parsing and packing MAVLink 2 messages

Downloads

5

Readme

Build Status Coverage Status

node-mavlink

node-mavlink is a library for parsing and packing MAVLink 2 messages using TypeScript or, when transpiled, using JavaScript in NodeJS. This project is forked from node-mavlink, incorporating fixes from pull requests and additional Array support.

Limitations

At this point, not supported are:

  • message signing

Installation

The module is published on npm. Install using:

npm install @beyond-skyline/node-mavlink --save

Usage

To be able to use this module, the MAVLink message definitions need to be parsed using the official pymavlink, which creates the TypeScript classes. Using the command-line interface, the classes can be generated using

python tools/mavgen.py -o ./assets --lang TypeScript --wire-protocol 2.0 <message_definition.xml>

which will produce all needed TypeScript files in a folder called assets. Instead of <message_definition.xml> you will probably use common.xml. Together with the all messages (classes directory) and enums (enums directory), a file messageRegistry.ts is created, which provides an array holding all message IDs and the respective constructor.

If you want to use the library with pure JavaScript, you need to transpile the generated files. You can install the transpiler with:

npm i typescript --save-dev

Then run within the assets directory

tsc

to start the process.

Examples

TypeScript

import {MAVLinkModule, MAVLinkMessage} from '@ifrunistuttgart/node-mavlink';  
import {messageRegistry} from './assets/message-registry';  
  
import Serialport from 'serialport';  
  
const mavLink = new MAVLinkModule(messageRegistry);  
const serialPort = new Serialport('COM4', {  
    baudRate: 57600  
});  
  
serialPort.on('data', function (data: Buffer) {  
    mavLink.parse(data);  
});  
  
mavLink.on('error', function (e: Error) {  
    // event listener for node-mavlink ALL error message  
 //console.log(e);
});  
  
mavLink.on('message', function (message: MAVLinkMessage) {  
    // event listener for all messages  
  console.log(message);  
});  
  
mavLink.on('COMMAND_LONG', function (bytes: Buffer) {  
    console.log('Sending COMMAND_LONG to PX4');  
  serialPort.write(bytes);  
});  
  
mavLink.on('HIGHRES_IMU', function (message: MAVLinkMessage) {  
    // event listener for HIGHRES_IMU message  
  console.log(message);  
});

JavaScript

var SerialPort = require('serialport');  
var messageRegistry = require('.assets/messageRegistry');  
var mavLink = require('@ifrunistuttgart/node-mavlink')(messageRegistry);  
  
var serialPort = new SerialPort('COM4', {  
    baudRate: 57600  
});  
  
serialPort.on('data', function (data) {  
    mavLink.parse(data);  
});  
  
mavLink.on('error', function (e) {  
    //console.log(e);  
});  
  
mavLink.on('message', function (message) {  
    // event listener for all messages  
  console.log(message);  
});  
  
mavLink.on('COMMAND_LONG', function (bytes) {  
    console.log('Sending COMMAND_LONG to PX4');  
  serialPort.write(bytes);  
});  
  
mavLink.on('HIGHRES_IMU', function (message) {  
    // event listener for HIGHRES_IMU message  
  console.log(message);  
});

License

node-mavlink is released under the GNU Lesser General Public License v3 or later.