소스 검색

Bluecell protocol 적용 / CRC Index 변수 화 / Firmdownload 식별 하기 쉽도록 변경 /

YJ 5 년 전
부모
커밋
96b71159e9

+ 27 - 1
Basic_Terminal/Basic_Terminal.csproj

@@ -33,6 +33,16 @@
33
     <WarningLevel>4</WarningLevel>
33
     <WarningLevel>4</WarningLevel>
34
   </PropertyGroup>
34
   </PropertyGroup>
35
   <ItemGroup>
35
   <ItemGroup>
36
+    <Reference Include="MetroFramework, Version=1.2.0.3, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
37
+      <HintPath>..\packages\MetroFramework.RunTime.1.2.0.3\lib\net40-Client\MetroFramework.dll</HintPath>
38
+    </Reference>
39
+    <Reference Include="MetroFramework.Design, Version=1.2.0.3, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
40
+      <HintPath>..\packages\MetroFramework.Design.1.2.0.3\lib\net40\MetroFramework.Design.dll</HintPath>
41
+      <Private>False</Private>
42
+    </Reference>
43
+    <Reference Include="MetroFramework.Fonts, Version=1.2.0.3, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
44
+      <HintPath>..\packages\MetroFramework.Fonts.1.2.0.3\lib\net40\MetroFramework.Fonts.dll</HintPath>
45
+    </Reference>
36
     <Reference Include="System" />
46
     <Reference Include="System" />
37
     <Reference Include="System.Core" />
47
     <Reference Include="System.Core" />
38
     <Reference Include="System.Xml.Linq" />
48
     <Reference Include="System.Xml.Linq" />
@@ -49,7 +59,6 @@
49
     <Compile Include="Func\Bluecell_BootProtocol.cs" />
59
     <Compile Include="Func\Bluecell_BootProtocol.cs" />
50
     <Compile Include="Func\Crc16.cs" />
60
     <Compile Include="Func\Crc16.cs" />
51
     <Compile Include="Func\Data_Handler.cs" />
61
     <Compile Include="Func\Data_Handler.cs" />
52
-    <Compile Include="Func\FileDownload.cs" />
53
     <Compile Include="Func\Update_Serial.cs" />
62
     <Compile Include="Func\Update_Serial.cs" />
54
     <Compile Include="Wnd\Debug.cs">
63
     <Compile Include="Wnd\Debug.cs">
55
       <SubType>Form</SubType>
64
       <SubType>Form</SubType>
@@ -89,7 +98,9 @@
89
     <Compile Include="Properties\Resources.Designer.cs">
98
     <Compile Include="Properties\Resources.Designer.cs">
90
       <AutoGen>True</AutoGen>
99
       <AutoGen>True</AutoGen>
91
       <DependentUpon>Resources.resx</DependentUpon>
100
       <DependentUpon>Resources.resx</DependentUpon>
101
+      <DesignTime>True</DesignTime>
92
     </Compile>
102
     </Compile>
103
+    <None Include="packages.config" />
93
     <None Include="Properties\Settings.settings">
104
     <None Include="Properties\Settings.settings">
94
       <Generator>SettingsSingleFileGenerator</Generator>
105
       <Generator>SettingsSingleFileGenerator</Generator>
95
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
106
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -106,5 +117,20 @@
106
   <ItemGroup>
117
   <ItemGroup>
107
     <WCFMetadata Include="Connected Services\" />
118
     <WCFMetadata Include="Connected Services\" />
108
   </ItemGroup>
119
   </ItemGroup>
120
+  <ItemGroup>
121
+    <None Include="Resources\TX_Red_Image.png" />
122
+  </ItemGroup>
123
+  <ItemGroup>
124
+    <None Include="Resources\TX_IMAGE.png" />
125
+  </ItemGroup>
126
+  <ItemGroup>
127
+    <None Include="Resources\RX_IMAGE.png" />
128
+  </ItemGroup>
129
+  <ItemGroup>
130
+    <None Include="Resources\RX_GREEN_IMAGE.png" />
131
+  </ItemGroup>
132
+  <ItemGroup>
133
+    <Content Include="MetroFramework.txt" />
134
+  </ItemGroup>
109
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
135
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
110
 </Project>
136
 </Project>

+ 38 - 5
Basic_Terminal/Func/Bluecell_BootProtocol.cs

@@ -20,13 +20,28 @@ namespace Basic_Terminal
20
         bluecell_data,
20
         bluecell_data,
21
 
21
 
22
     };
22
     };
23
-    enum Updateseq
23
+    public enum Updateseq
24
     {
24
     {
25
         Bluecell_Reset = 0,
25
         Bluecell_Reset = 0,
26
         Bluecell_Firmupdate_start,
26
         Bluecell_Firmupdate_start,
27
         Bluecell_Firmupdate_sending,
27
         Bluecell_Firmupdate_sending,
28
         Bluecell_Firmupdate_end,
28
         Bluecell_Firmupdate_end,
29
     };
29
     };
30
+    enum Bluecell_ProtIndex_p
31
+    {
32
+        Bluecell_Header = 0,
33
+        Bluecell_Type,
34
+        Bluecell_Length,
35
+        Bluecell_CrcIndex,
36
+        Bluecell_data,
37
+    }
38
+    enum Bluecell_Prot_t{
39
+        TYPE_BLUECELL_RESET = 0,
40
+        TYPE_BLUECELL_SET   = 1,
41
+        TYPE_BLUECELL_GET   = 2,
42
+        TYPE_BLUECELL_SAVE  = 3,
43
+        TYPE_BLUECELL_ACK   = 4,
44
+    };
30
     class Bluecell_BootProtocol
45
     class Bluecell_BootProtocol
31
     {
46
     {
32
         Serial serial;
47
         Serial serial;
@@ -39,14 +54,31 @@ namespace Basic_Terminal
39
 
54
 
40
 
55
 
41
         public const int bluecell_Firmupdate_sendlength = 1024;
56
         public const int bluecell_Firmupdate_sendlength = 1024;
42
-        public const byte bluecell_header    = 4;
43
-        public const byte bluecell_type      = 1;
57
+        Crc16 crc16 = new Crc16();
58
+        public const byte BLUECELL_HEADER = 0xBE;
59
+        public const byte BLUECELL_TAILER = 0xEB;
60
+        const byte BLUECELL_RESET_LENGTH = 6;
61
+        const byte BLUECELL_FIX_DATA_LENGTH = 3;
62
+        public void Bluecell_Reset(object serial)
63
+        {
64
+            this.serial = (Serial)serial;
65
+            byte[] temp_buf = new byte[BLUECELL_RESET_LENGTH];
66
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header]       = BLUECELL_HEADER;
67
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type]         = (byte)Bluecell_Prot_t.TYPE_BLUECELL_RESET;
68
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length]       = BLUECELL_RESET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
69
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex]     = (byte)Bluecell_ProtIndex_p.Bluecell_data;
70
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data]         = crc16.STH30_CreateCrc(temp_buf, BLUECELL_RESET_LENGTH - 3);
71
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1]     = BLUECELL_TAILER;
72
+            this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
73
+        }
74
+
44
         public const byte bluecell_length    = 2;
