fix: archive gb32960 decode failures
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user