Documentation ¶
Index ¶
- Constants
- func AddMBAPHead(cmdbody []byte, args ...byte) []byte
- func ByteToFloat32(bytes []byte) float32
- func ByteToFloat64(bytes []byte) float64
- func ByteToInt16(bytes []byte) int
- func ByteToLong(bytes []byte) int
- func ByteToUint16(bytes []byte) uint16
- func ByteToUint32(bytes []byte) uint32
- func Bytes2Data(databyte []byte, datatype int) interface{}
- func Bytes2Uint16(buf []byte) []uint16
- func CRC16(bs []byte) uint16
- func CRC16Byte(bs []byte) []byte
- func Data2bytes(datastr string, datatype int) (databytes []byte)
- func Float32ToByte(float float32) []byte
- func Float32ToStr(f float32) string
- func Float64ToByte(float float64) []byte
- func GetDCBA(in []byte, types int) (out []byte)
- func ModbusCRC(bs []byte) uint16
- func ModbusCRCCheck(resp []byte) bool
- func StrToFloat32(i string) float32
- func Uint162Bytes(value ...uint16) []byte
Constants ¶
View Source
const ( DataTypeBool = 0 // 开关类型 DataTypeInt = 10 // 16整型 DataTypeUint = 11 // 16无符号整型 DataTypeLong = 20 // 32长整型 DataTypeUlong = 21 // 32无符号整型 DataTypeFloat = 22 // 32浮点型 DataTypeDouble = 30 // 64浮点型 )
数据类型 [0, 10) 少于16位, [10, 20) 16位, [20, 30) 32位, [30, 40) 64位. 通过 / 10 得到 商 [0,1,2,3] >> [<16, 16, 32, 46]
View Source
const ( ABCD = 0 DCBA = 1 CDAB = 2 BADC = 3 )
Variables ¶
This section is empty.
Functions ¶
func ByteToFloat32 ¶
func ByteToFloat64 ¶
func ByteToUint16 ¶ added in v1.0.4
func ByteToUint32 ¶ added in v1.0.4
func Bytes2Data ¶ added in v1.0.4
字节数组转数值
func Bytes2Uint16 ¶
bytes2Uint16 bytes convert to uint16 for register.
func Data2bytes ¶ added in v1.0.4
数值转字节数组
func Float32ToByte ¶
func Float64ToByte ¶
func Uint162Bytes ¶
uint162Bytes creates a sequence of uint16 data.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.