75
         public const byte bluecell_length    = 2;
45
         public const byte bluecell_updatecnt = 2;
76
         public const byte bluecell_updatecnt = 2;
46
         public const byte bluecell_crc16     = 2;
77
         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();
78
+     
79
+   
49
 
80
 
81
+#if false
50
         public int Bluecell_Firmupdate_sendlength() {
82
         public int Bluecell_Firmupdate_sendlength() {
51
             return bluecell_Firmupdate_sendlength;
83
             return bluecell_Firmupdate_sendlength;
52
         }
84
         }
@@ -112,5 +144,6 @@ namespace Basic_Terminal
112
             fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
144
             fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
113
             return fix_data;
145
             return fix_data;
114
         }
146
         }
147
+#endif
115
     }
148
     }
116
 }
149
 }

+ 4 - 4
Basic_Terminal/Func/Crc16.cs

@@ -121,7 +121,7 @@ namespace Basic_Terminal
121
             }
121
             }
122
             return (crc16 == checksum ? EtError.CHECKSUM_ERROR : EtError.NO_ERROR);
122
             return (crc16 == checksum ? EtError.CHECKSUM_ERROR : EtError.NO_ERROR);
123
         }
123
         }
124
-        public byte STH30_CheckCrc(byte[] data, byte nbrOfBytes, byte checksum)
124
+        public bool STH30_CheckCrc(byte[] data, byte nbrOfBytes, byte checksum)
125
         {
125
         {
126
             byte bit;        // bit mask
126
             byte bit;        // bit mask
127
             int crc = 0xFF; // calculated checksum
127
             int crc = 0xFF; // calculated checksum
@@ -138,15 +138,15 @@ namespace Basic_Terminal
138
                     else crc = (crc << 1);
138
                     else crc = (crc << 1);
139
                 }
139
                 }
140
             }
140
             }
141
-            if (crc != checksum) return 0;
142
-            else return 1;
141
+            if (crc != checksum) return false;
142
+            else return true;
143
         }
143
         }
144
         public byte STH30_CreateCrc(byte[] data, byte nbrOfBytes)
144
         public byte STH30_CreateCrc(byte[] data, byte nbrOfBytes)
145
         {
145
         {
146
             byte bit;        // bit mask
146
             byte bit;        // bit mask
147
             int crc = 0xFF; // calculated checksum
147
             int crc = 0xFF; // calculated checksum
148
             byte byteCtr;    // byte counter
148
             byte byteCtr;    // byte counter
149
-            byte index = 1;
149
+            byte index = (int)Bluecell_ProtIndex_p.Bluecell_Type;
150
             // calculates 8-Bit checksum with given polynomial
150
             // calculates 8-Bit checksum with given polynomial
151
             for (byteCtr = 0; byteCtr < nbrOfBytes; byteCtr++)
151
             for (byteCtr = 0; byteCtr < nbrOfBytes; byteCtr++)
152
             {
152
             {

+ 36 - 12
Basic_Terminal/Func/Data_Handler.cs

@@ -17,7 +17,7 @@ namespace Basic_Terminal
17
         const byte Terminal_BootStart = 0x0B;
17
         const byte Terminal_BootStart = 0x0B;
18
 
18
 
19
 
19
 
20
-        private Boolean HeaderCheck(byte[] data)
20
+        public Boolean HeaderCheck(byte[] data)
21
         {
21
         {
22
             Boolean ret = false;
22
             Boolean ret = false;
23
 
23
 
@@ -27,9 +27,9 @@ namespace Basic_Terminal
27
             }
27
             }
28
             return ret;
28
             return ret;
29
         }
29
         }
30
-        private byte CrcCheck(byte[] data)
30
+        public bool CrcCheck(byte[] data)
31
         {
31
         {
32
-            byte ret = 0;
32
+            bool ret = false;
33
             Crc16 crc = new Crc16();
33
             Crc16 crc = new Crc16();
34
             byte length,crcindex;
34
             byte length,crcindex;
35
             try
35
             try
@@ -41,15 +41,25 @@ namespace Basic_Terminal
41
                 return ret;
41
                 return ret;
42
             }
42
             }
43
             crcindex = (byte)(length + 1);
43
             crcindex = (byte)(length + 1);
44
+            try
45
+            {
44
             ret = crc.STH30_CheckCrc(data,length,data[crcindex]);
46
             ret = crc.STH30_CheckCrc(data,length,data[crcindex]);
45
-
46
-
47
+            }
48
+            catch(Exception e)
49
+            {
50
+                return ret;
51
+            }
47
             return ret;
52
             return ret;
48
         }
53
         }
49
-        public void Recv_dataCheck(object fileDownload, byte[] data)
54
+        Serial serial;
55
+        Main_Form main_Form; //= new Main_Form();
56
+        public void Recv_dataCheck(object serial,object main_form, object fileDownload, byte[] data)
50
         {
57
         {
51
-            Boolean Header_Check;
52
-            byte Crc_Check, seq;
58
+            Boolean DataCheck;
59
+            Bluecell_BootProtocol bluecell_BootProtocol = new Bluecell_BootProtocol();
60
+            this.serial = (Serial)serial;
61
+            this.main_Form = (Main_Form)main_form;
62
+            byte seq;
53
             try
63
             try
54
             {
64
             {
55
                 seq = data[1];
65
                 seq = data[1];
@@ -67,13 +77,13 @@ namespace Basic_Terminal
67
             }
77
             }
68
             if (this.fileDownload.Update_ready == true)
78
             if (this.fileDownload.Update_ready == true)
69
             {
79
             {
70
-                Header_Check = HeaderCheck(data);
71
-                if (Header_Check == false)
80
+                DataCheck = HeaderCheck(data);
81
+                if (DataCheck == false)
72
                 {
82
                 {
73
                     return;
83
                     return;
74
                 }
84
                 }
75
-                Crc_Check = CrcCheck(data);
76
-                if(Crc_Check == 0)
85
+                DataCheck = CrcCheck(data);
86
+                if(DataCheck == false)
77
                 {
87
                 {
78
                     return;
88
                     return;
79
                 }
89
                 }
@@ -96,6 +106,20 @@ namespace Basic_Terminal
96
                 }
106
                 }
97
                 
107
                 
98
             }
108
             }
109
+            else/* * * * * * * * * * * * * *API RECV 부분 * * * * * * * * * * * * *  */
110
+            {
111
+                DataCheck = HeaderCheck(data);
112
+                if (DataCheck == false)
113
+                {
114
+                    return;
115
+                }
116
+                DataCheck = CrcCheck(data);
117
+                if (DataCheck == false)
118
+                {
119
+                    return;
120
+                }
121
+                //bluecell_BootProtocol.Bluecell_RF_Status_Get(this.serial,this.main_Form, data);
122
+            }
99
         }
