ratp

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

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

Go to latest
Published: Feb 5, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

README

ratp

The implementation of RATP (see RFC 916) on Go programming language.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConnRefused error = errors.New("Connection refused")

ErrConnRefused is the error returned when a peer refuses an incoming connection request.

View Source
var ErrConnReset error = errors.New("Connection reset")

ErrConnReset is the error returned when an established connection was terminated by a peer.

View Source
var ErrDataLeftUnsent error = errors.New("Data left unsent")

ErrDataLeftUnsent is the error returned if an established connection was terminated by a peer and unsent data left in the outgoing buffer.

View Source
var ErrInvalMDL error = errors.New("1 ≤ MDL ≤ 255")

ErrInvalMDL is the error returned by Connect if incorrect maximum data length (MDL) passed. Valid range: 1 ≤ MDL ≤ 255.

View Source
var ErrNotImpl error = errors.New("Not implemented")

ErrNotImpl is the error returned if the requested function or behavior is not implemented.

View Source
var ErrRetransmission error = errors.New("Connection aborted due to retransmission failure")

ErrRetransmission is the error returned when an established connection was reset due to exceeding the retransmission limit.

Functions

This section is empty.

Types

type Connection

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

Connection is the class, implementing io.ReadWriteCloser operations over RATP communications.

func (*Connection) Close

func (c *Connection) Close() error

Close closes the connection. The behavior of all methods after the first call of Close is undefined.

func (*Connection) Read

func (c *Connection) Read(data []byte) (int, error)

Read reads up to len(p) bytes into p. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. If some data is available but not len(p) bytes, Read conventionally returns what is available instead of waiting for more.

func (*Connection) Write

func (c *Connection) Write(p []byte) (int, error)

Write writes len(p) bytes from p to the RATP connection. It returns the number of bytes written from p (0 <= n <= len(p)) and any error encountered that caused the write to stop early. Write returns a non-nil error if it returns n < len(p).

type Logger

type Logger interface {
	Print(...interface{})
	Printf(string, ...interface{})
	Println(...interface{})
}

Logger is an interface used to pass abstract logger implementation to the package.

type RATP

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

RATP is the class, implementing RATP communications.

func New

func New(logger Logger) *RATP

New creates new instanse of RATP class. Parameter logger is an optional (can be nil) and used for passing an implementation of a logger for debugging purposes.

func (*RATP) Connect

func (r *RATP) Connect(serial string, serialCfg string, mdl int) (*Connection, error)

Connect creates a Connection object and performs a RATP active open over the serial device identified by a string passed in serial parameter. Parameter serialCfg determines the configuration of this device (e.g. "115200,8E1" for 115200 baud/s, 8 data bits, 1 stop bit, parity check enabled and set to "Even"). mdl (stands for "Maximum Data Length") determines the maximum size of RATP packet. Should be in the range 1 ≤ MDL ≤ 255. Use 255 if unsure.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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