本文介绍了传递命令到一个通信端口使用C#的SerialPort类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前,我正在试图从一个写在VB6例如测试应用程序通过一个特定的命令。在VB6的命令如下:
I'm currently trying to pass a specific command from an example test application written in VB6. In VB6 the command looks like:
Comm1.Output = "UUT_SEND ""REMS\n"" " + Chr(10)
目前我正在试图找出如何通过C#的SerialPort类传递相同的数据。
Currently I'm trying to figure out how to pass that same data via C#'s SerialPort class.
推荐答案
发送的东西出来的SerialPort是相对简单的....
sending stuff out the serialport is relatively straight forward....
var serialPort = new SerialPort("COM1", 9600);
serialPort.Write("UUT_SEND \"REMS\\n\" \n");
要得到任何答复,你将不得不挂钩DataReceived事件检索。
To get any responses you will have to hook the DataReceived event.
这篇关于传递命令到一个通信端口使用C#的SerialPort类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!