資源簡介
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.IO.Ports;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
namespace?First_Demo
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????????System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls?=?false;
????????}
????????///?
????????///?窗口初始化函數(shù)
????????///?
????????///?
????????///?
????????private?void?Form1_Load(object?sender?EventArgs?e)
????????{
????????????comboBox2.Text?=?“115200“;
????????????//清空接收區(qū)、發(fā)送、清空、發(fā)送框、接收框不可用
????????????button3.Enabled?=?false;
????????????button4.Enabled?=?false;
????????????button5.Enabled?=?false;
????????????textBox1_Input.Enabled?=?false;
????????????textBox2_Output.Enabled?=?false;
????????????Search_Port(serialPort1?comboBox1);
????????????comboBox1.Text?=?“COM25“;
????????????//手動添加的事件處理函數(shù)
????????????serialPort1.DataReceived?+=?new?SerialDataReceivedEventHandler(port_DataReceived);
????????}
????????///?
????????///?打開串口
????????///?
????????///?
????????///?
????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????string?buffer?=?comboBox1.Text;//獲取控件信息
????????????if?(buffer.Equals(““))//如果buffer數(shù)值為空
????????????{
????????????????MessageBox.Show(“請選擇串口“?“提示“);
????????????????return;
????????????}
????????????if?(serialPort1.IsOpen)//如果串口已經(jīng)打開
????????????{
????????????????try
????????????????{
????????????????????button2.Text?=?“打開串口“;
????????????????????serialPort1.Close();
????????????????????//清空接收區(qū)、發(fā)送、清空、發(fā)送框、接收框不可用
????????????????????button3.Enabled?=?false;
????????????????????button4.Enabled?=?false;
????????????????????textBox1_Input.Enabled?=?false;
????????????????????//掃描可用
????????????????????button1.Enabled?=?true;
????????????????????//端口號可用
????????????????????comboBox1.Enabled?=?true;
????????????????????//波特率可用
????????????????????comboBox2.Enabled?=?true;
????????????????}
????????????????catch?{?}
????????????????return;
????????????}
????????????try
????????????{
????????????????serialPort1.PortName?=?comboBox1.Text;//獲取端口號
????????????????serialPort1.BaudRate?=?Convert.ToInt32(comboBox2.Text?10);//獲取波特率
????????????????serialPort1.Open();
????????????????button2.Text?=?“關閉串口“;
????????????????//掃描按鍵不可用
????????????????button1.Enabled?=?false;
????????????????//端口號不可用
????????????????comboBox1.Enabled?=?false;
????????????????//波特率不可用
????????????????comboBox2.Enabled?=?false;
????????????????//清空接收區(qū)、發(fā)送、清空、發(fā)送框、接收框可用
????????????????button3.Enabled?=?true;
????????????????button4.Enabled?=?true;
????????????????button5.Enabled?=?true;
????????????????textBox1_Input.Enabled?=?true;
????????????????textBox2_Output.Enabled?=?true;
????????????}
????????????catch
??
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\
?????目錄???????????0??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\
?????文件?????????900??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo.sln
?????目錄???????????0??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\
?????文件?????????182??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\App.config
?????文件????????4057??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\First_Demo.csproj
?????文件???????19284??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\Form1.Designer.cs
?????文件????????9510??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\Form1.cs
?????文件?????6266109??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\Form1.resx
?????文件?????????500??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\Program.cs
?????目錄???????????0??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\Properties\
?????文件????????1322??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\Properties\AssemblyInfo.cs
?????文件????????3152??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\Properties\Resources.Designer.cs
?????文件????????6075??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\Properties\Resources.resx
?????文件????????1067??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\Properties\Settings.Designer.cs
?????文件?????????242??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\Properties\Settings.settings
?????目錄???????????0??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\UI圖片\
?????文件??????775702??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\UI圖片\Jellyfish.jpg
?????文件??????620888??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\UI圖片\Tulips.jpg
?????文件????????4286??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\First_Demo\串口助手.ico
?????文件?????????141??2020-03-16?01:03??C-sharp-serial-port-debugging-assistant-master\C#串口調(diào)試助手\刪除編譯過程文件.bat
- 上一篇:modbus通信
- 下一篇:RTL8290b校準程序
評論
共有 條評論