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

mavlink_ardupilotmega_v1.0

v0.0.2

Published

Implementation of the MAVLink protocol

Downloads

11

Readme

Generated MAVLink 1.0 protocol for ArdupilotMega

This module is auto-generated from the Javascript generator found in the main MAVLink repository. If you need implementations for other autopilots, check that out.

Initializing the parser

In your main node script, you need to include the generated parser and instantiate it; you also need some kind of binary stream library that can read/write binary data and emit an event when new data is ready to be parsed (TCP, UDP, serial port all have appropriate libraries in the npm-o-sphere). The connection's "data is ready" event is bound to invoke the MAVLink parser to try and extract a valid message.

// requires Underscore.js, can use Winston for logging ,
// see package.json for dependencies for the implementation
var mavlink = require('mavlink_ardupilotmega_v1.0'), 
 net = require('net');

// Instantiate the parser
mavlinkParser = new mavlink();

// Create a connection -- can be anything that can receive/send binary
connection = net.createConnection(5760, '127.0.0.1');

// Provision the instantiated mavlinkParser object with the connection
mavlinkParser.setConnection(connection);

// When the connection issues a "got data" event, try and parse it
connection.on('data', function(data) {
 mavlinkParser.parseBuffer(data);
});

Receiving MAVLink messages

If the serial buffer has a valid MAVLink message, the message is removed from the buffer and parsed. Upon parsing a valid message, the MAVLink implementation emits two events: message (for any message) and the specific message name that was parsed, so you can listen for specific messages and handle them.

// Attach an event handler for any valid MAVLink message
mavlinkParser.on('message', function(message) {
 console.log('Got a message of any type!');
 console.log(message);
});

// Attach an event handler for a specific MAVLink message
mavlinkParser.on('HEARTBEAT', function(message) {
 console.log('Got a heartbeat message!');
 console.log(message); // message is a HEARTBEAT message
});

Sending MAVLink messages

See the gotcha's and todo's section below for some important caveats. The below code is preliminary and will change to be more direct. At this point, the MAVLink parser doesn't manage any state information about the UAV or the connection itself, so a few fields need to be fudged, as indicated below.

Sending a MAVLink message is done by creating the message object, populating its fields, and packing/sending it across the wire. Messages are defined in the generated code, and you can look up the parameter list/docs for each message type there. For example, the message REQUEST_DATA_STREAM has this signature:

mavlink.messages.request_data_stream = function(target_system, target_component, req_stream_id, req_message_rate, start_stop) //...

Creating the message is done like this:

request = new mavlink.messages.request_data_stream(1, 1, mavlink.MAV_DATA_STREAM_ALL, 1, 1);
mavlinkParser.send(request);