package Common
import (
"strconv"
log "github.com/sirupsen/logrus"
)
type Compackets struct {
/// 命令类型01表示命令包、02表示语音包、03表示同传包
CmdType byte
/// 通道ID
ChnlID byte
/// 单元地址
Addr byte
/// 命令字
Cmd byte
/// 命令字扩展
Const byte
/// 命令数据1
ACmdData1 byte
/// 命令数据2
ACmdData2 byte
/// 命令数据3
ACmdData3 byte
/// 命令数据4
ACmdData4 byte
/// 包长高字节
LenH byte
/// 包长低字节
LenL byte
//dataLength = aLenH*256 + aLenL;
/// 数据长度
DataLength int
/// 数据部分
Data []byte
/// ipAddress
IPAddress string
SocketID int64
}
func (o *Compackets) ToString() string {
defer func() {
if r := recover(); r != nil {
log.Error("ToString:", r)
}
}()
var stringBuilder string
stringBuilder += ("7E ")
//stringBuilder.AppendFormat("{0:X2} ", CmdType);
//stringBuilder.AppendFormat("{0:X2} ", ChnlID);
//stringBuilder.AppendFormat("{0:X2} ", Addr);
stringBuilder += strconv.FormatInt(int64(o.Cmd), 16) + " "
stringBuilder += strconv.FormatInt(int64(o.Const), 16) + " "
stringBuilder += strconv.FormatInt(int64(o.LenH), 16) + " "
stringBuilder += strconv.FormatInt(int64(o.LenL), 16) + " "
for _, vlue := range o.Data {
stringBuilder += strconv.FormatInt(int64(vlue), 16) + " "
}
return stringBuilder
}