binary

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Escape uint8 = 0x7d
View Source
const IdentityBit uint8 = 0x7e

IdentityBit 标识位

Variables

This section is empty.

Functions

func EliminateChecksum

func EliminateChecksum(data []byte) []byte

EliminateChecksum 去除校验码

func EliminateIdentityBit

func EliminateIdentityBit(data []byte) []byte

EliminateIdentityBit 去除首尾校验码

Types

type ErrReader

type ErrReader struct {
	R   Reader
	Err error
}

func (*ErrReader) ReadBCD

func (er *ErrReader) ReadBCD(length int) string

func (*ErrReader) ReadByte

func (er *ErrReader) ReadByte() byte

func (*ErrReader) ReadBytes

func (er *ErrReader) ReadBytes(size int) []byte

func (*ErrReader) ReadString

func (er *ErrReader) ReadString(size int) string

func (*ErrReader) ReadUint16

func (er *ErrReader) ReadUint16() uint16

func (*ErrReader) ReadUint32

func (er *ErrReader) ReadUint32() uint32

type ErrWrite

type ErrWrite struct {
	W   Writer
	Err error
}

func (*ErrWrite) Write

func (ew *ErrWrite) Write(p []byte)

func (ErrWrite) WriteBCD

func (ew ErrWrite) WriteBCD(s string, length int)

func (ErrWrite) WriteByte

func (ew ErrWrite) WriteByte(c byte)

func (ErrWrite) WriteString

func (ew ErrWrite) WriteString(s string)

func (ErrWrite) WriteStringWithFill

func (ew ErrWrite) WriteStringWithFill(s string, maxLength int, from StartingEnd)

func (ErrWrite) WriteUint16

func (ew ErrWrite) WriteUint16(data uint16)

func (ErrWrite) WriteUint32

func (ew ErrWrite) WriteUint32(data uint32)

func (ErrWrite) WriteUint8

func (ew ErrWrite) WriteUint8(data uint8)

type Reader

type Reader struct {
	*bytes.Reader
}

func NewReader

func NewReader(b []byte) Reader

func (*Reader) ReadBCD

func (r *Reader) ReadBCD(length int) (string, error)

ReadBCD 读取BCD编码

func (*Reader) ReadBytes

func (r *Reader) ReadBytes(size int) ([]byte, error)

ReadBytes 读取多个字节

func (*Reader) ReadUint16

func (r *Reader) ReadUint16() (uint16, error)

ReadUint16 读取双字节

func (*Reader) ReadUint32

func (r *Reader) ReadUint32() (uint32, error)

ReadUint32 读取四字节

func (*Reader) ReaderString

func (r *Reader) ReaderString(size int) (string, error)

ReaderString 读取字符串

type StartingEnd

type StartingEnd int

StartingEnd 起始端

const (
	// Front 前置占位
	Front StartingEnd = iota

	// Behind 后置占位
	Behind
)

type Writer

type Writer struct {
	*bytes.Buffer
}

Writer JTT808数据缓冲写入对象

func NewWriter

func NewWriter() Writer

NewWriter 创建新的JTT808数据缓冲写入对象

func (Writer) WriteBCD

func (w Writer) WriteBCD(s string, length int) error

WriteBCD 写入BCD编码

func (Writer) WriteData

func (w Writer) WriteData(data []byte, maxLength int, from StartingEnd) error

WriteData 写入数据

func (Writer) WriteString

func (w Writer) WriteString(s string) error

func (Writer) WriteStringWithFill

func (w Writer) WriteStringWithFill(s string, maxLength int, from StartingEnd) error

func (Writer) WriteUint16

func (w Writer) WriteUint16(data uint16) error

WriteUint16 写入Uint16数据

func (Writer) WriteUint32

func (w Writer) WriteUint32(data uint32) error

WriteUint32 写入Uint32数据

func (Writer) WriteUint8

func (w Writer) WriteUint8(data uint8) error

WriteUint8 写入Uint8数据

Jump to

Keyboard shortcuts

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