資源簡介
基于c#的串口通訊簡單實例。我也寫了一篇關于這個的文章。大家可用參照文章來看代碼。此代碼實現了串口通訊,使用工具vs2017,串口助手,串口調試助手。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?System.IO.Ports;
using?System.Threading;//線程申明
namespace?ck3
{
????public?partial?class?Form1?:?Form
????{
????????private?void?CheckPort()//檢查串口是否可用
????????{
????????????ckCheckBox.Items.Clear();//清除控件中的當前值
????????????bool?havePort?=?false;
????????????string[]?a?=?SerialPort.GetPortNames();
????????????if?(a?!=?null)
????????????{
????????????????
????????????????for?(int?i?=?0;?i?????????????????{
????????????????????bool?use?=?false;
????????????????????try
????????????????????{
????????????????????????SerialPort?t?=?new?SerialPort(a[i]);
????????????????????????sp.Open();
????????????????????????sp.Close();
????????????????????????use?=?true;
????????????????????}
????????????????????catch
????????????????????{
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
????..A..H.?????42496??2018-11-10?10:43??ck3\.vs\ck3\v15\.suo
?????文件????????189??2018-10-14?10:35??ck3\ck3\App.config
?????文件??????18432??2018-10-14?15:15??ck3\ck3\bin\Debug\ck3.exe
?????文件????????189??2018-10-14?10:35??ck3\ck3\bin\Debug\ck3.exe.config
?????文件??????40448??2018-10-14?15:15??ck3\ck3\bin\Debug\ck3.pdb
?????文件???????3594??2018-10-14?11:15??ck3\ck3\ck3.csproj
?????文件??????10853??2018-11-10?10:27??ck3\ck3\Form1.cs
?????文件??????17565??2018-11-10?10:27??ck3\ck3\Form1.Designer.cs
?????文件???????6007??2018-10-14?15:15??ck3\ck3\Form1.resx
?????文件?????????42??2018-10-14?10:35??ck3\ck3\obj\Debug\ck3.csproj.CoreCompileInputs.cache
?????文件????????455??2018-10-14?12:39??ck3\ck3\obj\Debug\ck3.csproj.FileListAbsolute.txt
?????文件???????1012??2018-10-14?15:15??ck3\ck3\obj\Debug\ck3.csproj.GenerateResource.cache
?????文件??????18430??2018-10-14?10:35??ck3\ck3\obj\Debug\ck3.csprojAssemblyReference.cache
?????文件??????18432??2018-10-14?15:15??ck3\ck3\obj\Debug\ck3.exe
?????文件????????180??2018-10-14?15:15??ck3\ck3\obj\Debug\ck3.Form1.resources
?????文件??????40448??2018-10-14?15:15??ck3\ck3\obj\Debug\ck3.pdb
?????文件????????180??2018-10-14?11:15??ck3\ck3\obj\Debug\ck3.Properties.Resources.resources
?????文件???????1443??2018-10-14?12:41??ck3\ck3\obj\Debug\DesignTimeResolveAssemblyReferences.cache
?????文件???????7052??2018-10-14?10:35??ck3\ck3\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件??????????0??2018-10-14?10:35??ck3\ck3\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件??????????0??2018-10-14?10:35??ck3\ck3\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件??????????0??2018-10-14?10:35??ck3\ck3\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????文件????????515??2018-10-14?10:35??ck3\ck3\Program.cs
?????文件???????1304??2018-10-14?10:35??ck3\ck3\Properties\AssemblyInfo.cs
?????文件???????2819??2018-10-14?10:35??ck3\ck3\Properties\Resources.Designer.cs
?????文件???????5612??2018-10-14?10:35??ck3\ck3\Properties\Resources.resx
?????文件???????1090??2018-10-14?10:35??ck3\ck3\Properties\Settings.Designer.cs
?????文件????????249??2018-10-14?10:35??ck3\ck3\Properties\Settings.settings
?????文件???????1108??2018-10-14?10:35??ck3\ck3.sln
?????目錄??????????0??2018-11-10?09:32??ck3\.vs\ck3\v15\Server\sqlite3
............此處省略19個文件信息
- 上一篇:C#項目\\俄羅斯方塊
- 下一篇:使用C#編寫2048小游戲
評論
共有 條評論