|
mycom是串口通信类,在本blog前一篇中有完整代码。 下面是串口通讯测试程序的源代码,将mycom类放在此项目中 可以实现简单的串口通信,希望读者能通过这个程序对串口通信过程有一个初步的了解:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Threading; namespace BusApp { /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Button button1; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.TextBox textBox8; private System.Windows.Forms.Label label7;
public int iPort=1; //1,2,3,4 public int iRate=9600; //1200,2400,4800,9600 public byte bSize=8; //8 bits public byte bParity=0; // 0-4=no,odd,even,mark,space public byte bStopBits=1; // 0,1,2 = 1, 1.5, 2 public int iTimeout=1000; public mycom mycom1=new mycom(); public byte[] recb;
private System.Windows.Forms.TextBox msg; private System.Windows.Forms.TextBox t_port; private System.Windows.Forms.TextBox t_rate; private System.Windows.Forms.TextBox t_bytesize;
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >> |