flnet

package module
v0.0.0-...-369374e Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: MIT Imports: 5 Imported by: 0

README

go-flnet

FL-net implementation in pure Golang.

Golang CI GoDoc GitHub

Documentation

Overview

Package flnet provides simple handling of FL-net protocol, implemented in the Go Programming Language.

THIS PROJECT IS STILL WIP.

Index

Constants

View Source
const (
	TCDToken uint16 = iota + 65000
	TCDCyclic
	TCDParticipationRequest
	TCDByteBlockReadRequest
	TCDByteBlockWriteRequest
	TCDWordBlockReadRequest
	TCDWordBlockWriteRequest
	TCDNetworkParameterReadRequest
	TCDNetworkParameterWriteRequest
	TCDStopCommandRequest
	TCDOperationCommandRequest
	TCDProfileReadRequest
	TCDTrigger
)

TCD definitions.

Variables

View Source
var (
	ErrTooShortToMarshalBinary = errors.New("insufficient buffer to serialize parameter to")
	ErrTooShortToParse         = errors.New("too short to decode as parameter")
	ErrNotImplemented          = errors.New("not implemented")
)

Error definitions.

Functions

This section is empty.

Types

type Cyclic

type Cyclic struct {
	Header *FALinkHeader
	Data   []byte
}

Cyclic is a cyclic frame of FA Link frame.

func NewCyclic

func NewCyclic(sna, dna uint8, vseq uint32, cad1, csz1, cad2, csz2 uint16, data *[]byte) *Cyclic

NewCyclic creates a new Cyclic.

func (*Cyclic) MarshalBinary

func (c *Cyclic) MarshalBinary() ([]byte, error)

MarshalBinary returns the byte sequence generated from a Cyclic.

func (*Cyclic) MarshalLen

func (c *Cyclic) MarshalLen() int

MarshalLen returns the serial length of Cyclic.

func (*Cyclic) MarshalTo

func (c *Cyclic) MarshalTo(b []byte) error

MarshalTo puts the byte sequence in the byte array given as b.

func (*Cyclic) UnmarshalBinary

func (c *Cyclic) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a cyclic frame.

type FALinkHeader

type FALinkHeader struct {
	HType    [4]byte
	TFL      uint32
	SA       uint32
	DA       uint32
	VSeq     uint32
	Seq      uint32
	MCTL     uint32
	ULS      uint16
	MSZ      uint16
	MADD     uint32
	MFT      uint8
	MRLT     uint8
	Reserved uint16
	TCD      uint16
	Ver      uint16
	CAD1     uint16
	CSZ1     uint16
	CAD2     uint16
	CSZ2     uint16
	Mode     uint16
	PType    uint8
	Pri      uint8
	CBN      uint8
	TBN      uint8
	BSize    uint16
	LKS      uint8
	TW       uint8
	RCT      uint16
}

FALinkHeader is a FL-net header.

func NewFALinkHeader

func NewFALinkHeader(
	htype [4]byte,
	tfl uint32,
	sna uint8,
	dna uint8,
	vseq uint32,
	seq uint32,
	bct bool,
	ppt bool,
	rpl bool,
	uls uint16,
	msz uint16,
	madd uint32,
	mft uint8,
	mrlt uint8,
	reserved uint16,
	tcd uint16,
	ver uint16,
	cad1 uint16,
	csz1 uint16,
	cad2 uint16,
	csz2 uint16,
	minver uint,
	majver uint,
	tokmode bool,
	ptype uint8,
	pri uint8,
	cbn uint8,
	tbn uint8,
	bsize uint16,
	lks uint8,
	tw uint8,
	rct uint16,
) *FALinkHeader

NewFALinkHeader creates a new FALinkHeader.

func ParseHeader

func ParseHeader(b []byte) (*FALinkHeader, error)

ParseHeader decodes given byte sequence as a FL-net common header.

func (*FALinkHeader) MarshalBinary

func (h *FALinkHeader) MarshalBinary() ([]byte, error)

MarshalBinary returns the byte sequence generated from a FALinkHeader instance.

func (*FALinkHeader) MarshalLen

func (h *FALinkHeader) MarshalLen() int

MarshalLen returns the serial length.

func (*FALinkHeader) MarshalTo

func (h *FALinkHeader) MarshalTo(b []byte) error

