From 2de2689f0078d9acc8b17b601589b4112069d935 Mon Sep 17 00:00:00 2001 From: weidong Date: Tue, 21 Nov 2023 18:46:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=BD=E4=BB=A4=E8=A1=8C?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/imdroid/beidou/controller/CmdLineController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java b/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java index 5256783e..83ad807d 100644 --- a/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java +++ b/sec-beidou/src/main/java/com/imdroid/beidou/controller/CmdLineController.java @@ -43,24 +43,24 @@ public class CmdLineController extends BasicController{ @RequestParam("device_id") String deviceId, @RequestParam("cmd_type") int cmdType) { String sendCmd = cmd.replaceAll(" +",""); - short len = (short) (sendCmd.length()/2); + short len = 0; int msgType; if(cmdType == 0){ // GNSS msgType = 0xD310; - len += 4; + len = (short) (sendCmd.length()/2+4); sendCmd = "D310"+ HexUtil.Short2HexString(len)+ HexUtil.Int2HexString(Integer.parseInt(deviceId))+sendCmd; } else if(cmdType == 1){ // DTU msgType = 0xD31A; - len += 5; + len = (short) (sendCmd.length() + 5); sendCmd = "D31A"+ HexUtil.Short2HexString(len)+ HexUtil.Int2HexString(Integer.parseInt(deviceId))+ "01"+HexUtil.String2HexString(sendCmd); } else { msgType = 0xD311; - len += 4; + len = (short) (sendCmd.length()/2+4); sendCmd = "D311"+ HexUtil.Short2HexString(len)+ HexUtil.Int2HexString(Integer.parseInt(deviceId))+sendCmd; }