YJ 6 gadi atpakaļ
revīzija
1fe69ad345

+ 63 - 0
.gitattributes

@@ -0,0 +1,63 @@
1
+###############################################################################
2
+# Set default behavior to automatically normalize line endings.
3
+###############################################################################
4
+* text=auto
5
+
6
+###############################################################################
7
+# Set default behavior for command prompt diff.
8
+#
9
+# This is need for earlier builds of msysgit that does not have it on by
10
+# default for csharp files.
11
+# Note: This is only used by command line
12
+###############################################################################
13
+#*.cs     diff=csharp
14
+
15
+###############################################################################
16
+# Set the merge driver for project and solution files
17
+#
18
+# Merging from the command prompt will add diff markers to the files if there
19
+# are conflicts (Merging from VS is not affected by the settings below, in VS
20
+# the diff markers are never inserted). Diff markers may cause the following 
21
+# file extensions to fail to load in VS. An alternative would be to treat
22
+# these files as binary and thus will always conflict and require user
23
+# intervention with every merge. To do so, just uncomment the entries below
24
+###############################################################################
25
+#*.sln       merge=binary
26
+#*.csproj    merge=binary
27
+#*.vbproj    merge=binary
28
+#*.vcxproj   merge=binary
29
+#*.vcproj    merge=binary
30
+#*.dbproj    merge=binary
31
+#*.fsproj    merge=binary
32
+#*.lsproj    merge=binary
33
+#*.wixproj   merge=binary
34
+#*.modelproj merge=binary
35
+#*.sqlproj   merge=binary
36
+#*.wwaproj   merge=binary
37
+
38
+###############################################################################
39
+# behavior for image files
40
+#
41
+# image files are treated as binary by default.
42
+###############################################################################
43
+#*.jpg   binary
44
+#*.png   binary
45
+#*.gif   binary
46
+
47
+###############################################################################
48
+# diff behavior for common document formats
49
+# 
50
+# Convert binary document formats to text before diffing them. This feature
51
+# is only available from the command line. Turn it on by uncommenting the 
52
+# entries below.
53
+###############################################################################
54
+#*.doc   diff=astextplain
55
+#*.DOC   diff=astextplain
56
+#*.docx  diff=astextplain
57
+#*.DOCX  diff=astextplain
58
+#*.dot   diff=astextplain
59
+#*.DOT   diff=astextplain
60
+#*.pdf   diff=astextplain
61
+#*.PDF   diff=astextplain
62
+#*.rtf   diff=astextplain
63
+#*.RTF   diff=astextplain

+ 261 - 0
.gitignore

@@ -0,0 +1,261 @@
1
+## Ignore Visual Studio temporary files, build results, and
2
+## files generated by popular Visual Studio add-ons.
3
+
4
+# User-specific files
5
+*.suo
6
+*.user
7
+*.userosscache
8
+*.sln.docstates
9
+
10
+# User-specific files (MonoDevelop/Xamarin Studio)
11
+*.userprefs
12
+
13
+# Build results
14
+[Dd]ebug/
15
+[Dd]ebugPublic/
16
+[Rr]elease/
17
+[Rr]eleases/
18
+x64/
19
+x86/
20
+bld/
21
+[Bb]in/
22
+[Oo]bj/
23
+[Ll]og/
24
+
25
+# Visual Studio 2015 cache/options directory
26
+.vs/
27
+# Uncomment if you have tasks that create the project's static files in wwwroot
28
+#wwwroot/
29
+
30
+# MSTest test Results
31
+[Tt]est[Rr]esult*/
32
+[Bb]uild[Ll]og.*
33
+
34
+# NUNIT
35
+*.VisualState.xml
36
+TestResult.xml
37
+
38
+# Build Results of an ATL Project
39
+[Dd]ebugPS/
40
+[Rr]eleasePS/
41
+dlldata.c
42
+
43
+# DNX
44
+project.lock.json
45
+project.fragment.lock.json
46
+artifacts/
47
+
48
+*_i.c
49
+*_p.c
50
+*_i.h
51
+*.ilk
52
+*.meta
53
+*.obj
54
+*.pch
55
+*.pdb
56
+*.pgc
57
+*.pgd
58
+*.rsp
59
+*.sbr
60
+*.tlb
61
+*.tli
62
+*.tlh
63
+*.tmp
64
+*.tmp_proj
65
+*.log
66
+*.vspscc
67
+*.vssscc
68
+.builds
69
+*.pidb
70
+*.svclog
71
+*.scc
72
+
73
+# Chutzpah Test files
74
+_Chutzpah*
75
+
76
+# Visual C++ cache files
77
+ipch/
78
+*.aps
79
+*.ncb
80
+*.opendb
81
+*.opensdf
82
+*.sdf
83
+*.cachefile
84
+*.VC.db
85
+*.VC.VC.opendb
86
+
87
+# Visual Studio profiler
88
+*.psess
89
+*.vsp
90
+*.vspx
91
+*.sap
92
+
93
+# TFS 2012 Local Workspace
94
+$tf/
95
+
96
+# Guidance Automation Toolkit
97
+*.gpState
98
+
99
+# ReSharper is a .NET coding add-in
100
+_ReSharper*/
101
+*.[Rr]e[Ss]harper
102
+*.DotSettings.user
103
+
104
+# JustCode is a .NET coding add-in
105
+.JustCode
106
+
107
+# TeamCity is a build add-in
108
+_TeamCity*
109
+
110
+# DotCover is a Code Coverage Tool
111
+*.dotCover
112
+
113
+# NCrunch
114
+_NCrunch_*
115
+.*crunch*.local.xml
116
+nCrunchTemp_*
117
+
118
+# MightyMoose
119
+*.mm.*
120
+AutoTest.Net/
121
+
122
+# Web workbench (sass)
123
+.sass-cache/
124
+
125
+# Installshield output folder
126
+[Ee]xpress/
127
+
128
+# DocProject is a documentation generator add-in
129
+DocProject/buildhelp/
130
+DocProject/Help/*.HxT
131
+DocProject/Help/*.HxC
132
+DocProject/Help/*.hhc
133
+DocProject/Help/*.hhk
134
+DocProject/Help/*.hhp
135
+DocProject/Help/Html2
136
+DocProject/Help/html
137
+
138
+# Click-Once directory
139
+publish/
140
+
141
+# Publish Web Output
142
+*.[Pp]ublish.xml
143
+*.azurePubxml
144
+# TODO: Comment the next line if you want to checkin your web deploy settings
145
+# but database connection strings (with potential passwords) will be unencrypted
146
+#*.pubxml
147
+*.publishproj
148
+
149
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
150
+# checkin your Azure Web App publish settings, but sensitive information contained
151
+# in these scripts will be unencrypted
152
+PublishScripts/
153
+
154
+# NuGet Packages
155
+*.nupkg
156
+# The packages folder can be ignored because of Package Restore
157
+**/packages/*
158
+# except build/, which is used as an MSBuild target.
159
+!**/packages/build/
160
+# Uncomment if necessary however generally it will be regenerated when needed
161
+#!**/packages/repositories.config
162
+# NuGet v3's project.json files produces more ignoreable files
163
+*.nuget.props
164
+*.nuget.targets
165
+
166
+# Microsoft Azure Build Output
167
+csx/
168
+*.build.csdef
169
+
170
+# Microsoft Azure Emulator
171
+ecf/
172
+rcf/
173
+
174
+# Windows Store app package directories and files
175
+AppPackages/
176
+BundleArtifacts/
177
+Package.StoreAssociation.xml
178
+_pkginfo.txt
179
+
180
+# Visual Studio cache files
181
+# files ending in .cache can be ignored
182
+*.[Cc]ache
183
+# but keep track of directories ending in .cache
184
+!*.[Cc]ache/
185
+
186
+# Others
187
+ClientBin/
188
+~$*
189
+*~
190
+*.dbmdl
191
+*.dbproj.schemaview
192
+*.jfm
193
+*.pfx
194
+*.publishsettings
195
+node_modules/
196
+orleans.codegen.cs
197
+
198
+# Since there are multiple workflows, uncomment next line to ignore bower_components
199
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
200
+#bower_components/
201
+
202
+# RIA/Silverlight projects
203
+Generated_Code/
204
+
205
+# Backup & report files from converting an old project file
206
+# to a newer Visual Studio version. Backup files are not needed,
207
+# because we have git ;-)
208
+_UpgradeReport_Files/
209
+Backup*/
210
+UpgradeLog*.XML
211
+UpgradeLog*.htm
212
+
213
+# SQL Server files
214
+*.mdf
215
+*.ldf
216
+
217
+# Business Intelligence projects
218
+*.rdl.data
219
+*.bim.layout
220
+*.bim_*.settings
221
+
222
+# Microsoft Fakes
223
+FakesAssemblies/
224
+
225
+# GhostDoc plugin setting file
226
+*.GhostDoc.xml
227
+
228
+# Node.js Tools for Visual Studio
229
+.ntvs_analysis.dat
230
+
231
+# Visual Studio 6 build log
232
+*.plg
233
+
234
+# Visual Studio 6 workspace options file
235
+*.opt
236
+
237
+# Visual Studio LightSwitch build output
238
+**/*.HTMLClient/GeneratedArtifacts
239
+**/*.DesktopClient/GeneratedArtifacts
240
+**/*.DesktopClient/ModelManifest.xml
241
+**/*.Server/GeneratedArtifacts
242
+**/*.Server/ModelManifest.xml
243
+_Pvt_Extensions
244
+
245
+# Paket dependency manager
246
+.paket/paket.exe
247
+paket-files/
248
+
249
+# FAKE - F# Make
250
+.fake/
251
+
252
+# JetBrains Rider
253
+.idea/
254
+*.sln.iml
255
+
256
+# CodeRush
257
+.cr/
258
+
259
+# Python Tools for Visual Studio (PTVS)
260
+__pycache__/
261
+*.pyc

+ 25 - 0
Basic_Terminal.sln

@@ -0,0 +1,25 @@
1
+
2
+Microsoft Visual Studio Solution File, Format Version 12.00
3
+# Visual Studio 15
4
+VisualStudioVersion = 15.0.28307.572
5
+MinimumVisualStudioVersion = 10.0.40219.1
6
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basic_Terminal", "Basic_Terminal\Basic_Terminal.csproj", "{8E445677-6494-4448-8A13-1D5DC182D581}"
7
+EndProject
8
+Global
9
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+		Debug|Any CPU = Debug|Any CPU
11
+		Release|Any CPU = Release|Any CPU
12
+	EndGlobalSection
13
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
14
+		{8E445677-6494-4448-8A13-1D5DC182D581}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15
+		{8E445677-6494-4448-8A13-1D5DC182D581}.Debug|Any CPU.Build.0 = Debug|Any CPU
16
+		{8E445677-6494-4448-8A13-1D5DC182D581}.Release|Any CPU.ActiveCfg = Release|Any CPU
17
+		{8E445677-6494-4448-8A13-1D5DC182D581}.Release|Any CPU.Build.0 = Release|Any CPU
18
+	EndGlobalSection
19
+	GlobalSection(SolutionProperties) = preSolution
20
+		HideSolutionNode = FALSE
21
+	EndGlobalSection
22
+	GlobalSection(ExtensibilityGlobals) = postSolution
23
+		SolutionGuid = {E2406341-B23D-44EE-8A04-A757A8370E31}
24
+	EndGlobalSection
25
+EndGlobal

+ 6 - 0
Basic_Terminal/App.config

@@ -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>

+ 110 - 0
Basic_Terminal/Basic_Terminal.csproj

@@ -0,0 +1,110 @@
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>{8E445677-6494-4448-8A13-1D5DC182D581}</ProjectGuid>
8
+    <OutputType>WinExe</OutputType>
9
+    <RootNamespace>Basic_Terminal</RootNamespace>
10
+    <AssemblyName>Basic_Terminal</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="Func\Bluecell_BootProtocol.cs" />
50
+    <Compile Include="Func\Crc16.cs" />
51
+    <Compile Include="Func\Data_Handler.cs" />
52
+    <Compile Include="Func\FileDownload.cs" />
53
+    <Compile Include="Func\Update_Serial.cs" />
54
+    <Compile Include="Wnd\Debug.cs">
55
+      <SubType>Form</SubType>
56
+    </Compile>
57
+    <Compile Include="Wnd\Debug.Designer.cs">
58
+      <DependentUpon>Debug.cs</DependentUpon>
59
+    </Compile>
60
+    <Compile Include="Wnd\Download_bar.cs">
61
+      <SubType>Form</SubType>
62
+    </Compile>
63
+    <Compile Include="Wnd\Download_bar.Designer.cs">
64
+      <DependentUpon>Download_bar.cs</DependentUpon>
65
+    </Compile>
66
+    <Compile Include="Wnd\Main_Form.cs">
67
+      <SubType>Form</SubType>
68
+    </Compile>
69
+    <Compile Include="Wnd\Main_Form.Designer.cs">
70
+      <DependentUpon>Main_Form.cs</DependentUpon>
71
+    </Compile>
72
+    <Compile Include="Program.cs" />
73
+    <Compile Include="Properties\AssemblyInfo.cs" />
74
+    <Compile Include="Func\Serial.cs" />
75
+    <EmbeddedResource Include="Wnd\Debug.resx">
76
+      <DependentUpon>Debug.cs</DependentUpon>
77
+    </EmbeddedResource>
78
+    <EmbeddedResource Include="Wnd\Download_bar.resx">
79
+      <DependentUpon>Download_bar.cs</DependentUpon>
80
+    </EmbeddedResource>
81
+    <EmbeddedResource Include="Wnd\Main_Form.resx">
82
+      <DependentUpon>Main_Form.cs</DependentUpon>
83
+    </EmbeddedResource>
84
+    <EmbeddedResource Include="Properties\Resources.resx">
85
+      <Generator>ResXFileCodeGenerator</Generator>
86
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
87
+      <SubType>Designer</SubType>
88
+    </EmbeddedResource>
89
+    <Compile Include="Properties\Resources.Designer.cs">
90
+      <AutoGen>True</AutoGen>
91
+      <DependentUpon>Resources.resx</DependentUpon>
92
+    </Compile>
93
+    <None Include="Properties\Settings.settings">
94
+      <Generator>SettingsSingleFileGenerator</Generator>
95
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
96
+    </None>
97
+    <Compile Include="Properties\Settings.Designer.cs">
98
+      <AutoGen>True</AutoGen>
99
+      <DependentUpon>Settings.settings</DependentUpon>
100
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
101
+    </Compile>
102
+  </ItemGroup>
103
+  <ItemGroup>
104
+    <None Include="App.config" />
105
+  </ItemGroup>
106
+  <ItemGroup>
107
+    <WCFMetadata Include="Connected Services\" />
108
+  </ItemGroup>
109
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
110
+</Project>

+ 116 - 0
Basic_Terminal/Func/Bluecell_BootProtocol.cs

@@ -0,0 +1,116 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace Basic_Terminal
8
+{
9
+    public enum Bluepro_t
10
+    {
11
+        bluecell_header0 = 0,
12
+        bluecell_header1,
13
+        bluecell_header2,
14
+        bluecell_header3,
15
+        bluecell_type,
16
+        bluecell_length_h,
17
+        bluecell_length_l,
18
+        bluecell_updatecnt_h,
19
+        bluecell_updatecnt_l,
20
+        bluecell_data,
21
+
22
+    };
23
+    enum Updateseq
24
+    {
25
+        Bluecell_Reset = 0,
26
+        Bluecell_Firmupdate_start,
27
+        Bluecell_Firmupdate_sending,
28
+        Bluecell_Firmupdate_end,
29
+    };
30
+    class Bluecell_BootProtocol
31
+    {
32
+        Serial serial;
33
+        /*bluecell Header*/
34
+        public const byte Bluecell_Header0 = 0x42;//ASCII : B
35
+        public const byte Bluecell_Header1 = 0x4C;//ASCII : L
36
+        public const byte Bluecell_Header2 = 0x55;//ASCII : U
37
+        public const byte Bluecell_Header3 = 0x45;//ASCII : E
38
+        /*bluecell type*/
39
+
40
+
41
+        public const int bluecell_Firmupdate_sendlength = 1024;
42
+        public const byte bluecell_header    = 4;
43
+        public const byte bluecell_type      = 1;
44
+        public const byte bluecell_length    = 2;
45
+        public const byte bluecell_updatecnt = 2;
46
+        public const byte bluecell_crc16     = 2;
47
+        public const byte bluecell_nessarybyte = bluecell_header + bluecell_type + bluecell_length + bluecell_updatecnt + bluecell_crc16;
48
+        Crc16 crc16 = new Crc16();
49
+
50
+        public int Bluecell_Firmupdate_sendlength() {
51
+            return bluecell_Firmupdate_sendlength;
52
+        }
53
+        private void BootHeaderput(ref byte[] fix_data)
54
+        {
55
+            fix_data[(int)Bluepro_t.bluecell_header0] = Bluecell_Header0;
56
+            fix_data[(int)Bluepro_t.bluecell_header1] = Bluecell_Header1;
57
+            fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
58
+            fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
59
+        }
60
+
61
+        public byte[] Boot_Reset(object serial,byte[] Updatedata)
62
+        {
63
+            this.serial = (Serial)serial;
64
+            byte[] fix_data = new byte[11];
65
+            //Array.Clear(data, 0, data.Length);
66
+            BootHeaderput(ref fix_data);
67
+            fix_data[(int)Bluepro_t.bluecell_type]    = (byte)Updateseq.Bluecell_Reset;
68
+            fix_data[(int)Bluepro_t.bluecell_length_h]  = 0;
69
+            fix_data[(int)Bluepro_t.bluecell_length_l]  = 5;
70
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((Updatedata.Length & 0xFF00) >> 8);
71
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((Updatedata.Length & 0x00FF));
72
+
73
+            fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0xFF00) >> 8);
74
+            fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0x00FF));
75
+            this.serial.Serial_DataSend(fix_data, fix_data.Length);
76
+            return fix_data;            
77
+        }
78
+     
79
+        public byte[] Boot_DataSending(byte[] update_data,UInt16 length, UInt16 updatacnt)
80
+        {
81
+            //Array.Clear(data, 0, data.Length);
82
+            byte[] fix_data = new byte[bluecell_Firmupdate_sendlength];
83
+            //BootHeaderput(ref fix_data);
84
+            //length += 5;
85
+            Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
86
+            BootHeaderput(ref fix_data);
87
+            fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_sending;
88
+            fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
89
+            fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
90
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((updatacnt & 0xFF00) >> 8);
91
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((updatacnt & 0x00FF));
92
+
93
+            //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
94
+            fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
95
+            fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
96
+            return fix_data;
97
+        }
98
+        public byte[] Boot_DataEnd(byte[] update_data, int length)
99
+        {
100
+            //Array.Clear(data, 0, data.Length);
101
+            byte[] fix_data = new byte[11];
102
+            Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
103
+            BootHeaderput(ref fix_data);
104
+            fix_data[(int)Bluepro_t.bluecell_type]    = (byte)Updateseq.Bluecell_Firmupdate_end;
105
+            fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
106
+            fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
107
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
108
+            fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
109
+
110
+            //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
111
+            fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
112
+            fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
113
+            return fix_data;
114
+        }
115
+    }
116
+}

