资源简介
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扩展属性查看及修改
相关资源
- 51多机通信(内附Proteus及.hex文件)
- USB转串口(RS232/RS485/RS422)驱动程序文
- VC++ RS232 RS485串口通信源代码_
- FTDI usb转RS232驱动 官方版
- 三菱rs232通讯
- labview VISA串口驱动引擎
- STM32 ModBus RTU 从机程序
- 汉枫_HF-LPB嵌入式WiFi模块_UART转WiFi_S
- Z—TEK usb转rs232串口驱动
- 串口程序--Verilog
- Mac电脑串口工具(2018更新--界面修改
- usb转串口驱动USBtoRS232
- RS-232中国标准文档
- STM32 RS232串口控制
- RS232串口CRC程序
- RS232串口实验程序
- RS232接线说明带原理图库和封装库(
- rs232转USB接口驱动
- RS232 串口转接板
- STM32F103C6T6做的USB转RS232模块图纸源码
- usb转232串口驱动,08年老版本。带修复
- usb t0 rs232
- 基于RS232的数据采集系统设计
- rs232串口收发verilog程序
- ucos+USB+RS232
- macos下的串口调试工具
- Serial IO Card-华塑PCMCIA转串口RS232-ox
- 官方FT-232USB转串口驱动
- stm32f103 CAN-RS232/RS485
- ANSI/TIA/EIA-232-F
评论
共有 条评论