C#的SerialPort和超级终端终端、SerialPort

2023-09-03 03:55:32 作者:失去了呼吸的声音

我使用C#和的SerialPort和com0com(虚拟串行端口) 我的问题是,我的C#应用​​程序无法recive从超级数据,事件DataRecived不会触发,如果我叫manualy的readExisting我得到什么 为了测试这个问题,您可以创建这样一个有同样的问题的 HTTP://balau82.word$p$pss.com/2009/04/18/simplest-serial-port-terminal-in-csharp/ ,如果运行这个程序一切正常的两个实例,但如果你运行一个实例andne超级终端中的数据是从C#发送到hiperterminal而不是从超级终端回来。

i am using c# and Serialport and com0com(virtual serial ports) My problem is that my c# application can't recive data from hyperterminal,the event DataRecived is not fired and if i call manualy the readExisting i get nothing To test this problem you can create a basic c# app like this one that has same problem http://balau82.wordpress.com/2009/04/18/simplest-serial-port-terminal-in-csharp/ , if you run 2 instances of this app all is ok, but if you run one instance andne hyperterminal the data is send from C# to hiperterminal but not from hyperterm back.

推荐答案

这是相当太简单了,保证都不行。你需要在设置的SerialPort通信属性与超级终端配合他们。波特率,数据位,校验位和停止位最少。和超级终端将不发送任何东西,如果它没有检测到上线设备。你必须设置RtsEnable和DtrEnable属性为true。

It's rather too simple, guaranteed to not work. You'll need to set the communication properties on the SerialPort to match them with HyperTerminal. Baudrate, DataBits, Parity and StopBits at least. And HyperTerminal won't send anything if it doesn't detect the device on-line. You have to set the RtsEnable and DtrEnable properties to true.