123
         }
100
     }
124
     }
101
 }
125
 }

+ 0 - 146
Basic_Terminal/Func/FileDownload.cs

@@ -1,146 +0,0 @@
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
-}

+ 55 - 14
Basic_Terminal/Func/Serial.cs

@@ -13,12 +13,13 @@ namespace Basic_Terminal
13
 {
13
 {
14
     class Serial
14
     class Serial
15
     {
15
     {
16
+        Main_Form main_form;
16
         private System.IO.Ports.SerialPort serialPort;
17
         private System.IO.Ports.SerialPort serialPort;
17
         private Debug Debug = new Debug();    // Teminal Text Wnd Open
18
         private Debug Debug = new Debug();    // Teminal Text Wnd Open
18
         public string Serial_Name { get => serialPort.PortName;  set => serialPort.PortName = value;}
19
         public string Serial_Name { get => serialPort.PortName;  set => serialPort.PortName = value;}
19
         Data_Handler data_Handler = new Data_Handler();
20
         Data_Handler data_Handler = new Data_Handler();
20
         //FileDownload fileDownload;
21
         //FileDownload fileDownload;
21
-        Update_Serial fileDownload;
22
+        Update_Serial fileDownload = null;
22
 
23
 
23
         public void SetPortNameValues(object obj)
24
         public void SetPortNameValues(object obj)
24
         {
25
         {
@@ -45,6 +46,10 @@ namespace Basic_Terminal
45
                 ((ComboBox)obj).Text = " "; //if there are no com ports ,write Empty
46
                 ((ComboBox)obj).Text = " "; //if there are no com ports ,write Empty
46
             }
47
             }
47
         }
48
         }
49
+        public void Serial_Port_name_Set(ref ComboBox cb_port)
50
+        {
51
+            serialPort.PortName = Serial_Name = cb_port.SelectedItem.ToString();
52
+        }
48
         public void Serial_Initialize(ref ComboBox cb_port)
53
         public void Serial_Initialize(ref ComboBox cb_port)
49
         {
54
         {
50
             
55
             
@@ -101,38 +106,54 @@ namespace Basic_Terminal
101
             return arr_byteStr;
106
             return arr_byteStr;
102
 #endif
107
 #endif
103
         }
108
         }
104
-       
109
+        private delegate void BoolSet();
105
         public void Serial_DataRecvFunction(object sender, SerialDataReceivedEventArgs e)
110
         public void Serial_DataRecvFunction(object sender, SerialDataReceivedEventArgs e)
106
         {
111
         {
112
+            string tmpSTR = "";
113
+            Data_Handler data_Handler = new Data_Handler();
114
+            int nLnegth = serialPort.BytesToRead;
115
+            byte[] btdata = new byte[nLnegth];
116
+            serialPort.Read(btdata, 0, nLnegth);
117
+            main_form.Invoke(new BoolSet(main_form.RX_Light_ON));
118
+            main_form.TX_RX_Light = true;
107
             if (this.Debug.Created && Debug.RadioButton_ascii.Checked == true)
119
             if (this.Debug.Created && Debug.RadioButton_ascii.Checked == true)
108
             {
120
             {
109
-                string data = serialPort.ReadExisting();
110
-                if (Debug.Created)
121
+                string data = Encoding.Default.GetString(btdata);
122
+                // string data = serialPort.ReadExisting();
123
+
111
                     if (Debug.RadioButton_ascii.Checked == true)
124
                     if (Debug.RadioButton_ascii.Checked == true)
112
                         Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
125
                         Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
113
                     else
126
                     else
114
                         Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(data, true));
127
                         Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(data, true));
115
 
128
 
116
-                data_Handler.Recv_dataCheck(this.fileDownload, Str2bytes(data));
129
+                data_Handler.Recv_dataCheck(this,this.main_form,this.fileDownload, btdata);
117
             }
130
             }
118
             else
131
             else
119
             {
132
             {
120
                 // 리스트 두개 사용
133
                 // 리스트 두개 사용
121
-                int nLnegth = serialPort.BytesToRead;
122
-                byte[] btdata = new byte[nLnegth];
123
-                serialPort.Read(btdata, 0, nLnegth);
124
 
134
 
125
                 if (nLnegth > 0)
135
                 if (nLnegth > 0)
126
                 {
136
                 {
127
                     if (this.Debug.Created)
137
                     if (this.Debug.Created)
128
                     {
138
                     {
129
-                        string tmpSTR = Encoding.Default.GetString(btdata).TrimEnd('\0');
139
+                        if (this.Debug.radioButton_ascii.Checked == true)
140
+                        {
141
+                            tmpSTR = Encoding.Default.GetString(btdata).TrimEnd('\0');
130
                         Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(tmpSTR, true));
142
                         Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(tmpSTR, true));
143
+                        }
144
+                        else
145
+                        {
146
+                            Debug.Invoke(new ByteSend(Debug.Data_Recv_Hex), btdata);
147
+                        }
148
+                    }
149
+                    else
150
+                    {
151
+                        if (this.Debug.Created)
152
+                            Debug.Invoke(new ByteSend(Debug.Data_Recv_Hex), btdata);
131
                     }
153
                     }
132
-                    data_Handler.Recv_dataCheck(this.fileDownload, btdata);
133
-                   
134
                     // 이부분에서 데이타 처리하는 부분으로 전송하여 사용하면 됨
154
                     // 이부분에서 데이타 처리하는 부분으로 전송하여 사용하면 됨
135
                 }
155
                 }
156
+                data_Handler.Recv_dataCheck(this, this.main_form,this.fileDownload, btdata);
136
             }
157
             }
