link

package module
v0.0.0-...-2822064 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: MIT Imports: 13 Imported by: 1

README

Request-response and notifications over a serial link.

Introduction

While this library was written to work with serial devices, this works with any byte stream. It was written to interact with an Arduino, and have a more robust link between hardware and software.

Under development.

License

See the LICENSE.md file (MIT license).

Documentation

Index

Constants

View Source
const (
	MessageRequest = iota
	MessageResponse
	MessageNotification
)

The different message types.

View Source
const ListenerChannelSize = 32

ListenerChannelSize is the size of the channel that is created for each listener.

View Source
const RequestTimeout = 5 * time.Second

RequestTimeout is the time the Request method waits for a response.

View Source
const WriterChannelSize = 32

WriterChannelSize is the size of the writer channel.

Variables

This section is empty.

Functions

This section is empty.

Types

type Link struct {
	// contains filtered or unexported fields
}

Link represents a link.

func New

func New() *Link

New returns a new instance initilized instance of Link.

func (*Link) Notify

func (l *Link) Notify(message Message) error

Notify will send a notification message.

func (*Link) Register

func (l *Link) Register() (Listener, chan Message)

Register interest in received messages.

func (*Link) Reply

func (l *Link) Reply(request Message, message Message) error

Reply to a given request message.

func (*Link) Request

func (l *Link) Request(message Message) (Message, error)

Request a message, and wait for a response or a time-out.

func (*Link) Serve

func (l *Link) Serve(stream io.ReadWriter)

Serve a link.

func (*Link) Shutdown

func (l *Link) Shutdown()

Shutdown the link. This does not close the underlying stream.

func (*Link) Unregister

func (l *Link) Unregister(id Listener)

Unregister interest in received messages.

func (*Link) Write

func (l *Link) Write(message Message) error

Write a message to the link.

type Listener

type Listener uuid.UUID

Listener represets the identifier of a listener.

type Message

type Message struct {
	Type    MessageType
	ID      uint32
	Command string
}

Message contains a parsed representation of a serial message.

type MessageType

type MessageType int

MessageType indicates the type of the message.

Directories

Path Synopsis
examples
basic module

Jump to

Keyboard shortcuts

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