2024年3月23日发(作者:)

C# 使用SerialPort控件用类及线程实现串口通信

C# 使用SerialPort 源码实例

编辑源码复制到剪贴板打印

using System;

using c;

using entModel;

using ;

using g;

using ;

using ;

using ;

using ing;

namespace TestSerialPort

{

public partial class frmTESTSerialPort : Form

{

public frmTESTSerialPort()

{

InitializeComponent();

orIllegalCrossThreadCalls = false;

}

private Button button1;

private TextBox txtSend;

private TextBox txtReceive;

private Label label1;

private Label label2;

///

/// 必需的设计器变量。

///

private iner components = null;

///

/// 清理所有正在使用的资源。

///

/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

e();

}

e(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///

private void InitializeComponent()

{

1 = new ();

d = new x();

eive = new x();

1 = new ();

2 = new ();

dLayout();

//

// button1

//

on = new (440, 379);

= "button1";

= new (75, 23);

ex = 0;

= "发送";

ualStyleBackColor = true;

+= new andler(1_Click);

//

// txtSend

//

on = new (59, 12);

ine = true;

= "txtSend";

= new (456, 164);

ex = 2;

//

// txtReceive

//

on = new (59, 200);

ine = true;

= "txtReceive";

= new (456, 164);

ex = 2;

//

// label1

//

on = new (13, 15);

= "label1";