From 9336ed819ce1440d9f01c0d1fc4c6b3008862d4e Mon Sep 17 00:00:00 2001 From: zms Date: Mon, 17 Nov 2025 17:07:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D1005=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=8F=92=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/D331RtcmMessageExecutor.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D331RtcmMessageExecutor.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D331RtcmMessageExecutor.java index c6d50d72..f09e391c 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D331RtcmMessageExecutor.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D331RtcmMessageExecutor.java @@ -187,11 +187,17 @@ public class D331RtcmMessageExecutor implements Executor buf.writeBytes(forwardBytes); //推送策略:F9P基站(505)兼容博通(510)推送 添加指定基站ID的推送 - if ((deviceBs.getModel()==null || deviceBs.getModel() == GnssDevice.MODEL_G505) && - (device.getModel()!=null && device.getModel()==GnssDevice.MODEL_G510)|| - TARGET_BASE_STATION_ID_FOR_1005.equals(deviceBs.getDeviceId())){ + // 避免修改共享的 forwardBytes,针对 2307 机型仅修改本次缓冲区 + if (deviceId.startsWith("2307") && buf.readableBytes() > 2) { + buf.setByte(2, (byte) (buf.getByte(2) & 0x07)); + } + if (((deviceBs.getModel()==null || deviceBs.getModel() == GnssDevice.MODEL_G505) && + (device.getModel()!=null && device.getModel()==GnssDevice.MODEL_G510)) + || TARGET_BASE_STATION_ID_FOR_1005.equals(deviceBs.getDeviceId())){ buf = insert1005(deviceBs, deviceId, buf); } + // 实际发送到设备通道 + deviceChannel.writeAndFlush(buf); } } @@ -206,8 +212,11 @@ public class D331RtcmMessageExecutor implements Executor //logger.info("Adding D300 string for device: {}", deviceId); // 获取当前buf中的数据 - byte[] originalData = buf.array(); - String originalHex = ByteUtil.bytesToHexString(originalData); + int readerIndex = buf.readerIndex(); + int readable = buf.readableBytes(); + byte[] originalData = new byte[readable]; + buf.getBytes(readerIndex, originalData); + String originalHex = ByteUtil.bytesToHexString(originalData).toLowerCase(java.util.Locale.ROOT); // 找到D300和D301的位置 int d300Index = originalHex.indexOf("d300"); @@ -230,7 +239,7 @@ public class D331RtcmMessageExecutor implements Executor if (insertIndex != -1) { // 创建新的buf - buf1005 = Unpooled.buffer(); + buf1005 = Unpooled.buffer(originalData.length + 64); // 写入D300/D301之前的数据 buf1005.writeBytes(originalData, 0, insertIndex / 2); @@ -252,15 +261,15 @@ public class D331RtcmMessageExecutor implements Executor // 写入剩余的数据 buf1005.writeBytes(originalData, insertIndex / 2, originalData.length - insertIndex / 2); + // 更新最后转发时间(仅在成功插入时) + lastD300ForwardTimeMap.put(deviceId, currentTime); + // 添加日志,记录插入位置和完整数据 // logger.info("Inserted RTCM 1005 message before position {}, complete data: {}", // insertIndex, // ByteUtil.bytesToHexString(buf.array())); } - // 更新最后转发时间 - lastD300ForwardTimeMap.put(deviceId, currentTime); - // 添加日志,记录测站转发的完整数据 //logger.info("Forward data to device: {}, time: {}, complete data: {}", // deviceId,