是否可以仅使用 C# 编程来模拟 com 端口发送和接收数据? [英] Is it possible to simulate com port sending and receiving data using only C# programming?

查看:27
本文介绍了是否可以仅使用 C# 编程来模拟 com 端口发送和接收数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个设备通过我的计算机上的 com 端口发送数据.

I have a device which sends data by com port on my computer.

我知道如何模拟它,但是必须插入控制器才能模拟发送数据(使用Proteus)

I know how to simulate it, but the controller must be plugged in to simulate sending data (using Proteus)

是否可以在不插入任何外部设备的情况下模拟com端口发送数据?

Is it possible to simulate the com port sending data without having any external device plugged in?

例如:我想写一个打开 com 端口并等待数据的 C# 程序,以及另一个在同一个端口上写入数据的 C# 程序.

For example: I want to write a C# program which opens the com port and waits for data, and another c# program which writes data on the same port.

推荐答案

最好的方法是使用软件 COM 端口仿真器.我使用 com0com :

The best way to do this is to use a software COM port emulator. I use com0com :

零调制解调器模拟器

这在系统上提供了虚拟 NM COM 端口对(即:输出到一个是输入到另一个,反之亦然).这些设备显示在设备管理器中就像一个真正的 COM 端口,因此您可以在 C# 中与它们进行交互,就好像它们是真正的硬件设备一样.

This provides virtual NM COM port pairs on the system (ie: what is output to one is input to the other and vice-versa). The devices show up in Device Manager just like a real COM port so you interact with them in C# as though they were real hardware devices.

这篇关于是否可以仅使用 C# 编程来模拟 com 端口发送和接收数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