update 获取字节数组

This commit is contained in:
Guoqs
2024-11-27 08:44:34 +08:00
parent 75cdfba054
commit 34ad0023c8

View File

@@ -61,13 +61,20 @@ public class YKCDataProtocol {
this.crcByte = new byte[]{msg[msg.length - 2], msg[msg.length - 1]}; this.crcByte = new byte[]{msg[msg.length - 2], msg[msg.length - 1]};
} }
/**
* 获取字节数组
*/
public byte[] getBytes() {
return Bytes.concat(this.head, this.length, this.serialNumber, this.encryptFlag, this.frameType, this.msgBody, this.crcByte);
}
/** /**
* 转换为十六进制字符串 * 转换为十六进制字符串
* *
* @return 报文 * @return 报文
*/ */
public String getHEXString() { public String getHEXString() {
byte[] bytes = Bytes.concat(this.head, this.length, this.serialNumber, this.encryptFlag, this.frameType, this.msgBody, this.crcByte); byte[] bytes = getBytes();
return BytesUtil.binary(bytes, 16); return BytesUtil.binary(bytes, 16);
} }
} }