Documentation ¶
Index ¶
- Constants
- type Frame
- func (z *Frame) CalcChecksum() byte
- func (z *Frame) IsAck() bool
- func (z *Frame) IsCan() bool
- func (z *Frame) IsData() bool
- func (z *Frame) IsNak() bool
- func (z *Frame) IsRequest() bool
- func (z *Frame) IsResponse() bool
- func (z *Frame) MarshalBinary() ([]byte, error)
- func (z *Frame) SetChecksum()
- func (z *Frame) VerifyChecksum() error
- type ILayer
- type Layer
- type ParseEvent
- type ParseStatus
- type Parser
Constants ¶
const ( // HeaderData is a byte for a data frame. HeaderData byte = 0x01 // HeaderAck is a byte for a ack frame. HeaderAck = 0x06 // HeaderNak is a byte for a nak frame. HeaderNak = 0x15 // HeaderCan is a byte for a can frame. HeaderCan = 0x18 // TypeRequest is for a request frame. TypeRequest byte = 0x00 // TypeResponse is for a response frame. 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 }
Frame contains a frame.
func NewRequestFrame ¶
NewRequestFrame will build a new request frame.
func UnmarshalFrame ¶
UnmarshalFrame turns a byte slice into a Frame.
func (*Frame) CalcChecksum ¶
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) IsResponse ¶
IsResponse checks if the frame is a response frame.
func (*Frame) MarshalBinary ¶
MarshalBinary will 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 ¶
VerifyChecksum calculates a checksum for the frame and compares it to the frame's checksum, returning an error if they do not agree.
type Layer ¶
type Layer struct {
// contains filtered or unexported fields
}
Layer contains a frame layer.
func NewFrameLayer ¶
func NewFrameLayer(ctx context.Context, transportLayer io.ReadWriter, logger *zap.Logger) (*Layer, error)
NewFrameLayer will return a new frame layer.
func (*Layer) GetOutputChannel ¶
GetOutputChannel will return the output channel.
type ParseEvent ¶
type ParseEvent struct {
// contains filtered or unexported fields
}
ParseEvent represents a parsed frame and whether it was successful.
type ParseStatus ¶
type ParseStatus int
ParseStatus respresents an enum for the status parsing a frame.
const ( // ParseOk means a frame was successfully parsed. ParseOk ParseStatus = iota // ParseNotOk means a frame was not successfully parsed. ParseNotOk // ParseTimeout means a frame timed out. ParseTimeout )