资源简介
Rs232 串口 调试信息传输 (C#)

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace RS232
{
public partial class fclsRS232Tester : Form
{
string InputData = String.Empty;
// This delegate enables asynchronous calls for setting
// the text property on a TextBox control:
delegate void SetTextCallback(string text);
public fclsRS232Tester()
{
InitializeComponent();
// Nice methods to browse all available ports:
string[] ports = SerialPort.GetPortNames();
// Add all port names to the combo box:
foreach (string port in ports)
{
cmbComSelect.Items.Add(port);
}
comboBox1.SelectedIndex = 1;
}
private void cmbComSelect_SelectionchangeCommitted(object sender EventArgs e)
{
if (port.IsOpen) port.Close();
port.PortName = cmbComSelect.SelectedItem.ToString();
port.BaudRate = int.Parse(comboBox1.SelectedItem.ToString());
port.Parity = Parity.None;
port.DataBits = 8;
port.StopBits = StopBits.One;
// try to open the selected port:
try
{
port.Open();
}
// give a message if the port is not available:
catch
{
MessageBox.Show(“Serial port “ + port.PortName + “ cannot be opened!“ “RS232 tester“ MessageBoxButtons.OK MessageBoxIcon.Warning);
cmbComSelect.SelectedText = ““;
stsStatus.Text = “Select serial port!“;
}
}
private void btnSend_Click(object sender EventArgs e)
{
if (port.IsOpen) port.Write(txtOut.Text);
else MessageBox.Show(“Serial port is closed!“ “RS232 tester“ MessageBoxButtons.OK MessageBoxIcon.Error);
txtOut.Clear();
}
private void btnClear_Click(object sender EventArgs e)
{
txtIn.Clear();
}
private void port_DataReceived_1(object sender SerialDataReceivedEventArgs e)
{
InputData = port.ReadExisting();
MessageBox.Show(InputData);
if (InputData != String.Empty)
{
// txtIn.Text = InputData; // because of different threads this does not work properly !!
SetText(InputData);
}
}
private void SetText(string text)
{
// InvokeRequired required compares the thread ID of the
// calling thread to the thread ID of the creating thread.
// If these threads are different it returns true.
if (this.
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12800 2009-02-24 13:44 RS232\bin\Debug\RS232.exe
文件 26112 2009-02-24 13:44 RS232\bin\Debug\RS232.pdb
文件 11771 2008-07-17 17:08 RS232\bin\Debug\rs232.rar
文件 14328 2009-03-20 15:55 RS232\bin\Debug\RS232.vshost.exe
文件 24576 2007-01-22 14:33 RS232\bin\Release\RS232.exe
文件 5632 2005-09-23 06:56 RS232\bin\Release\RS232.vshost.exe
文件 1154 2007-11-07 21:50 RS232\ClassDiagram1.cd
文件 3550 2009-02-24 13:44 RS232\Form1.cs
文件 9969 2008-07-17 16:56 RS232\Form1.Designer.cs
文件 6207 2008-07-17 16:56 RS232\Form1.resx
文件 847 2009-02-24 13:44 RS232\obj\Debug\RS232.csproj.GenerateResource.Cache
文件 12800 2009-02-24 13:44 RS232\obj\Debug\RS232.exe
文件 180 2008-11-27 12:08 RS232\obj\Debug\RS232.fclsRS232Tester.resources
文件 26112 2009-02-24 13:44 RS232\obj\Debug\RS232.pdb
文件 180 2008-11-27 12:08 RS232\obj\Debug\RS232.Properties.Resources.resources
文件 264 2008-04-04 23:25 RS232\obj\RS232.csproj.FileList.txt
文件 1504 2008-07-17 17:08 RS232\obj\RS232.csproj.FileListAbsolute.txt
文件 482 2007-01-09 11:09 RS232\Program.cs
文件 1288 2007-11-08 14:05 RS232\Properties\AssemblyInfo.cs
文件 2834 2008-11-27 12:07 RS232\Properties\Resources.Designer.cs
文件 5612 2007-01-09 11:08 RS232\Properties\Resources.resx
文件 1103 2008-11-27 12:07 RS232\Properties\Settings.Designer.cs
文件 249 2007-01-09 11:08 RS232\Properties\Settings.settings
文件 3466 2008-11-27 12:07 RS232\RS232.csproj
文件 168 2008-11-27 12:07 RS232\RS232.csproj.user
目录 0 2008-04-17 16:28 RS232\obj\Debug\Refactor
目录 0 2008-11-27 12:08 RS232\obj\Debug\TempPE
目录 0 2008-04-17 16:28 RS232\obj\Release\TempPE
目录 0 2008-11-27 12:07 RS232\bin\Debug
目录 0 2008-04-17 16:28 RS232\bin\Release
............此处省略12个文件信息
相关资源
- C# Socket Tcp文件传输和文字聊天系统
- C#串口通信程序(VS2010)(serialPort组
- 最新Trimble全站仪串口通讯
- opc ua客户端171716
- c#串口通信(支持Hex/ascii码消息发送)
- C#串口通信之基恩士读码器读二维码
- 串口调试助手代码(XCOM V2.0)
- 多功能串口助手(附源码)
- 电子秤重量读取(串口通讯)
- 串口数据监测助手(工程源码)
- C#实现串口上位机
- C# RS232串口通信
- 三菱Q-PLC与C#串口
- 大文件Socket 传输 客户端和服务端
- c# 串口通讯的(收发数据)
- Csharp串口通讯
- c#获取串口
- HJ212数据传输工具源码
- WPF开发串口调试助手
- 串口通讯工具源码
- C#串口通讯
- 串口上位机
- Modbus通讯 串口通讯
- C# 串口通讯源码(简易串口助手)
- IAP小工具(Ymodem-IAP)源码
- C#串口dll及
- C# winform Socket大文件传输
- 松下PLC与C#通讯串口调试入门教程.z
- vb调用c#编写的串口DLL文件(vb源码
- C#串口通讯代码
评论
共有 条评论