Skip to content

Commit afdb2d4

Browse files
committed
first commit
0 parents  commit afdb2d4

31 files changed

+812
-0
lines changed
Binary file not shown.
Binary file not shown.

Ports/.vs/Ports/FileContentIndex/read.lock

Whitespace-only changes.

Ports/.vs/Ports/v17/.suo

24 KB
Binary file not shown.

Ports/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>

Ports/Ports.Designer.cs

Lines changed: 169 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Ports/Ports.cs

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.IO.Ports;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using System.Windows.Forms;
11+
12+
namespace Ports
13+
{
14+
public partial class Ports : Form
15+
{
16+
public Ports()
17+
{
18+
InitializeComponent();
19+
}
20+
21+
private void scanBT_Click(object sender, EventArgs e)
22+
{
23+
comportCB.Text = "";
24+
comportCB.Items.Clear();
25+
String[] ports = SerialPort.GetPortNames();
26+
comportCB.Items.AddRange(ports);
27+
}
28+
29+
private void connectBT_Click(object sender, EventArgs e)
30+
{
31+
if(ConnectPort() == true)
32+
{
33+
connectBT.Enabled = false;
34+
disconnectBT.Enabled = true;
35+
comportCB.Enabled = false;
36+
baudrateCB.Enabled = false;
37+
scanBT.Enabled = false;
38+
sendBT.Enabled = true;
39+
}
40+
}
41+
42+
public bool ConnectPort()
43+
{
44+
try {
45+
if(comportCB.Text != "" || baudrateCB.Text != "")
46+
{
47+
serialPort1.PortName = comportCB.Text;
48+
serialPort1.BaudRate = Int32.Parse(baudrateCB.Text);
49+
serialPort1.Open();
50+
return true;
51+
}
52+
}
53+
catch(Exception ex)
54+
{
55+
MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK);
56+
}
57+
return false;
58+
}
59+
60+
private void disconnectBT_Click(object sender, EventArgs e)
61+
{
62+
serialPort1.Close();
63+
connectBT.Enabled = true;
64+
disconnectBT.Enabled = false;
65+
comportCB.Enabled = true;
66+
baudrateCB.Enabled = true;
67+
scanBT.Enabled = true;
68+
sendBT.Enabled = false;
69+
}
70+
71+
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
72+
{
73+
this.Invoke(new EventHandler(serialPort1_DataReceived));
74+
}
75+
76+
private void serialPort1_DataReceived(object sender, EventArgs e)
77+
{
78+
string dump = serialPort1.ReadLine();
79+
incomingTB.Text = incomingTB.Text + dump;
80+
}
81+
82+
private void clearBT_Click(object sender, EventArgs e)
83+
{
84+
incomingTB.Text = "";
85+
}
86+
87+
private void sendBT_Click(object sender, EventArgs e)
88+
{
89+
try
90+
{
91+
if (!(serialPort1.IsOpen)) { serialPort1.Open(); }
92+
serialPort1.Write(outgoingTB.Text);
93+
outgoingTB.Text = "";
94+
}
95+
catch(Exception ex)
96+
{
97+
MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK);
98+
}
99+
}
100+
}
101+
}

Ports/Ports.csproj

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{FCE32D9B-22E3-4EA3-81CA-3D23693B95E7}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>Ports</RootNamespace>
10+
<AssemblyName>Ports</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Deployment" />
43+
<Reference Include="System.Drawing" />
44+
<Reference Include="System.Net.Http" />
45+
<Reference Include="System.Windows.Forms" />
46+
<Reference Include="System.Xml" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="Ports.cs">
50+
<SubType>Form</SubType>
51+
</Compile>
52+
<Compile Include="Ports.Designer.cs">
53+
<DependentUpon>Ports.cs</DependentUpon>
54+
</Compile>
55+
<Compile Include="Program.cs" />
56+
<Compile Include="Properties\AssemblyInfo.cs" />
57+
<EmbeddedResource Include="Ports.resx">
58+
<DependentUpon>Ports.cs</DependentUpon>
59+
</EmbeddedResource>
60+
<EmbeddedResource Include="Properties\Resources.resx">
61+
<Generator>ResXFileCodeGenerator</Generator>
62+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
63+
<SubType>Designer</SubType>
64+
</EmbeddedResource>
65+
<Compile Include="Properties\Resources.Designer.cs">
66+
<AutoGen>True</AutoGen>
67+
<DependentUpon>Resources.resx</DependentUpon>
68+
</Compile>
69+
<None Include="Properties\Settings.settings">
70+
<Generator>SettingsSingleFileGenerator</Generator>
71+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
72+
</None>
73+
<Compile Include="Properties\Settings.Designer.cs">
74+
<AutoGen>True</AutoGen>
75+
<DependentUpon>Settings.settings</DependentUpon>
76+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
77+
</Compile>
78+
</ItemGroup>
79+
<ItemGroup>
80+
<None Include="App.config" />
81+
</ItemGroup>
82+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
83+
</Project>

0 commit comments

Comments
 (0)