137
             /****
158
             /****
138
              *메모리 누수 방지용 코드
159
              *메모리 누수 방지용 코드
@@ -154,8 +175,11 @@ namespace Basic_Terminal
154
                 {
175
                 {
155
                     if (cb.Text != "")
176
                     if (cb.Text != "")
156
                     {
177
                     {
178
+                        //this.main_form.Invoke(new BoolSet(this.main_form.Serial_PortName_get));
179
+                        serialPort.PortName = cb.Text;
157
                         serialPort.Open();
180
                         serialPort.Open();
158
                         Btn_Portonoff.Text = "Port Close";
181
                         Btn_Portonoff.Text = "Port Close";
182
+                        Debug.Debug_Main_Form_Get(this.main_form);
159
                     }
183
                     }
160
                     else
184
                     else
161
                     {
185
                     {
@@ -189,6 +213,8 @@ namespace Basic_Terminal
189
             try
213
             try
190
             {
214
             {
191
                 serialPort.Write(data,0,data.Length);
215
                 serialPort.Write(data,0,data.Length);
216
+                main_form.pictureBox_R_TX.Visible = false;
217
+                main_form.pictureBox_G_TX.Visible = true;
192
             }
218
             }
193
             catch (System.Exception ex)
219
             catch (System.Exception ex)
194
             {
220
             {
@@ -197,14 +223,25 @@ namespace Basic_Terminal
197
         }
223
         }
198
         public void Serial_DataSend(byte[] buffer, int count)
224
         public void Serial_DataSend(byte[] buffer, int count)
199
         {
225
         {
200
-            try { serialPort.Write(buffer, 0, count); }
201
-            catch { MessageBox.Show("Port Open Failed!!!"); }
226
+            try {
227
+                serialPort.Write(buffer, 0, count);
228
+                main_form.Invoke(new BoolSet(main_form.TX_Light_ON));
229
+                main_form.TX_RX_Light = true;
230
+            }
231
+            catch
232
+            {
233
+                MessageBox.Show("Port Open Failed!!!");
234
+            }
202
         }
235
         }
203
-        public void FileDownloadClass_Get(object filedownload)
236
+        public void FileDownloadClass_Set(object filedownload)
204
         {
237
         {
205
             //this.fileDownload = (FileDownload)filedownload;
238
             //this.fileDownload = (FileDownload)filedownload;
206
             this.fileDownload = (Update_Serial)filedownload;
239
             this.fileDownload = (Update_Serial)filedownload;
207
         }
240
         }
241
+        public object FileDownloadClass_Get()
242
+        {
243
+            return this.fileDownload;
244
+        }
208
         public void Test_Serial()
245
         public void Test_Serial()
209
         {
246
         {
210
             byte[] tempdata = new byte[1024];
247
             byte[] tempdata = new byte[1024];
@@ -229,5 +266,9 @@ namespace Basic_Terminal
229
             if (this.Debug.Created)
266
             if (this.Debug.Created)
230
                 this.Debug.ascii_to_hex_radiobuttonConvert();
267
                 this.Debug.ascii_to_hex_radiobuttonConvert();
231
         }
268
         }
269
+        public void Serial_Main_Form_Get(object frm)
270
+        {
271
+            this.main_form = (Main_Form)frm;
272
+        }
232
     }
273
     }
233
 }
274
 }

+ 9 - 5
Basic_Terminal/Func/Update_Serial.cs

@@ -80,7 +80,7 @@ namespace Basic_Terminal
80
                 // label2.Text = "Full Name  : " + fileFullName;
80
                 // label2.Text = "Full Name  : " + fileFullName;
81
                 // label3.Text = "File Path  : " + filePath;`
81
                 // label3.Text = "File Path  : " + filePath;`
82
                 //File경로 + 파일명 리턴
82
                 //File경로 + 파일명 리턴
83
-                this.serial.FileDownloadClass_Get(this);
83
+                this.serial.FileDownloadClass_Set(this);
84
                 Data_Request_Func = 1;
84
                 Data_Request_Func = 1;
85
 
85
 
86
                 Firmware_byte_load = File.ReadAllBytes(this.ofd.FileName);
86
                 Firmware_byte_load = File.ReadAllBytes(this.ofd.FileName);
@@ -90,13 +90,15 @@ namespace Basic_Terminal
90
                 PreFirmSendingcnt = 0;
90
                 PreFirmSendingcnt = 0;
91
                 FirmSendingcnt = 0;
91
                 FirmSendingcnt = 0;
92
                 Update_ready = true;
92
                 Update_ready = true;
93
+                Bluecell_BootProtocol.Bluecell_Reset(this.serial);
94
+            /*    
93
                 tempdata[0] = 0xbe;
95
                 tempdata[0] = 0xbe;
94
                 tempdata[1] = Termianl_Reset;
96
                 tempdata[1] = Termianl_Reset;
95
                 tempdata[2] = 0x02;
97
                 tempdata[2] = 0x02;
96
                 tempdata[3] = STH30_CreateCrc(tempdata, tempdata[2]);
98
                 tempdata[3] = STH30_CreateCrc(tempdata, tempdata[2]);
97
                 tempdata[4] = 0xeb;
99
                 tempdata[4] = 0xeb;
98
                
100
                
99
-                this.serial.Serial_DataSend(tempdata, 5);
101
+                this.serial.Serial_DataSend(tempdata, 5);*/
100
                 try
102
                 try
101
                 {
103
                 {
102
                    // Controller_Debug.Controller_TX_TextLoad(tempdata);
104
                    // Controller_Debug.Controller_TX_TextLoad(tempdata);
@@ -115,7 +117,7 @@ namespace Basic_Terminal
115
 
117
 
116
             return "";
118
             return "";
117
         }
119
         }
118
-
120
+        private int Current_step = 0;
119
         public void FirmwareUpdateCheck(byte check)
121
         public void FirmwareUpdateCheck(byte check)
120
         {
122
         {
121
 
123
 
@@ -146,6 +148,7 @@ namespace Basic_Terminal
146
                 }
148
                 }
147
                 else
149
                 else
