• 大小: 467KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-28
  • 语言: C#
  • 标签: C#  串口通信  

资源简介

本压缩文件是一个完整的C#编写的串口采集软件,可以实时接收串口数据并显示在文本框内,以Excel表格的形式实时记录储存数据,含有全部代码和界面设计等,也可直接使用.本人采用的是vs2010,若有下载后不能使用的请给我留言说明问题.

资源截图

代码片段和文件信息

using System;
using System.Windows.Forms;
using System.IO.Ports;
using System.Reflection;
using System.Text;
using System.Collections;
using Microsoft.Office;
using Microsoft.Office.Interop.Excel;

namespace serialport
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    /// 

   /// 利用comboBox控件来选择串口号并设置默认的波特率为9600无奇偶校验32位有符号整型一位停止位.
      
        private void comBoxSelect_SelectedIndexChanged_1(object sender System.EventArgs e)
        {

           
                switch (comBoxSelect.Text)
                {
                    case “COM1“:
                        {
                            serialPort1 = new SerialPort(“COM1“ 9600 Parity.None 8 StopBits.One);

                            // 为 serialPort1绑定事件句柄选择COM1
                            serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
                        }; break;
                    case “COM2“:
                        {
                            serialPort1 = new SerialPort(“COM2“ 9600 Parity.None 8 StopBits.One);

                            // 为 serialPort1绑定事件句柄选择COM2
                            serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
                        }; break;
                    case “COM3“:
                        {
                            serialPort1 = new SerialPort(“COM3“ 9600 Parity.None 8 StopBits.One);

                            // 为 serialPort1绑定事件句柄选择COM3
                            serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
                        }; break;
                    case “COM4“:
                        {
                            serialPort1 = new SerialPort(“COM4“ 9600 Parity.None 8 StopBits.One);

                            // 为 serialPort1绑定事件句柄选择COM4
                            serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
                        }; break;
                    case “COM5“:
                        {
                            serialPort1 = new SerialPort(“COM5“ 9600 Parity.None 8 StopBits.One);

                            //关键 为 serialPort1绑定事件句柄选择COM5
                            serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
                        }; break;
                    case “COM6“:
                        {
                            serialPort1 = new SerialPort(“COM6“ 9600 Parity.None 8 StopBits.One);

                            //关键 为 serialPort1绑定事件句柄选择COM6
                            serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
                        }; break;
                    default: break;

                }

          

        }
    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      19968  2014-11-26 22:28  serialport1\serialport1\bin\Debug\serialport.exe

     文件      32256  2014-11-26 22:28  serialport1\serialport1\bin\Debug\serialport.pdb

     文件      11600  2014-11-26 22:28  serialport1\serialport1\bin\Debug\serialport.vshost.exe

     文件        490  2009-08-31 00:40  serialport1\serialport1\bin\Debug\serialport.vshost.exe.manifest

     文件     123392  2014-12-01 10:46  serialport1\serialport1\bin\Debug\serialport1.exe

     文件      30208  2014-12-01 10:46  serialport1\serialport1\bin\Debug\serialport1.pdb

     文件      11600  2014-12-01 10:47  serialport1\serialport1\bin\Debug\serialport1.vshost.exe

     文件        490  2009-08-31 00:40  serialport1\serialport1\bin\Debug\serialport1.vshost.exe.manifest

     文件      18944  2014-11-27 17:14  serialport1\serialport1\bin\Release\serialport1.exe

     文件      24064  2014-11-27 17:14  serialport1\serialport1\bin\Release\serialport1.pdb

     文件      10955  2014-12-01 10:47  serialport1\serialport1\Form1.cs

     文件       7505  2014-12-01 09:36  serialport1\serialport1\Form1.Designer.cs

     文件       6189  2014-12-01 09:36  serialport1\serialport1\Form1.resx

     文件       5359  2014-11-27 17:33  serialport1\serialport1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6863  2014-12-01 10:46  serialport1\serialport1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件       3584  2014-11-26 22:29  serialport1\serialport1\obj\x86\Debug\Interop.MsoEuro.dll

     文件        874  2014-11-26 22:28  serialport1\serialport1\obj\x86\Debug\serialport.csproj.FileListAbsolute.txt

     文件        975  2014-11-26 22:20  serialport1\serialport1\obj\x86\Debug\serialport.csproj.GenerateResource.Cache

     文件       1048  2014-11-26 20:34  serialport1\serialport1\obj\x86\Debug\serialport.csproj.ResolveComReference.cache

     文件      19968  2014-11-26 22:28  serialport1\serialport1\obj\x86\Debug\serialport.exe

     文件        180  2014-12-01 09:36  serialport1\serialport1\obj\x86\Debug\serialport.Form1.resources

     文件      32256  2014-11-26 22:28  serialport1\serialport1\obj\x86\Debug\serialport.pdb

     文件     102550  2014-11-30 17:08  serialport1\serialport1\obj\x86\Debug\serialport.Properties.Resources.resources

     文件        727  2014-12-01 10:47  serialport1\serialport1\obj\x86\Debug\serialport1.csproj.FileListAbsolute.txt

     文件       1046  2014-12-01 09:36  serialport1\serialport1\obj\x86\Debug\serialport1.csproj.GenerateResource.Cache

     文件       1048  2014-11-26 22:29  serialport1\serialport1\obj\x86\Debug\serialport1.csproj.ResolveComReference.cache

     文件     123392  2014-12-01 10:46  serialport1\serialport1\obj\x86\Debug\serialport1.exe

     文件      30208  2014-12-01 10:46  serialport1\serialport1\obj\x86\Debug\serialport1.pdb

     文件       4608  2014-11-30 17:01  serialport1\serialport1\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件       5359  2014-11-27 17:24  serialport1\serialport1\obj\x86\Release\DesignTimeResolveAssemblyReferences.cache

............此处省略37个文件信息

评论

共有 条评论