关机重启

main
wangbin 2 months ago
parent e9d73527a5
commit 58cd56b97d

@ -6,6 +6,8 @@ import (
"fmt"
"io/ioutil"
"net"
"os/exec"
"runtime"
"strconv"
"strings"
@ -129,6 +131,25 @@ func (para *FlxNetworkCmdReader) UDPValidateRecvBuffer(packLen int, RecvBuffer [
PackBuff = RecvBuffer[startIndex : startIndex+packLen]
//校验CRC
CRCBuff := CRCCheck12(PackBuff[:packLen-2])
if PackBuff[0] == 0x7e && RecvBuffer[1] == 0x24 && RecvBuffer[2] == 0x01 {
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
cmd = exec.Command("shutdown", "/r", "/t", "0")
} else {
cmd = exec.Command("shutdown", "-h", "now")
}
cmd.Run()
}
if PackBuff[0] == 0x7e && RecvBuffer[1] == 0x24 && RecvBuffer[2] == 0x00 {
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
cmd = exec.Command("shutdown", "/s", "/t", "0")
} else {
cmd = exec.Command("shutdown", "-h", "now")
}
cmd.Run()
}
if CRCBuff[0] != PackBuff[packLen-2] || CRCBuff[1] != PackBuff[packLen-1] {
//InvokeOnDataReciveLogHandler(string.Format(FlxNetCCUConstantText.ReciveDataBufferImperfect_Error, "飞利信网口中控机")); //--写日志

Loading…
Cancel
Save