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; }