Sending quot;ENTERquot; key through serial port(发送“ENTER通过串口键)
问题描述
您好,我想向通过串口连接的设备发送一些命令.怎么寄?
Hi I want to send some command to my device which is connected via serial port. How to send it?
例如,我在谷歌搜索中找到了这个,但对我来说没用.
For example i found this on google search but for me it's useless.
Control + E 是 5 的键盘快捷键,所以:
Control + E is a keyboard shortcut for 5, so:
serial.Write(new byte[]{ 5 }, 0, 1);
推荐答案
微软版的回车或换行是
,即0x0d 0x0a hex.
The microsoft version of enter or new line is
which is 0x0d 0x0a in hex.
是回车
在外壳或打印机中,这会将光标放回行首.
In a shell or a printer this would put the cursor back to the beginning of the line.
是换行符
将光标放在一个下面的行,在某些 shell 中,这也会将光标放在下一行的开头.打印机只需稍微滚动一下纸张即可.
Puts the cursor one line below, in some shells this also puts the cursor to the beginning of the next line. a printer would simply scroll the paper a bit.
历史课就讲这么多.当前的 Windows 系统仍然使用这些字符来表示行结束.当按下 enter 时,Dos 会生成此代码.
So much for the history lesson. Current windows systems still use these characters to indicate a line ending. Dos generated this code when pressing enter.
键码有点不同.从 esc 键开始是 1.Enter 是 28.
The key code is a bit different. Beginning with the esc key being the 1. Enter is 28.
来源:来自 www.comptechdoc.org 的 linux hlkeycodes
这篇关于发送“ENTER"通过串口键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:发送“ENTER"通过串口键
基础教程推荐
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