+ 163 - 0
Basic_Terminal/Func/Crc16.cs

@@ -0,0 +1,163 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace Basic_Terminal
8
+{
9
+    
10
+
11
+    class Crc16
12
+    {
13
+        private readonly ushort[] Table_CRC16 = {
14
+            0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
15
+            0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
16
+            0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
17
+            0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
18
+            0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
19
+            0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
20
+            0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
21
+            0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
22
+            0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
23
+            0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
24
+            0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
25
+            0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
26
+            0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
27
+            0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
28
+            0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
29
+            0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
30
+            0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
31
+            0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
32
+            0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
33
+            0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
34
+            0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
35
+            0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
36
+            0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
37
+            0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
38
+            0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
39
+            0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
40
+            0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
41
+            0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
42
+            0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
43
+            0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
44
+            0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
45
+            0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
46
+        };
47
+        const int POLYNOMIAL = 0x131; // P(x) = x^8 + x^5 + x^4 + 1 = 100110001
48
+        public enum EtError
49
+        {
50
+            CHECKSUM_ERROR = 0,
51
+            NO_ERROR
52
+        }
53
+        //-----------------------------------------------
54
+        //UART CRC üũ �Լ�
55
+        //-----------------------------------------------
56
+        public ushort CRC16_Generate(byte[] buf_ptr, int len)
57
+        {
58
+            byte dt = 0;
59
+            ushort crc16 = 0;
60
+            ushort index = 4;
61
+            len *= 8;
62
+            for (crc16 = (ushort)0x0000; len >= 8; len -= 8)
63
+            {
64
+                crc16 = (ushort)(Table_CRC16[(crc16 >> 8) ^ (ushort)(buf_ptr[index++])] ^ (crc16 << 8));
65
+            }
66
+
67
+            if (len != 0)
68
+            {
69
+                dt = (byte)( buf_ptr[index] << 8);
70
+
71
+                while (len != 0)
72
+                {
73
+                    len--;
74
+
75
+                    if (((crc16 ^ dt) & ((ushort)1 << 15)) != 0)
76
+                    {
77
+                        crc16 = (ushort)(crc16 << 1);
78
+                        crc16 = (ushort)(crc16 ^ 0x1021);
79
+                    }
80
+                    else
81
+                    {
82
+                        crc16 = (ushort)(crc16 << 1);
83
+                    }
84
+                    dt = (byte)(dt << 1);
85
+                }
86
+            }
87
+            return (crc16);
88
+        }
89
+
90
+        public EtError CRC16_Check(byte[] buf_ptr, int len, ushort checksum)
91
+        {
92
+            byte dt = 0;
93
+            ushort crc16 = 0;
94
+            ushort index = 4;
95
+
96
+            len *= 8;
97
+            for (crc16 = (ushort)0x0000; len >= 8; len -= 8, index++)
98
+            {
99
+                crc16 = (ushort)(Table_CRC16[(crc16 >> 8) ^ (ushort)(buf_ptr[index])] ^ (crc16 << 8));
100
+            }
101
+
102
+            if (len != 0)
103
+            {
104
+                dt = (byte)(buf_ptr[index] << 8);
105
+
106
+                while (len != 0)
107
+                {
108
+                    len--;
109
+
110
+                    if (((crc16 ^ dt) & ((ushort)1 << 15)) != 0)
111
+                    {
112
+                        crc16 = (ushort)(crc16 << 1);
113
+                        crc16 = (ushort)(crc16 ^ 0x1021);
114
+                    }
115
+                    else
116
+                    {
117
+                        crc16 = (ushort)(crc16 << 1);
118
+                    }
119
+                    dt = (byte)(dt << 1);
120
+                }
121
+            }
122
+            return (crc16 == checksum ? EtError.CHECKSUM_ERROR : EtError.NO_ERROR);
123
+        }
124
+        public byte STH30_CheckCrc(byte[] data, byte nbrOfBytes, byte checksum)
125
+        {
126
+            byte bit;        // bit mask
127
+            int crc = 0xFF; // calculated checksum
128
+            byte byteCtr;    // byte counter
129
+            byte index = 1;
130
+
131
+            // calculates 8-Bit checksum with given polynomial
132
+            for (byteCtr = 0; byteCtr < nbrOfBytes; byteCtr++)
133
+            {
134
+                crc ^= (data[index++]);
135
+                for (bit = 8; bit > 0; --bit)
136
+                {
137
+                    if (Convert.ToBoolean(crc & 0x80)) { crc = (crc << 1) ^ POLYNOMIAL; }
138
+                    else crc = (crc << 1);
139
+                }
140
+            }
141
+            if (crc != checksum) return 0;
142
+            else return 1;
143
+        }
144
+        public byte STH30_CreateCrc(byte[] data, byte nbrOfBytes)
145
+        {
146
+            byte bit;        // bit mask
147
+            int crc = 0xFF; // calculated checksum
148
+            byte byteCtr;    // byte counter
149
+            byte index = 1;
150
+            // calculates 8-Bit checksum with given polynomial
151
+            for (byteCtr = 0; byteCtr < nbrOfBytes; byteCtr++)
152
+            {
153
+                crc ^= (data[index++]);
154
+                for (bit = 8; bit > 0; --bit)
155
+                {
156
+                    if (Convert.ToBoolean(crc & 0x80)) { crc = (crc << 1) ^ POLYNOMIAL; }
157
+                    else crc = (crc << 1);
158
+                }
159
+            }
160
+            return (byte)crc;
161
+        }
162
+    }
163
+}

