From d2f8c8a26820611150fab2a5abcff85df17dcc46 Mon Sep 17 00:00:00 2001 From: jixishi Date: Fri, 26 Apr 2024 22:29:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Ctrl=E7=BB=84=E5=90=88?= =?UTF-8?q?=E9=94=AE=E5=8F=91=E9=80=81=E6=8C=87=E4=BB=A4.ctrl=20=E5=A6=82.?= =?UTF-8?q?ctrl=20c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- command.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/command.go b/command.go index b74ca0b..149bbf1 100644 --- a/command.go +++ b/command.go @@ -30,6 +30,15 @@ func cmdargs() { strout(out, config.outputCode, fmt.Sprintf(">-------Args(%v)-------<\n", len(args)-1)) strout(out, config.outputCode, fmt.Sprintf("%q\n", args[1:])) } +func cmdctrl() { + b := []byte(args[1]) + x := []byte{b[0] & 0x1f} + _, err = serialPort.Write(x) + if err != nil { + log.Fatal(err) + } + strout(out, config.outputCode, fmt.Sprintf("Ctrl+%s\n", b)) +} func cmdhex() { strout(out, config.outputCode, fmt.Sprintf(">-----Hex Send-----<\n")) strout(out, config.outputCode, fmt.Sprintf("%q\n", args[1:])) @@ -45,7 +54,7 @@ func cmdhex() { } func cmdinit() { commands = append(commands, Command{name: ".help", description: "帮助信息", function: cmdhelp}) - commands = append(commands, Command{name: ".args", description: "参数信息", function: cmdargs}) + commands = append(commands, Command{name: ".ctrl", description: "发送Ctrl组合键", function: cmdctrl}) commands = append(commands, Command{name: ".hex", description: "发送Hex", function: cmdhex}) commands = append(commands, Command{name: ".exit", description: "退出终端", function: cmdexit}) }