MarshalTo puts the byte sequence in the byte array given as b.

func (*FALinkHeader) UnmarshalBinary

func (h *FALinkHeader) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a FL-net common header.

type FLnet

type FLnet interface {
	MarshalBinary() ([]byte, error)
	MarshalTo(b []byte) error
	MarshalLen() int
	UnmarshalBinary(b []byte) error
}

FLnet is an interface that defines FL-net messages.

func Parse

func Parse(b []byte) (FLnet, error)

Parse decodes the given bytes. This function checks the TCD.

type ParticipationHeader

type ParticipationHeader struct {
	Header  *FALinkHeader
	NDN     [10]byte
	VDN     [10]byte
	MSN     [10]byte
	Reserve uint16
}

ParticipationHeader is used for the commands of token participation.

func (*ParticipationHeader) MarshalBinary

func (p *ParticipationHeader) MarshalBinary() ([]byte, error)

MarshalBinary returns the byte sequence generated from a participation header.

func (*ParticipationHeader) MarshalLen

func (p *ParticipationHeader) MarshalLen() int

MarshalLen returns the serial length of Trigger

func (*ParticipationHeader) MarshalTo

func (p *ParticipationHeader) MarshalTo(b []byte) error

MarshalTo puts the byte sequence in the byte array given as b.

func (*ParticipationHeader) UnmarshalBinary

func (p *ParticipationHeader) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a participation header.

type ParticipationRequest

type ParticipationRequest struct {
	*ParticipationHeader
}

ParticipationRequest is a ParticipationRequest frame of FA Link frame.

func NewParticipationRequest

func NewParticipationRequest(sna, dna uint8, vseq, seq uint32, ndn, vdn, msn string) *ParticipationRequest

NewParticipationRequest creates a new ParticipationRequest.

func (*ParticipationRequest) MarshalBinary

func (p *ParticipationRequest) MarshalBinary() ([]byte, error)

MarshalBinary returns the byte sequence generated from a ParticipationRequest.

func (*ParticipationRequest) MarshalLen

func (p *ParticipationRequest) MarshalLen() int

MarshalLen returns the serial length of ParticipationRequest

func (*ParticipationRequest) MarshalTo

func (p *ParticipationRequest) MarshalTo(b []byte) error

MarshalTo puts the byte sequence in the byte array given as b.

func (*ParticipationRequest) UnmarshalBinary

func (p *ParticipationRequest) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a ParticipationRequest frame.

type Token

type Token struct {
	Header *FALinkHeader
}

Token is a token frame of FA Link frame.

func NewToken

func NewToken() *Token

NewToken creates a new Token.

func (*Token) MarshalBinary

func (t *Token) MarshalBinary() ([]byte, error)

MarshalBinary returns the byte sequence generated from a Token.

func (*Token) MarshalLen

func (t *Token) MarshalLen() int

MarshalLen returns the serial length of Token.

func (*Token) MarshalTo

func (t *Token) MarshalTo(b []byte) error

MarshalTo puts the byte sequence in the byte array given as b.

func (*Token) UnmarshalBinary

func (t *Token) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a FL-net common header.

type Trigger

type Trigger struct {
	*ParticipationHeader
}

Trigger is a trigger frame of FA Link frame.

func NewTrigger

func NewTrigger(sna, dna uint8, vseq, seq uint32, ndn, vdn, msn string) *Trigger

NewTrigger creates a new Trigger.

func (*Trigger) MarshalBinary

func (t *Trigger) MarshalBinary() ([]byte, error)

MarshalBinary returns the byte sequence generated from a Trigger.

func (*Trigger) MarshalLen

func (t *Trigger) MarshalLen() int

MarshalLen returns the serial length of Trigger

func (*Trigger) MarshalTo

func (t *Trigger) MarshalTo(b []byte) error

MarshalTo puts the byte sequence in the byte array given as b.

func (*Trigger) UnmarshalBinary

func (t *Trigger) UnmarshalBinary(b []byte) error

UnmarshalBinary sets the values retrieved from byte sequence in a trigger frame.

Directories

Path Synopsis
Package utils provides some utilities which might be useful for protcol stack.
Package utils provides some utilities which might be useful for protcol stack.

Jump to

Keyboard shortcuts

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