Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToUint16(b []byte) uint
- func Checksum(data []byte) byte
- func PackBytes(parts ...interface{}) []byte
- func Uint16ToBytes(n uint) []byte
- func VerifyChecksum(data []byte, receivedChecksum byte) bool
- type Frame
- type FrameBuffer
- type GenericFrame
- type Mailbox
- type Rx64Frame
- type Tx64Frame
- type TxStatusFrame
Constants ¶
const ( // Frame start delimiter FrameHeader byte = 0x7E // TX frame type (64-bit address) Tx64FrameType byte = 0x00 // TX status frame type TxStatusFrameType byte = 0x89 // RX frame type (64-bit address) Rx64FrameType byte = 0x80 )
Variables ¶
var BroadcastAddress = []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF}
Broadcast address for use by 64-bit TX frames
Functions ¶
func BytesToUint16 ¶
Converts a 2-byte big Endian array into an unsigned 16-bit integer
func PackBytes ¶
func PackBytes(parts ...interface{}) []byte
Takes a variable number of single bytes or byte arrays and concatenates them into a single byte array
func Uint16ToBytes ¶
Converts an unsigned 16-bit integer to a 2-byte big Endian array
func VerifyChecksum ¶
Verifies the computed checksum of XBee frame data with the checksum received over the wire. It is encouraged that you discard any XBee frame which does not pass this check
Types ¶
type Frame ¶
type Frame interface {
FrameData() []byte
}
Represents a generic XBee frame type
func BuildFrame ¶
Given raw frame data, this function attempts to construct the appropriate frame object by inspecting the first byte of the frame data (presumed to be the frame type byte). If the frame type cannot be identified by this software, a "generic" frame object is constructed preserving the raw data for other implementations to handle
func BuildGenericFrame ¶
Constructs a new "generic" frame object from the provided frame data
func BuildRx64Frame ¶
Constructs a new RX64 frame from the provided frame data
func BuildTx64Frame ¶
Constructs a new TX64 frame object from the provided frame data
func BuildTxStatusFrame ¶
Constructs a new TX status frame object from the provided frame data
type FrameBuffer ¶
type FrameBuffer struct {
// contains filtered or unexported fields
}
A generic full-duplex frame buffer that allows for reading/ writing XBee frames to the underlying serial device (or any other kind of io.ReadWriter
func NewFrameBuffer ¶
func NewFrameBuffer(rw io.ReadWriter) *FrameBuffer
Creates a new FrameBuffer object
func (*FrameBuffer) ReadFrame ¶
func (fb *FrameBuffer) ReadFrame() Frame
Reads a single XBee frame from the underlying serial device. Note that this method will block on reads until the full frame has been consumed. Additionally, this method will skip any bytes received between the presumed end of the previous frame and the beginning (0x7E) of the next
func (*FrameBuffer) WriteFrame ¶
func (fb *FrameBuffer) WriteFrame(frame Frame) (n int, err error)
Writes a Frame object to the underlying serial device. Note that this does *not* buffer writes nor does it do packet fragmentation
type GenericFrame ¶
Represents a "generic" (unimplemented) XBee frame
func (*GenericFrame) FrameData ¶
func (g *GenericFrame) FrameData() []byte
func (*GenericFrame) String ¶
func (g *GenericFrame) String() string
type Mailbox ¶
type Mailbox struct {
// contains filtered or unexported fields
}
func NewMailbox ¶
func NewMailbox(rw io.ReadWriter) *Mailbox
type TxStatusFrame ¶
Represents a TX status frame
func (*TxStatusFrame) FrameData ¶
func (tx *TxStatusFrame) FrameData() []byte
func (*TxStatusFrame) String ¶
func (tx *TxStatusFrame) String() string