Documentation ¶
Overview ¶
Package cemi provides the functionality to parse and generate KNX CEMI-encoded frames.
Index ¶
- func Pack(buffer []byte, message Message)
- func Size(message Message) uint
- func Unpack(data []byte, message *Message) (n uint, err error)
- type APCI
- type AppData
- type ControlData
- type ControlField1
- type ControlField2
- type GroupAddr
- type IndividualAddr
- type Info
- type LBusmonInd
- type LData
- type LDataCon
- type LDataInd
- type LDataReq
- type LRaw
- type LRawCon
- type LRawInd
- type LRawReq
- type Message
- type MessageCode
- type Priority
- type TransportUnit
- type UnsupportedMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APCI ¶
type APCI uint8
APCI is the Application-layer Protocol Control Information.
const ( GroupValueRead APCI = 0 GroupValueResponse APCI = 1 GroupValueWrite APCI = 2 IndividualAddrWrite APCI = 3 IndividualAddrRequest APCI = 4 IndividualAddrResponse APCI = 5 AdcRead APCI = 6 AdcResponse APCI = 7 MemoryRead APCI = 8 MemoryResponse APCI = 9 MemoryWrite APCI = 10 UserMessage APCI = 11 MaskVersionRead APCI = 12 MaskVersionResponse APCI = 13 Restart APCI = 14 Escape APCI = 15 )
These are usable APCI values.
func (APCI) IsGroupCommand ¶
IsGroupCommand determines if the APCI indicates a group command.
type AppData ¶
An AppData contains application data in a transport unit.
type ControlData ¶
A ControlData encodes control information in a transport unit.
func (*ControlData) Pack ¶
func (control *ControlData) Pack(buffer []byte)
Pack into a transport data unit including its leading length byte.
type ControlField1 ¶
type ControlField1 uint8
ControlField1 contains various control information.
const ( // Control1StdFrame indicate that the frame is not an extended frame. Extended frames contain // application data units greater than 15 bytes. Control1StdFrame ControlField1 = 1 << 7 // Control1NoRepeat causes a repeated frame not to be sent on the medium. If you send two // identical frames, than one of them will not be sent on the medium when this flag is present. Control1NoRepeat ControlField1 = 1 << 5 // Control1NoSysBroadcast causes the frame to be transmitted in normal broadcast mode, instead // of system broadcast mode. Control1NoSysBroadcast ControlField1 = 1 << 4 // Control1WantAck requests an acknowledgement. Only works for L_Data.req. Control1WantAck ControlField1 = 1 << 1 // Control1HasError indicates an error. Only relevant in L_Data.con. Control1HasError ControlField1 = 1 )
func Control1Prio ¶
func Control1Prio(prio Priority) ControlField1
Control1Prio generates the control field 1 flag for the given priority.
type ControlField2 ¶
type ControlField2 uint8
ControlField2 contains various control information.
const ( // Control2GroupAddr determines that the destination address inside the frame is a group address, // instead of an individual address. Control2GroupAddr ControlField2 = 1 << 7 // Control2LTEFrame indicates that the frame is a LTE-frame. Control2LTEFrame ControlField2 = 1 << 2 )
func Control2Hops ¶
func Control2Hops(hops uint8) ControlField2
Control2Hops generates the control field 2 flag for the given number of hops.
func (ControlField2) Hops ¶
func (ctrl2 ControlField2) Hops() uint8
Hops retrieves the number of hops.
func (ControlField2) IsGroupAddr ¶
func (ctrl2 ControlField2) IsGroupAddr() bool
IsGroupAddr determines if the destination address is a group address.
type GroupAddr ¶
type GroupAddr uint16
GroupAddr is an address for a KNX group object.
func NewGroupAddr2 ¶
NewGroupAddr2 generates a group address with format a/b.
func NewGroupAddr3 ¶
NewGroupAddr3 generates a group address with format a/b/c.
func NewGroupAddrString ¶
NewGroupAddrString parses the given string as a group address. Supported formats are %d/%d/%d, %d/%d and %d.
type IndividualAddr ¶
type IndividualAddr uint16
IndividualAddr is an address for a KNX device.
func NewIndividualAddr2 ¶
func NewIndividualAddr2(a, b uint8) IndividualAddr
NewIndividualAddr2 generates a group address with format a/b.
func NewIndividualAddr3 ¶
func NewIndividualAddr3(a, b, c uint8) IndividualAddr
NewIndividualAddr3 generates a group address with format a/b/c.
func NewIndividualAddrString ¶
func NewIndividualAddrString(addr string) (IndividualAddr, error)
NewIndividualAddrString parses the given string as a individual address. Supported formats are %d.%d.%d, %d.%d and %d.
func (IndividualAddr) String ¶
func (addr IndividualAddr) String() string
String generates a string representation.
type LBusmonInd ¶
type LBusmonInd []byte
A LBusmonInd represents a L_Busmon.ind message.
func (LBusmonInd) MessageCode ¶
func (LBusmonInd) MessageCode() MessageCode
MessageCode returns the message code for L_Busmon.ind.
func (LBusmonInd) Pack ¶
func (lbm LBusmonInd) Pack(buffer []byte)
Pack the message body into the buffer.
type LData ¶
type LData struct { Info Info Control1 ControlField1 Control2 ControlField2 Source IndividualAddr Destination uint16 Data TransportUnit }
A LData is a link-layer data frame. L_Data.req, L_Data.con and L_Data.ind share this structure.
type LDataCon ¶
type LDataCon struct {
LData
}
A LDataCon represents a L_Data.con message body.
func (LDataCon) MessageCode ¶
func (LDataCon) MessageCode() MessageCode
MessageCode returns the message code for L_Data.con.
type LDataInd ¶
type LDataInd struct {
LData
}
A LDataInd represents a L_Data.ind message body.
func (LDataInd) MessageCode ¶
func (LDataInd) MessageCode() MessageCode
MessageCode returns the message code for L_Data.ind.
type LDataReq ¶
type LDataReq struct {
LData
}
A LDataReq represents a L_Data.req message body.
func (LDataReq) MessageCode ¶
func (LDataReq) MessageCode() MessageCode
MessageCode returns the message code for L_Data.req.
type LRaw ¶
type LRaw []byte
A LRaw is a raw link-layer frame. L_Raw.req, L_Raw.con and L_Raw.ind share this structure.
type LRawCon ¶
type LRawCon struct {
LRaw
}
A LRawCon represents a L_Raw.con message body.
func (LRawCon) MessageCode ¶
func (LRawCon) MessageCode() MessageCode
MessageCode returns the message code for L_Raw.con.
type LRawInd ¶
type LRawInd struct {
LRaw
}
A LRawInd represents a L_Raw.ind message body.
func (LRawInd) MessageCode ¶
func (LRawInd) MessageCode() MessageCode
MessageCode returns the message code for L_Raw.ind.
type LRawReq ¶
type LRawReq struct {
LRaw
}
A LRawReq represents a L_Raw.req message body.
func (LRawReq) MessageCode ¶
func (LRawReq) MessageCode() MessageCode
MessageCode returns the message code for L_Raw.req.
type Message ¶
type Message interface { util.Packable MessageCode() MessageCode }
Message is the body of a CEMI-encoded frame.
type MessageCode ¶
type MessageCode uint8
MessageCode is used to identify the type of message inside a CEMI-encoded frame.
const ( // LBusmonIndCode is the message code for L_Busmon.ind. LBusmonIndCode MessageCode = 0x2B // LDataReqCode is the message code for L_Data.req. LDataReqCode MessageCode = 0x11 // LDataIndCode is the message code for L_Data.ind. LDataIndCode MessageCode = 0x29 // LDataConCode is the message code for L_Data.con. LDataConCode MessageCode = 0x2E // LRawReqCode is the message code for L_Raw.req. LRawReqCode MessageCode = 0x10 // LRawIndCode is the message code for L_Raw.ind. LRawIndCode MessageCode = 0x2D // LRawConCode is the message code for L_Raw.con. LRawConCode MessageCode = 0x2F )
func (MessageCode) String ¶
func (code MessageCode) String() string
String converts the message code to a string.
type Priority ¶
type Priority uint8
A Priority determines the priority.
const ( // PrioSystem is for high priority, configuration and management frames. PrioSystem Priority = 0 // PrioNormal indicates normal priority. Ideal for short frames. PrioNormal Priority = 1 // PrioUrgent indicates urgent priority. PrioUrgent Priority = 2 // PrioLow indicates low priority. Ideal for long frames. PrioLow Priority = 3 )
type TransportUnit ¶
A TransportUnit is responsible to transport data.
type UnsupportedMessage ¶
type UnsupportedMessage struct { Code MessageCode Data []byte }
An UnsupportedMessage is the raw representation of a message inside a CEMI-encoded frame.
func (*UnsupportedMessage) MessageCode ¶
func (body *UnsupportedMessage) MessageCode() MessageCode
MessageCode returns the message code.
func (*UnsupportedMessage) Pack ¶
func (body *UnsupportedMessage) Pack(buffer []byte)
Pack the message body into the buffer.
func (*UnsupportedMessage) Size ¶
func (body *UnsupportedMessage) Size() uint
Size returns the packed size.