+ 101 - 0
Basic_Terminal/Func/Data_Handler.cs

@@ -0,0 +1,101 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace Basic_Terminal
8
+{
9
+    class Data_Handler
10
+    {
11
+        //FileDownload fileDownload;
12
+        Update_Serial fileDownload;
13
+        const byte Terminal_Controller_Update_Ack = 0x11;
14
+        const byte Terminal_Controller_Update_Nak = 0x22;
15
+        const byte Terminal_Controller_FirmwareUpdateLen = 250;
16
+        const byte Terminal_Reset = 0x0A;
17
+        const byte Terminal_BootStart = 0x0B;
18
+
19
+
20
+        private Boolean HeaderCheck(byte[] data)
21
+        {
22
+            Boolean ret = false;
23
+
24
+            if(data[0] == 0xbe)
25
+            {
26
+                ret = true;
27
+            }
28
+            return ret;
29
+        }
30
+        private byte CrcCheck(byte[] data)
31
+        {
32
+            byte ret = 0;
33
+            Crc16 crc = new Crc16();
34
+            byte length,crcindex;
35
+            try
36
+            {
37
+                length = data[2];
38
+            }
39
+            catch
40
+            {
41
+                return ret;
42
+            }
43
+            crcindex = (byte)(length + 1);
44
+            ret = crc.STH30_CheckCrc(data,length,data[crcindex]);
45
+
46
+
47
+            return ret;
48
+        }
49
+        public void Recv_dataCheck(object fileDownload, byte[] data)
50
+        {
51
+            Boolean Header_Check;
52
+            byte Crc_Check, seq;
53
+            try
54
+            {
55
+                seq = data[1];
56
+            }
57
+            catch {
58
+                return;
59
+            }
60
+            if (fileDownload != null)
61
+            {
62
+                this.fileDownload = (Update_Serial)fileDownload;
63
+            }
64
+            else
65
+            {
66
+                this.fileDownload = new Update_Serial();
67
+            }
68
+            if (this.fileDownload.Update_ready == true)
69
+            {
70
+                Header_Check = HeaderCheck(data);
71
+                if (Header_Check == false)
72
+                {
73
+                    return;
74
+                }
75
+                Crc_Check = CrcCheck(data);
76
+                if(Crc_Check == 0)
77
+                {
78
+                    return;
79
+                }
80
+
81
+
82
+                switch (seq)
83
+                {
84
+                    case Terminal_Reset:
85
+                    case Terminal_BootStart:
86
+                    case Terminal_Controller_Update_Ack:
87
+                    case Terminal_Controller_Update_Nak:
88
+                        //int DataAckcnt = data[(int)Bluepro_t.bluecell_type + 1];
89
+                        //this.fileDownload.UpdateFileSend(data, DataAckcnt);
90
+                        this.fileDownload.Termianl__Operate(data);
91
+                        break;
92
+                    case 3:
93
+                        break;
94
+                    default:
95
+                        break;
96
+                }
97
+                
98
+            }
99
+        }
100
+    }
101
+}

+ 146 - 0
Basic_Terminal/Func/FileDownload.cs

@@ -0,0 +1,146 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+using System.Windows.Forms;
8
+using System.IO;
9
+using System.IO.Ports;
10
+namespace Basic_Terminal
11
+{
12
+    enum DataSeq
13
+    {
14
+        UpdateResetOK = 0,
15
+        UpdateStartOK,
16
+        UpdateSendingOK,
17
+        UpdateEndOK,
18
+    }
19
+    class FileDownload
20
+    {
21
+        
22
+        Bluecell_BootProtocol Bluecell_BootProtocol = new Bluecell_BootProtocol();
23
+        byte[] All_update_data;
24
+        /***
25
+         *Data File open
26
+        */
27
+        OpenFileDialog ofd;
28
+        Serial serial;
29
+
30
+        public bool Update_ready = false;
31
+        
32
+        public string ShowFileOpenDialog(ref object serial,object ofd)
33
+        {
34
+            this.ofd = (OpenFileDialog)ofd;
35
+            this.serial = (Serial)serial;
36
+            this.ofd.Title = "업데이터 파일 탐색기";//파일오픈창 생성 및 설정
37
+            this.ofd.FileName = "*.bin";
38
+            //ofd.Filter = "bin 파일 (*.bin) | *.bin; | 모든 파일 (*.*) | *.*";
39
+            this.ofd.Filter = "bin 파일 (*.bin) | *.bin;";
40
+            DialogResult dr = this.ofd.ShowDialog();            //파일 오픈창 로드
41
+            if (dr == DialogResult.OK)//OK버튼 클릭시
42
+            {
43
+                string fileName = this.ofd.SafeFileName;                //File명과 확장자를 가지고 온다.
44
+                string fileFullName = this.ofd.FileName;//File경로와 File명을 모두 가지고 온다.
45
+                string filePath = fileFullName.Replace(fileName, "");//File경로만 가지고 온다.
46
+               
47
+
48
+                this.serial.FileDownloadClass_Get(this);
49
+                All_update_data = File.ReadAllBytes(this.ofd.FileName);
50
+                Bluecell_BootProtocol.Boot_Reset(this.serial, All_update_data);
51
+                //byte[] updatedata = Bluecell_BootProtocol.Boot_DataSending(All_update_data, (Bluecell_BootProtocol.bluecell_Firmupdate_sendlength - 11), (UInt16)0);
52
+                //this.serial.Serial_DataSend(updatedata);
53
+
54
+                Update_ready = true;
55
+                return fileFullName;
56
+            }
57
+            else if (dr == DialogResult.Cancel)//취소버튼 클릭시 또는 ESC키로 파일창을 종료 했을경우
58
+            {
59
+                return "";
60
+            }
61
+            return "";
62
+        }
63
+
64
+#if false
65
+        public void Recv_dataCheck(byte[] data)
66
+        {
67
+            Boolean HeaderCheck = Serial_HeaderCheck(data);
68
+            int DataAckcnt = data[(int)Bluepro_t.bluecell_type + 1];
69
+            if (HeaderCheck == false)
70
+            {
71
+                return;
72
+            }
73
+            else
74
+            {
75
+                DataSeq seq = DataSeq.UpdateResetOK;
76
+                switch (seq)
77
+                {
78
+                    case DataSeq.UpdateSendingOK:
79
+                        UpdateFileSend(data, DataAckcnt);
80
+                        break;
81
+                    case DataSeq.UpdateEndOK:
82
+                        break;
83
+                    default:
84
+                        break;
85
+                }
86
+            }
87
+        }
88
+#endif
89
+        int sourceindex = 0;
90
+        public void UpdateFileSend(byte[] data,int cnt)
91
+        {
92
+            if (this.serial == null)
93
+                return;
94
+            /*Define*/
95
+            int Quotient = 0, remainder = 0;
96
+           
97
+            byte[] updatedata = new byte[Bluecell_BootProtocol.bluecell_Firmupdate_sendlength];
98
+            /*Filse size */
99
+            Quotient = All_update_data.Length / (Bluecell_BootProtocol.bluecell_Firmupdate_sendlength - 11);
100
+            remainder = All_update_data.Length % (Bluecell_BootProtocol.bluecell_Firmupdate_sendlength - 11);
101
+            /*file copy*/
102
+            // Header : 4byte + Type : 1byte + Length : 2byte + update_cnt : 2byte = 9byte  /* CRC :2byte  */ : Total : 11byte
103
+            Array.Copy(All_update_data, sourceindex, updatedata, Bluecell_BootProtocol.bluecell_nessarybyte - 2, (Bluecell_BootProtocol.bluecell_Firmupdate_sendlength - 11)); 
104
+            /*file write*/
105
+            if (remainder > 0 && cnt > Quotient)
106
+            {
107
+                this.serial.Serial_DataSend(data, remainder);
108
+                sourceindex = 0;
109
+                All_update_data = null;
110
+            }
111
+            else
112
+            {
113
+                data = Bluecell_BootProtocol.Boot_DataSending(updatedata, (Bluecell_BootProtocol.bluecell_Firmupdate_sendlength - 11), (UInt16)cnt);
114
+                this.serial.Serial_DataSend(data,Bluecell_BootProtocol.bluecell_Firmupdate_sendlength);
115
+                /*send index modify*/
116
+                sourceindex = (cnt + 1)  * (Bluecell_BootProtocol.bluecell_Firmupdate_sendlength - 11);
117
+            }
118
+        }
119
+        public static string AsciiToHex(string asciiString)
120
+        {
121
+            StringBuilder builder = new StringBuilder();
122
+            foreach (char c in asciiString)
123
+            {
124
+                builder.Append(Convert.ToInt32(c).ToString("X"));
125
+            }
126
+            return builder.ToString();
127
+        }
128
+
129
+        public Boolean Serial_HeaderCheck(byte[] data)
130
+        {
131
+            Boolean ret = false;
132
+
133
+            if (data[(int)Bluepro_t.bluecell_header0] == Bluecell_BootProtocol.Bluecell_Header0
134
+                && data[(int)Bluepro_t.bluecell_header1] == Bluecell_BootProtocol.Bluecell_Header1
135
+                && data[(int)Bluepro_t.bluecell_header2] == Bluecell_BootProtocol.Bluecell_Header2
136
+                && data[(int)Bluepro_t.bluecell_header3] == Bluecell_BootProtocol.Bluecell_Header3
137
+                )/*모든 Header OK */
138
+            {
139
+                ret = true;
140
+            }
141
+            return ret;
142
+        }
143
+
144
+       
145
+    }
146
+}

+ 206 - 0
Basic_Terminal/Func/Serial.cs

