这节介绍实现的是利用SerialPort类进行串口的链接。
.Net Framework 作为微软开发的一个框架,万变不离其宗,要怎么使用一个东西,就最好看它的说明书 。
SerialPort Class 的文档链接:https://docs.microsoft.com/en-us/dotnet/api/system.io.ports.serialport?view=netframework-4.5
它的示例介绍写着:
The following code example demonstrates the use of the SerialPort class to allow two users to chat from two separate computers connected by a null modem cable. In this example, the users are prompted for the port settings and a username before chatting. Both computers must be executing the program to achieve full functionality of this example.
提取重点就是:两个计算机的users 通过使用SerialPort class 去进行聊天 ,两个电脑通过的是a null modem cable(这里应该指的是串口线,因为RS232线的名字是RS232 Cable (Null Modem Cable))进行连接。
我们现阶段主要实现的从串口中获取数据,写数据暂时不需要,所以我们可以在里面提取我们需要的部分。
在文档的左侧,我们可以选择其方法和事件来选择我们所需要的实例。