亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? frmcomm.cs

?? C#寫的串口通信程序例子
?? CS
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace SerialComm
{
	/// <summary>
	/// Form1 的摘要說明。
	/// </summary>

	public class frmComm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button buttonOpen;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.Label label5;
		private System.Windows.Forms.ComboBox comboRaud;
		private System.Windows.Forms.ComboBox comboData;
		private System.Windows.Forms.ComboBox comboCheck;
		private System.Windows.Forms.ComboBox comboStop;
		private System.Windows.Forms.Button buttonExit;
		private System.Windows.Forms.ComboBox comboComm;
		private AxMSCommLib.AxMSComm axMSComm1;
		private System.Windows.Forms.Button buttonSend;
		private System.Windows.Forms.TextBox txtReceive;
		private System.Windows.Forms.TextBox txtSend;
	
		/// <summary>
		/// 必需的設計器變量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmComm()
		{
			//
			// Windows 窗體設計器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 調用后添加任何構造函數代碼
			//
		}

		/// <summary>
		/// 清理所有正在使用的資源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗體設計器生成的代碼
		/// <summary>
		/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
		/// 此方法的內容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmComm));
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.buttonOpen = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.label5 = new System.Windows.Forms.Label();
			this.comboRaud = new System.Windows.Forms.ComboBox();
			this.comboData = new System.Windows.Forms.ComboBox();
			this.comboCheck = new System.Windows.Forms.ComboBox();
			this.comboStop = new System.Windows.Forms.ComboBox();
			this.comboComm = new System.Windows.Forms.ComboBox();
			this.txtReceive = new System.Windows.Forms.TextBox();
			this.txtSend = new System.Windows.Forms.TextBox();
			this.buttonExit = new System.Windows.Forms.Button();
			this.axMSComm1 = new AxMSCommLib.AxMSComm();
			this.buttonSend = new System.Windows.Forms.Button();
			this.groupBox1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.axMSComm1)).BeginInit();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.buttonOpen);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.label4);
			this.groupBox1.Controls.Add(this.label5);
			this.groupBox1.Controls.Add(this.comboRaud);
			this.groupBox1.Controls.Add(this.comboData);
			this.groupBox1.Controls.Add(this.comboCheck);
			this.groupBox1.Controls.Add(this.comboStop);
			this.groupBox1.Controls.Add(this.comboComm);
			this.groupBox1.Location = new System.Drawing.Point(0, 0);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(144, 176);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "串口配置";
			// 
			// buttonOpen
			// 
			this.buttonOpen.Location = new System.Drawing.Point(8, 144);
			this.buttonOpen.Name = "buttonOpen";
			this.buttonOpen.Size = new System.Drawing.Size(128, 23);
			this.buttonOpen.TabIndex = 1;
			this.buttonOpen.Text = "打開串口";
			this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(48, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "串口號";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 48);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(48, 16);
			this.label2.TabIndex = 0;
			this.label2.Text = "波特率";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 72);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(48, 16);
			this.label3.TabIndex = 0;
			this.label3.Text = "數據位";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(8, 96);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(48, 16);
			this.label4.TabIndex = 0;
			this.label4.Text = "校驗位";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(8, 120);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(48, 16);
			this.label5.TabIndex = 0;
			this.label5.Text = "停止位";
			// 
			// comboRaud
			// 
			this.comboRaud.Items.AddRange(new object[] {
														   "CBR_4800",
														   "CBR_9600",
														   "CBR_14400"});
			this.comboRaud.Location = new System.Drawing.Point(56, 44);
			this.comboRaud.Name = "comboRaud";
			this.comboRaud.Size = new System.Drawing.Size(80, 20);
			this.comboRaud.TabIndex = 2;
			this.comboRaud.Text = "CBR_9600";
			// 
			// comboData
			// 
			this.comboData.Items.AddRange(new object[] {
														   "8",
														   "7"});
			this.comboData.Location = new System.Drawing.Point(56, 68);
			this.comboData.Name = "comboData";
			this.comboData.Size = new System.Drawing.Size(80, 20);
			this.comboData.TabIndex = 2;
			this.comboData.Text = "8";
			// 
			// comboCheck
			// 
			this.comboCheck.Items.AddRange(new object[] {
															"n",
															"1"});
			this.comboCheck.Location = new System.Drawing.Point(56, 92);
			this.comboCheck.Name = "comboCheck";
			this.comboCheck.Size = new System.Drawing.Size(80, 20);
			this.comboCheck.TabIndex = 2;
			this.comboCheck.Text = "n";
			// 
			// comboStop
			// 
			this.comboStop.Items.AddRange(new object[] {
														   "1",
														   "1.5",
														   "2"});
			this.comboStop.Location = new System.Drawing.Point(56, 116);
			this.comboStop.Name = "comboStop";
			this.comboStop.Size = new System.Drawing.Size(80, 20);
			this.comboStop.TabIndex = 2;
			this.comboStop.Text = "1";
			// 
			// comboComm
			// 
			this.comboComm.Items.AddRange(new object[] {
														   "COM1",
														   "COM2"});
			this.comboComm.Location = new System.Drawing.Point(56, 20);
			this.comboComm.Name = "comboComm";
			this.comboComm.Size = new System.Drawing.Size(80, 20);
			this.comboComm.TabIndex = 2;
			this.comboComm.Text = "COM1";
			// 
			// txtReceive
			// 
			this.txtReceive.Location = new System.Drawing.Point(152, 8);
			this.txtReceive.Multiline = true;
			this.txtReceive.Name = "txtReceive";
			this.txtReceive.Size = new System.Drawing.Size(352, 168);
			this.txtReceive.TabIndex = 1;
			this.txtReceive.Text = "";
			//this.txtReceive.TextChanged += new System.EventHandler(this.txtReceive_TextChanged);
			// 
			// txtSend
			// 
			this.txtSend.Location = new System.Drawing.Point(152, 184);
			this.txtSend.Multiline = true;
			this.txtSend.Name = "txtSend";
			this.txtSend.Size = new System.Drawing.Size(352, 56);
			this.txtSend.TabIndex = 2;
			this.txtSend.Text = "";
			// 
			// buttonExit
			// 
			this.buttonExit.Location = new System.Drawing.Point(8, 216);
			this.buttonExit.Name = "buttonExit";
			this.buttonExit.Size = new System.Drawing.Size(128, 23);
			this.buttonExit.TabIndex = 1;
			this.buttonExit.Text = "退出";
			this.buttonExit.Click += new System.EventHandler(this.buttonExit_Click);
			// 
			// axMSComm1
			// 
			this.axMSComm1.Enabled = true;
			this.axMSComm1.Location = new System.Drawing.Point(376, 24);
			this.axMSComm1.Name = "axMSComm1";
			this.axMSComm1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMSComm1.OcxState")));
			this.axMSComm1.Size = new System.Drawing.Size(38, 38);
			this.axMSComm1.TabIndex = 3;
			this.axMSComm1.OnComm += new System.EventHandler(this.axMSComm1_OnComm);
			// 
			// buttonSend
			// 
			this.buttonSend.Enabled = false;
			this.buttonSend.Location = new System.Drawing.Point(8, 184);
			this.buttonSend.Name = "buttonSend";
			this.buttonSend.Size = new System.Drawing.Size(128, 23);
			this.buttonSend.TabIndex = 1;
			this.buttonSend.Text = "發送";
			this.buttonSend.Click += new System.EventHandler(this.buttonSend_Click);
			// 
			// frmComm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(512, 245);
			this.Controls.Add(this.axMSComm1);
			this.Controls.Add(this.txtSend);
			this.Controls.Add(this.txtReceive);
			this.Controls.Add(this.buttonExit);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.buttonSend);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.Name = "frmComm";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "串口通信";
			this.Load += new System.EventHandler(this.frmComm_Load);
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.axMSComm1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 應用程序的主入口點。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmComm());
		}
		
		private void frmComm_Load(object sender, System.EventArgs e)
		{
		
		}

		private void buttonExit_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void buttonOpen_Click(object sender, System.EventArgs e)
		{
			if(buttonOpen.Text=="打開串口")
			{
				buttonSend.Enabled=true;
				string setting="";
				switch(comboComm.SelectedIndex)
				{
					case 0:
						axMSComm1.CommPort=1;
						break;
					case 1:
						axMSComm1.CommPort=2;
						break;
					default:
						axMSComm1.CommPort=1;
						break;
				}
				switch(comboRaud.SelectedIndex)
				{
					case 0:
						setting+="4800,";
						break;
					case 2:
						setting+="14400,";
						break;
					default:
						setting+="9600,";
						break;
				}
				switch(comboCheck.SelectedIndex)
				{
					case 1:
						setting+="1,";
						break;
					default:
						setting+="n,";
						break;

				}
				switch(comboData.SelectedIndex)
				{
					case 1:
						setting+="7,";
						break;
					default:
						setting+="8,";
						break;
				}
				switch(comboStop.SelectedIndex)
				{
					case 1:
						setting+="1.5";
						break;
					case 2:
						setting+="2";
						break;
					default:
						setting+="1";
						break;
				}
				axMSComm1.Settings=setting;
				axMSComm1.InBufferSize=1024;
				axMSComm1.OutBufferSize=512;
				axMSComm1.InputMode=0;
				axMSComm1.RThreshold=1;
				axMSComm1.InputLen=0;
				try
				{
					axMSComm1.PortOpen=true;
				}
				catch(Exception ex)
				{
					MessageBox.Show(this,"打開串口失敗");
					return;
				}
				buttonOpen.Text="關閉串口";
				comboComm.Enabled=false;
				comboData.Enabled=false;
				comboStop.Enabled=false;
				comboCheck.Enabled=false;
				comboRaud.Enabled=false;
            }
			else
			{
				comboComm.Enabled=true;
				comboData.Enabled=true;
				comboStop.Enabled=true;
				comboCheck.Enabled=true;
				comboRaud.Enabled=true;
				buttonOpen.Text="打開串口";
				axMSComm1.PortOpen=false;
				buttonSend.Enabled=false;
				txtReceive.Text=null;
				
			}
			
		}

		private void buttonSend_Click(object sender, System.EventArgs e)
		{
			//string output=txtSend.Text;
			byte []output=new byte[12];
			for(int i=0;i<10;i++)
			{
				output[i]=(byte)(0x01+(byte)i);
			}
			try
			{
				axMSComm1.Output=output;
				txtSend.Text=null;
			}
			catch(Exception ex)
			{
				MessageBox.Show(this,"發送錯誤");
			}
		}
		private void axMSComm1_OnComm(object sender,EventArgs e)
		{
			int k;
			object input;
			if(axMSComm1.CommEvent==2)
			{
				k=axMSComm1.InBufferCount;
				if(k>0)
				{
					input=axMSComm1.Input;
					txtReceive.Text+=(string)input;

				}
			}
		}

		
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆精品国产91久久久使用方法 | 春色校园综合激情亚洲| 成人免费高清在线观看| 欧美美女网站色| 国产精品麻豆视频| 久久不见久久见中文字幕免费| av中文字幕一区| 精品久久久久久久久久久久包黑料 | 日日摸夜夜添夜夜添精品视频| 国内成+人亚洲+欧美+综合在线| 99久免费精品视频在线观看| 日韩一区二区三区四区五区六区| 自拍av一区二区三区| 久久99国产乱子伦精品免费| 精品视频资源站| 亚洲四区在线观看| 欧美性受xxxx黑人xyx| 国产日韩欧美麻豆| 激情av综合网| 91精品国产高清一区二区三区蜜臀| 国产精品你懂的| 国产91精品入口| 久久久精品欧美丰满| 美女网站在线免费欧美精品| 欧美日韩高清在线播放| 亚洲综合丝袜美腿| 色婷婷香蕉在线一区二区| 欧美激情在线免费观看| 国产一区二区免费在线| 精品久久久久久亚洲综合网| 美国一区二区三区在线播放| 日韩欧美美女一区二区三区| 三级久久三级久久| 欧美一区二区三区色| 午夜伦理一区二区| 91精品国产高清一区二区三区蜜臀 | 欧美一区二区三区免费大片| 香蕉成人伊视频在线观看| 在线观看www91| 亚洲成人动漫在线免费观看| 欧美日韩激情一区二区| 五月天亚洲婷婷| 亚欧色一区w666天堂| 欧美体内she精高潮| 亚洲永久免费av| 欧美日韩国产美女| 精品一区二区三区久久久| 精品久久国产字幕高潮| 国产ts人妖一区二区| 亚洲欧美中日韩| 色8久久精品久久久久久蜜| 亚洲国产综合在线| 日韩一区二区电影在线| 国产激情一区二区三区桃花岛亚洲 | 国产精品久久久久一区| 成人免费看黄yyy456| 亚洲欧美激情视频在线观看一区二区三区 | 欧美白人最猛性xxxxx69交| 久久99国产精品尤物| 国产精品久久久久毛片软件| 日本乱码高清不卡字幕| 麻豆久久一区二区| 国产精品午夜电影| 欧美美女一区二区三区| 国产精品中文字幕日韩精品| 亚洲精品午夜久久久| 日韩一区二区在线观看视频| 国产精品一二三四区| 一区二区三区中文字幕| 日韩欧美123| 99re视频精品| 久久精品免费看| 自拍偷拍国产精品| 精品对白一区国产伦| eeuss影院一区二区三区| 午夜成人免费电影| 国产精品福利电影一区二区三区四区| 欧美色图片你懂的| 成人影视亚洲图片在线| 免费在线观看一区二区三区| 日韩一区在线播放| 久久欧美中文字幕| 欧美日本乱大交xxxxx| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 综合精品久久久| 日韩三级中文字幕| 日本道色综合久久| 成人激情开心网| 精品一区二区三区在线观看国产| 亚洲黄色免费电影| 国产资源在线一区| 亚洲国产精品久久一线不卡| 国产日产欧产精品推荐色| 91精品国产综合久久香蕉的特点 | 不卡一卡二卡三乱码免费网站| 日韩电影免费一区| 亚洲综合视频在线| 中文字幕亚洲一区二区av在线| 精品1区2区在线观看| 欧美日韩一区成人| 欧美亚洲国产怡红院影院| 成人综合婷婷国产精品久久免费| 久久国产欧美日韩精品| 午夜精品久久久久久久| 亚洲另类中文字| 亚洲视频一区在线观看| 欧美国产日韩一二三区| 久久美女高清视频| 久久综合一区二区| 日韩精品一区二区三区四区视频 | 91视频观看免费| 成人一级片网址| 国产99久久久国产精品潘金网站| 国产在线麻豆精品观看| 乱中年女人伦av一区二区| 日韩1区2区3区| 麻豆成人av在线| 久久国产精品99久久久久久老狼| 免费观看在线色综合| 美女国产一区二区| 国产又黄又大久久| 国产精品1区2区| av亚洲精华国产精华| 99久久免费视频.com| 色综合一个色综合| 色先锋aa成人| 欧美日韩精品一区二区| 91精品国产91久久综合桃花| 日韩一区二区在线看| 久久综合狠狠综合久久综合88| 精品国产一二三| 国产精品丝袜久久久久久app| 国产精品美女久久久久av爽李琼| 成人免费在线视频| 亚洲永久免费av| 欧美a一区二区| 国产黄色成人av| 91影视在线播放| 制服丝袜中文字幕一区| 久久一二三国产| 中文字幕一区免费在线观看| 亚洲制服丝袜av| 激情综合色丁香一区二区| 粉嫩一区二区三区在线看| 欧美最新大片在线看| 日韩免费观看2025年上映的电影| 日本一区二区视频在线观看| 亚洲免费色视频| 蜜桃视频在线一区| 成人激情视频网站| 91麻豆精品国产91久久久| 国产精品日产欧美久久久久| 午夜电影一区二区三区| 国产精品12区| 91精品国产综合久久香蕉麻豆| 久久久久久久久久看片| 亚洲一级二级三级在线免费观看| 玖玖九九国产精品| 91麻豆国产自产在线观看| 精品国产免费一区二区三区香蕉| 18涩涩午夜精品.www| 另类中文字幕网| 在线观看免费视频综合| 国产午夜精品福利| 首页国产欧美日韩丝袜| 成人app软件下载大全免费| 5月丁香婷婷综合| 亚洲视频一二三区| 久久99精品视频| 樱桃视频在线观看一区| 韩国精品免费视频| 91精品国产色综合久久不卡电影 | 久久电影网电视剧免费观看| 一本大道久久a久久精二百| 精品国内二区三区| 亚洲最色的网站| 不卡高清视频专区| 久久久精品黄色| 久久精品国产秦先生| 欧美久久久久久蜜桃| 亚洲欧美国产77777| 风间由美一区二区三区在线观看 | 在线精品视频免费观看| 中文字幕国产一区| 国产一区二区日韩精品| 91精品国产免费久久综合| 伊人性伊人情综合网| av午夜精品一区二区三区| 欧美韩日一区二区三区四区| 久久国产乱子精品免费女| 日韩一级精品视频在线观看| 性久久久久久久久| 精品1区2区3区| 亚洲一区二区精品视频| 色婷婷精品久久二区二区蜜臂av| 国产精品麻豆网站| www.欧美日韩国产在线| 亚洲私人影院在线观看| 色先锋aa成人| 亚洲制服丝袜av|