@@ -0,0 +1,206 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+//Add code
7
+using System.Windows.Forms;
8
+using System.IO;
9
+using System.IO.Ports;
10
+
11
+namespace Basic_Terminal
12
+{
13
+    class Serial
14
+    {
15
+        private System.IO.Ports.SerialPort serialPort;
16
+        private Debug Debug = new Debug();    // Teminal Text Wnd Open
17
+        public string Serial_Name { get => serialPort.PortName;  set => serialPort.PortName = value;}
18
+        Data_Handler data_Handler = new Data_Handler();
19
+        //FileDownload fileDownload;
20
+        Update_Serial fileDownload;
21
+        public void Serial_Initialize(ref ComboBox cb_port)
22
+        {
23
+            
24
+            this.serialPort = new System.IO.Ports.SerialPort();
25
+            this.serialPort.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.Serial_DataRecvFunction);
26
+
27
+            cb_port.BeginUpdate();
28
+            foreach (string comport in SerialPort.GetPortNames())//foreach (string comport in SerialPort_TestProgram.GetPortNames())
29
+            {
30
+                cb_port.Items.Add(comport);
31
+            }
32
+            cb_port.EndUpdate();
33
+            //SerialPort 초기 설정.
34
+         //  serialPort.Encoding = Encoding.GetEncoding("Windows-1252");
35
+            cb_port.DataSource =  SerialPort.GetPortNames();
36
+            try
37
+            {
38
+                serialPort.PortName = Serial_Name = cb_port.SelectedItem.ToString();
39
+                serialPort.BaudRate = (int)115200;
40
+                serialPort.DataBits = (int)8;
41
+                serialPort.Parity = System.IO.Ports.Parity.None;
42
+                serialPort.StopBits = StopBits.One;
43
+            }
44
+            catch { }
45
+
46
+        }
47
+        private delegate void StringSend(string Text);
48
+        private delegate void ByteSend(byte[] Text);
49
+
50
+        public string Str2hex(string strData,Boolean Compotable)
51
+        {
52
+            string resultHex = string.Empty;
53
+            byte[] arr_byteStr = Encoding.Default.GetBytes(strData);
54
+
55
+            foreach (byte byteStr in arr_byteStr)
56
+            {
57
+                if(Compotable == true)
58
+                    resultHex += string.Format("{0:X2}", byteStr) + " ";
59
+                else
60
+                    resultHex += string.Format("{0:X2}", byteStr);
61
+            }
62
+
63
+            return resultHex;
64
+        }
65
+
66
+        static public byte[] Str2bytes(string byteData)
67
+        {
68
+
69
+#if false
70
+            System.Text.ASCIIEncoding asencoding = new System.Text.ASCIIEncoding();
71
+            return Encoding.Default.GetBytes(byteData);
72
+#else 
73
+            byte[] arr_byteStr = Encoding.Default.GetBytes(byteData);
74
+            return arr_byteStr;
75
+#endif
76
+        }
77
+       
78
+        public void Serial_DataRecvFunction(object sender, SerialDataReceivedEventArgs e)
79
+        {
80
+            if (this.Debug.Created && Debug.RadioButton_ascii.Checked == true)
81
+            {
82
+                string data = serialPort.ReadExisting();
83
+                if (Debug.Created)
84
+                    if (Debug.RadioButton_ascii.Checked == true)
85
+                        Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
86
+                    else
87
+                        Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(data, true));
88
+
89
+                data_Handler.Recv_dataCheck(this.fileDownload, Str2bytes(data));
90
+            }
91
+            else
92
+            {
93
+                // 리스트 두개 사용
94
+                int nLnegth = serialPort.BytesToRead;
95
+                byte[] btdata = new byte[nLnegth];
96
+                serialPort.Read(btdata, 0, nLnegth);
97
+
98
+                if (nLnegth > 0)
99
+                {
100
+                    if (this.Debug.Created)
101
+                    {
102
+                        string tmpSTR = Encoding.Default.GetString(btdata).TrimEnd('\0');
103
+                        Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(tmpSTR, true));
104
+                    }
105
+                    data_Handler.Recv_dataCheck(this.fileDownload, btdata);
106
+                   
107
+                    // 이부분에서 데이타 처리하는 부분으로 전송하여 사용하면 됨
108
+                }
109
+            }
110
+            /****
111
+             *메모리 누수 방지용 코드
112
+             */
113
+            System.GC.Collect(0, GCCollectionMode.Forced);
114
+            System.GC.WaitForFullGCComplete();
115
+        }
116
+        public Boolean Serial_PortOpen(ref Button Btn_Portonoff,ref ComboBox cb)
117
+        {
118
+            Boolean ret = false;
119
+            try
120
+            {
121
+                if (serialPort.IsOpen) { //When the port is open
122
+                    serialPort.Close();
123
+                    Btn_Portonoff.Text = "Port Open";
124
+                    ret = true;
125
+                }
126
+                else//When the port is close
127
+                {
128
+                    if (cb.Text != "")
129
+                    {
130
+                        serialPort.Open();
131
+                        Btn_Portonoff.Text = "Port Close";
132
+                    }
133
+                    else
134
+                    {
135
+                        MessageBox.Show("Port is not set");
136
+                        ret = true;
137
+                    }
138
+                }
139
+            }
140
+            catch
141
+            {
142
+                MessageBox.Show("already port open " + Serial_Name);
143
+               
144
+            }
145
+            return ret;
146
+        }
147
+        public void Serial_TerminalOpen(object serial)
148
+        {
149
+            this.Debug.Serial_ClassSet(serial);
150
+            try
151
+            {
152
+                this.Debug.Show();
153
+            }
154
+            catch
155
+            {
156
+                Debug = new Debug();
157
+                this.Debug.Show();
158
+            }
159
+        }
160
+        public void Serial_DataSend(byte[] data)
161
+        {
162
+            try
163
+            {
164
+                serialPort.Write(data,0,data.Length);
165
+            }
166
+            catch (System.Exception ex)
167
+            {
168
+                MessageBox.Show(ex.Message);
169
+            }
170
+        }
171
+        public void Serial_DataSend(byte[] buffer, int count)
172
+        {
173
+            try { serialPort.Write(buffer, 0, count); }
174
+            catch { MessageBox.Show("Port Open Failed!!!"); }
175
+        }
176
+        public void FileDownloadClass_Get(object filedownload)
177
+        {
178
+            //this.fileDownload = (FileDownload)filedownload;
179
+            this.fileDownload = (Update_Serial)filedownload;
180
+        }
181
+        public void Test_Serial()
182
+        {
183
+            byte[] tempdata = new byte[1024];
184
+            for (int i = 0; i < 255; i++)
185
+            {
186
+
187
+                tempdata[i] = Convert.ToByte(i);
188
+                
189
+                
190
+            }
191
+            this.serialPort.Write(tempdata, 0, 255);
192
+            //this.serialPort.Write(tempdata.ToString());
193
+
194
+        }
195
+        public void debug_hextoasciiConvert()
196
+        {
197
+            if(this.Debug.Created)
198
+                this.Debug.hex_to_ascii_radiobuttonConvert();
199
+        }
200
+        public void debug_asciitohexConvert()
201
+        {
202
+            if (this.Debug.Created)
203
+                this.Debug.ascii_to_hex_radiobuttonConvert();
204
+        }
205
+    }
206
+}

+ 271 - 0
Basic_Terminal/Func/Update_Serial.cs

