简体   繁体   English

虚拟 COM 端口在 PuTTy 中有效,但在我的程序中无效

[英]Virtual COM port works in PuTTy but not in my program

When I connect a device to the computer using USB virtual COM port and open the port in my application (in Qt, QSerialPort), it receives nothing.当我使用 USB 虚拟 COM 端口将设备连接到计算机并在我的应用程序中打开该端口时(在 Qt,QSerialPort 中),它什么也没收到。

When I open the port in PuTTy, it works as expected.当我在 PuTTy 中打开端口时,它按预期工作。

Surprisingly, after closing PuTTy and opening the port in my application again, it started to work as expected.令人惊讶的是,关闭 PuTTy 并再次在我的应用程序中打开端口后,它开始按预期工作。

This problem only occurs with some devices, namely Raspberry Pi Pico, but not with other devices like STM32 USB VCP and USB-UART transceivers.此问题仅出现在某些设备上,即 Raspberry Pi Pico,但不会出现在其他设备上,如 STM32 USB VCP 和 USB-UART 收发器。

The likely cause is that the USB device needs to have the DTR signal (which is part of RS232) set to high in order to start transmitting.可能的原因是 USB 设备需要将 DTR 信号(RS232 的一部分)设置为高电平才能开始传输。 (many devices disregard the value of DTR, some do not) (许多设备无视 DTR 的值,有些则没有)

Use serial->setDataTerminalReady(true);使用serial->setDataTerminalReady(true); on QSerialPort after opening it.打开QSerialPort上。

PuTTy seems to set it to high after opening, but not set it low on closing. PuTTy似乎在打开后将其设置为高,但在关闭时并未将其设置为低。 That's why it makes it work in your app after opening it once.这就是为什么它在打开一次后就可以在您的应用程序中运行的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM