codec

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Pkl              = "pkl" // 数据包总长度
	Cmd              = "op"  // 数据包类型(命令类型)
	Seq              = "seq" // 序号(一对请求与响应序号相同)
	HeadLen   uint32 = 12
	PacketMax        = 5120
)

Variables

This section is empty.

Functions

func UnpackHead

func UnpackHead(h []byte) (pkl, cmd, seq uint32)

Types

type IHead

type IHead interface {
	Logger
	Encode() []byte
	Decode([]byte) error
}

type Logger

type Logger interface {
	Log() []log.Field
}

type Operation added in v0.2.0

type Operation interface {
	ToInt() uint32
	OpLog() log.Field
	String() string
}

type Pdu

type Pdu interface {
	Logger
	Encode() []byte
	Decode(seq uint32, frame []byte) error
}

type RequestPdu

type RequestPdu interface {
	Pdu
	ToResponse(code uint32) Pdu
}

type Sequence32

type Sequence32 interface {
	NextVal() int32
}

Sequence32 32位序号生成器

var B32Seq Sequence32

type Sequence64

type Sequence64 interface {
	NextVal() int64
}

Sequence64 64位序号生成器

var B64Seq Sequence64

type SequenceBCD

type SequenceBCD interface {
	NextVal() []byte
}

SequenceBCD BCD码序号生成器

var BcdSeq SequenceBCD

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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