@@ -0,0 +1,271 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.IO;
4
+using System.Linq;
5
+using System.Text;
6
+using System.Threading.Tasks;
7
+
8
+using System.Windows.Forms;
9
+
10
+
11
+namespace Basic_Terminal
12
+{
13
+    class Update_Serial
14
+    {
15
+        public byte[] Firmware_byte_load;
16
+        byte Data_Request_Val = 0;
17
+        int FirmTotalcnt = 0;
18
+        int FirmCurrcnt = 0;
19
+        int PreFirmSendingcnt = 0;
20
+        int FirmSendingcnt = 0;
21
+        int pretempupdateret = 0;
22
+        bool update_ready = false;
23
+        const byte blucell_stx = 0xbe;
24
+        const byte blucell_etx = 0xeb;
25
+        const byte Termianl_Controller_Update_Ack = 0x11;
26
+        const byte Termianl_Controller_Update_Nak = 0x22;
27
+        const byte Termianl_Controller_FirmwareUpdateLen = 250;
28
+        const byte Termianl_Reset = 0x0A;
29
+        const byte Termianl_BootStart = 0x0B;
30
+        const int POLYNOMIAL = 0x131; // P(x) = x^8 + x^5 + x^4 + 1 = 100110001
31
+        Bluecell_BootProtocol Bluecell_BootProtocol = new Bluecell_BootProtocol();
32
+        Download_bar download_Bar = new Download_bar();
33
+        private delegate void StringSend(string Text);
34
+        private delegate void VoidSend();
35
+        OpenFileDialog ofd;
36
+        Serial serial;
37
+
38
+
39
+        private byte Data_Request_Func
40
+        {
41
+            get
42
+            { return Data_Request_Val; }
43
+            set
44
+            { Data_Request_Val = value; }
45
+
46
+        }
47
+
48
+        public bool Update_ready { get => update_ready; set => update_ready = value; }
49
+
50
+
51
+        /***
52
+*Data File open
53
+***/
54
+        public string ShowFileOpenDialog(ref Serial serial, object ofd)
55
+        {
56
+            byte[] tempdata = new byte[5];
57
+            this.ofd = (OpenFileDialog)ofd;
58
+            this.serial = (Serial)serial;
59
+            //파일오픈창 생성 및 설정
60
+            this.ofd.Title = "업데이터 파일 탐색기";
61
+            this.ofd.FileName = "*.bin";
62
+            this.ofd.Filter = "binary 파일 (*.binary,*.bin) | *.binary;, *.bin; | 모든 파일 (*.*) | *.*";
63
+
64
+            //파일 오픈창 로드
65
+            DialogResult dr = this.ofd.ShowDialog();
66
+
67
+            //OK버튼 클릭시
68
+            if (dr == DialogResult.OK)
69
+            {
70
+                //File명과 확장자를 가지고 온다.
71
+                string fileName = this.ofd.SafeFileName;
72
+                //File경로와 File명을 모두 가지고 온다.
73
+                string fileFullName = this.ofd.FileName;
74
+                //File경로만 가지고 온다.
75
+                string filePath = fileFullName.Replace(fileName, "");
76
+                this.serial.debug_hextoasciiConvert();
77
+
78
+                //출력 예제용 로직
79
+                //  label1.Text = "File Name  : " + fileName;
80
+                // label2.Text = "Full Name  : " + fileFullName;
81
+                // label3.Text = "File Path  : " + filePath;`
82
+                //File경로 + 파일명 리턴
83
+                this.serial.FileDownloadClass_Get(this);
84
+                Data_Request_Func = 1;
85
+
86
+                Firmware_byte_load = File.ReadAllBytes(this.ofd.FileName);
87
+                FirmTotalcnt = Firmware_byte_load.Length / Termianl_Controller_FirmwareUpdateLen;
88
+
89
+                FirmCurrcnt = 0;
90
+                PreFirmSendingcnt = 0;
91
+                FirmSendingcnt = 0;
92
+                Update_ready = true;
93
+                tempdata[0] = 0xbe;
94
+                tempdata[1] = Termianl_Reset;
95
+                tempdata[2] = 0x02;
96
+                tempdata[3] = STH30_CreateCrc(tempdata, tempdata[2]);
97
+                tempdata[4] = 0xeb;
98
+               
99
+                this.serial.Serial_DataSend(tempdata, 5);
100
+                try
101
+                {
102
+                   // Controller_Debug.Controller_TX_TextLoad(tempdata);
103
+                }
104
+                catch { }
105
+                download_Bar.ShowDialog();
106
+                /*Update_label.Visible = true;
107
+                progressBar1.Visible = true;*/
108
+                return fileFullName;
109
+            }
110
+            //취소버튼 클릭시 또는 ESC키로 파일창을 종료 했을경우
111
+            else if (dr == DialogResult.Cancel)
112
+            {
113
+                return "";
114
+            }
115
+
116
+            return "";
117
+        }
118
+
119
+        public void FirmwareUpdateCheck(byte check)
120
+        {
121
+
122
+            byte[] temp_data = new byte[Termianl_Controller_FirmwareUpdateLen + 5];
123
+            byte cnt = 3;
124
+            int lastlen = 0;
125
+            // FirmTotalcnt = Firmware_byte_load.Length / Termianl_Controller_FirmwareUpdateLen;
126
+            lastlen = Firmware_byte_load.Length % Termianl_Controller_FirmwareUpdateLen;
127
+            temp_data[0] = blucell_stx;
128
+            temp_data[1] = 0xDD;
129
+            if (check == Termianl_BootStart)
130
+            {
131
+                System.Threading.Thread.Sleep(2000);
132
+            }
133
+            if (Termianl_Controller_Update_Ack == check || Termianl_BootStart == check)
134
+            {
135
+                PreFirmSendingcnt = FirmSendingcnt;
136
+                if (FirmCurrcnt != FirmTotalcnt)
137
+                {
138
+                    temp_data[2] = Termianl_Controller_FirmwareUpdateLen + 2;
139
+                    for (int i = 0; i < Termianl_Controller_FirmwareUpdateLen; i++)
140
+                    {
141
+                        temp_data[cnt++] = Firmware_byte_load[FirmSendingcnt++];
142
+                    }
143
+                    FirmCurrcnt++;
144
+                    temp_data[Termianl_Controller_FirmwareUpdateLen + 3] = STH30_CreateCrc(temp_data, temp_data[2]);
145
+                    temp_data[Termianl_Controller_FirmwareUpdateLen + 4] = blucell_etx;
146
+                }
147
+                else
148
+                {
149
+                    Update_ready = false;
150
+                    temp_data[1] = 0xEE;
151
+                    temp_data[2] = Convert.ToByte(lastlen + 2);
152
+                    for (int i = 0; i < lastlen; i++)
153
+                    {
154
+                        temp_data[cnt++] = Firmware_byte_load[FirmSendingcnt++];
155
+                    }
156
+                    temp_data[temp_data[2] + 1] = STH30_CreateCrc(temp_data, temp_data[2]);
157
+                    temp_data[temp_data[2] + 2] = blucell_etx;
158
+                    /*ownload_Bar.ShowDialog();*/
159
+                    this.download_Bar.Invoke(new StringSend(this.download_Bar.Progressbar), "0 %");
160
+                    //download_Bar.Progressbar("0 %");
161
+                    this.download_Bar.Progressbar_gauge_zero();
162
+                    this.download_Bar.FormClosed(this.download_Bar);
163
+                    this.serial.debug_asciitohexConvert();
164
+                    FirmSendingcnt = PreFirmSendingcnt = FirmCurrcnt = FirmTotalcnt = pretempupdateret = Data_Request_Val = 0;
165
+      
166
+                    /*Update_label.Text = "0%";
167
+                    Update_label.Visible = false;
168
+                    progressBar1.Visible = false;
169
+                    progressBar1.Value = 0;*/
170
+                    //  MessageBox.Show("Update Complete !!");
171
+                }
172
+
173
+            }
174
+            else
175
+            {
176
+                FirmSendingcnt = PreFirmSendingcnt;
177
+                if (FirmCurrcnt != FirmTotalcnt)
178
+                {
179
+                    temp_data[2] = Termianl_Controller_FirmwareUpdateLen + 2;
180
+                    for (int i = 0; i < Termianl_Controller_FirmwareUpdateLen; i++)
181
+                    {
182
+                        temp_data[cnt++] = Firmware_byte_load[FirmSendingcnt++];
183
+
184
+                    }
185
+                    FirmCurrcnt++;
186
+                    temp_data[Termianl_Controller_FirmwareUpdateLen + 3] = STH30_CreateCrc(temp_data, temp_data[2]);
187
+                    temp_data[Termianl_Controller_FirmwareUpdateLen + 4] = blucell_etx;
188
+                }
189
+                else
190
+                {
191
+                    Update_ready = false;
192
+                    temp_data[1] = 0xEE;
193
+                    temp_data[2] = Convert.ToByte(lastlen + 2);
194
+                    for (int i = 0; i < lastlen; i++)
195
+                    {
196
+                        temp_data[cnt++] = Firmware_byte_load[FirmSendingcnt++];
197
+                    }
198
+                    temp_data[temp_data[2] + 1] = STH30_CreateCrc(temp_data, temp_data[2]);
199
+                    temp_data[temp_data[2] + 2] = blucell_etx;
200
+                    /* Update_label.Visible = false;
201
+                     progressBar1.Visible = false;*/
202
+                    download_Bar.Close();
203
+                }
204
+            }
205
+            int tempupdateret = Firmware_byte_load.Length / 100;
206
+            tempupdateret = FirmSendingcnt / tempupdateret;
207
+            //CheckForIllegalCrossThreadCalls = false;
208
+            this.download_Bar.Update_Percent(Convert.ToString(tempupdateret));
209
+            if (pretempupdateret != tempupdateret)
210
+            {
211
+
212
+                for (int i = 0; i <= tempupdateret - this.download_Bar.Update_get(); i++)
213
+                {
214
+                    this.download_Bar.PerformStepup(this.download_Bar);
215
+                    //this.download_Bar.PerformStepinc(tempupdateret);
216
+                    // progressBar1.PerformStep();
217
+                }
218
+
219
+                pretempupdateret = tempupdateret;
220
+            }
221
+
222
+            //serialPort1.Write(temp_data, 0, temp_data[2] + 3);
223
+            this.serial.Serial_DataSend(temp_data, temp_data[2] + 3);
224
+            try
225
+            {
226
+               // Controller_Debug.Controller_TX_TextLoad(temp_data);
227
+            }
228
+            catch { }
229
+        }
230
+
231
+        public void Termianl__Operate(byte[] Text)
232
+        {
233
+            byte Type = 0;
234
+            Type = Text[Bluecell_BootProtocol.bluecell_type];
235
+            switch (Type)
236
+            {
237
+               
238
+                case Termianl_BootStart:
239
+                case Termianl_Controller_Update_Ack:
240
+                case Termianl_Controller_Update_Nak:
241
+                    if (Update_ready == true)
242
+                        FirmwareUpdateCheck(Type);
243
+                    break;
244
+               
245
+                default:
246
+                    // MessageBox.Show("다시 시도 해주세요.");
247
+                    break;
248
+            }
249
+        }
250
+
251
+        byte STH30_CreateCrc(byte[] data, byte nbrOfBytes)
252
+        {
253
+            byte bit;        // bit mask
254
+            int crc = 0xFF; // calculated checksum
255
+            byte byteCtr;    // byte counter
256
+            byte index = 1;
257
+            // calculates 8-Bit checksum with given polynomial
258
+            for (byteCtr = 0; byteCtr < nbrOfBytes; byteCtr++)
259
+            {
260
+                crc ^= (data[index++]);
261
+                for (bit = 8; bit > 0; --bit)
262
+                {
263
+                    if (Convert.ToBoolean(crc & 0x80)) { crc = (crc << 1) ^ POLYNOMIAL; }
264
+                    else crc = (crc << 1);
265
+                }
266
+            }
267
+            return (byte)crc;
268
+        }
269
+        
270
+    }
271
+}

+ 22 - 0
Basic_Terminal/Program.cs

@@ -0,0 +1,22 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Threading.Tasks;
5
+using System.Windows.Forms;
6
+
7
+namespace Basic_Terminal
8
+{
9
+    static class Program
10
+    {
11
+        /// <summary>
12
+        /// 해당 응용 프로그램의 주 진입점입니다.
13
+        /// </summary>
14
+        [STAThread]
15
+        static void Main()
16
+        {
17
+            Application.EnableVisualStyles();
18
+            Application.SetCompatibleTextRenderingDefault(false);
19
+            Application.Run(new Main_Form());
20
+        }
21
+    }
22
+}

+ 36 - 0
Basic_Terminal/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
1
+using System.Reflection;
2
+using System.Runtime.CompilerServices;
3
+using System.Runtime.InteropServices;
4
+
5
+// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 
6
+// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
7
+// 이러한 특성 값을 변경하세요.
8
+[assembly: AssemblyTitle("Basic_Terminal")]
9
+[assembly: AssemblyDescription("")]
10
+[assembly: AssemblyConfiguration("")]
11
+[assembly: AssemblyCompany("")]
12
+[assembly: AssemblyProduct("Basic_Terminal")]
13
+[assembly: AssemblyCopyright("Copyright ©  2019")]
14
+[assembly: AssemblyTrademark("")]
15
+[assembly: AssemblyCulture("")]
16
+
17
+// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 
18
+// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
19
+// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
20
+[assembly: ComVisible(false)]
21
+
22
+// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
23
+[assembly: Guid("8e445677-6494-4448-8a13-1d5dc182d581")]
24
+
25
+// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
26
+//
27
+//      주 버전
28
+//      부 버전 
29
+//      빌드 번호
30
+//      수정 버전
31
+//
32
+// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로
33
+// 지정되도록 할 수 있습니다.
34
+// [assembly: AssemblyVersion("1.0.*")]
35
+[assembly: AssemblyVersion("1.0.0.0")]
36
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
Basic_Terminal/Properties/Resources.Designer.cs

@@ -0,0 +1,71 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+//     이 코드는 도구를 사용하여 생성되었습니다.
4
+//     런타임 버전:4.0.30319.42000
5
+//
6
+//     파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
7
+//     이러한 변경 내용이 손실됩니다.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+namespace Basic_Terminal.Properties
12
+{
13
+
14
+
15
+    /// <summary>
16
+    ///   지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다.
17
+    /// </summary>
18
+    // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder
19
+    // 클래스에서 자동으로 생성되었습니다.
20
+    // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여
21
+    // ResGen을 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오.
22
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25
+    internal class Resources
26
+    {
27
+
28
+        private static global::System.Resources.ResourceManager resourceMan;
29
+
30
+        private static global::System.Globalization.CultureInfo resourceCulture;
31
+
32
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33
+        internal Resources()
34
+        {
35
+        }
36
+
37
+        /// <summary>
38
+        ///   이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다.
39
+        /// </summary>
40
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41
+        internal static global::System.Resources.ResourceManager ResourceManager
42
+        {
43
+            get
44
+            {
45
+                if ((resourceMan == null))
46
+                {
47
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Basic_Terminal.Properties.Resources", typeof(Resources).Assembly);
48
+                    resourceMan = temp;
49
+                }
50
+                return resourceMan;
51
+            }
52
+        }
53
+
54
+        /// <summary>
55
+        ///   이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을
56
+        ///   재정의합니다.
57
+        /// </summary>
58
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59
+        internal static global::System.Globalization.CultureInfo Culture
60
+        {
61
+            get
62
+            {
63
+                return resourceCulture;
64
+            }
65
+            set
66
+            {
67
+                resourceCulture = value;
68
+            }
69
+        }
70
+    }
71
+}

+ 117 - 0
Basic_Terminal/Properties/Resources.resx

