myrtio

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 1 Imported by: 0

README

MyrtIO Go library

Library for MyrtIO protocol support in Golang.

Allows you to format and parse messages, as well as use ready-made transports.

Transports
  • Serial
  • UDP — not ready yet

Usage

func main() {
    port, err := serial.New(serialPath, serialBaudRate)
	if err != nil {
		log.Panic(err)
	}
    // Send ping
    response, err := m.port.RunAction(&myrtio.Message{
		Feature: 0,
		Action:  0,
	})
	if err != nil {
		log.Printf("Error: %v\n", err.Error())
	}
	defer port.Close()
}

Documentation

Index

Constants

View Source
const (
	FirstHeaderCode  byte = 0xFE
	SecondHeaderCode byte = 0xEF
	TailCode         byte = 0xAF
	SuccessCode      byte = 0xEE
	ErrorCode        byte = 0xFF
)
View Source
const MaxMessageLength = 128
View Source
const MetaHeaderPadding = 3
View Source
const MinMessageLength = 6

header (2) + length + feature + action + tail

Variables

View Source
var ErrWrongHeader = errors.New("unexpected header codes")
View Source
var ErrWrongLength = errors.New("message length is not correct")
View Source
var ErrWrongTail = errors.New("unexpected tail code")

Functions

This section is empty.

Types

type Message

type Message struct {
	Feature byte
	Action  byte
	Payload []byte
}

func ParseMessage

func ParseMessage(message []byte) (*Message, error)

func (*Message) Bytes

func (m *Message) Bytes() []byte

type Transport

type Transport interface {
	RunAction(message *Message) (*Message, error)
	Close() error
}

Directories

Path Synopsis
cmd
terminal command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL