MAVLink protocol implementation for Go

#go-mavlink

go impletation of the MAVLink protocol.

MAVLink or Micro Air Vehicle Link is a protocol for communicating with small unmanned vehicle. It's designed as a header-only message marshaling library. MAVLink was first released early 2009 by Lorenz Meier under LGPL license.

This implementation is mainly inspired by the C version (see on GitHub). Only tested under Unix

#Usage

Here two quick examples to understand how to deal with it but first, look at the MavPacket definition.

###MavPacket definition :

type Message interface {
        ID() uint8
        Size() uint8
}

type MavHeader struct {
        FrameStart     uint8
        PayloadLength  uint8
        PacketSequence uint8
        SystemID       uint8
        ComponentID    uint8
        MessageID      uint8
}

type MavPacket struct {
        Header   MavHeader
        Msg      Message
        Checksum uint16
}

You got all the message definitions in message.go.

##UDP communication (receiving example)

package main

import (
	"bufio"
	"fmt"
	mav "github.com/Sabmit/go-mavlink"
	"log"
	"net"
)

func main() {
	laddr, _ := net.ResolveUDPAddr("udp", "127.0.0.1:14550")
	conn, _ := net.ListenUDP("udp", laddr) // check errors

	parser := mav.GetMavParser()
    reader := bufio.NewReader(conn)

    for {
    	c, _ := reader.ReadByte() // check errors

        packet, err := parser(c)
        if err != nil {
        	log.Fatalf("Parser error: ", err)
        } else if packet != nil {
        	fmt.Println("Packet received :", packet.Bytes())
    	}
	}
}

The C server is available here, you can also test it by hand...

$ echo -ne "\xfe\x09\x0\x01\xC8\x00\x0\x0\x0\x0\x0\x0\x0\x0\x0\x5A\x3E" | nc -u 127.0.0.1 14550

##Serial communication (Sending example)

import (
	"github.com/tarm/goserial"
	mav "github.com/Sabmit/go-mavlink"
       "log"
)

func main() {
	port := &serial.Config{Name: "/dev/ttyUSB0", Baud: 57600}
        s, _ := serial.OpenPort(port) // check errors

	message := new(mav.RequestDataStream)
        message.ReqMessageRate = 20

        err := mav.Send(s, 1, 200, message)
        if err != nil {
		log.Fatalf("Error while sending the packet:", err)
	}
}

##More The operation is simple : get the MavParser and then, parse each received byte untill you get a non-nil pointer pointing to the full MavPacket.

Please read main_udp.go and main_serial.go if you want the full code examples.

#TO-DO

  • For now, only the received packet has its own checksum computed on the go
  • Verify if all properties of each message is in its own place (see Mavlink generator)

#See

#Authors

Similar Resources

Golang implementation of the Raft consensus protocol

raft raft is a Go library that manages a replicated log and can be used with an FSM to manage replicated state machines. It is a library for providing

Jan 9, 2023

Server-sent live updates: protocol and reference implementation

Server-sent live updates: protocol and reference implementation

Protocol and Reference Implementation Mercure is a protocol allowing to push data updates to web browsers and other HTTP clients in a convenient, fast

Jan 1, 2023

easyssh-proxy provides a simple implementation of some SSH protocol features in Go

easyssh-proxy easyssh-proxy provides a simple implementation of some SSH protocol features in Go. Feature This project is forked from easyssh but add

Dec 30, 2022

Implementation of the FTPS protocol for Golang.

FTPS Implementation for Go Information This implementation does not implement the full FTP/FTPS specification. Only a small subset. I have not done a

Mar 14, 2022

Tiny-HTTPS protocol implementation (experiment purpose.)

thttps Basic TLS implementation in Go, written as a learning project. Most components are forked from Go version 1.7 tiny-HTTPS is not suitable for re

Mar 7, 2022

Interblockchain communication protocol (IBC) implementation in Golang.

ibc-go Interblockchain communication protocol (IBC) implementation in Golang built as a SDK module. Components Core The core/ directory contains the S

Jan 7, 2023

Implementation of the NELI leader election protocol for Go and Kafka

Implementation of the NELI leader election protocol for Go and Kafka

goNELI Implementation of the NELI leader election protocol for Go and Kafka. goNELI encapsulates the 'fast' variation of the protocol, running in excl

Dec 8, 2022

Implementation of the Filecoin protocol, written in Go

Implementation of the Filecoin protocol, written in Go

Project Lotus - 莲 Lotus is an implementation of the Filecoin Distributed Storage Network. For more details about Filecoin, check out the Filecoin Spec

Jan 9, 2023

⛏ 🐹 Minecraft Protocol implementation in Go

⛏ 🐹 Minecraft Protocol implementation in Go

illustration by @talentlessguy Install Go 1.16.x is required to use this library go get github.com/BRA1L0R/go-mcproto Opening a connection client := m