@@ -0,0 +1,117 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:element name="root" msdata:IsDataSet="true">
64
+      <xsd:complexType>
65
+        <xsd:choice maxOccurs="unbounded">
66
+          <xsd:element name="metadata">
67
+            <xsd:complexType>
68
+              <xsd:sequence>
69
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
70
+              </xsd:sequence>
71
+              <xsd:attribute name="name" type="xsd:string" />
72
+              <xsd:attribute name="type" type="xsd:string" />
73
+              <xsd:attribute name="mimetype" type="xsd:string" />
74
+            </xsd:complexType>
75
+          </xsd:element>
76
+          <xsd:element name="assembly">
77
+            <xsd:complexType>
78
+              <xsd:attribute name="alias" type="xsd:string" />
79
+              <xsd:attribute name="name" type="xsd:string" />
80
+            </xsd:complexType>
81
+          </xsd:element>
82
+          <xsd:element name="data">
83
+            <xsd:complexType>
84
+              <xsd:sequence>
85
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
86
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
87
+              </xsd:sequence>
88
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
89
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
90
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
91
+            </xsd:complexType>
92
+          </xsd:element>
93
+          <xsd:element name="resheader">
94
+            <xsd:complexType>
95
+              <xsd:sequence>
96
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
97
+              </xsd:sequence>
98
+              <xsd:attribute name="name" type="xsd:string" use="required" />
99
+            </xsd:complexType>
100
+          </xsd:element>
101
+        </xsd:choice>
102
+      </xsd:complexType>
103
+    </xsd:element>
104
+  </xsd:schema>
105
+  <resheader name="resmimetype">
106
+    <value>text/microsoft-resx</value>
107
+  </resheader>
108
+  <resheader name="version">
109
+    <value>2.0</value>
110
+  </resheader>
111
+  <resheader name="reader">
112
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
113
+  </resheader>
114
+  <resheader name="writer">
115
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+</root>

+ 30 - 0
Basic_Terminal/Properties/Settings.Designer.cs

@@ -0,0 +1,30 @@
1
+//------------------------------------------------------------------------------
2
+// <auto-generated>
3
+//     This code was generated by a tool.
4
+//     Runtime Version:4.0.30319.42000
5
+//
6
+//     Changes to this file may cause incorrect behavior and will be lost if
7
+//     the code is regenerated.
8
+// </auto-generated>
9
+//------------------------------------------------------------------------------
10
+
11
+namespace Basic_Terminal.Properties
12
+{
13
+
14
+
15
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18
+    {
19
+
20
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21
+
22
+        public static Settings Default
23
+        {
24
+            get
25
+            {
26
+                return defaultInstance;
27
+            }
28
+        }
29
+    }
30
+}

+ 7 - 0
Basic_Terminal/Properties/Settings.settings

@@ -0,0 +1,7 @@
1
+<?xml version='1.0' encoding='utf-8'?>
2
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
3
+  <Profiles>
4
+    <Profile Name="(Default)" />
5
+  </Profiles>
6
+  <Settings />
7
+</SettingsFile>

+ 168 - 0
Basic_Terminal/Wnd/Debug.Designer.cs

@@ -0,0 +1,168 @@
1
+namespace Basic_Terminal
2
+{
3
+    partial class Debug
4
+    {
5
+        /// <summary>
6
+        /// Required designer variable.
7
+        /// </summary>
8
+        private System.ComponentModel.IContainer components = null;
9
+
10
+        /// <summary>
11
+        /// Clean up any resources being used.
12
+        /// </summary>
13
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
14
+        protected override void Dispose(bool disposing)
15
+        {
16
+            if (disposing && (components != null))
17
+            {
18
+                components.Dispose();
19
+            }
20
+            base.Dispose(disposing);
21
+        }
22
+
23
+        #region Windows Form Designer generated code
24
+
25
+        /// <summary>
26
+        /// Required method for Designer support - do not modify
27
+        /// the contents of this method with the code editor.
28
+        /// </summary>
29
+        private void InitializeComponent()
30
+        {
31
+            this.tbReceived = new System.Windows.Forms.RichTextBox();
32
+            this.groupBox1 = new System.Windows.Forms.GroupBox();
33
+            this.checkBox2 = new System.Windows.Forms.CheckBox();
34
+            this.checkBox1 = new System.Windows.Forms.CheckBox();
35
+            this.radioButton_ascii = new System.Windows.Forms.RadioButton();
36
+            this.radioButton_hex = new System.Windows.Forms.RadioButton();
37
+            this.button_Clear = new System.Windows.Forms.Button();
38
+            this.button_Send = new System.Windows.Forms.Button();
39
+            this.textBox_senddata = new System.Windows.Forms.TextBox();
40
+            this.groupBox1.SuspendLayout();
41
+            this.SuspendLayout();
42
+            // 
43
+            // tbReceived
44
+            // 
45
+            this.tbReceived.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
46
+            this.tbReceived.ForeColor = System.Drawing.SystemColors.Window;
47
+            this.tbReceived.Location = new System.Drawing.Point(0, 0);
48
+            this.tbReceived.MaxLength = 0;
49
+            this.tbReceived.Name = "tbReceived";
50
+            this.tbReceived.ReadOnly = true;
51
+            this.tbReceived.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
52
+            this.tbReceived.Size = new System.Drawing.Size(800, 403);
53
+            this.tbReceived.TabIndex = 63;
54
+            this.tbReceived.Text = "";
55
+            // 
56
+            // groupBox1
57
+            // 
58
+            this.groupBox1.Controls.Add(this.checkBox2);
59
+            this.groupBox1.Controls.Add(this.checkBox1);
60
+            this.groupBox1.Controls.Add(this.radioButton_ascii);
61
+            this.groupBox1.Controls.Add(this.radioButton_hex);
62
+            this.groupBox1.Controls.Add(this.button_Clear);
63
+            this.groupBox1.Controls.Add(this.button_Send);
64
+            this.groupBox1.Controls.Add(this.textBox_senddata);
65
+            this.groupBox1.Location = new System.Drawing.Point(13, 410);
66
+            this.groupBox1.Name = "groupBox1";
67
+            this.groupBox1.Size = new System.Drawing.Size(787, 89);
68
+            this.groupBox1.TabIndex = 64;
69
+            this.groupBox1.TabStop = false;
70
+            this.groupBox1.Text = "보내는 문자열";
71
+            // 
72
+            // checkBox2
73
+            // 
74
+            this.checkBox2.AutoSize = true;
75
+            this.checkBox2.Location = new System.Drawing.Point(254, 20);
76
+            this.checkBox2.Name = "checkBox2";
77
+            this.checkBox2.Size = new System.Drawing.Size(116, 16);
78
+            this.checkBox2.TabIndex = 4;
79
+            this.checkBox2.Text = "수신 문자열 표시";
80
+            this.checkBox2.UseVisualStyleBackColor = true;
81
+            // 
82
+            // checkBox1
83
+            // 
84
+            this.checkBox1.AutoSize = true;
85
+            this.checkBox1.Location = new System.Drawing.Point(131, 20);
86
+            this.checkBox1.Name = "checkBox1";
87
+            this.checkBox1.Size = new System.Drawing.Size(116, 16);
88
+            this.checkBox1.TabIndex = 4;
89
+            this.checkBox1.Text = "송신 문자열 표시";
90
+            this.checkBox1.UseVisualStyleBackColor = true;
91
+            // 
92
+            // radioButton_ascii
93
+            // 
94
+            this.radioButton_ascii.AutoSize = true;
95
+            this.radioButton_ascii.Checked = true;
96
+            this.radioButton_ascii.Location = new System.Drawing.Point(71, 20);
97
+            this.radioButton_ascii.Name = "radioButton_ascii";
98
+            this.radioButton_ascii.Size = new System.Drawing.Size(54, 16);
99
+            this.radioButton_ascii.TabIndex = 3;
100
+            this.radioButton_ascii.TabStop = true;
101
+            this.radioButton_ascii.Text = "ASCII";
102
+            this.radioButton_ascii.UseVisualStyleBackColor = true;
103
+            // 
104
+            // radioButton_hex
105
+            // 
106
+            this.radioButton_hex.AutoSize = true;
107
+            this.radioButton_hex.Location = new System.Drawing.Point(7, 20);
108
+            this.radioButton_hex.Name = "radioButton_hex";
109
+            this.radioButton_hex.Size = new System.Drawing.Size(45, 16);
110
+            this.radioButton_hex.TabIndex = 3;
111
+            this.radioButton_hex.Text = "Hex";
112
+            this.radioButton_hex.UseVisualStyleBackColor = true;
113
+            // 
114
+            // button_Clear
115
+            // 
116
+            this.button_Clear.Location = new System.Drawing.Point(702, 20);
117
+            this.button_Clear.Name = "button_Clear";
118
+            this.button_Clear.Size = new System.Drawing.Size(71, 23);
119
+            this.button_Clear.TabIndex = 2;
120
+            this.button_Clear.Text = "삭제";
121
+            this.button_Clear.UseVisualStyleBackColor = true;
122
+            this.button_Clear.Click += new System.EventHandler(this.Button_Clear_Click);
123
+            // 
124
+            // button_Send
125
+            // 
126
+            this.button_Send.Location = new System.Drawing.Point(702, 53);
127
+            this.button_Send.Name = "button_Send";
128
+            this.button_Send.Size = new System.Drawing.Size(71, 23);
129
+            this.button_Send.TabIndex = 1;
130
+            this.button_Send.Text = "보내기";
131
+            this.button_Send.UseVisualStyleBackColor = true;
132
+            this.button_Send.Click += new System.EventHandler(this.Button_Send_Click);
133
+            // 
134
+            // textBox_senddata
135
+            // 
136
+            this.textBox_senddata.Location = new System.Drawing.Point(7, 54);
137
+            this.textBox_senddata.Name = "textBox_senddata";
138
+            this.textBox_senddata.Size = new System.Drawing.Size(688, 21);
139
+            this.textBox_senddata.TabIndex = 0;
140
+            // 
141
+            // Debug
142
+            // 
143
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
144
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
145
+            this.ClientSize = new System.Drawing.Size(802, 511);
146
+            this.Controls.Add(this.groupBox1);
147
+            this.Controls.Add(this.tbReceived);
148
+            this.Name = "Debug";
149
+            this.Text = "Debug";
150
+            this.groupBox1.ResumeLayout(false);
151
+            this.groupBox1.PerformLayout();
152
+            this.ResumeLayout(false);
153
+
154
+        }
155
+
156
+        #endregion
157
+
158
+        public System.Windows.Forms.RichTextBox tbReceived;
159
+        private System.Windows.Forms.GroupBox groupBox1;
160
+        private System.Windows.Forms.Button button_Send;
161
+        private System.Windows.Forms.TextBox textBox_senddata;
162
+        private System.Windows.Forms.Button button_Clear;
163
+        private System.Windows.Forms.CheckBox checkBox2;
164
+        private System.Windows.Forms.CheckBox checkBox1;
165
+        private System.Windows.Forms.RadioButton radioButton_ascii;
166
+        private System.Windows.Forms.RadioButton radioButton_hex;
167
+    }
168
+}

+ 174 - 0
Basic_Terminal/Wnd/Debug.cs

