소스 검색

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

YJ 5 년 전
부모
커밋
96b71159e9

+ 27 - 1
Basic_Terminal/Basic_Terminal.csproj

@@ -33,6 +33,16 @@
33 33
     <WarningLevel>4</WarningLevel>
34 34
   </PropertyGroup>
35 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 46
     <Reference Include="System" />
37 47
     <Reference Include="System.Core" />
38 48
     <Reference Include="System.Xml.Linq" />
@@ -49,7 +59,6 @@
49 59
     <Compile Include="Func\Bluecell_BootProtocol.cs" />
50 60
     <Compile Include="Func\Crc16.cs" />
51 61
     <Compile Include="Func\Data_Handler.cs" />
52
-    <Compile Include="Func\FileDownload.cs" />
53 62
     <Compile Include="Func\Update_Serial.cs" />
54 63
     <Compile Include="Wnd\Debug.cs">
55 64
       <SubType>Form</SubType>
@@ -89,7 +98,9 @@
89 98
     <Compile Include="Properties\Resources.Designer.cs">
90 99
       <AutoGen>True</AutoGen>
91 100
       <DependentUpon>Resources.resx</DependentUpon>
101
+      <DesignTime>True</DesignTime>
92 102
     </Compile>
103
+    <None Include="packages.config" />
93 104
     <None Include="Properties\Settings.settings">
94 105
       <Generator>SettingsSingleFileGenerator</Generator>
95 106
       <LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -106,5 +117,20 @@
106 117
   <ItemGroup>
107 118
     <WCFMetadata Include="Connected Services\" />
108 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 135
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
110 136
 </Project>

+ 38 - 5
Basic_Terminal/Func/Bluecell_BootProtocol.cs

@@ -20,13 +20,28 @@ namespace Basic_Terminal
20 20
         bluecell_data,
21 21
 
22 22
     };
