Documentation
¶
Index ¶
- Constants
- Variables
- func Read(r *bufio.Reader, opts ...ReadOption) error
- type Buffer
- func (buf *Buffer) BooleanParse() (bool, error)
- func (buf *Buffer) Debug()
- func (buf *Buffer) Expect(expectedType uint8, expectedLength int) error
- func (buf *Buffer) ExpectType(expectedType uint8) error
- func (buf *Buffer) GetCurrentByte() byte
- func (buf *Buffer) GetNextLength() int
- func (buf *Buffer) GetNextType() uint8
- func (buf *Buffer) I8Parse() (int8, error)
- func (buf *Buffer) I16Parse() (int16, error)
- func (buf *Buffer) I32Parse() (int32, error)
- func (buf *Buffer) I64Parse() (int64, error)
- func (buf *Buffer) NumberParse(numType uint8, maxSize int) (int64, error)
- func (buf *Buffer) OctetStringParse() (OctetString, error)
- func (buf *Buffer) OptionalIsSkipped() bool
- func (buf *Buffer) StatusParse() (int64, error)
- func (buf *Buffer) TimeParse() (Time, error)
- func (buf *Buffer) U8Parse() (uint8, error)
- func (buf *Buffer) U16Parse() (uint16, error)
- func (buf *Buffer) U32Parse() (uint32, error)
- func (buf *Buffer) U64Parse() (uint64, error)
- func (buf *Buffer) UpdateBytesRead(delta int)
- func (buf *Buffer) ValueParse() (Value, error)
- type CloseRequest
- type CloseResponse
- type GetListRequest
- type GetListResponse
- type ListEntry
- type Message
- type MessageBody
- type MessageBodyData
- type OctetString
- type OpenRequest
- type OpenResponse
- type ReadOption
- type Time
- type Value
Constants ¶
View Source
const ( OCTET_MESSAGE_END = 0x00 OCTET_TYPE_FIELD = 0x70 OCTET_LENGTH_FIELD = 0x0F OCTET_ANOTHER_TL = 0x80 OCTET_TYPE_OCTET_STRING = 0x00 OCTET_TYPE_BOOLEAN = 0x40 OCTET_TYPE_INTEGER = 0x50 OCTET_TYPE_UNSIGNED = 0x60 OCTET_TYPE_LIST = 0x70 OCTET_OPTIONAL_SKIPPED = 0x01 )
View Source
const ( TYPE_NUMBER_8 = 1 TYPE_NUMBER_16 = 2 TYPE_NUMBER_32 = 4 TYPE_NUMBER_64 = 8 )
View Source
const ( MESSAGE_OPEN_REQUEST = 0x00000100 MESSAGE_OPEN_RESPONSE = 0x00000101 MESSAGE_CLOSE_REQUEST = 0x00000200 MESSAGE_CLOSE_RESPONSE = 0x00000201 MESSAGE_GET_PROFILE_PACK_REQUEST = 0x00000300 MESSAGE_GET_PROFILE_PACK_RESPONSE = 0x00000301 MESSAGE_GET_PROFILE_LIST_REQUEST = 0x00000400 MESSAGE_GET_PROFILE_LIST_RESPONSE = 0x00000401 MESSAGE_GET_PROC_PARAMETER_REQUEST = 0x00000500 MESSAGE_GET_PROC_PARAMETER_RESPONSE = 0x00000501 MESSAGE_SET_PROC_PARAMETER_REQUEST = 0x00000600 MESSAGE_SET_PROC_PARAMETER_RESPONSE = 0x00000601 // This doesn't exist in the spec MESSAGE_GET_LIST_REQUEST = 0x00000700 MESSAGE_GET_LIST_RESPONSE = 0x00000701 MESSAGE_ATTENTION_RESPONSE = 0x0000FF01 )
Variables ¶
View Source
var ErrSequenceTooLong = errors.New("max sequence length exceeded")
ErrSequenceTooLong means that the max length of a sequence has been reached before end of sequence has been detected.
View Source
var ErrUnrecognizedSequence = errors.New("unrecognized sequence")
ErrUnrecognizedSequence means that a sequence was found but its end was not found. E.g. a new sequence started before the end of current sequence was found.
Functions ¶
func Read ¶
func Read(r *bufio.Reader, opts ...ReadOption) error
Read reads and parses sml file from given buffered reader. If sml file is not recognized ErrUnrecognizedSequence is returned. If sml file is too long ErrSequenceTooLong is returned. If file is successfully read and parsed slice of found messages is returned
Types ¶
type Buffer ¶
func (*Buffer) BooleanParse ¶
func (*Buffer) ExpectType ¶
func (*Buffer) GetCurrentByte ¶
func (*Buffer) GetNextLength ¶
func (*Buffer) GetNextType ¶
func (*Buffer) NumberParse ¶
func (*Buffer) OctetStringParse ¶
func (buf *Buffer) OctetStringParse() (OctetString, error)
func (*Buffer) OptionalIsSkipped ¶
func (*Buffer) StatusParse ¶
func (*Buffer) UpdateBytesRead ¶
func (*Buffer) ValueParse ¶
type CloseRequest ¶
type CloseRequest struct {
GlobalSignature OctetString
}
func CloseRequestParse ¶
func CloseRequestParse(buf *Buffer) (CloseRequest, error)
type CloseResponse ¶
type CloseResponse CloseRequest
func CloseResponseParse ¶
func CloseResponseParse(buf *Buffer) (CloseResponse, error)
type GetListRequest ¶
type GetListRequest struct {
ClientID OctetString
ServerID OctetString // optional
Username OctetString // optional
Password OctetString // optional
ListName OctetString // optional
}
func GetListRequestParse ¶
func GetListRequestParse(buf *Buffer) (GetListRequest, error)
type GetListResponse ¶
type GetListResponse struct {
ClientID OctetString
ServerID OctetString
ListName OctetString
ActSensorTime Time
ValList []*ListEntry
ListSignature OctetString
ActGatewayTime Time
}
func GetListResponseParse ¶
func GetListResponseParse(buf *Buffer) (GetListResponse, error)
type ListEntry ¶
type ListEntry struct {
ObjName OctetString
Unit uint8
Value Value
ValueSignature OctetString
// contains filtered or unexported fields
}
func ListEntryParse ¶
func (*ListEntry) ObjectName ¶
func (*ListEntry) ValueString ¶
type Message ¶
type Message struct {
TransactionID OctetString
GroupID uint8
AbortOnError uint8
MessageBody MessageBody
Crc uint16
}
type MessageBody ¶
type MessageBody struct {
Tag uint32
Data MessageBodyData
}
func MessageBodyParse ¶
func MessageBodyParse(buf *Buffer) (MessageBody, error)
type MessageBodyData ¶
type MessageBodyData interface{}
type OctetString ¶
type OctetString []byte
type OpenRequest ¶
type OpenRequest struct {
Codepage OctetString // optional
ClientID OctetString
ReqFileID OctetString
ServerID OctetString // optional
Username OctetString // optional
Password OctetString // optional
Version uint8 // optional
}
func OpenRequestParse ¶
func OpenRequestParse(buf *Buffer) (OpenRequest, error)
type OpenResponse ¶
type OpenResponse struct {
Codepage OctetString
ClientID OctetString
ReqFileID OctetString
ServerID OctetString
RefTime Time
Version uint8
}
func OpenResponseParse ¶
func OpenResponseParse(buf *Buffer) (OpenResponse, error)
type ReadOption ¶
type ReadOption func(*options)
func WithObisCallback ¶
func WithObisCallback(obisCode OctetString, callback func(message *ListEntry)) ReadOption
Source Files
¶
Click to show internal directories.
Click to hide internal directories.