@@ -0,0 +1,174 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+//Add code
11
+using System.Runtime.InteropServices; //ini파일 로드 필요라이브러리
12
+namespace Basic_Terminal
13
+{
14
+    public partial class Debug : Form
15
+    {
16
+        int LineLimit = 500;
17
+        [DllImport("user32.dll")]
18
+        public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
19
+        private const int WM_SETREDRAW = 11;
20
+        Serial serial;
21
+        public RadioButton RadioButton_ascii { get => radioButton_ascii; set => radioButton_ascii = value; }
22
+        public RadioButton RadioButton_hex { get => radioButton_hex; set => radioButton_hex = value; }
23
+
24
+        public Debug()
25
+        {
26
+            
27
+            InitializeComponent();
28
+            
29
+        }
30
+#if true
31
+        public void Data_Recv_Str(string text)
32
+        {
33
+            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
34
+            try
35
+            {
36
+                try
37
+                {
38
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
39
+                }
40
+                catch (Exception e) { MessageBox.Show(e.StackTrace); }
41
+                if (tbReceived.Lines.Length > nLimitLines)
42
+                {
43
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
44
+                    while ((tempLines.Count - nLimitLines) > 0)
45
+                    {
46
+                        tempLines.RemoveFirst();
47
+                    }
48
+
49
+                    tbReceived.Lines = tempLines.ToArray();
50
+
51
+                }
52
+                try
53
+                {
54
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
55
+                }
56
+                catch { return; }
57
+                tbReceived.AppendText(text);
58
+                tbReceived.SelectionStart = tbReceived.Text.Length;//맨 마지막 선택... 
59
+                tbReceived.ScrollToCaret();
60
+            }
61
+            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
62
+        }
63
+#endif
64
+#if false
65
+        public void Data_Recv_Hex(byte[] text)
66
+        {
67
+           int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
68
+            try
69
+            {
70
+                try
71
+                {
72
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
73
+                }
74
+                catch (Exception e) { MessageBox.Show(e.StackTrace); }
75
+                if (tbReceived.Lines.Length > nLimitLines)
76
+                {
77
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
78
+                    while ((tempLines.Count - nLimitLines) > 0)
79
+                    {
80
+                        tempLines.RemoveFirst();
81
+                    }
82
+
83
+                    tbReceived.Lines = tempLines.ToArray();
84
+
85
+                }
86
+                try
87
+                {
88
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
89
+                }
90
+                catch { return; }
91
+                tbReceived.AppendText(text.ToString());
92
+                tbReceived.SelectionStart = tbReceived.Text.Length;//맨 마지막 선택... 
93
+                tbReceived.ScrollToCaret();
94
+            }
95
+            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
96
+
97
+        }
98
+#endif
99
+        public void Data_Send(byte[] text)
100
+        {
101
+            string AppendMessage = "\n[TX]";
102
+
103
+            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
104
+            try
105
+            {
106
+                for (int i = 0; i < text.Length; i++)
107
+                {
108
+                    AppendMessage += Convert.ToString(text[i], 16);
109
+                }
110
+                tbReceived.AppendText(AppendMessage);
111
+                try
112
+                {
113
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
114
+                }
115
+                catch { return; }
116
+                if (tbReceived.Lines.Length > nLimitLines)
117
+                {
118
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
119
+
120
+                    while ((tempLines.Count - nLimitLines) > 0)
121
+                    {
122
+                        tempLines.RemoveFirst();
123
+                    }
124
+
125
+                    tbReceived.Lines = tempLines.ToArray();
126
+                }
127
+                try
128
+                {
129
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
130
+                }
131
+                catch { return; }
132
+                tbReceived.Select(tbReceived.Text.Length, 0);
133
+                tbReceived.ScrollToCaret();
134
+            }
135
+            finally { }
136
+
137
+        }
138
+    
139
+        public void Serial_ClassSet(object serial)
140
+        {
141
+            this.serial = (Serial)serial;
142
+        }
143
+        private void Button_Send_Click(object sender, EventArgs e)
144
+        {
145
+            try
146
+            {
147
+                this.serial.Serial_DataSend(Encoding.ASCII.GetBytes(textBox_senddata.Text));
148
+            }
149
+            catch (System.Exception ex)
150
+            {
151
+                MessageBox.Show(ex.Message);
152
+            }
153
+        }
154
+
155
+        private void Button_Clear_Click(object sender, EventArgs e)
156
+        {
157
+            try
158
+            {
159
+                this.tbReceived.Text = "";
160
+            }
161
+            finally { }
162
+        }
163
+        public void hex_to_ascii_radiobuttonConvert()
164
+        {
165
+            radioButton_hex.Checked = true;
166
+            radioButton_ascii.Checked = false;
167
+        }
168
+        public void ascii_to_hex_radiobuttonConvert()
169
+        {
170
+            radioButton_ascii.Checked = true;
171
+            radioButton_hex.Checked = false;
172
+        }
173
+    }
174
+}

+ 120 - 0
Basic_Terminal/Wnd/Debug.resx

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 81 - 0
Basic_Terminal/Wnd/Download_bar.Designer.cs

@@ -0,0 +1,81 @@
1
+namespace Basic_Terminal
2
+{
3
+    partial class Download_bar
4
+    {
5
+        /// <summary>
6
+        /// Required designer variable.
7
+        /// </summary>
8
+        private System.ComponentModel.IContainer components = null;
9
+
10
+        /// <summary>
11
+        /// Clean up any resources being used.
12
+        /// </summary>
13
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
14
+        protected override void Dispose(bool disposing)
15
+        {
16
+            if (disposing && (components != null))
17
+            {
18
+                components.Dispose();
19
+            }
20
+            base.Dispose(disposing);
21
+        }
22
+
23
+        #region Windows Form Designer generated code
24
+
25
+        /// <summary>
26
+        /// Required method for Designer support - do not modify
27
+        /// the contents of this method with the code editor.
28
+        /// </summary>
29
+        private void InitializeComponent()
30
+        {
31
+            this.Firm_Progressbar = new System.Windows.Forms.ProgressBar();
32
+            this.Update_label = new System.Windows.Forms.Label();
33
+            this.SuspendLayout();
34
+            // 
35
+            // Firm_Progressbar
36
+            // 
37
+            this.Firm_Progressbar.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
38
+            | System.Windows.Forms.AnchorStyles.Left) 
39
+            | System.Windows.Forms.AnchorStyles.Right)));
40
+            this.Firm_Progressbar.Location = new System.Drawing.Point(12, 24);
41
+            this.Firm_Progressbar.Name = "Firm_Progressbar";
42
+            this.Firm_Progressbar.Size = new System.Drawing.Size(478, 46);
43
+            this.Firm_Progressbar.Step = 1;
44
+            this.Firm_Progressbar.TabIndex = 133;
45
+            // 
46
+            // Update_label
47
+            // 
48
+            this.Update_label.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
49
+            | System.Windows.Forms.AnchorStyles.Left) 
50
+            | System.Windows.Forms.AnchorStyles.Right)));
51
+            this.Update_label.AutoSize = true;
52
+            this.Update_label.BackColor = System.Drawing.Color.Transparent;
53
+            this.Update_label.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
54
+            this.Update_label.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
55
+            this.Update_label.Location = new System.Drawing.Point(245, 9);
56
+            this.Update_label.Name = "Update_label";
57
+            this.Update_label.Size = new System.Drawing.Size(23, 12);
58
+            this.Update_label.TabIndex = 134;
59
+            this.Update_label.Text = "0%";
60
+            // 
61
+            // Download_bar
62
+            // 
63
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
64
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
65
+            this.ClientSize = new System.Drawing.Size(502, 94);
66
+            this.Controls.Add(this.Update_label);
67
+            this.Controls.Add(this.Firm_Progressbar);
68
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
69
+            this.Name = "Download_bar";
70
+            this.Text = "Download_bar";
71
+            this.ResumeLayout(false);
72
+            this.PerformLayout();
73
+
74
+        }
75
+
76
+        #endregion
77
+
78
+        private System.Windows.Forms.ProgressBar Firm_Progressbar;
79
+        public System.Windows.Forms.Label Update_label;
80
+    }
81
+}

+ 61 - 0
Basic_Terminal/Wnd/Download_bar.cs

@@ -0,0 +1,61 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+
11
+namespace Basic_Terminal
12
+{
13
+    public partial class Download_bar : Form
14
+    {
15
+        public Download_bar()
16
+        {
17
+            InitializeComponent();
18
+        }
19
+        public void Progressbar(String val)
20
+        {
21
+            Update_label.Text = val;
22
+        }
23
+        public void Progressbar_gauge_zero()
24
+        {
25
+            Firm_Progressbar.Value = 0;
26
+        }
27
+        public new void FormClosed(object form)
28
+        {
29
+            Download_bar download_Bar = (Download_bar)form;
30
+            CheckForIllegalCrossThreadCalls = false;
31
+            download_Bar.Close();
32
+        }
33
+        public void PerformStepup(object form)
34
+        {
35
+            Download_bar download_Bar = (Download_bar)form;
36
+            CheckForIllegalCrossThreadCalls = false;
37
+            Firm_Progressbar.PerformStep();
38
+        }
39
+        public void PerformStepinc(int val)
40
+        {
41
+            //Download_bar download_Bar = (Download_bar)form;
42
+            CheckForIllegalCrossThreadCalls = false;
43
+            Firm_Progressbar.Increment(val);
44
+        }
45
+        public void Update_Percent(String val)
46
+        {
47
+            CheckForIllegalCrossThreadCalls = false;
48
+            Firm_Progressbar.PerformStep();
49
+            try
50
+            {
51
+                Update_label.Text = val + "%";
52
+            }
53
+            catch { }
54
+        }
55
+        public int Update_get()
56
+        {
57
+            return Firm_Progressbar.Value;
58
+        }
59
+
60
+    }
61
+}

+ 120 - 0
Basic_Terminal/Wnd/Download_bar.resx

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 219 - 0
Basic_Terminal/Wnd/Main_Form.Designer.cs

