91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 75KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-26
  • 語言: 其他
  • 標簽: RS232??

資源簡介

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個文件信息

評論

共有 條評論