我创建了一个表单,我想在主页上的两个不同的COM端口上发送表单数据。怎么用C#? [英] I created one form and I want to send that form data on two different com ports on main page. How in C#?

查看:62
本文介绍了我创建了一个表单,我想在主页上的两个不同的COM端口上发送表单数据。怎么用C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个生成4个数据的表单,现在我想在两个不同波特率的com端口上发送数据。



我有什么试过:



我试图把条件放在那个com端口然后通过构造函数重载但是失败

I created a form which will generate4 data and now I want to send data on two different com ports with different baud rates.

What I have tried:

I tried to put condition on that com ports and then by constructor overloading but failed

推荐答案

你必须创建2个COM端口对象的实例,所以每个都是单独寻址的。



看看这个好的article 了解更多详情。非常重要的是文章末尾的线程安全的Invoke()代码,因为COM-ports可以在自己的线程中工作,因此与(主应用的)主线程的交互必须是线程安全的。
You must create 2 instance of you COM-port objects, so every one is individual addressed.

Take a look at this good article for further details. Very important is the thread safe Invoke() code at the end of the article, because the COM-ports ware working in a own thread, so interaction with the main thread (of your app) must be thread safe.


这篇关于我创建了一个表单,我想在主页上的两个不同的COM端口上发送表单数据。怎么用C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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