@@ -0,0 +1,219 @@
1
+namespace Basic_Terminal
2
+{
3
+    partial class Main_Form
4
+    {
5
+        /// <summary>
6
+        /// 필수 디자이너 변수입니다.
7
+        /// </summary>
8
+        private System.ComponentModel.IContainer components = null;
9
+
10
+        /// <summary>
11
+        /// 사용 중인 모든 리소스를 정리합니다.
12
+        /// </summary>
13
+        /// <param name="disposing">관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다.</param>
14
+        protected override void Dispose(bool disposing)
15
+        {
16
+            if (disposing && (components != null))
17
+            {
18
+                components.Dispose();
19
+            }
20
+            base.Dispose(disposing);
21
+        }
22
+
23
+        #region Windows Form 디자이너에서 생성한 코드
24
+
25
+        /// <summary>
26
+        /// 디자이너 지원에 필요한 메서드입니다. 
27
+        /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요.
28
+        /// </summary>
29
+        private void InitializeComponent()
30
+        {
31
+            this.groupBox9 = new System.Windows.Forms.GroupBox();
32
+            this.button3 = new System.Windows.Forms.Button();
33
+            this.button_terminal = new System.Windows.Forms.Button();
34
+            this.Ascii_checkBox = new System.Windows.Forms.CheckBox();
35
+            this.cmCom_Port = new System.Windows.Forms.Label();
36
+            this.button_PortOpen = new System.Windows.Forms.Button();
37
+            this.comboBox_Port = new System.Windows.Forms.ComboBox();
38
+            this.cmBaudRate = new System.Windows.Forms.Label();
39
+            this.comboBox_baudrate = new System.Windows.Forms.ComboBox();
40
+            this.Crc16_Check = new System.Windows.Forms.Button();
41
+            this.label1 = new System.Windows.Forms.Label();
42
+            this.groupBox9.SuspendLayout();
43
+            this.SuspendLayout();
44
+            // 
45
+            // groupBox9
46
+            // 
47
+            this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
48
+            | System.Windows.Forms.AnchorStyles.Left) 
49
+            | System.Windows.Forms.AnchorStyles.Right)));
50
+            this.groupBox9.Controls.Add(this.button3);
51
+            this.groupBox9.Controls.Add(this.button_terminal);
52
+            this.groupBox9.Controls.Add(this.Ascii_checkBox);
53
+            this.groupBox9.Controls.Add(this.cmCom_Port);
54
+            this.groupBox9.Controls.Add(this.button_PortOpen);
55
+            this.groupBox9.Controls.Add(this.comboBox_Port);
56
+            this.groupBox9.Controls.Add(this.cmBaudRate);
57
+            this.groupBox9.Controls.Add(this.comboBox_baudrate);
58
+            this.groupBox9.Location = new System.Drawing.Point(12, 23);
59
+            this.groupBox9.Name = "groupBox9";
60
+            this.groupBox9.Size = new System.Drawing.Size(225, 223);
61
+            this.groupBox9.TabIndex = 82;
62
+            this.groupBox9.TabStop = false;
63
+            this.groupBox9.Text = "Connection";
64
+            // 
65
+            // button3
66
+            // 
67
+            this.button3.Location = new System.Drawing.Point(14, 171);
68
+            this.button3.Name = "button3";
69
+            this.button3.Size = new System.Drawing.Size(197, 34);
70
+            this.button3.TabIndex = 93;
71
+            this.button3.Text = "Firmware Update";
72
+            this.button3.UseVisualStyleBackColor = true;
73
+            this.button3.Click += new System.EventHandler(this.Firmware_Update_Click);
74
+            // 
75
+            // button_terminal
76
+            // 
77
+            this.button_terminal.Location = new System.Drawing.Point(14, 131);
78
+            this.button_terminal.Name = "button_terminal";
79
+            this.button_terminal.Size = new System.Drawing.Size(197, 34);
80
+            this.button_terminal.TabIndex = 94;
81
+            this.button_terminal.Text = "Terminal";
82
+            this.button_terminal.UseVisualStyleBackColor = true;
83
+            this.button_terminal.Click += new System.EventHandler(this.Button_terminal_Click);
84
+            // 
85
+            // Ascii_checkBox
86
+            // 
87
+            this.Ascii_checkBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
88
+            | System.Windows.Forms.AnchorStyles.Left) 
89
+            | System.Windows.Forms.AnchorStyles.Right)));
90
+            this.Ascii_checkBox.AutoSize = true;
91
+            this.Ascii_checkBox.Location = new System.Drawing.Point(14, 69);
92
+            this.Ascii_checkBox.Name = "Ascii_checkBox";
93
+            this.Ascii_checkBox.Size = new System.Drawing.Size(55, 16);
94
+            this.Ascii_checkBox.TabIndex = 92;
95
+            this.Ascii_checkBox.Text = "ASCII";
96
+            this.Ascii_checkBox.UseVisualStyleBackColor = true;
97
+            // 
98
+            // cmCom_Port
99
+            // 
100
+            this.cmCom_Port.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
101
+            | System.Windows.Forms.AnchorStyles.Left) 
102
+            | System.Windows.Forms.AnchorStyles.Right)));
103
+            this.cmCom_Port.AutoSize = true;
104
+            this.cmCom_Port.Location = new System.Drawing.Point(11, 18);
105
+            this.cmCom_Port.Name = "cmCom_Port";
106
+            this.cmCom_Port.Size = new System.Drawing.Size(58, 12);
107
+            this.cmCom_Port.TabIndex = 89;
108
+            this.cmCom_Port.Text = "Com Port";
109
+            // 
110
+            // button_PortOpen
111
+            // 
112
+            this.button_PortOpen.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
113
+            | System.Windows.Forms.AnchorStyles.Left) 
114
+            | System.Windows.Forms.AnchorStyles.Right)));
115
+            this.button_PortOpen.Location = new System.Drawing.Point(13, 91);
116
+            this.button_PortOpen.Name = "button_PortOpen";
117
+            this.button_PortOpen.Size = new System.Drawing.Size(197, 34);
118
+            this.button_PortOpen.TabIndex = 86;
119
+            this.button_PortOpen.Text = "Port Open";
120
+            this.button_PortOpen.UseVisualStyleBackColor = true;
121
+            this.button_PortOpen.Click += new System.EventHandler(this.Button_PortOpen_Click);
122
+            // 
123
+            // comboBox_Port
124
+            // 
125
+            this.comboBox_Port.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
126
+            | System.Windows.Forms.AnchorStyles.Left) 
127
+            | System.Windows.Forms.AnchorStyles.Right)));
128
+            this.comboBox_Port.Cursor = System.Windows.Forms.Cursors.Default;
129
+            this.comboBox_Port.FormattingEnabled = true;
130
+            this.comboBox_Port.Location = new System.Drawing.Point(109, 15);
131
+            this.comboBox_Port.Name = "comboBox_Port";
132
+            this.comboBox_Port.Size = new System.Drawing.Size(101, 20);
133
+            this.comboBox_Port.TabIndex = 88;
134
+            this.comboBox_Port.SelectedIndexChanged += new System.EventHandler(this.ComboBox_Port_SelectedIndexChanged);
135
+            // 
136
+            // cmBaudRate
137
+            // 
138
+            this.cmBaudRate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
139
+            | System.Windows.Forms.AnchorStyles.Left) 
140
+            | System.Windows.Forms.AnchorStyles.Right)));
141
+            this.cmBaudRate.AutoSize = true;
142
+            this.cmBaudRate.Location = new System.Drawing.Point(11, 47);
143
+            this.cmBaudRate.Name = "cmBaudRate";
144
+            this.cmBaudRate.Size = new System.Drawing.Size(94, 12);
145
+            this.cmBaudRate.TabIndex = 90;
146
+            this.cmBaudRate.Text = "Baud Rate(bps)";
147
+            // 
148
+            // comboBox_baudrate
149
+            // 
150
+            this.comboBox_baudrate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
151
+            | System.Windows.Forms.AnchorStyles.Left) 
152
+            | System.Windows.Forms.AnchorStyles.Right)));
153
+            this.comboBox_baudrate.FormattingEnabled = true;
154
+            this.comboBox_baudrate.Items.AddRange(new object[] {
155
+            "9600",
156
+            "14400",
157
+            "19200",
158
+            "38400",
159
+            "57600",
160
+            "115200",
161
+            "128000"});
162
+            this.comboBox_baudrate.Location = new System.Drawing.Point(110, 45);
163
+            this.comboBox_baudrate.Name = "comboBox_baudrate";
164
+            this.comboBox_baudrate.Size = new System.Drawing.Size(101, 20);
165
+            this.comboBox_baudrate.TabIndex = 91;
166
+            this.comboBox_baudrate.Text = "115200";
167
+            // 
168
+            // Crc16_Check
169
+            // 
170
+            this.Crc16_Check.Location = new System.Drawing.Point(12, 285);
171
+            this.Crc16_Check.Name = "Crc16_Check";
172
+            this.Crc16_Check.Size = new System.Drawing.Size(96, 23);
173
+            this.Crc16_Check.TabIndex = 83;
174
+            this.Crc16_Check.Text = "Crc16 Check";
175
+            this.Crc16_Check.UseVisualStyleBackColor = true;
176
+            this.Crc16_Check.Click += new System.EventHandler(this.Crc16_Check_Click);
177
+            // 
178
+            // label1
179
+            // 
180
+            this.label1.AutoSize = true;
181
+            this.label1.Location = new System.Drawing.Point(127, 290);
182
+            this.label1.Name = "label1";
183
+            this.label1.Size = new System.Drawing.Size(110, 12);
184
+            this.label1.TabIndex = 84;
185
+            this.label1.Text = "Check Sum Result";
186
+            // 
187
+            // Main_Form
188
+            // 
189
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
190
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
191
+            this.ClientSize = new System.Drawing.Size(800, 450);
192
+            this.Controls.Add(this.label1);
193
+            this.Controls.Add(this.Crc16_Check);
194
+            this.Controls.Add(this.groupBox9);
195
+            this.Name = "Main_Form";
196
+            this.Text = "Terminal";
197
+            this.groupBox9.ResumeLayout(false);
198
+            this.groupBox9.PerformLayout();
199
+            this.ResumeLayout(false);
200
+            this.PerformLayout();
201
+
202
+        }
203
+
204
+        #endregion
205
+
206
+        private System.Windows.Forms.GroupBox groupBox9;
207
+        private System.Windows.Forms.Button button3;
208
+        private System.Windows.Forms.Button button_terminal;
209
+        private System.Windows.Forms.CheckBox Ascii_checkBox;
210
+        private System.Windows.Forms.Label cmCom_Port;
211
+        private System.Windows.Forms.Button button_PortOpen;
212
+        private System.Windows.Forms.Label cmBaudRate;
213
+        private System.Windows.Forms.ComboBox comboBox_baudrate;
214
+        private System.Windows.Forms.Button Crc16_Check;
215
+        private System.Windows.Forms.Label label1;
216
+        public System.Windows.Forms.ComboBox comboBox_Port;
217
+    }
218
+}
219
+

+ 67 - 0
Basic_Terminal/Wnd/Main_Form.cs

@@ -0,0 +1,67 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+//Add code
11
+
12
+using System.IO;
13
+using System.IO.Ports;
14
+namespace Basic_Terminal
15
+{
16
+    
17
+    public partial class Main_Form : Form
18
+    {
19
+        Serial serial = new Serial(); // Uart Open
20
+        
21
+        Update_Serial file = new Update_Serial();
22
+        public Main_Form()
23
+        {
24
+            InitializeComponent();
25
+            serial.Serial_Initialize(ref comboBox_Port);
26
+        }
27
+       
28
+        private void Firmware_Update_Click(object sender, EventArgs e)
29
+        {
30
+            OpenFileDialog ofd = new OpenFileDialog();
31
+            //FileDownload file = new FileDownload();
32
+            if (Ascii_checkBox.Checked == true)
33
+                Ascii_checkBox.Checked = false;
34
+            file.ShowFileOpenDialog(ref serial, ofd);
35
+        }
36
+        private void Crc16_Check_Click(object sender, EventArgs e)
37
+        {
38
+#if false
39
+            Crc16 crc16 = new Crc16();
40
+            byte[] tempdata = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,0x0A };
41
+            label1.Text = crc16.CRC16_Generate(tempdata, 11).ToString();
42
+#endif
43
+            this.serial.Test_Serial();
44
+        }
45
+
46
+        private void Button_PortOpen_Click(object sender, EventArgs e)
47
+        {
48
+            Serial_connectiondisable(serial.Serial_PortOpen(ref button_PortOpen,ref comboBox_Port));
49
+        }
50
+
51
+        private void ComboBox_Port_SelectedIndexChanged(object sender, EventArgs e)
52
+        {
53
+            serial.Serial_Name = comboBox_Port.SelectedItem.ToString();
54
+        }
55
+
56
+        private void Button_terminal_Click(object sender, EventArgs e)
57
+        {
58
+            serial.Serial_TerminalOpen(serial);
59
+        }
60
+        public void Serial_connectiondisable(Boolean on_off)
61
+        {
62
+            comboBox_Port.Enabled = on_off;
63
+            comboBox_baudrate.Enabled = on_off;
64
+        }
65
+
66
+    }
67
+}

+ 120 - 0
Basic_Terminal/Wnd/Main_Form.resx

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>