设计通过串行端口与硬件通信的应用程序
我正在尝试在c#中设计一个通过串行端口进行通信的Windows应用程序.该项目将具有一个连接选择屏幕,一个带菜单栏的主窗体以及连接到每个菜单项的多个对话框.应用程序的流程如下所示:
连接选择对话框将显示在MainForm_Load事件上,并捕获串行端口名称.
选择菜单项后,将通过串行端口发送关联的命令,并且对话框将显示响应数据.
我遇到了来自c ++的基本c#概念的麻烦.
如何只创建一个可以在所有对话框之间共享数据的串行类?
如何从对话框访问串行读取响应并以文本字段或更有意义的方式显示该数据?
当我进行绘制时,它看起来很简单,但是我不知道如何从串行端口访问数据以在每个对话框中显示.
I am making an attempt to design a Windows application in c# that communicates through a serial port. The project will have a connection select screen, a main form with a menu bar and multiple dialogs connected to each menu item. The flow of the application would look like this:
The connection select dialog will be shown on the MainForm_Load event and capture the serial port name.
When a menu items is selected, the associated command will be sent through the serial port and the dialog will show the response data.
I am having trouble with the basic c# concepts coming from c++.
How can I create just one serial class that can share data between all the dialogs?
How can I access the serial read response from my dialog and display that data in a text field or a more meaningful way?
When I draw this up, it appears simple, but I do not know how to access data from the serial port to display in each dialog.
Microsoft文档应该可以帮助您:
http://msdn.microsoft.com/en-us/library/system. io.ports.serialport.aspx [ ^ ]
这是具有完整代码的网站:
http://www.dreamincode.net/forums/topic/35775 -serial-port-communication-in-c%23/ [
The documentation from Microsoft should help you along:
http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx[^]
Here is a site with complete code:
http://www.dreamincode.net/forums/topic/35775-serial-port-communication-in-c%23/[^]