148
                 {
150
                 {
151
+                    Current_step = 0;
149
                     Update_ready = false;
152
                     Update_ready = false;
150
                     temp_data[1] = 0xEE;
153
                     temp_data[1] = 0xEE;
151
                     temp_data[2] = Convert.ToByte(lastlen + 2);
154
                     temp_data[2] = Convert.ToByte(lastlen + 2);
@@ -209,9 +212,10 @@ namespace Basic_Terminal
209
             if (pretempupdateret != tempupdateret)
212
             if (pretempupdateret != tempupdateret)
210
             {
213
             {
211
 
214
 
212
-                for (int i = 0; i <= tempupdateret - this.download_Bar.Update_get(); i++)
215
+                for(int i = Current_step; i < tempupdateret; i++)
213
                 {
216
                 {
214
                     this.download_Bar.PerformStepup(this.download_Bar);
217
                     this.download_Bar.PerformStepup(this.download_Bar);
218
+                    Current_step++;
215
                     //this.download_Bar.PerformStepinc(tempupdateret);
219
                     //this.download_Bar.PerformStepinc(tempupdateret);
216
                     // progressBar1.PerformStep();
220
                     // progressBar1.PerformStep();
217
                 }
221
                 }
@@ -231,7 +235,7 @@ namespace Basic_Terminal
231
         public void Termianl__Operate(byte[] Text)
235
         public void Termianl__Operate(byte[] Text)
232
         {
236
         {
233
             byte Type = 0;
237
             byte Type = 0;
234
-            Type = Text[Bluecell_BootProtocol.bluecell_type];
238
+            Type = Text[(int)Bluecell_ProtIndex_p.Bluecell_Type];
235
             switch (Type)
239
             switch (Type)
236
             {
240
             {
237
                
241
                

+ 25 - 0
Basic_Terminal/MetroFramework.txt

@@ -0,0 +1,25 @@
1
+MetroFramework - Modern UI for WinForms
2
+
3
+Copyright (c) 2013 Jens Thiel, http://thielj.github.io/MetroFramework
4
+
5
+Permission is hereby granted, free of charge, to any person obtaining a copy of 
6
+this software and associated documentation files (the "Software"), to deal in the 
7
+Software without restriction, including without limitation the rights to use, copy, 
8
+modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
9
+and to permit persons to whom the Software is furnished to do so, subject to the 
10
+following conditions:
11
+
12
+The above copyright notice and this permission notice shall be included in 
13
+all copies or substantial portions of the Software.
14
+
15
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
16
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
17
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
18
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
19
+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
20
+OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+
23
+Portions of this software are:
24
+
25
+  Copyright (c) 2011 Sven Walter, http://github.com/viperneo

+ 60 - 28
Basic_Terminal/Properties/Resources.Designer.cs

@@ -8,64 +8,96 @@
8
 // </auto-generated>
8
 // </auto-generated>
9
 //------------------------------------------------------------------------------
9
 //------------------------------------------------------------------------------
10
 
10
 
11
-namespace Basic_Terminal.Properties
12
-{
13
-
14
-
11
+namespace Basic_Terminal.Properties {
12
+    using System;
13
+    
14
+    
15
     /// <summary>
15
     /// <summary>
16
     ///   지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다.
16
     ///   지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다.
17
     /// </summary>
17
     /// </summary>
18
     // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder
18
     // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder
19
     // 클래스에서 자동으로 생성되었습니다.
19
     // 클래스에서 자동으로 생성되었습니다.
20
-    // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여
21
-    // ResGen을 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오.
22
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
20
+    // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 ResGen을
21
+    // 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오.
22
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
23
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
24
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25
-    internal class Resources
26
-    {
27
-
25
+    internal class Resources {
26
+        
28
         private static global::System.Resources.ResourceManager resourceMan;
27
         private static global::System.Resources.ResourceManager resourceMan;
29
-
28
+        
30
         private static global::System.Globalization.CultureInfo resourceCulture;
29
         private static global::System.Globalization.CultureInfo resourceCulture;
31
-
30
+        
32
         [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
31
         [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33
-        internal Resources()
34
-        {
32
+        internal Resources() {
35
         }
33
         }
36
-
34
+        
37
         /// <summary>
35
         /// <summary>
38
         ///   이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다.
36
         ///   이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다.
39
         /// </summary>
37
         /// </summary>
40
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
38
         [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
-                {
39
+        internal static global::System.Resources.ResourceManager ResourceManager {
40
+            get {
41
+                if (object.ReferenceEquals(resourceMan, null)) {
47
                     global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Basic_Terminal.Properties.Resources", typeof(Resources).Assembly);
42
                     global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Basic_Terminal.Properties.Resources", typeof(Resources).Assembly);
48
                     resourceMan = temp;
43
                     resourceMan = temp;
49
                 }
44
                 }
50
                 return resourceMan;
45
                 return resourceMan;
51
             }
46
             }
52
         }
47
         }
53
-
48
+        
54
         /// <summary>
49
         /// <summary>
55
         ///   이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을
50
         ///   이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을
56
         ///   재정의합니다.
51
         ///   재정의합니다.
57
         /// </summary>
52
         /// </summary>
58
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
53
         [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59
-        internal static global::System.Globalization.CultureInfo Culture
60
-        {
61
-            get
62
-            {
54
+        internal static global::System.Globalization.CultureInfo Culture {
55
+            get {
63
                 return resourceCulture;
56
                 return resourceCulture;
64
             }
57
             }
65
-            set
66
-            {
58
+            set {
67
                 resourceCulture = value;
59
                 resourceCulture = value;
68
             }
60
             }
69
         }
61
         }
62
+        
63
+        /// <summary>
64
+        ///   System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다.
65
+        /// </summary>
66
+        internal static System.Drawing.Bitmap RX_GREEN_IMAGE {
67
+            get {
68
+                object obj = ResourceManager.GetObject("RX_GREEN_IMAGE", resourceCulture);
69
+                return ((System.Drawing.Bitmap)(obj));
70
+            }
71
+        }
72
+        
73
+        /// <summary>
74
+        ///   System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다.
75
+        /// </summary>
76
+        internal static System.Drawing.Bitmap RX_IMAGE {
77
+            get {
78
+                object obj = ResourceManager.GetObject("RX_IMAGE", resourceCulture);
79
+                return ((System.Drawing.Bitmap)(obj));
80
+            }
81
+        }
82
+        
83
+        /// <summary>
84
+        ///   System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다.
85
+        /// </summary>
86
+        internal static System.Drawing.Bitmap TX_IMAGE {
87
+            get {
88
+                object obj = ResourceManager.GetObject("TX_IMAGE", resourceCulture);
89
+                return ((System.Drawing.Bitmap)(obj));
90
+            }
91
+        }
92
+        
93
+        /// <summary>
94
+        ///   System.Drawing.Bitmap 형식의 지역화된 리소스를 찾습니다.
95
+        /// </summary>
96
+        internal static System.Drawing.Bitmap TX_Red_Image {
97
+            get {
98
+                object obj = ResourceManager.GetObject("TX_Red_Image", resourceCulture);
99
+                return ((System.Drawing.Bitmap)(obj));
100
+            }
101
+        }
70
     }
102
     }
71
 }
103
 }

+ 21 - 5
Basic_Terminal/Properties/Resources.resx

@@ -46,7 +46,7 @@
46
     
46
     
47
     mimetype: application/x-microsoft.net.object.binary.base64
47
     mimetype: application/x-microsoft.net.object.binary.base64
48
     value   : The object must be serialized with 
48
     value   : The object must be serialized with 
49
-            : System.Serialization.Formatters.Binary.BinaryFormatter
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
             : and then encoded with base64 encoding.
50
             : and then encoded with base64 encoding.
51
     
51
     
52
     mimetype: application/x-microsoft.net.object.soap.base64
52
     mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
60
             : and then encoded with base64 encoding.
60
             : and then encoded with base64 encoding.
61
     -->
61
     -->
62
   <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
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" />
63
     <xsd:element name="root" msdata:IsDataSet="true">
64
     <xsd:element name="root" msdata:IsDataSet="true">
64
       <xsd:complexType>
65
       <xsd:complexType>
65
         <xsd:choice maxOccurs="unbounded">
66
         <xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
68
               <xsd:sequence>
69
               <xsd:sequence>
69
                 <xsd:element name="value" type="xsd:string" minOccurs="0" />
70
                 <xsd:element name="value" type="xsd:string" minOccurs="0" />
70
               </xsd:sequence>
71
               </xsd:sequence>
71
-              <xsd:attribute name="name" type="xsd:string" />
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
72
               <xsd:attribute name="type" type="xsd:string" />
73
               <xsd:attribute name="type" type="xsd:string" />
73
               <xsd:attribute name="mimetype" type="xsd:string" />
74
               <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
74
             </xsd:complexType>
76
             </xsd:complexType>
75
           </xsd:element>
77
           </xsd:element>
76
           <xsd:element name="assembly">
78
           <xsd:element name="assembly">
@@ -85,9 +87,10 @@
85
                 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
87
                 <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" />
88
                 <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
87
               </xsd:sequence>
89
               </xsd:sequence>
88
-              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
89
               <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
91
               <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
90
               <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
92
               <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
91
             </xsd:complexType>
94
             </xsd:complexType>
92
           </xsd:element>
95
           </xsd:element>
93
           <xsd:element name="resheader">
96
           <xsd:element name="resheader">
@@ -109,9 +112,22 @@
109
     <value>2.0</value>
112
     <value>2.0</value>
110
   </resheader>
113
   </resheader>
111
   <resheader name="reader">
114
   <resheader name="reader">
112
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
113
   </resheader>
116
   </resheader>
114
   <resheader name="writer">
117
   <resheader name="writer">
115
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
   </resheader>
119
   </resheader>
120
+  <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
121
+  <data name="TX_Red_Image" type="System.Resources.ResXFileRef, System.Windows.Forms">
122
+    <value>..\Resources\TX_Red_Image.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
123
+  </data>
124
+  <data name="TX_IMAGE" type="System.Resources.ResXFileRef, System.Windows.Forms">
125
+    <value>..\Resources\TX_IMAGE.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
126
+  </data>
127
+  <data name="RX_IMAGE" type="System.Resources.ResXFileRef, System.Windows.Forms">
128
+    <value>..\Resources\RX_IMAGE.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
129
+  </data>
130
+  <data name="RX_GREEN_IMAGE" type="System.Resources.ResXFileRef, System.Windows.Forms">
131
+    <value>..\Resources\RX_GREEN_IMAGE.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
132
+  </data>
117
 </root>
133
 </root>

BIN
Basic_Terminal/Resources/RX_GREEN_IMAGE.png


BIN
Basic_Terminal/Resources/RX_IMAGE.png


BIN
Basic_Terminal/Resources/TX_IMAGE.png


BIN
Basic_Terminal/Resources/TX_Red_Image.png


+ 81 - 15
Basic_Terminal/Wnd/Main_Form.Designer.cs

@@ -28,6 +28,7 @@
28
         /// </summary>
28
         /// </summary>
29
         private void InitializeComponent()
29
         private void InitializeComponent()
30
         {
30
         {
31
+            this.components = new System.ComponentModel.Container();
31
             this.groupBox9 = new System.Windows.Forms.GroupBox();
32
             this.groupBox9 = new System.Windows.Forms.GroupBox();
32
             this.button3 = new System.Windows.Forms.Button();
33
             this.button3 = new System.Windows.Forms.Button();
33
             this.button_terminal = new System.Windows.Forms.Button();
34
             this.button_terminal = new System.Windows.Forms.Button();
@@ -39,14 +40,22 @@
39
             this.comboBox_baudrate = new System.Windows.Forms.ComboBox();
40
             this.comboBox_baudrate = new System.Windows.Forms.ComboBox();
40
             this.Crc16_Check = new System.Windows.Forms.Button();
41
             this.Crc16_Check = new System.Windows.Forms.Button();
41
             this.label1 = new System.Windows.Forms.Label();
42
             this.label1 = new System.Windows.Forms.Label();
43
+            this.groupBox12 = new System.Windows.Forms.GroupBox();
44
+            this.pictureBox_R_TX = new System.Windows.Forms.PictureBox();
45
+            this.pictureBox_G_TX = new System.Windows.Forms.PictureBox();
46
+            this.pictureBox_R_RX = new System.Windows.Forms.PictureBox();
47
+            this.pictureBox_G_RX = new System.Windows.Forms.PictureBox();
48
+            this.timer = new System.Windows.Forms.Timer(this.components);
42
             this.groupBox9.SuspendLayout();
49
             this.groupBox9.SuspendLayout();
50
+            this.groupBox12.SuspendLayout();
51
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_R_TX)).BeginInit();
52
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_G_TX)).BeginInit();
53
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_R_RX)).BeginInit();
54
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_G_RX)).BeginInit();
43
             this.SuspendLayout();
55
             this.SuspendLayout();
44
             // 
56
             // 
45
             // groupBox9
57
             // groupBox9
46
             // 
58
             // 
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);
59
             this.groupBox9.Controls.Add(this.button3);
51
             this.groupBox9.Controls.Add(this.button_terminal);
60
             this.groupBox9.Controls.Add(this.button_terminal);
52
             this.groupBox9.Controls.Add(this.Ascii_checkBox);
61
             this.groupBox9.Controls.Add(this.Ascii_checkBox);
@@ -55,7 +64,7 @@
55
             this.groupBox9.Controls.Add(this.comboBox_Port);
64
             this.groupBox9.Controls.Add(this.comboBox_Port);
56
             this.groupBox9.Controls.Add(this.cmBaudRate);
65
             this.groupBox9.Controls.Add(this.cmBaudRate);
57
             this.groupBox9.Controls.Add(this.comboBox_baudrate);
66
             this.groupBox9.Controls.Add(this.comboBox_baudrate);
58
-            this.groupBox9.Location = new System.Drawing.Point(12, 23);
67
+            this.groupBox9.Location = new System.Drawing.Point(12, 83);
59
             this.groupBox9.Name = "groupBox9";
68
             this.groupBox9.Name = "groupBox9";
60
             this.groupBox9.Size = new System.Drawing.Size(225, 223);
69
             this.groupBox9.Size = new System.Drawing.Size(225, 223);
61
             this.groupBox9.TabIndex = 82;
70
             this.groupBox9.TabIndex = 82;
@@ -109,9 +118,6 @@
109
             // 
118
             // 
110
             // button_PortOpen
119
             // button_PortOpen
111
             // 
120
             // 
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);
121
             this.button_PortOpen.Location = new System.Drawing.Point(13, 91);
116
             this.button_PortOpen.Name = "button_PortOpen";
122
             this.button_PortOpen.Name = "button_PortOpen";
117
             this.button_PortOpen.Size = new System.Drawing.Size(197, 34);
123
             this.button_PortOpen.Size = new System.Drawing.Size(197, 34);
@@ -122,9 +128,6 @@
122
             // 
128
             // 
123
             // comboBox_Port
129
             // comboBox_Port
124
             // 
130
             // 
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;
131
             this.comboBox_Port.Cursor = System.Windows.Forms.Cursors.Default;
129
             this.comboBox_Port.FormattingEnabled = true;
132
             this.comboBox_Port.FormattingEnabled = true;
130
             this.comboBox_Port.Location = new System.Drawing.Point(109, 15);
133
             this.comboBox_Port.Location = new System.Drawing.Point(109, 15);
@@ -148,9 +151,6 @@
148
             // 
151
             // 
149
             // comboBox_baudrate
152
             // comboBox_baudrate
150
             // 
153
             // 
151
-            this.comboBox_baudrate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
152
-            | System.Windows.Forms.AnchorStyles.Left) 
153
-            | System.Windows.Forms.AnchorStyles.Right)));
154
             this.comboBox_baudrate.FormattingEnabled = true;
