mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-11 18:59:51 +08:00
Merge branch 'dev' of http://192.168.2.46:8099/jsowell/jsowell-charger-web into dev
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package com.jsowell.netty.decoder;
|
package com.jsowell.netty.decoder;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import com.jsowell.netty.domain.ChargingPileMessage;
|
import com.jsowell.netty.domain.ChargingPileMessage;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@@ -13,7 +12,6 @@ import java.util.List;
|
|||||||
public class MessageDecode extends ByteToMessageDecoder {
|
public class MessageDecode extends ByteToMessageDecoder {
|
||||||
@Override
|
@Override
|
||||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||||
// log.info("MessageDecode.decode");
|
|
||||||
// 检查是否有足够的字节可以读取
|
// 检查是否有足够的字节可以读取
|
||||||
if (in.readableBytes() < 14) { // 最小长度(包头3 + 长度2 + 物理ID4 + 消息ID2 + 命令1 + 校验2)
|
if (in.readableBytes() < 14) { // 最小长度(包头3 + 长度2 + 物理ID4 + 消息ID2 + 命令1 + 校验2)
|
||||||
return;
|
return;
|
||||||
@@ -27,51 +25,4 @@ public class MessageDecode extends ByteToMessageDecoder {
|
|||||||
ChargingPileMessage message = ChargingPileMessage.parseMessage(bytes);
|
ChargingPileMessage message = ChargingPileMessage.parseMessage(bytes);
|
||||||
out.add(message);
|
out.add(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
|
||||||
// // 检查是否至少有最小长度的字节可以读取
|
|
||||||
// if (in.readableBytes() < 14) { // 最小长度(包头3 + 长度2 + 物理ID4 + 消息ID2 + 命令1 + 校验2)
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 标记读指针位置
|
|
||||||
// in.markReaderIndex();
|
|
||||||
//
|
|
||||||
// // 读取包头
|
|
||||||
// byte[] headerBytes = new byte[3];
|
|
||||||
// in.readBytes(headerBytes);
|
|
||||||
// String header = new String(headerBytes);
|
|
||||||
//
|
|
||||||
// // 读取长度
|
|
||||||
// int length = in.readUnsignedShort();
|
|
||||||
//
|
|
||||||
// // 检查剩余字节数是否足够读取整个包
|
|
||||||
// if (in.readableBytes() < length - 5) { // 减去包头和长度本身占的字节数
|
|
||||||
// in.resetReaderIndex();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 读取物理ID
|
|
||||||
// int physicalId = in.readInt();
|
|
||||||
//
|
|
||||||
// // 读取消息ID
|
|
||||||
// int messageId = in.readUnsignedShort();
|
|
||||||
//
|
|
||||||
// // 读取命令
|
|
||||||
// byte command = in.readByte();
|
|
||||||
//
|
|
||||||
// // 读取数据
|
|
||||||
// byte[] data = new byte[length - 12]; // 减去固定字段的字节数
|
|
||||||
// in.readBytes(data);
|
|
||||||
//
|
|
||||||
// // 读取校验
|
|
||||||
// int checksum = in.readUnsignedShort();
|
|
||||||
//
|
|
||||||
// // 创建ChargingPileMessage对象并添加到输出列表
|
|
||||||
// ChargingPileMessage message = new ChargingPileMessage(header, length, physicalId, messageId, command, data, checksum);
|
|
||||||
// out.add(message);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@ public class ChargingPileMessage {
|
|||||||
private int length; // 长度 (2字节)
|
private int length; // 长度 (2字节)
|
||||||
private int physicalId; // 物理ID (4字节)
|
private int physicalId; // 物理ID (4字节)
|
||||||
private int messageId; // 消息ID (2字节)
|
private int messageId; // 消息ID (2字节)
|
||||||
private byte command; // 命令 (1字节)
|
private String command; // 命令 (1字节)
|
||||||
private byte[] data; // 数据 (n字节)
|
private byte[] data; // 数据 (n字节)
|
||||||
private int checksum; // 校验 (2字节)
|
private int checksum; // 校验 (2字节)
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class ChargingPileMessage {
|
|||||||
|
|
||||||
// 读取命令
|
// 读取命令
|
||||||
byte command = messageBytes[11];
|
byte command = messageBytes[11];
|
||||||
message.setChecksum(command);
|
message.setCommand(BytesUtil.bcd2StrLittle(new byte[] {command}));
|
||||||
// System.out.println("命令:" + BytesUtil.bcd2StrLittle(new byte[] {command}));
|
// System.out.println("命令:" + BytesUtil.bcd2StrLittle(new byte[] {command}));
|
||||||
|
|
||||||
// 读取数据
|
// 读取数据
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
<!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico" /> -->
|
<!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico" /> -->
|
||||||
<link rel="icon" href="#" />
|
<link rel="icon" href="#" />
|
||||||
<title><%= webpackConfig.name %></title>
|
<title><%= webpackConfig.name %></title>
|
||||||
|
<script src="http://api.tianditu.gov.cn/api?v=4.0&tk=d1eaedfce9e50588c78a91bbbdc5d5bc" type="text/javascript"></script>
|
||||||
<!--[if lt IE 11
|
<!--[if lt IE 11
|
||||||
]><script>
|
]><script>
|
||||||
window.location.href = "/html/ie.html";
|
window.location.href = "/html/ie.html";
|
||||||
|
|||||||
Reference in New Issue
Block a user