代码拉取完成,页面将自动刷新
package xs
import (
"bytes"
"encoding/binary"
)
func (command *Command) Encode(bigEndian bool) []byte {
lenOfBuf1 := len(command.Buf1)
if lenOfBuf1 > 0xff {
command.Buf1 = command.Buf1[0:0xff]
lenOfBuf1 = 0xff
}
lenOfBuf := len(command.Buf)
buf := make([]byte, 8+lenOfBuf+lenOfBuf1)
buf[0] = command.Cmd //1
buf[1] = command.Arg1 //1
buf[2] = command.Arg2 //1
buf[3] = uint8(lenOfBuf1) //1
bInt := uint32(lenOfBuf)
bytesBuff := bytes.NewBuffer([]byte{})
if bigEndian {
_ = binary.Write(bytesBuff, binary.BigEndian, bInt)
} else {
_ = binary.Write(bytesBuff, binary.LittleEndian, bInt)
}
copy(buf[4:], bytesBuff.Bytes()) //4
idx := 8
if lenOfBuf > 0 {
copy(buf[idx:], command.Buf)
idx += lenOfBuf
}
if lenOfBuf1 > 0 {
copy(buf[idx:], command.Buf1)
}
return buf
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。