23
-    enum Updateseq
23
+    public enum Updateseq
24 24
     {
25 25
         Bluecell_Reset = 0,
26 26
         Bluecell_Firmupdate_start,
27 27
         Bluecell_Firmupdate_sending,
28 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 45
     class Bluecell_BootProtocol
31 46
     {
32 47
         Serial serial;
@@ -39,14 +54,31 @@ namespace Basic_Terminal
39 54
 
40 55
 
41 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 75
         public const byte bluecell_length    = 2;
45 76
         public const byte bluecell_updatecnt = 2;
46 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 82
         public int Bluecell_Firmupdate_sendlength() {
51 83
             return bluecell_Firmupdate_sendlength;
52 84
         }
@@ -112,5 +144,6 @@ namespace Basic_Terminal
112 144
             fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
113 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 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 126
             byte bit;        // bit mask
127 127
             int crc = 0xFF; // calculated checksum
@@ -138,15 +138,15 @@ namespace Basic_Terminal
138 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 144
         public byte STH30_CreateCrc(byte[] data, byte nbrOfBytes)
145 145
         {
146 146
             byte bit;        // bit mask
147 147
             int crc = 0xFF; // calculated checksum
148 148
             byte byteCtr;    // byte counter
149
-            byte index = 1;
149
+            byte index = (int)Bluecell_ProtIndex_p.Bluecell_Type;
150 150
             // calculates 8-Bit checksum with given polynomial
151 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 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 22
             Boolean ret = false;
23 23
 
@@ -27,9 +27,9 @@ namespace Basic_Terminal
27 27
             }
28 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 33
             Crc16 crc = new Crc16();
34 34
             byte length,crcindex;
35 35
             try
@@ -41,15 +41,25 @@ namespace Basic_Terminal
41 41
                 return ret;
42 42
             }
43 43
             crcindex = (byte)(length + 1);
44
+            try
45
+            {
44 46
             ret = crc.STH30_CheckCrc(data,length,data[crcindex]);
45
-
46
-
47
+            }
48
+            catch(Exception e)
49
+            {
50
+                return ret;
51
+            }
47 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 63
             try
54 64
             {
55 65
                 seq = data[1];
@@ -67,13 +77,13 @@ namespace Basic_Terminal
67 77
             }
68 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 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 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 14
     class Serial
15 15
     {
16
+        Main_Form main_form;
16 17
         private System.IO.Ports.SerialPort serialPort;
17 18
         private Debug Debug = new Debug();    // Teminal Text Wnd Open
18 19
         public string Serial_Name { get => serialPort.PortName;  set => serialPort.PortName = value;}
19 20
         Data_Handler data_Handler = new Data_Handler();
20 21
         //FileDownload fileDownload;
21
-        Update_Serial fileDownload;
22
+        Update_Serial fileDownload = null;
22 23
 
23 24
         public void SetPortNameValues(object obj)
24 25
         {
@@ -45,6 +46,10 @@ namespace Basic_Terminal
45 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 53
         public void Serial_Initialize(ref ComboBox cb_port)
49 54
         {
50 55
             
@@ -101,38 +106,54 @@ namespace Basic_Terminal
101 106
             return arr_byteStr;
102 107
 #endif
103 108
         }
104
-       
109
+        private delegate void BoolSet();
105 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 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 124
                     if (Debug.RadioButton_ascii.Checked == true)
112 125
                         Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
113 126
                     else
114 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 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 135
                 if (nLnegth > 0)
126 136
                 {
127 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 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 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 180
                         serialPort.Open();
158 181
                         Btn_Portonoff.Text = "Port Close";
182
+                        Debug.Debug_Main_Form_Get(this.main_form);
159 183
                     }
160 184
                     else
161 185
                     {
@@ -189,6 +213,8 @@ namespace Basic_Terminal
189 213
             try
190 214
             {
191 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 219
             catch (System.Exception ex)
194 220
             {
@@ -197,14 +223,25 @@ namespace Basic_Terminal
197 223
         }
198 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 238
             //this.fileDownload = (FileDownload)filedownload;
206 239
             this.fileDownload = (Update_Serial)filedownload;
207 240
         }
241
+        public object FileDownloadClass_Get()
242
+        {
243
+            return this.fileDownload;
244
+        }
208 245
         public void Test_Serial()
209 246
         {
210 247
             byte[] tempdata = new byte[1024];
@@ -229,5 +266,9 @@ namespace Basic_Terminal
229 266
             if (this.Debug.Created)
230 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 80
                 // label2.Text = "Full Name  : " + fileFullName;
81 81
                 // label3.Text = "File Path  : " + filePath;`
82 82
                 //File경로 + 파일명 리턴
83
-                this.serial.FileDownloadClass_Get(this);
83
+                this.serial.FileDownloadClass_Set(this);
84 84
                 Data_Request_Func = 1;
85 85
 
86 86
                 Firmware_byte_load = File.ReadAllBytes(this.ofd.FileName);
@@ -90,13 +90,15 @@ namespace Basic_Terminal
90 90
                 PreFirmSendingcnt = 0;
91 91
                 FirmSendingcnt = 0;
92 92
                 Update_ready = true;
93
+                Bluecell_BootProtocol.Bluecell_Reset(this.serial);
94
+            /*    
93 95
                 tempdata[0] = 0xbe;
94 96
                 tempdata[1] = Termianl_Reset;
95 97
                 tempdata[2] = 0x02;
96 98
                 tempdata[3] = STH30_CreateCrc(tempdata, tempdata[2]);
97 99
                 tempdata[4] = 0xeb;
98 100
                
99
-                this.serial.Serial_DataSend(tempdata, 5);
101
+                this.serial.Serial_DataSend(tempdata, 5);*/
100 102
                 try
101 103
                 {
102 104
                    // Controller_Debug.Controller_TX_TextLoad(tempdata);
@@ -115,7 +117,7 @@ namespace Basic_Terminal
115 117
 
116 118
             return "";
117 119
         }
118
-
120
+        private int Current_step = 0;
119 121
         public void FirmwareUpdateCheck(byte check)
120 122
         {
121 123
 
@@ -146,6 +148,7 @@ namespace Basic_Terminal
146 148
                 }
147 149
                 else
148 150
                 {
151
+                    Current_step = 0;
149 152
                     Update_ready = false;
150 153
                     temp_data[1] = 0xEE;
151 154
                     temp_data[2] = Convert.ToByte(lastlen + 2);
@@ -209,9 +212,10 @@ namespace Basic_Terminal
209 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 217
                     this.download_Bar.PerformStepup(this.download_Bar);
218
+                    Current_step++;
215 219
                     //this.download_Bar.PerformStepinc(tempupdateret);
216 220
                     // progressBar1.PerformStep();
217 221
                 }
@@ -231,7 +235,7 @@ namespace Basic_Terminal
231 235
         public void Termianl__Operate(byte[] Text)
232 236
         {
233 237
             byte Type = 0;
234
-            Type = Text[Bluecell_BootProtocol.bluecell_type];
238
+            Type = Text[(int)Bluecell_ProtIndex_p.Bluecell_Type];
235 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 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 15
     /// <summary>
16 16
     ///   지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다.
17 17
     /// </summary>
18 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 23
     [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 24
     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25
-    internal class Resources
26
-    {
27
-
25
+    internal class Resources {
26
+        
28 27
         private static global::System.Resources.ResourceManager resourceMan;
29
-
28
+        
30 29
         private static global::System.Globalization.CultureInfo resourceCulture;
31
-
30
+        
32 31
         [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33
-        internal Resources()
34
-        {
32
+        internal Resources() {
35 33
         }
36
-
34
+        
37 35
         /// <summary>
38 36
         ///   이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다.
39 37
         /// </summary>
40 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 42
                     global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Basic_Terminal.Properties.Resources", typeof(Resources).Assembly);
48 43
                     resourceMan = temp;
49 44
                 }
50 45
                 return resourceMan;
51 46
             }
52 47
         }
53
-
48
+        
54 49
         /// <summary>
55 50
         ///   이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을
56 51
         ///   재정의합니다.
57 52
         /// </summary>
58 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 56
                 return resourceCulture;
64 57
             }
65
-            set
66
-            {
58
+            set {
67 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 47
     mimetype: application/x-microsoft.net.object.binary.base64
48 48
     value   : The object must be serialized with 
49
-            : System.Serialization.Formatters.Binary.BinaryFormatter
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50 50
             : and then encoded with base64 encoding.
51 51
     
52 52
     mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
60 60
             : and then encoded with base64 encoding.
61 61
     -->
62 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 64
     <xsd:element name="root" msdata:IsDataSet="true">
64 65
       <xsd:complexType>
65 66
         <xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
68 69
               <xsd:sequence>
69 70
                 <xsd:element name="value" type="xsd:string" minOccurs="0" />
70 71
               </xsd:sequence>
71
-              <xsd:attribute name="name" type="xsd:string" />
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
72 73
               <xsd:attribute name="type" type="xsd:string" />
73 74
               <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
74 76
             </xsd:complexType>
75 77
           </xsd:element>
76 78
           <xsd:element name="assembly">
@@ -85,9 +87,10 @@
85 87
                 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
86 88
                 <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
87 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 91
               <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
90 92
               <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
91 94
             </xsd:complexType>
92 95
           </xsd:element>
93 96
           <xsd:element name="resheader">
@@ -109,9 +112,22 @@
109 112
     <value>2.0</value>
110 113
   </resheader>
111 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 116
   </resheader>
114 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 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 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 28
         /// </summary>
29 29
         private void InitializeComponent()
30 30
         {
31
+            this.components = new System.ComponentModel.Container();
31 32
             this.groupBox9 = new System.Windows.Forms.GroupBox();
32 33
             this.button3 = new System.Windows.Forms.Button();
33 34
             this.button_terminal = new System.Windows.Forms.Button();
@@ -39,14 +40,22 @@
39 40
             this.comboBox_baudrate = new System.Windows.Forms.ComboBox();
40 41
             this.Crc16_Check = new System.Windows.Forms.Button();
41 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 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 55
             this.SuspendLayout();
44 56
             // 
45 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 59
             this.groupBox9.Controls.Add(this.button3);
51 60
             this.groupBox9.Controls.Add(this.button_terminal);
52 61
             this.groupBox9.Controls.Add(this.Ascii_checkBox);
@@ -55,7 +64,7 @@
55 64
             this.groupBox9.Controls.Add(this.comboBox_Port);
56 65
             this.groupBox9.Controls.Add(this.cmBaudRate);
57 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 68
             this.groupBox9.Name = "groupBox9";
60 69
             this.groupBox9.Size = new System.Drawing.Size(225, 223);
61 70
             this.groupBox9.TabIndex = 82;
@@ -109,9 +118,6 @@
109 118
             // 
110 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 121
             this.button_PortOpen.Location = new System.Drawing.Point(13, 91);
116 122
             this.button_PortOpen.Name = "button_PortOpen";
117 123
             this.button_PortOpen.Size = new System.Drawing.Size(197, 34);
@@ -122,9 +128,6 @@
122 128
             // 
123 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 131
             this.comboBox_Port.Cursor = System.Windows.Forms.Cursors.Default;
129 132
             this.comboBox_Port.FormattingEnabled = true;
130 133
             this.comboBox_Port.Location = new System.Drawing.Point(109, 15);
@@ -148,9 +151,6 @@
148 151
             // 
149 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 154
             this.comboBox_baudrate.FormattingEnabled = true;
155 155
             this.comboBox_baudrate.Items.AddRange(new object[] {
156 156
             "9600",
@@ -168,7 +168,7 @@
168 168
             // 
169 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 172
             this.Crc16_Check.Name = "Crc16_Check";
173 173
             this.Crc16_Check.Size = new System.Drawing.Size(96, 23);
174 174
             this.Crc16_Check.TabIndex = 83;
@@ -179,17 +179,72 @@
179 179
             // label1
180 180
             // 
181 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 183
             this.label1.Name = "label1";
184 184
             this.label1.Size = new System.Drawing.Size(110, 12);
185 185
             this.label1.TabIndex = 84;
186 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 242
             // Main_Form
189 243
             // 
190 244
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
191 245
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
192 246
             this.ClientSize = new System.Drawing.Size(800, 450);
247
+            this.Controls.Add(this.groupBox12);
193 248
             this.Controls.Add(this.label1);
194 249
             this.Controls.Add(this.Crc16_Check);
195 250
             this.Controls.Add(this.groupBox9);
@@ -197,6 +252,11 @@
197 252
             this.Text = "Terminal";
198 253
             this.groupBox9.ResumeLayout(false);
199 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 260
             this.ResumeLayout(false);
201 261
             this.PerformLayout();
202 262
 
@@ -215,6 +275,12 @@
215 275
         private System.Windows.Forms.Button Crc16_Check;
216 276
         private System.Windows.Forms.Label label1;
217 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 17
     public partial class Main_Form : Form
18 18
     {
19 19
         Serial serial = new Serial(); // Uart Open
20
-        
20
+        Bluecell_BootProtocol bluecell_BootProtocol = new Bluecell_BootProtocol();
21 21
         Update_Serial file = new Update_Serial();
22 22
         public Main_Form()
23 23
         {
@@ -45,7 +45,21 @@ namespace Basic_Terminal
45 45
 
46 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 65
         private void ComboBox_Port_SelectedIndexChanged(object sender, EventArgs e)
@@ -58,15 +72,81 @@ namespace Basic_Terminal
58 72
         {
59 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 77
             comboBox_Port.Enabled = on_off;
64 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 146
         private void comboBox_Port_MouseDown(object sender, MouseEventArgs e)
68 147
         {
69 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 117
   <resheader name="writer">
118 118
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119 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 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>