Sep 20, 2022

Official Go implementation of the Fixcoin protocol

XFSGO Official Go implementation of the XFS protocol. Usage To learn more about the available xfsgo commands, use xfsgo help or type a command followe

May 18, 2022

Fast implementation of the collectd network protocol for go.

go-cdclient A fast, dependency free implementation of the collectd binary network protocol. How fast? This package can form an encrypted metric packet

Feb 6, 2022

(Partial) Implementation of the EEBUS protocol in Go

EEBUS This is an open source implementation of parts of the EEBUS protocol Version 1.0.1 specification in Go WARNING The code in this repository is a

Dec 11, 2022

Reference go implementation of globalDCE protocol

globalDCE-go This is the reference implementation of the command line interface of globalDCE coded in the go programming language. This project is sti

Nov 15, 2021

Reference go implementation of globaldce protocol

globaldce-go This is the reference implementation of the command line interface of globaldce coded in the go programming language. This project is sti

Nov 8, 2021

Go Implementation of the Spacemesh protocol full node. 💾⏰💪

Go Implementation of the Spacemesh protocol full node. 💾⏰💪

A Programmable Cryptocurrency go-spacemesh 💾 ⏰ 💪 Thanks for your interest in this open source project. This repo is the go implementation of the Spa

Dec 29, 2022

Reference implementation of globaldce protocol coded in go

globaldce This is the reference implementation of the command line interface of globaldce coded in the go programming language. This project is still

Nov 15, 2021

BrisGolang is a Go implementation of the game of briscola using the WebSocket protocol for client/server communication.

BrisGolang BrisGolang is a Go implementation of the game of briscola using the WebSocket protocol for client/server communication. Usage You can play

Nov 1, 2021

Implementation of Pinocchio Protocol in Go language

pinocchio-protocol-zksnarks Implementation of Pinocchio Protocol in Go language 1 零知识证明和zksnarks 1.1 为什么需要可证明的计算? 随着技术的发展,计算能力表现出不对称的特性,例如云计算等拥有大量的算力,

Nov 3, 2021

Refrence implementation of the globaldce protocol

globaldce-toolbox This is the reference implementation of globaldce protocole coded in the go programming language. This project is still experimental

Dec 14, 2022
🦖 Streaming-Serverless Framework for Low-latency Edge Computing applications, running atop QUIC protocol, engaging 5G technology.
🦖 Streaming-Serverless Framework for Low-latency Edge Computing applications, running atop QUIC protocol, engaging 5G technology.

YoMo YoMo is an open-source Streaming Serverless Framework for building Low-latency Edge Computing applications. Built atop QUIC Transport Protocol an

Dec 29, 2022
MQTTtimer is based mqtt protocol sync timer

MQTTTimer is based mqtt protocol sync timer. You can used ntp sync time protocol in IoT without ntp server. used mqtt protocol sync time is tcp connne

Oct 27, 2021
Dwarka - API gateway offers REST API to manage various device controlled using MQTT protocol

dwarka API gateway offers REST API to manage various device controlled using 'MQ

Sep 16, 2022
Golang implementation of PyMISP-feedgenerator

Go-MispFeedGenerator Generate MISP feeds without a MISP Instance! Go-MispFeedGenerator aka Go-MFG1000, is a library providing all functions needed to

Nov 23, 2022
Go language implementation of a blockchain based on the BDLS BFT protocol. The implementation was adapted from Ethereum and Sperax implementation

BDLS protocol based PoS Blockchain Most functionalities of this client is similar to the Ethereum golang implementation. If you do not find your quest

Oct 14, 2022
wire protocol for multiplexing connections or streams into a single connection, based on a subset of the SSH Connection Protocol

qmux qmux is a wire protocol for multiplexing connections or streams into a single connection. It is based on the SSH Connection Protocol, which is th

Dec 26, 2022
Eunomia is a distributed application framework that support Gossip protocol, QuorumNWR algorithm, PBFT algorithm, PoW algorithm, and ZAB protocol and so on.

Introduction Eunomia is a distributed application framework that facilitates developers to quickly develop distributed applications and supports distr

Sep 28, 2021
A simple tool to convert socket5 proxy protocol to http proxy protocol

Socket5 to HTTP 这是一个超简单的 Socket5 代理转换成 HTTP 代理的小工具。 如何安装? Golang 用户 # Required Go 1.17+ go install github.com/mritd/s2h@master Docker 用户 docker pull m

Jan 2, 2023
A project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol formatA project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol format

Intro This project outputs Bluetooth Low Energy (BLE) sensors data in InfluxDB line protocol format. It integrates nicely with the Telegraf execd inpu

Apr 15, 2022
Create a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compileCreate a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compile

Interview Assignment Overview You assignment is to create a Protocol Buffers (Protobuf) plugin, which is executed with the protoc compiler. In this ex

Nov 19, 2021