serialpacket

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

serialpacket

SerialPacket is a net.PacketConn implementation over RS232.

It's designed to work with kcp-go to provide reliable transmission over LoRa or other noisy channels.

Test:

$  socat -d -d pty,raw,echo=0 pty,raw,echo=0
2022/03/27 22:48:28 socat[14099] N PTY is /dev/pts/5
2022/03/27 22:48:28 socat[14099] N PTY is /dev/pts/6
2022/03/27 22:48:28 socat[14099] N starting data transfer loop with FDs [5,5] and [7,7]

$ export PORT1="/dev/pts/5"
$ export PORT1="/dev/pts/6"

Documentation

Index

Constants

View Source
const (
	HEADER_SIZE = 2
	MAGIC_SIZE  = 4
	MTU         = 240
)

Frame Definition

|MAGIC(4B) | LENGTH (1B) | RESERVE(1B) | DATA (LENGTH) |

Max Packet Size: 240

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
)
View Source
var (
	MagicBytes = []byte{0xFF, 0x00, 0xAA, 0x55}
)

Functions

This section is empty.

Types

type Conn

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

Conn is the packet connection definition for a serial connection

func NewConn

func NewConn(port *serial.Port) (*Conn, error)

NewConn creates a net.PacketConn on a serial line

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

func (*Conn) ReadFrom

func (c *Conn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

func (*Conn) WriteTo

func (c *Conn) WriteTo(p []byte, _ net.Addr) (n int, err error)

type SerialPacketAddr

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

SerialPacketAddr is the address definition in net.Addr

func NewSerialPacketAddr

func NewSerialPacketAddr(name string) *SerialPacketAddr

NewSerialPacketAddr creates an address with given name and port

func (*SerialPacketAddr) Network

func (addr *SerialPacketAddr) Network() string

func (*SerialPacketAddr) String

func (addr *SerialPacketAddr) String() string

Jump to

Keyboard shortcuts

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