154
             this.comboBox_baudrate.FormattingEnabled = true;
155
             this.comboBox_baudrate.Items.AddRange(new object[] {
155
             this.comboBox_baudrate.Items.AddRange(new object[] {
156
             "9600",
156
             "9600",
@@ -168,7 +168,7 @@
168
             // 
168
             // 
169
             // Crc16_Check
169
             // Crc16_Check
170
             // 
170
             // 
171
-            this.Crc16_Check.Location = new System.Drawing.Point(12, 285);
171
+            this.Crc16_Check.Location = new System.Drawing.Point(12, 345);
172
             this.Crc16_Check.Name = "Crc16_Check";
172
             this.Crc16_Check.Name = "Crc16_Check";
173
             this.Crc16_Check.Size = new System.Drawing.Size(96, 23);
173
             this.Crc16_Check.Size = new System.Drawing.Size(96, 23);
174
             this.Crc16_Check.TabIndex = 83;
174
             this.Crc16_Check.TabIndex = 83;
@@ -179,17 +179,72 @@
179
             // label1
179
             // label1
180
             // 
180
             // 
181
             this.label1.AutoSize = true;
181
             this.label1.AutoSize = true;
182
-            this.label1.Location = new System.Drawing.Point(127, 290);
182
+            this.label1.Location = new System.Drawing.Point(127, 350);
183
             this.label1.Name = "label1";
183
             this.label1.Name = "label1";
184
             this.label1.Size = new System.Drawing.Size(110, 12);
184
             this.label1.Size = new System.Drawing.Size(110, 12);
185
             this.label1.TabIndex = 84;
185
             this.label1.TabIndex = 84;
186
             this.label1.Text = "Check Sum Result";
186
             this.label1.Text = "Check Sum Result";
187
             // 
187
             // 
188
+            // groupBox12
189
+            // 
190
+            this.groupBox12.Controls.Add(this.pictureBox_R_TX);
191
+            this.groupBox12.Controls.Add(this.pictureBox_G_TX);
192
+            this.groupBox12.Controls.Add(this.pictureBox_R_RX);
193
+            this.groupBox12.Controls.Add(this.pictureBox_G_RX);
194
+            this.groupBox12.Location = new System.Drawing.Point(12, 11);
195
+            this.groupBox12.Name = "groupBox12";
196
+            this.groupBox12.Size = new System.Drawing.Size(225, 66);
197
+            this.groupBox12.TabIndex = 104;
198
+            this.groupBox12.TabStop = false;
199
+            this.groupBox12.Text = "DATA Status";
200
+            // 
201
+            // pictureBox_R_TX
202
+            // 
203
+            this.pictureBox_R_TX.Image = global::Basic_Terminal.Properties.Resources.TX_Red_Image;
204
+            this.pictureBox_R_TX.Location = new System.Drawing.Point(31, 20);
205
+            this.pictureBox_R_TX.Name = "pictureBox_R_TX";
206
+            this.pictureBox_R_TX.Size = new System.Drawing.Size(38, 36);
207
+            this.pictureBox_R_TX.TabIndex = 97;
208
+            this.pictureBox_R_TX.TabStop = false;
209
+            // 
210
+            // pictureBox_G_TX
211
+            // 
212
+            this.pictureBox_G_TX.Image = global::Basic_Terminal.Properties.Resources.TX_IMAGE;
213
+            this.pictureBox_G_TX.Location = new System.Drawing.Point(31, 20);
214
+            this.pictureBox_G_TX.Name = "pictureBox_G_TX";
215
+            this.pictureBox_G_TX.Size = new System.Drawing.Size(38, 36);
216
+            this.pictureBox_G_TX.TabIndex = 96;
217
+            this.pictureBox_G_TX.TabStop = false;
218
+            // 
219
+            // pictureBox_R_RX
220
+            // 
221
+            this.pictureBox_R_RX.Image = global::Basic_Terminal.Properties.Resources.RX_IMAGE;
222
+            this.pictureBox_R_RX.Location = new System.Drawing.Point(157, 20);
223
+            this.pictureBox_R_RX.Name = "pictureBox_R_RX";
224
+            this.pictureBox_R_RX.Size = new System.Drawing.Size(38, 36);
225
+            this.pictureBox_R_RX.TabIndex = 96;
226
+            this.pictureBox_R_RX.TabStop = false;
227
+            // 
228
+            // pictureBox_G_RX
229
+            // 
230
+            this.pictureBox_G_RX.Image = global::Basic_Terminal.Properties.Resources.RX_GREEN_IMAGE;
231
+            this.pictureBox_G_RX.Location = new System.Drawing.Point(157, 20);
232
+            this.pictureBox_G_RX.Name = "pictureBox_G_RX";
233
+            this.pictureBox_G_RX.Size = new System.Drawing.Size(38, 36);
234
+            this.pictureBox_G_RX.TabIndex = 98;
235
+            this.pictureBox_G_RX.TabStop = false;
236
+            // 
237
+            // timer
238
+            // 
239
+            this.timer.Interval = 500;
240
+            this.timer.Tick += new System.EventHandler(this.timer_Tick);
241
+            // 
188
             // Main_Form
242
             // Main_Form
189
             // 
243
             // 
190
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
244
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
191
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
245
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
192
             this.ClientSize = new System.Drawing.Size(800, 450);
246
             this.ClientSize = new System.Drawing.Size(800, 450);
247
+            this.Controls.Add(this.groupBox12);
193
             this.Controls.Add(this.label1);
248
             this.Controls.Add(this.label1);
194
             this.Controls.Add(this.Crc16_Check);
249
             this.Controls.Add(this.Crc16_Check);
195
             this.Controls.Add(this.groupBox9);
250
             this.Controls.Add(this.groupBox9);
@@ -197,6 +252,11 @@
197
             this.Text = "Terminal";
252
             this.Text = "Terminal";
198
             this.groupBox9.ResumeLayout(false);
253
             this.groupBox9.ResumeLayout(false);
199
             this.groupBox9.PerformLayout();
254
             this.groupBox9.PerformLayout();
255
+            this.groupBox12.ResumeLayout(false);
256
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_R_TX)).EndInit();
257
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_G_TX)).EndInit();
258
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_R_RX)).EndInit();
259
+            ((System.ComponentModel.ISupportInitialize)(this.pictureBox_G_RX)).EndInit();
200
             this.ResumeLayout(false);
