frame

package
v0.0.0-...-f8c32d9 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(frame *Frame) []uint8

func MakeDefaultTransactionIdProvider

func MakeDefaultTransactionIdProvider() func() uint8

Types

type Builder

type Builder interface {
	FrameType(frameType FrameType) Builder
	ManufacturerCode(manufacturerCode uint16) Builder
	Direction(direction Direction) Builder
	DisableDefaultResponse(disableDefaultResponse bool) Builder
	CommandId(commandId uint8) Builder
	Command(command interface{}) Builder
	Build() (*Frame, error)
}

func New

func New() Builder

type Direction

type Direction uint8
const (
	DirectionClientServer Direction = 0x00
	DirectionServerClient Direction = 0x01
)

type Frame

type Frame struct {
	FrameControl              *FrameControl
	ManufacturerCode          uint16 `cond:"uint:FrameControl.ManufacturerSpecific==1"`
	TransactionSequenceNumber uint8
	CommandIdentifier         uint8
	Payload                   []uint8
}

frame usually has three bytes of header before payload (additional 2-byte *ManufacturerCode* when *ManufacturerSpecific* bit is set)

func Decode

func Decode(buf []uint8) (*Frame, error)

type FrameControl

type FrameControl struct {
	FrameType              FrameType `bits:"0b00000011" bitmask:"start"`
	ManufacturerSpecific   uint8     `bits:"0b00000100"`
	Direction              Direction `bits:"0b00001000"`
	DisableDefaultResponse uint8     `bits:"0b00010000"`
	Reserved               uint8     `bits:"0b11100000" bitmask:"end"`
}

type FrameType

type FrameType uint8
const (
	FrameTypeGlobal FrameType = 0x00
	FrameTypeLocal  FrameType = 0x01
)

Jump to

Keyboard shortcuts

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