This commit is contained in:
2024-02-20 16:05:54 +08:00
parent fd51d1a357
commit 055a55cda1
7 changed files with 60 additions and 47 deletions

View File

@@ -72,7 +72,8 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
byte[] msg = (byte[]) message;
// 获取帧类型
String frameType = YKCUtils.frameType2Str(BytesUtil.copyBytes(msg, 5, 1));
byte[] frameTypeBytes = BytesUtil.copyBytes(msg, 5, 1);
String frameType = YKCUtils.frameType2Str(frameTypeBytes);
// 获取序列号域
int serialNumber = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(msg, 2, 2));
// 获取channel
@@ -95,8 +96,12 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
ByteBuf buffer = ctx.alloc().buffer().writeBytes(response);
this.channelWrite(channel.id(), buffer);
if (!CollectionUtils.containsAny(notPrintFrameTypeList, frameType)) {
log.info("【>>>>>平台响应消息>>>>>】channel:{}, 帧类型:{}, 帧名称:{}, 序列号域:{}, response:{}",
channel.id(), frameType, YKCFrameTypeCode.getFrameTypeStr(frameType), serialNumber,
// 应答帧类型
byte[] responseFrameTypeBytes = YKCFrameTypeCode.ResponseRelation.getResponseFrameTypeBytes(frameTypeBytes);
String responseFrameType = YKCUtils.frameType2Str(responseFrameTypeBytes);
log.info("【>>>>>平台响应消息>>>>>】channel:{}, 响应帧类型:{}, 响应帧名称:{}, 原帧类型:{}, 原帧名称:{}, 序列号域:{}, response:{}",
channel.id(), responseFrameType, YKCFrameTypeCode.getFrameTypeStr(responseFrameType),
frameType, YKCFrameTypeCode.getFrameTypeStr(frameType), serialNumber,
BytesUtil.binary(response, 16));
}
}