frame

package
v0.0.0-...-02b3c19 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderData byte = 0x01
	HeaderAck       = 0x06
	HeaderNak       = 0x15
	HeaderCan       = 0x18
)
View Source
const (
	TypeRequest  byte = 0x00
	TypeResponse      = 0x01
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Frame

type Frame struct {

	// Header is one of FrameHeader*
	Header byte

	// Length = byte length of all fields, excluding Header and Checksum
	Length byte

	// Type is one of FrameType*
	Type byte

	// Payload is the command id and command payload
	Payload []byte

	// Checksum = 0xff XOR Type XOR Length XOR payload[0] XOR [...payload[n]]
	Checksum byte
}

func NewAckFrame

func NewAckFrame() *Frame

func NewCanFrame

func NewCanFrame() *Frame

func NewNakFrame

func NewNakFrame() *Frame

func NewRequestFrame

func NewRequestFrame(payload []byte) *Frame

func UnmarshalFrame

func UnmarshalFrame(frame []byte) *Frame

UnmarshalFrame turns a byte slice into a Frame

func (*Frame) CalcChecksum

func (z *Frame) CalcChecksum() byte

CalcChecksum calculates the checksum for this frame, given the current data. The Z-Wave checksum is calculated by taking 0xFF XOR Length XOR Type XOR Payload[0:n]

func (*Frame) IsAck

func (z *Frame) IsAck() bool

func (*Frame) IsCan

func (z *Frame) IsCan() bool

func (*Frame) IsData

func (z *Frame) IsData() bool

func (*Frame) IsNak

func (z *Frame) IsNak() bool

func (*Frame) IsRequest

func (z *Frame) IsRequest() bool

func (*Frame) IsResponse

func (z *Frame) IsResponse() bool

func (*Frame) MarshalBinary

func (z *Frame) MarshalBinary() ([]byte, error)

Marshal this frame into a byte slice

func (*Frame) SetChecksum

func (z *Frame) SetChecksum()

SetChecksum calculates the frame checksum and saves it into the frame

func (*Frame) VerifyChecksum

func (z *Frame) VerifyChecksum() error

VerifyChecksum calculates a checksum for the frame and compares it to the frame's checksum, returning an error if they do not agree

type ILayer

type ILayer interface {
	Write(frame *Frame)
	GetOutputChannel() <-chan Frame
}

type Layer

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

func NewFrameLayer

func NewFrameLayer(transportLayer io.ReadWriter) *Layer

func (*Layer) GetOutputChannel

func (l *Layer) GetOutputChannel() <-chan Frame

func (*Layer) Write

func (l *Layer) Write(frame *Frame)

type ParseEvent

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

type ParseStatus

type ParseStatus int
const (
	ParseOk ParseStatus = iota
	ParseNotOk
	ParseTimeout
)

type Parser

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

func NewParser

func NewParser(input <-chan byte, output chan<- *ParseEvent, acks, naks, cans chan bool) *Parser

Jump to

Keyboard shortcuts

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