修改命令行窗口的bug

This commit is contained in:
weidong 2023-11-21 18:46:47 +08:00
parent e7df85fdfa
commit 2de2689f00

View File

@ -43,24 +43,24 @@ public class CmdLineController extends BasicController{
@RequestParam("device_id") String deviceId, @RequestParam("device_id") String deviceId,
@RequestParam("cmd_type") int cmdType) { @RequestParam("cmd_type") int cmdType) {
String sendCmd = cmd.replaceAll(" +",""); String sendCmd = cmd.replaceAll(" +","");
short len = (short) (sendCmd.length()/2); short len = 0;
int msgType; int msgType;
if(cmdType == 0){ // GNSS if(cmdType == 0){ // GNSS
msgType = 0xD310; msgType = 0xD310;
len += 4; len = (short) (sendCmd.length()/2+4);
sendCmd = "D310"+ HexUtil.Short2HexString(len)+ sendCmd = "D310"+ HexUtil.Short2HexString(len)+
HexUtil.Int2HexString(Integer.parseInt(deviceId))+sendCmd; HexUtil.Int2HexString(Integer.parseInt(deviceId))+sendCmd;
} }
else if(cmdType == 1){ // DTU else if(cmdType == 1){ // DTU
msgType = 0xD31A; msgType = 0xD31A;
len += 5; len = (short) (sendCmd.length() + 5);
sendCmd = "D31A"+ HexUtil.Short2HexString(len)+ sendCmd = "D31A"+ HexUtil.Short2HexString(len)+
HexUtil.Int2HexString(Integer.parseInt(deviceId))+ HexUtil.Int2HexString(Integer.parseInt(deviceId))+
"01"+HexUtil.String2HexString(sendCmd); "01"+HexUtil.String2HexString(sendCmd);
} }
else { else {
msgType = 0xD311; msgType = 0xD311;
len += 4; len = (short) (sendCmd.length()/2+4);
sendCmd = "D311"+ HexUtil.Short2HexString(len)+ sendCmd = "D311"+ HexUtil.Short2HexString(len)+
HexUtil.Int2HexString(Integer.parseInt(deviceId))+sendCmd; HexUtil.Int2HexString(Integer.parseInt(deviceId))+sendCmd;
} }