且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使USB串口通信适应RS232到USB串口通信。

更新时间:2023-01-12 11:46:26

为了您的目的,我会丢弃您在网上某处找到的代码并查看本文。

C#中的串口通信初学者 [ ^ ]



因为你有一个USB转RS232转换器,它将枚举为一个或多个虚拟COM端口(VCP)。

在大多数情况下这与连接物理串口相同。



开始与设备通信的方法是通过类SerialPort [ ^ ]。您也可以在那里找到一些入门示例。
For your purpose I would discard the code you found "somewhere on the net" and take a look at this article.
Serial Comms in C# for Beginners[^]

As you have a USB to RS232 converter it will enumerate as one or more Virtual COM Ports (VCP).
In most ways this is the same as connecting to a physical serial port.

The way to start communicating with your device is via the class SerialPort[^]. You can find some starter examples there too.