fix: archive gb32960 decode failures
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
lingniu
2026-06-29 18:47:19 +08:00
parent 8804c01d99
commit d1748fcc2f
2 changed files with 48 additions and 0 deletions

View File

@@ -109,6 +109,7 @@ public class Gb32960ChannelHandler extends SimpleChannelInboundHandler<byte[]> {
} catch (Exception e) {
// 解码失败只丢当前帧不主动断开连接。真实设备偶发脏字节时FrameDecoder 会继续寻找下一帧头。
log.warn("[gb32960] decode failed peer={} len={}", addr(ctx), frame.length, e);
dispatchMalformed(ctx, frame, e.getMessage());
return;
}
@@ -224,6 +225,22 @@ public class Gb32960ChannelHandler extends SimpleChannelInboundHandler<byte[]> {
Instant.now());
}
private void dispatchMalformed(ChannelHandlerContext ctx, byte[] frame, String errorMessage) {
Map<String, String> sourceMeta = new HashMap<>(4);
sourceMeta.put("vin", "unknown");
sourceMeta.put("peer", addr(ctx));
sourceMeta.put("parseError", "true");
sourceMeta.put("parseErrorMessage", errorMessage == null ? "" : errorMessage);
dispatcher.dispatch(new RawFrame(
ProtocolId.GB32960,
0,
0,
frame,
frame == null ? new byte[0] : frame,
sourceMeta,
Instant.now()));
}
private static boolean requiresDurableAck(CommandType cmd) {
return switch (cmd) {
case VEHICLE_LOGIN,