资源简介
RS232串口通信RS232串口通信RS232串口通信RS232串口通信RS232串口通信
代码片段和文件信息
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);
}
}
private void cmbComSelect_SelectionchangeCommitted(object sender EventArgs e)
{
if (port.IsOpen) port.Close();
port.PortName = cmbComSelect.SelectedItem.ToString();
stsStatus.Text = port.PortName + “: 48008N1“;
// 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.WriteLine(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();
if (InputData != String.Empty)
{
// txtIn.Text = InputData; // because of different threads this does not work properly !!
SetText(InputData);
}
}
/*
To make a thread-safe call a Windows Forms control:
1. Query the control‘s InvokeRequired property.
2. If InvokeRequired returns true call Invoke with a delegate that makes the actual call to the control.
3. If InvokeRequired returns false call the control directly.
In the following code example this logic is implemented in a utility method called SetText.
A delegate type named SetTextDelegate encapsulates the SetText method.
When the TextBox control‘s
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-03-30 16:30 RS232\
目录 0 2018-03-30 16:30 RS232\.vs\
目录 0 2018-03-30 16:30 RS232\.vs\RS232\
目录 0 2018-03-30 16:30 RS232\.vs\RS232\v15\
文件 17408 2018-03-30 16:36 RS232\.vs\RS232\v15\.suo
目录 0 2018-03-30 16:30 RS232\Backup\
目录 0 2018-03-30 16:30 RS232\Backup\RS232\
文件 904 2007-01-09 11:08 RS232\Backup\RS232.sln
文件 1154 2007-11-07 21:50 RS232\Backup\RS232\ClassDiagram1.cd
文件 4446 2007-11-16 12:35 RS232\Backup\RS232\Form1.cs
文件 8723 2007-11-07 21:52 RS232\Backup\RS232\Form1.Designer.cs
文件 6207 2007-11-16 12:35 RS232\Backup\RS232\Form1.resx
文件 482 2007-01-09 11:09 RS232\Backup\RS232\Program.cs
目录 0 2018-03-30 16:30 RS232\Backup\RS232\Properties\
文件 1288 2007-11-08 14:05 RS232\Backup\RS232\Properties\AssemblyInfo.cs
文件 2837 2007-01-09 11:08 RS232\Backup\RS232\Properties\Resources.Designer.cs
文件 5612 2007-01-09 11:08 RS232\Backup\RS232\Properties\Resources.resx
文件 1088 2007-01-09 11:08 RS232\Backup\RS232\Properties\Settings.Designer.cs
文件 249 2007-01-09 11:08 RS232\Backup\RS232\Properties\Settings.settings
文件 3258 2007-11-07 21:50 RS232\Backup\RS232\RS232.csproj
目录 0 2007-11-16 12:35 RS232\RS232\
文件 983 2018-03-30 16:30 RS232\RS232.sln
文件 13312 2007-11-10 08:56 RS232\RS232.suo
目录 0 2007-11-08 14:06 RS232\RS232\bin\
目录 0 2018-03-30 16:32 RS232\RS232\bin\Debug\
文件 12288 2018-03-30 16:31 RS232\RS232\bin\Debug\RS232.exe
文件 22016 2018-03-30 16:31 RS232\RS232\bin\Debug\RS232.pdb
文件 5632 2005-09-23 06:56 RS232\RS232\bin\Debug\RS232.vshost.exe
目录 0 2007-11-08 14:06 RS232\RS232\bin\Release\
文件 24576 2007-01-22 14:33 RS232\RS232\bin\Release\RS232.exe
文件 5632 2005-09-23 06:56 RS232\RS232\bin\Release\RS232.vshost.exe
............此处省略31个文件信息
- 上一篇:人工智能导论大作业(学长版)
- 下一篇:CAD扩展属性查看及修改
相关资源
- 用proteus设计仿真硬件电路图:用808
- 实测亲测xilinx fpga uart 串口rs232工程,
- FPGA-cpld串口rs232模块 发送接收程序
- RS232和RS485 模块接口原理图
- 基于RS232接口的电机状态上位机监控界
- 插针式GPRS模块USR-GPRS232-7S3硬件开发库
- 51 单片机串口通信程序,RS232串口通信
- RS232通信代码
- RS232封装库
- 投影机RS232开关绿色版
- USB线转RS232串口驱动
- FPGA 串口通信RS232
- 串口精灵调试工具 侦测RS232/422/485串
- 串口通信隔离芯片
- PL2303 Windows Driver Download USB to UART R
- RS232串口接口HART调制解调器HART MODEM
- 用serialport.cpp_serialport.h写的一个串口
- 无源RS232-485转换
- 爱威轮 无源窃电型、有源型、光电隔
- Z-TEK(力特)USB转RS232驱动(PL2303)
- EAP SECSI HSMS SECSII 通信模拟器(支持
- 基于RS232通讯的电池管理系统源码
- 基于FPGA的rs232串口通信verilog编码
- 山特ups在线不间断电源Rs232串口通信协
- cordova集成RS232串口通讯
- 交通灯+RS232+模拟串口通讯 proteus 仿真
- PC 机与单片机通信(RS232 协议)
- 通用串口测试工具
- RTX实时平台实现RS232通讯
- LabView与RS232串口通讯程序,一看就懂
评论
共有 条评论