serial-port - 如何在PuTTY串行通信中仅在按回车时发送字符?

标签 serial-port putty virtual-serial-port

我正在尝试使用PuTTY通过我的计算机的串行线路进行通信。我已经配置了正确的串行线路、波特率、数据位数、停止位、奇偶校验和流量控制,并建立了连接。当我单击“确定”打开连接时,我会看到黑屏,并且每次按键都会发送,但不会显示在屏幕上(窗口保持黑色)。如何配置 PuTTY,使其仅在我按 Enter 键后发送我的命令或操作码?

我在大学时使用PuTTY进行Telnet/SSH,它总是显示我的命令,并且只有在我按下回车键后才输入它们,所以我有点困惑。

最佳答案

您需要的设置是左侧“终端”类别下的“本地回显”“线路编辑”

要让字符在输入时显示在屏幕上,请将“本地回显”设置为“强制启用”

要让终端在按 Enter 之前不发送命令,请将“本地行编辑”设置为“强制启用”

PuTTY Line discipline options

说明:

来自 PuTTY 用户手册(通过单击 PuTTY 中的“帮助”按钮找到):

4.3.8 ‘Local echo’

With local echo disabled, characters you type into the PuTTY window are not echoed in the window by PuTTY. They are simply sent to the server. (The server might choose to echo them back to you; this can't be controlled from the PuTTY control panel.)

Some types of session need local echo, and many do not. In its default mode, PuTTY will automatically attempt to deduce whether or not local echo is appropriate for the session you are working in. If you find it has made the wrong decision, you can use this configuration option to override its choice: you can force local echo to be turned on, or force it to be turned off, instead of relying on the automatic detection.

4.3.9 ‘Local line editing’ Normally, every character you type into the PuTTY window is sent immediately to the server the moment you type it.

If you enable local line editing, this changes. PuTTY will let you edit a whole line at a time locally, and the line will only be sent to the server when you press Return. If you make a mistake, you can use the Backspace key to correct it before you press Return, and the server will never see the mistake.

Since it is hard to edit a line locally without being able to see it, local line editing is mostly used in conjunction with local echo (section 4.3.8). This makes it ideal for use in raw mode or when connecting to MUDs or talkers. (Although some more advanced MUDs do occasionally turn local line editing on and turn local echo off, in order to accept a password from the user.)

Some types of session need local line editing, and many do not. In its default mode, PuTTY will automatically attempt to deduce whether or not local line editing is appropriate for the session you are working in. If you find it has made the wrong decision, you can use this configuration option to override its choice: you can force local line editing to be turned on, or force it to be turned off, instead of relying on the automatic detection.

当为这些选项启用“自动”时,Putty 有时会做出错误的选择,因为它会尝试检测连接配置。应用于串行线,这有点棘手。

关于serial-port - 如何在PuTTY串行通信中仅在按回车时发送字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4999280/

相关文章:

ssh - 如何更改密码ssh连接?

c++ - 移除 USB 设备时以编程方式中断串行 I/O - C++

linux - 将来自一个 COM 端口的传入数据镜像到 Linux 上的虚拟 COM 端口

c - 如何在换行到达之前读取 tty 设备上的终端输入?

vim - Emacs 中是否有 'set paste' 选项可以从外部剪贴板粘贴?

linux - 文件描述符处于阻塞模式,但 read() 未阻塞

linux - 使用 awk 计算数字的平均值

c++ - Qt/C++中创建虚拟串口

Android连接BLE模块并通过串口发送数据

c# - 未初始化的串行端口属性是否像使用默认构造函数时一样被赋予默认值?