260
             this.ResumeLayout(false);
201
             this.PerformLayout();
261
             this.PerformLayout();
202
 
262
 
@@ -215,6 +275,12 @@
215
         private System.Windows.Forms.Button Crc16_Check;
275
         private System.Windows.Forms.Button Crc16_Check;
216
         private System.Windows.Forms.Label label1;
276
         private System.Windows.Forms.Label label1;
217
         public System.Windows.Forms.ComboBox comboBox_Port;
277
         public System.Windows.Forms.ComboBox comboBox_Port;
278
+        private System.Windows.Forms.GroupBox groupBox12;
279
+        public System.Windows.Forms.PictureBox pictureBox_R_TX;
280
+        public System.Windows.Forms.PictureBox pictureBox_G_TX;
281
+        public System.Windows.Forms.PictureBox pictureBox_R_RX;
282
+        public System.Windows.Forms.PictureBox pictureBox_G_RX;
283
+        public System.Windows.Forms.Timer timer;
218
     }
284
     }
219
 }
285
 }
220
 
286
 

+ 83 - 3
Basic_Terminal/Wnd/Main_Form.cs

@@ -17,7 +17,7 @@ namespace Basic_Terminal
17
     public partial class Main_Form : Form
17
     public partial class Main_Form : Form
18
     {
18
     {
19
         Serial serial = new Serial(); // Uart Open
19
         Serial serial = new Serial(); // Uart Open
20
-        
20
+        Bluecell_BootProtocol bluecell_BootProtocol = new Bluecell_BootProtocol();
21
         Update_Serial file = new Update_Serial();
21
         Update_Serial file = new Update_Serial();
22
         public Main_Form()
22
         public Main_Form()
23
         {
23
         {
@@ -45,7 +45,21 @@ namespace Basic_Terminal
45
 
45
 
46
         private void Button_PortOpen_Click(object sender, EventArgs e)
46
         private void Button_PortOpen_Click(object sender, EventArgs e)
47
         {
47
         {
48
-            Serial_connectiondisable(serial.Serial_PortOpen(ref button_PortOpen,ref comboBox_Port));
48
+            bool ret = false;
49
+            ret = Serial_connectiondisable(serial.Serial_PortOpen(ref button_PortOpen, ref comboBox_Port));
50
+            if (ret == false && timer.Enabled == false)
51
+            {
52
+                timer.Start(); //타이머를 발동시킨다.
53
+            }
54
+            else if (timer.Enabled == true)
55
+            {
56
+                timer.Stop(); //타이머를 멈춘다.
57
+            }
58
+            else
59
+            {
60
+                /*NOP*/
61
+            }
62
+            serial.Serial_Main_Form_Get(this);
49
         }
63
         }
50
 
64
 
51
         private void ComboBox_Port_SelectedIndexChanged(object sender, EventArgs e)
65
         private void ComboBox_Port_SelectedIndexChanged(object sender, EventArgs e)
@@ -58,15 +72,81 @@ namespace Basic_Terminal
58
         {
72
         {
59
             serial.Serial_TerminalOpen(serial);
73
             serial.Serial_TerminalOpen(serial);
60
         }
74
         }
61
-        public void Serial_connectiondisable(Boolean on_off)
75
+        public bool Serial_connectiondisable(Boolean on_off)
62
         {
76
         {
63
             comboBox_Port.Enabled = on_off;
77
             comboBox_Port.Enabled = on_off;
64
             comboBox_baudrate.Enabled = on_off;
78
             comboBox_baudrate.Enabled = on_off;
79
+
80
+            return on_off;
65
         }
81
         }
82
+        private delegate void BoolSet();
66
 
83
 
84
+        public void TX_Light_ON()
85
+        {
86
+            this.pictureBox_G_TX.Visible = true;
87
+            this.pictureBox_R_TX.Visible = false;
88
+        }
89
+        public void TX_Light_OFF()
90
+        {
91
+            this.pictureBox_R_TX.Visible = true;
92
+            this.pictureBox_G_TX.Visible = false;
93
+        }
94
+        public void RX_Light_ON()
95
+        {
96
+            this.pictureBox_G_RX.Visible = true;
97
+            this.pictureBox_R_RX.Visible = false;
98
+        }
99
+        public void RX_Light_OFF()
100
+        {
101
+            this.pictureBox_R_RX.Visible = true;
102
+            this.pictureBox_G_RX.Visible = false;
103
+        }
104
+        Int64 Timer_Cnt = 0;
105
+        Int32 ReqTimer_Cnt = 0;
106
+        public bool TX_RX_Light = false;
107
+        private void timer_Tick(object sender, EventArgs e)
108
+        {
109
+            Update_Serial update_Serial = null;
110
+            bool req_set = false;
111
+            if(update_Serial == null)
112
+            {
113
+                update_Serial = (Update_Serial)serial.FileDownloadClass_Get();
114
+                if (update_Serial == null)
115
+                    req_set = true;
116
+                else if(update_Serial.Update_ready == false)
117
+                    req_set = true;
118
+            }
119
+            if (req_set)
120
+            {
121
+                ReqTimer_Cnt++;
122
+            }
123
+            if (TX_RX_Light == true)
124
+            {
125
+                Timer_Cnt++;
126
+            }
127
+            if (Timer_Cnt < 1000)
128
+            {
129
+                if (this.pictureBox_G_TX.Visible == true)
130
+                {
131
+                    TX_Light_OFF();
132
+                }
133
+                if (this.pictureBox_G_RX.Visible == true)
134
+                {
135
+                    RX_Light_OFF();
136
+                }
137
+                Timer_Cnt = 0;
138
+                TX_RX_Light = false;
139
+            }
140
+          if(ReqTimer_Cnt > 6)
141
+            {
142
+               // bluecell_BootProtocol.Bluecell_RF_Status_Req(serial);
143
+                ReqTimer_Cnt = 0;
144
+            }
145
+        }
67
         private void comboBox_Port_MouseDown(object sender, MouseEventArgs e)
146
         private void comboBox_Port_MouseDown(object sender, MouseEventArgs e)
68
         {
147
         {
69
             serial.SetPortNameValues(comboBox_Port);
148
             serial.SetPortNameValues(comboBox_Port);
70
         }
149
         }
150
+
71
     }
151
     }
72
 }
152
 }

+ 3 - 0
Basic_Terminal/Wnd/Main_Form.resx

@@ -117,4 +117,7 @@
117
   <resheader name="writer">
117
   <resheader name="writer">
118
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
118
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
   </resheader>
119
   </resheader>
120
+  <metadata name="timer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121
+    <value>17, 17</value>
122
+  </metadata>
120
 </root>
123
 </root>

+ 7 - 0
Basic_Terminal/packages.config

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<packages>
3
+  <package id="MetroFramework" version="1.2.0.3" targetFramework="net472" />
4
+  <package id="MetroFramework.Design" version="1.2.0.3" targetFramework="net472" />
5
+  <package id="MetroFramework.Fonts" version="1.2.0.3" targetFramework="net472" />
6
+  <package id="MetroFramework.RunTime" version="1.2.0.3" targetFramework="net472" />
7
+</packages>