在c#中从串口发送和接收命令到文本框 [英] send and receive command from serial port to textbox in c#

查看:233
本文介绍了在c#中从串口发送和接收命令到文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用serialport做一个项目。我有一种形式的三种形式,我从串口接收命令'g',并根据指定的时间间隔将其显示到文本框。在另一种形式中,我希望从串口接收命令'c'并将其显示到文本框,并使用魔杖将数据从文本框发送到serialport,以通过单击按钮更新该值。在最后一种形式中,我希望从serialport接收命令'v'并将其显示到文本框,并通过按钮单击将数据从文本框发送到serialport。我不知道开始这个代码...请帮助我......我是使用串口通信的新手....

提前致谢

Hi I am doing one project using serialport. I have three forms in one form i receive command 'g' from serial port and display it to text box based on specify time interval. And in another form i want to receive command 'c' from serial port and display it to textbox and also wand to send data from textbox to serialport to update that value through one button click. And in last form i want to receive command 'v' from serialport and display it to textbox and send the data from textbox to serialport through button click. I have no idea to start this code... Please help me.... i am new in using serial port communication....
Thanks in advance

推荐答案

您应该有一个(工作)线程进行串口通信。反过来,这样的线程会将适当接收的数据发送到适当的GUI控件(参见如何:对Windows窗体控件进行线程安全调用 [ ^ ])。它也可以从GUI控件获取输入,以便将它们发送到串口。
You should have a single (working) thread for serial port communication. Such thread in turn, would dispatch apporpriately received data to the proper GUI control (see How to: Make Thread-Safe Calls to Windows Forms Controls[^]). It would as well get input from the GUI controls in order to send them to the serial port.


您已经在 http://www.codeproject.com/Messages/4862914/send-and-receive-command-from -serial-port-to-textb.aspx [ ^ ];请仅在一个论坛发帖。
You already posted this question at http://www.codeproject.com/Messages/4862914/send-and-receive-command-from-serial-port-to-textb.aspx[^]; please post in one forum only.


这篇关于在c#中从串口发送和接收命令到文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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