瀏覽代碼

Terminal GUI Base 작업 중 ... / ERR 필수 수정 요구

박영준 5 年之前
父節點
當前提交
054099533d

二進制
.vs/Jdas_Mbic/v15/.suo


二進制
.vs/Jdas_Mbic/v15/Server/sqlite3/storage.ide


二進制
.vs/Jdas_Mbic/v15/Server/sqlite3/storage.ide-shm


二進制
.vs/Jdas_Mbic/v15/Server/sqlite3/storage.ide-wal


+ 130 - 0
Jdas_Mbic/Function/Data_Handler.cs

@@ -0,0 +1,130 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+namespace Jdas_Mbic.Function
8
+{
9
+    class Data_Handler
10
+    {
11
+        //FileDownload fileDownload;
12
+        Update_Serial fileDownload;
13
+        const byte Terminal_Controller_Update_Ack = 0x11;
14
+        const byte Terminal_Controller_Update_Nak = 0x22;
15
+        const byte Terminal_Controller_FirmwareUpdateLen = 250;
16
+        const byte Terminal_Reset = 0x0A;
17
+        const byte Terminal_BootStart = 0x0B;
18
+
19
+
20
+        public Boolean HeaderCheck(byte[] data)
21
+        {
22
+            Boolean ret = false;
23
+
24
+            if (data[0] == 0xbe)
25
+            {
26
+                ret = true;
27
+            }
28
+            return ret;
29
+        }
30
+        public bool CrcCheck(byte[] data)
31
+        {
32
+            bool ret = false;
33
+            Crc16 crc = new Crc16();
34
+            byte length, crcindex;
35
+            try
36
+            {
37
+                length = data[2];
38
+            }
39
+            catch
40
+            {
41
+                return ret;
42
+            }
43
+            crcindex = (byte)(length + 1);
44
+            try
45
+            {
46
+                ret = crc.STH30_CheckCrc(data, length, data[crcindex]);
47
+            }
48
+            catch (Exception e)
49
+            {
50
+                return ret;
51
+            }
52
+            return ret;
53
+        }
54
+
55
+        Serial serial;
56
+        Main_Form main_Form; //= new Main_Form();
57
+        public void Recv_dataCheck(object serial, object main_form, object fileDownload, byte[] data)
58
+        {
59
+            Boolean DataCheck;
60
+            Bluecell_BootProtocol bluecell_BootProtocol = new Bluecell_BootProtocol();
61
+            this.serial = (Serial)serial;
62
+            this.main_Form = (Main_Form)main_form;
63
+            byte seq;
64
+            try
65
+            {
66
+                seq = data[1];
67
+            }
68
+            catch
69
+            {
70
+                return;
71
+            }
72
+            if (fileDownload != null)
73
+            {
74
+                this.fileDownload = (Update_Serial)fileDownload;
75
+            }
76
+            else
77
+            {
78
+                this.fileDownload = new Update_Serial();
79
+            }
80
+            /* * * * * * * * * * * * * *파일 다운로드 부분* * * * * * * * * * * * *  */
81
+            if (this.fileDownload.Update_ready == true)
82
+            {
83
+                DataCheck = HeaderCheck(data);
84
+                if (DataCheck == false)
85
+                {
86
+                    return;
87
+                }
88
+                DataCheck = CrcCheck(data);
89
+                if (DataCheck == false)
90
+                {
91
+                    return;
92
+                }
93
+
94
+
95
+                switch (seq)
96
+                {
97
+                    case Terminal_Reset:
98
+                    case Terminal_BootStart:
99
+                    case Terminal_Controller_Update_Ack:
100
+                    case Terminal_Controller_Update_Nak:
101
+                        //int DataAckcnt = data[(int)Bluepro_t.bluecell_type + 1];
102
+                        //this.fileDownload.UpdateFileSend(data, DataAckcnt);
103
+                        this.fileDownload.Termianl__Operate(data);
104
+                        break;
105
+                    case 3:
106
+                        break;
107
+                    default:
108
+                        break;
109
+                }
110
+
111
+            }
112
+            else/* * * * * * * * * * * * * *API RECV 부분 * * * * * * * * * * * * *  */
113
+            {
114
+                DataCheck = HeaderCheck(data);
115
+                if (DataCheck == false)
116
+                {
117
+                    return;
118
+                }
119
+                DataCheck = CrcCheck(data);
120
+                if (DataCheck == false)
121
+                {
122
+                    return;
123
+                }
124
+
125
+                bluecell_BootProtocol.Bluecell_RF_Status_Get(this.serial, this.main_Form, data);
126
+
127
+            }
128
+        }
129
+    }
130
+}

+ 271 - 0
Jdas_Mbic/Function/Update_Serial.cs

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

+ 2 - 0
Jdas_Mbic/Jdas_Mbic.csproj

@@ -48,6 +48,8 @@
48 48
   </ItemGroup>
49 49
   <ItemGroup>
50 50
     <Compile Include="Function\CRC16.cs" />
51
+    <Compile Include="Function\Data_Handler.cs" />
52
+    <Compile Include="Function\Update_Serial.cs" />
51 53
     <Compile Include="Main.cs">
52 54
       <SubType>Form</SubType>
53 55
     </Compile>

+ 16 - 16
Jdas_Mbic/Main.Designer.cs

@@ -108,7 +108,7 @@
108 108
             this.pictureBox_G_RX = new System.Windows.Forms.PictureBox();
109 109
             this.pictureBox_R_RX = new System.Windows.Forms.PictureBox();
110 110
             this.groupBox9 = new System.Windows.Forms.GroupBox();
111
-            this.button3 = new System.Windows.Forms.Button();
111
+            this.button_FirmwareUpdate = new System.Windows.Forms.Button();
112 112
             this.button_terminal = new System.Windows.Forms.Button();
113 113
             this.setcheck_checkBox = new System.Windows.Forms.CheckBox();
114 114
             this.cmCom_Port = new System.Windows.Forms.Label();
@@ -323,7 +323,7 @@
323 323
             this.groupBox5.Size = new System.Drawing.Size(319, 175);
324 324
             this.groupBox5.TabIndex = 137;
325 325
             this.groupBox5.TabStop = false;
326
-            this.groupBox5.Text = "TRX1";
326
+            this.groupBox5.Text = "TRX3";
327 327
             // 
328 328
             // label19
329 329
             // 
@@ -521,7 +521,7 @@
521 521
             this.groupBox2.Size = new System.Drawing.Size(319, 175);
522 522
             this.groupBox2.TabIndex = 138;
523 523
             this.groupBox2.TabStop = false;
524
-            this.groupBox2.Text = "TRX1";
524
+            this.groupBox2.Text = "TRX4";
525 525
             // 
526 526
             // label1
527 527
             // 
@@ -917,7 +917,7 @@
917 917
             this.groupBox4.Size = new System.Drawing.Size(319, 175);
918 918
             this.groupBox4.TabIndex = 140;
919 919
             this.groupBox4.TabStop = false;
920
-            this.groupBox4.Text = "TRX1";
920
+            this.groupBox4.Text = "TRX2";
921 921
             // 
922 922
             // label12
923 923
             // 
@@ -1150,7 +1150,7 @@
1150 1150
             // 
1151 1151
             // groupBox9
1152 1152
             // 
1153
-            this.groupBox9.Controls.Add(this.button3);
1153
+            this.groupBox9.Controls.Add(this.button_FirmwareUpdate);
1154 1154
             this.groupBox9.Controls.Add(this.button_terminal);
1155 1155
             this.groupBox9.Controls.Add(this.setcheck_checkBox);
1156 1156
             this.groupBox9.Controls.Add(this.cmCom_Port);
@@ -1167,16 +1167,16 @@
1167 1167
             this.groupBox9.TabStop = false;
1168 1168
             this.groupBox9.Text = "Connection";
1169 1169
             // 
1170
-            // button3
1170
+            // button_FirmwareUpdate
1171 1171
             // 
1172
-            this.button3.Location = new System.Drawing.Point(12, 184);
1173
-            this.button3.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
1174
-            this.button3.Name = "button3";
1175
-            this.button3.Size = new System.Drawing.Size(180, 34);
1176
-            this.button3.TabIndex = 93;
1177
-            this.button3.Text = "Firmware Update";
1178
-            this.button3.UseVisualStyleBackColor = true;
1179
-            this.button3.Click += new System.EventHandler(this.button3_Click);
1172
+            this.button_FirmwareUpdate.Location = new System.Drawing.Point(12, 184);
1173
+            this.button_FirmwareUpdate.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3);
1174
+            this.button_FirmwareUpdate.Name = "button_FirmwareUpdate";
1175
+            this.button_FirmwareUpdate.Size = new System.Drawing.Size(180, 34);
1176
+            this.button_FirmwareUpdate.TabIndex = 93;
1177
+            this.button_FirmwareUpdate.Text = "Firmware Update";
1178
+            this.button_FirmwareUpdate.UseVisualStyleBackColor = true;
1179
+            this.button_FirmwareUpdate.Click += new System.EventHandler(this.button_FirmwareUpdate_Click);
1180 1180
             // 
1181 1181
             // button_terminal
1182 1182
             // 
@@ -1823,7 +1823,7 @@
1823 1823
         public System.Windows.Forms.PictureBox pictureBox_G_RX;
1824 1824
         public System.Windows.Forms.PictureBox pictureBox_R_RX;
1825 1825
         private System.Windows.Forms.GroupBox groupBox9;
1826
-        private System.Windows.Forms.Button button3;
1826
+        private System.Windows.Forms.Button button_FirmwareUpdate;
1827 1827
         private System.Windows.Forms.Button button_terminal;
1828 1828
         private System.Windows.Forms.CheckBox setcheck_checkBox;
1829 1829
         private System.Windows.Forms.Label cmCom_Port;
@@ -1853,7 +1853,6 @@
1853 1853
         private System.Windows.Forms.Button button_Initalize;
1854 1854
         private System.Windows.Forms.DataGridViewTextBoxColumn Column_DB;
1855 1855
         private System.Windows.Forms.DataGridViewTextBoxColumn Column_Offset;
1856
-        private System.IO.Ports.SerialPort serialPort_JdasMbic;
1857 1856
         private System.Windows.Forms.Timer timer_JdasMbic;
1858 1857
         private System.Windows.Forms.GroupBox groupBox7;
1859 1858
         private System.Windows.Forms.Button button_TableUL;
@@ -1871,6 +1870,7 @@
1871 1870
         public System.Windows.Forms.Label label33;
1872 1871
         public System.Windows.Forms.PictureBox pictureBox26;
1873 1872
         public System.Windows.Forms.PictureBox pictureBox27;
1873
+        public System.IO.Ports.SerialPort serialPort_JdasMbic;
1874 1874
     }
1875 1875
 }
1876 1876
 

+ 68 - 11
Jdas_Mbic/Main.cs

@@ -277,46 +277,98 @@ namespace Jdas_Mbic
277 277
                 dataGridView_TableSetting[1, TmpList[i]].Value = Convert.ToString(CurrentVal + SumVal);
278 278
             }
279 279
         }
280
+     //   Bluecell_Serial bluecellserial = new Bluecell_Serial();
280 281
 
281 282
         private void button_PortOpen_Click(object sender, EventArgs e)
282 283
         {
283
-
284
+            bool ret = false;
285
+            ret = Serial_connectiondisable(Serial_PortOpen(ref button_PortOpen, ref comboBox_Port));
286
+            if (ret == false && timer_JdasMbic.Enabled == false)
287
+            {
288
+                timer_JdasMbic.Start(); //타이머를 발동시킨다.
289
+            }
290
+            else if (timer_JdasMbic.Enabled == true)
291
+            {
292
+                timer_JdasMbic.Stop(); //타이머를 멈춘다.
293
+            }
294
+            else
295
+            {
296
+                /*NOP*/
297
+            }
298
+            //serial.Serial_Main_Form_Get(this);
284 299
         }
300
+
285 301
         private void button_terminal_Click(object sender, EventArgs e)
286 302
         {
287 303
             Terminal tml = new Terminal();
288 304
             tml.Show();
289 305
         }
290
-
291
-        private void button3_Click(object sender, EventArgs e)
306
+        public void Serial_Initialize(ref ComboBox cb_port)
292 307
         {
293
-
308
+            Serial_Init();
294 309
         }
295
-        public void Serial_Initialize(ref ComboBox cb_port)
310
+        public void Serial_Init()
296 311
         {
297
-
298 312
             this.serialPort_JdasMbic = new System.IO.Ports.SerialPort();
299 313
             this.serialPort_JdasMbic.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.sPort_DataReceived);
300 314
 
301
-            cb_port.BeginUpdate();
315
+            comboBox_Port.BeginUpdate();
302 316
             foreach (string comport in SerialPort.GetPortNames())//foreach (string comport in SerialPort_TestProgram.GetPortNames())
303 317
             {
304
-                cb_port.Items.Add(comport);
318
+                comboBox_Port.Items.Add(comport);
305 319
             }
306
-            cb_port.EndUpdate();
320
+            comboBox_Port.EndUpdate();
307 321
             //SerialPort 초기 설정.
308 322
             //  serialPort.Encoding = Encoding.GetEncoding("Windows-1252");
309
-            cb_port.DataSource = SerialPort.GetPortNames();
323
+            comboBox_Port.DataSource = SerialPort.GetPortNames();
310 324
             try
311 325
             {
312
-                serialPort_JdasMbic.PortName =  cb_port.SelectedItem.ToString();
326
+                serialPort_JdasMbic.PortName = comboBox_Port.SelectedItem.ToString();
313 327
                 serialPort_JdasMbic.BaudRate = (int)115200;
314 328
                 serialPort_JdasMbic.DataBits = (int)8;
315 329
                 serialPort_JdasMbic.Parity = System.IO.Ports.Parity.None;
316 330
                 serialPort_JdasMbic.StopBits = StopBits.One;
317 331
             }
318 332
             catch { }
333
+        }
334
+        public bool Serial_connectiondisable(Boolean on_off)
335
+        {
336
+            comboBox_Port.Enabled = on_off;
337
+            comboBox_baudrate.Enabled = on_off;
338
+            return on_off;
339
+        }
340
+        public Boolean Serial_PortOpen(ref Button Btn_Portonoff, ref ComboBox cb)
341
+        {
342
+            Boolean ret = false;
343
+            try
344
+            {
345
+                if (serialPort_JdasMbic.IsOpen)
346
+                { //When the port is open
347
+                    serialPort_JdasMbic.Close();
348
+                    Btn_Portonoff.Text = "Port Open";
349
+                    ret = true;
350
+                }
351
+                else//When the port is close
352
+                {
353
+                    if (cb.Text != "")
354
+                    {
355
+                        serialPort_JdasMbic.Open();
356
+                        Btn_Portonoff.Text = "Port Close";
357
+                    //   Debug.Debug_Main_Form_Get(this.main_form);
358
+                    }
359
+                    else
360
+                    {
361
+                        MessageBox.Show("Port is not set");
362
+                        ret = true;
363
+                    }
364
+                }
365
+            }
366
+            catch
367
+            {
368
+                MessageBox.Show("already port open " + comboBox_Port.Text);
319 369
 
370
+            }
371
+            return ret;
320 372
         }
321 373
         private delegate void StringSend(string Text);
322 374
         private delegate void GridviewSend(ref object gridview, string Text);
@@ -546,5 +598,10 @@ namespace Jdas_Mbic
546 598
         {
547 599
 
548 600
         }
601
+
602
+        private void button_FirmwareUpdate_Click(object sender, EventArgs e)
603
+        {
604
+
605
+        }
549 606
     }
550 607
 }

+ 116 - 13
Jdas_Mbic/Terminal.Designer.cs

@@ -28,35 +28,138 @@
28 28
         /// </summary>
29 29
         private void InitializeComponent()
30 30
         {
31
-            this.richTextBox1 = new System.Windows.Forms.RichTextBox();
31
+            this.tbReceived = new System.Windows.Forms.RichTextBox();
32
+            this.groupBox1 = new System.Windows.Forms.GroupBox();
33
+            this.checkBox2 = new System.Windows.Forms.CheckBox();
34
+            this.checkBox1 = new System.Windows.Forms.CheckBox();
35
+            this.radioButton_ascii = new System.Windows.Forms.RadioButton();
36
+            this.radioButton_hex = new System.Windows.Forms.RadioButton();
37
+            this.button_Clear = new System.Windows.Forms.Button();
38
+            this.button_Send = new System.Windows.Forms.Button();
39
+            this.textBox_senddata = new System.Windows.Forms.TextBox();
40
+            this.groupBox1.SuspendLayout();
32 41
             this.SuspendLayout();
33 42
             // 
34
-            // richTextBox1
43
+            // tbReceived
35 44
             // 
36
-            this.richTextBox1.BackColor = System.Drawing.Color.Black;
37
-            this.richTextBox1.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
38
-            this.richTextBox1.ForeColor = System.Drawing.Color.Yellow;
39
-            this.richTextBox1.Location = new System.Drawing.Point(12, 12);
40
-            this.richTextBox1.Name = "richTextBox1";
41
-            this.richTextBox1.Size = new System.Drawing.Size(776, 426);
42
-            this.richTextBox1.TabIndex = 0;
43
-            this.richTextBox1.Text = "";
45
+            this.tbReceived.BackColor = System.Drawing.Color.Black;
46
+            this.tbReceived.Font = new System.Drawing.Font("굴림", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
47
+            this.tbReceived.ForeColor = System.Drawing.Color.Yellow;
48
+            this.tbReceived.Location = new System.Drawing.Point(12, 12);
49
+            this.tbReceived.Name = "tbReceived";
50
+            this.tbReceived.Size = new System.Drawing.Size(776, 323);
51
+            this.tbReceived.TabIndex = 0;
52
+            this.tbReceived.Text = "";
53
+            // 
54
+            // groupBox1
55
+            // 
56
+            this.groupBox1.Controls.Add(this.checkBox2);
57
+            this.groupBox1.Controls.Add(this.checkBox1);
58
+            this.groupBox1.Controls.Add(this.radioButton_ascii);
59
+            this.groupBox1.Controls.Add(this.radioButton_hex);
60
+            this.groupBox1.Controls.Add(this.button_Clear);
61
+            this.groupBox1.Controls.Add(this.button_Send);
62
+            this.groupBox1.Controls.Add(this.textBox_senddata);
63
+            this.groupBox1.Location = new System.Drawing.Point(12, 349);
64
+            this.groupBox1.Name = "groupBox1";
65
+            this.groupBox1.Size = new System.Drawing.Size(776, 89);
66
+            this.groupBox1.TabIndex = 65;
67
+            this.groupBox1.TabStop = false;
68
+            this.groupBox1.Text = "보내는 문자열";
69
+            // 
70
+            // checkBox2
71
+            // 
72
+            this.checkBox2.AutoSize = true;
73
+            this.checkBox2.Location = new System.Drawing.Point(254, 20);
74
+            this.checkBox2.Name = "checkBox2";
75
+            this.checkBox2.Size = new System.Drawing.Size(116, 16);
76
+            this.checkBox2.TabIndex = 4;
77
+            this.checkBox2.Text = "수신 문자열 표시";
78
+            this.checkBox2.UseVisualStyleBackColor = true;
79
+            // 
80
+            // checkBox1
81
+            // 
82
+            this.checkBox1.AutoSize = true;
83
+            this.checkBox1.Location = new System.Drawing.Point(131, 20);
84
+            this.checkBox1.Name = "checkBox1";
85
+            this.checkBox1.Size = new System.Drawing.Size(116, 16);
86
+            this.checkBox1.TabIndex = 4;
87
+            this.checkBox1.Text = "송신 문자열 표시";
88
+            this.checkBox1.UseVisualStyleBackColor = true;
89
+            // 
90
+            // radioButton_ascii
91
+            // 
92
+            this.radioButton_ascii.AutoSize = true;
93
+            this.radioButton_ascii.Checked = true;
94
+            this.radioButton_ascii.Location = new System.Drawing.Point(71, 20);
95
+            this.radioButton_ascii.Name = "radioButton_ascii";
96
+            this.radioButton_ascii.Size = new System.Drawing.Size(54, 16);
97
+            this.radioButton_ascii.TabIndex = 3;
98
+            this.radioButton_ascii.TabStop = true;
99
+            this.radioButton_ascii.Text = "ASCII";
100
+            this.radioButton_ascii.UseVisualStyleBackColor = true;
101
+            // 
102
+            // radioButton_hex
103
+            // 
104
+            this.radioButton_hex.AutoSize = true;
105
+            this.radioButton_hex.Location = new System.Drawing.Point(7, 20);
106
+            this.radioButton_hex.Name = "radioButton_hex";
107
+            this.radioButton_hex.Size = new System.Drawing.Size(45, 16);
108
+            this.radioButton_hex.TabIndex = 3;
109
+            this.radioButton_hex.Text = "Hex";
110
+            this.radioButton_hex.UseVisualStyleBackColor = true;
111
+            // 
112
+            // button_Clear
113
+            // 
114
+            this.button_Clear.Location = new System.Drawing.Point(698, 19);
115
+            this.button_Clear.Name = "button_Clear";
116
+            this.button_Clear.Size = new System.Drawing.Size(71, 23);
117
+            this.button_Clear.TabIndex = 2;
118
+            this.button_Clear.Text = "삭제";
119
+            this.button_Clear.UseVisualStyleBackColor = true;
120
+            // 
121
+            // button_Send
122
+            // 
123
+            this.button_Send.Location = new System.Drawing.Point(698, 52);
124
+            this.button_Send.Name = "button_Send";
125
+            this.button_Send.Size = new System.Drawing.Size(71, 23);
126
+            this.button_Send.TabIndex = 1;
127
+            this.button_Send.Text = "보내기";
128
+            this.button_Send.UseVisualStyleBackColor = true;
129
+            // 
130
+            // textBox_senddata
131
+            // 
132
+            this.textBox_senddata.Location = new System.Drawing.Point(7, 54);
133
+            this.textBox_senddata.Name = "textBox_senddata";
134
+            this.textBox_senddata.Size = new System.Drawing.Size(679, 21);
135
+            this.textBox_senddata.TabIndex = 0;
44 136
             // 
45 137
             // Terminal
46 138
             // 
47 139
             this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
48 140
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
49
-            this.ClientSize = new System.Drawing.Size(800, 450);
50
-            this.Controls.Add(this.richTextBox1);
141
+            this.ClientSize = new System.Drawing.Size(812, 450);
142
+            this.Controls.Add(this.groupBox1);
143
+            this.Controls.Add(this.tbReceived);
51 144
             this.Name = "Terminal";
52 145
             this.Text = "Terminal";
53 146
             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Terminal_FormClosing);
147
+            this.groupBox1.ResumeLayout(false);
148
+            this.groupBox1.PerformLayout();
54 149
             this.ResumeLayout(false);
55 150
 
56 151
         }
57 152
 
58 153
         #endregion
59 154
 
60
-        private System.Windows.Forms.RichTextBox richTextBox1;
155
+        private System.Windows.Forms.RichTextBox tbReceived;
156
+        private System.Windows.Forms.GroupBox groupBox1;
157
+        private System.Windows.Forms.CheckBox checkBox2;
158
+        private System.Windows.Forms.CheckBox checkBox1;
159
+        public System.Windows.Forms.RadioButton radioButton_ascii;
160
+        public System.Windows.Forms.RadioButton radioButton_hex;
161
+        private System.Windows.Forms.Button button_Clear;
162
+        private System.Windows.Forms.Button button_Send;
163
+        private System.Windows.Forms.TextBox textBox_senddata;
61 164
     }
62 165
 }

+ 448 - 0
Jdas_Mbic/Terminal.cs

@@ -4,10 +4,16 @@ using System.ComponentModel;
4 4
 using System.Data;
5 5
 using System.Drawing;
6 6
 using System.Linq;
7
+using System.Runtime.InteropServices;
7 8
 using System.Text;
8 9
 using System.Threading.Tasks;
9 10
 using System.Windows.Forms;
10 11
 
12
+//Add code
13
+using System.IO;
14
+using System.IO.Ports;
15
+using Jdas_Mbic.Function;
16
+
11 17
 namespace Jdas_Mbic
12 18
 {
13 19
     public partial class Terminal : Form
@@ -21,5 +27,447 @@ namespace Jdas_Mbic
21 27
         {
22 28
             this.Dispose();
23 29
         }
30
+
31
+        
32
+        JdasMbic main_form;
33
+        int LineLimit = 500;
34
+        [DllImport("user32.dll")]
35
+        public static extern int SendMessage(IntPtr hWnd, Int32 wMsg, bool wParam, Int32 lParam);
36
+        private const int WM_SETREDRAW = 11;
37
+        
38
+        public RadioButton RadioButton_ascii { get => radioButton_ascii; set => radioButton_ascii = value; }
39
+        public RadioButton RadioButton_hex { get => radioButton_hex; set => radioButton_hex = value; }
40
+#if true
41
+        public void Data_Recv_Str(string text)
42
+        {
43
+
44
+            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
45
+            try
46
+            {
47
+                try
48
+                {
49
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
50
+                }
51
+                catch (Exception e) { MessageBox.Show(e.StackTrace); }
52
+                if (tbReceived.Lines.Length > nLimitLines)
53
+                {
54
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
55
+                    while ((tempLines.Count - nLimitLines) > 0)
56
+                    {
57
+                        tempLines.RemoveFirst();
58
+                    }
59
+
60
+                    tbReceived.Lines = tempLines.ToArray();
61
+
62
+                }
63
+                try
64
+                {
65
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
66
+                }
67
+                catch { return; }
68
+                tbReceived.AppendText(text);
69
+                tbReceived.SelectionStart = tbReceived.Text.Length;//맨 마지막 선택... 
70
+                tbReceived.ScrollToCaret();
71
+            }
72
+            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
73
+        }
74
+#endif
75
+#if false
76
+        public void Data_Recv_Hex(byte[] text)
77
+        {
78
+           int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
79
+            try
80
+            {
81
+                try
82
+                {
83
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
84
+                }
85
+                catch (Exception e) { MessageBox.Show(e.StackTrace); }
86
+                if (tbReceived.Lines.Length > nLimitLines)
87
+                {
88
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
89
+                    while ((tempLines.Count - nLimitLines) > 0)
90
+                    {
91
+                        tempLines.RemoveFirst();
92
+                    }
93
+
94
+                    tbReceived.Lines = tempLines.ToArray();
95
+
96
+                }
97
+                try
98
+                {
99
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
100
+                }
101
+                catch { return; }
102
+                tbReceived.AppendText(text.ToString());
103
+                tbReceived.SelectionStart = tbReceived.Text.Length;//맨 마지막 선택... 
104
+                tbReceived.ScrollToCaret();
105
+            }
106
+            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
107
+
108
+        }
109
+#endif
110
+        public void Data_Recv_Hex(byte[] text)
111
+        {
112
+            string AppendMessage = "";
113
+
114
+            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
115
+            try
116
+            {/*
117
+                try
118
+                {
119
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
120
+                }
121
+                catch (Exception e) { MessageBox.Show(e.StackTrace); }*/
122
+                for (int i = 0; i < text.Length; i++)
123
+                {
124
+                    AppendMessage += Convert.ToString(text[i], 16);
125
+                    AppendMessage += " ";
126
+                }
127
+                AppendMessage += "\r\n";
128
+                tbReceived.AppendText(AppendMessage);
129
+
130
+                if (tbReceived.Lines.Length > nLimitLines)
131
+                {
132
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
133
+
134
+                    while ((tempLines.Count - nLimitLines) > 0)
135
+                    {
136
+                        tempLines.RemoveFirst();
137
+                    }
138
+
139
+                    tbReceived.Lines = tempLines.ToArray();
140
+                }
141
+                try
142
+                {
143
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
144
+                }
145
+                catch { return; }
146
+                tbReceived.Select(tbReceived.Text.Length, 0);
147
+                tbReceived.ScrollToCaret();
148
+            }
149
+            catch { try { SendMessage(this.Handle, WM_SETREDRAW, true, 0); } catch { return; } }
150
+
151
+        }
152
+        public void Data_Send(byte[] text)
153
+        {
154
+            string AppendMessage = "\n[TX]";
155
+
156
+            int nLimitLines = Convert.ToInt32(LineLimit); //제한 라인 수
157
+            try
158
+            {
159
+                for (int i = 0; i < text.Length; i++)
160
+                {
161
+                    AppendMessage += Convert.ToString(text[i], 16);
162
+                }
163
+                tbReceived.AppendText(AppendMessage);
164
+                try
165
+                {
166
+                    SendMessage(this.Handle, WM_SETREDRAW, false, 0);
167
+                }
168
+                catch { return; }
169
+                if (tbReceived.Lines.Length > nLimitLines)
170
+                {
171
+                    LinkedList<string> tempLines = new LinkedList<string>(tbReceived.Lines);
172
+
173
+                    while ((tempLines.Count - nLimitLines) > 0)
174
+                    {
175
+                        tempLines.RemoveFirst();
176
+                    }
177
+
178
+                    tbReceived.Lines = tempLines.ToArray();
179
+                }
180
+                try
181
+                {
182
+                    SendMessage(this.Handle, WM_SETREDRAW, true, 0);
183
+                }
184
+                catch { return; }
185
+                tbReceived.Select(tbReceived.Text.Length, 0);
186
+                tbReceived.ScrollToCaret();
187
+            }
188
+            finally { }
189
+
190
+        }
191
+
192
+
193
+        private void Button_Send_Click(object sender, EventArgs e)
194
+        {
195
+
196
+        }
197
+
198
+        private void Button_Clear_Click(object sender, EventArgs e)
199
+        {
200
+
201
+        }
202
+        public void hex_to_ascii_radiobuttonConvert()
203
+        {
204
+            radioButton_hex.Checked = true;
205
+            radioButton_ascii.Checked = false;
206
+        }
207
+        public void ascii_to_hex_radiobuttonConvert()
208
+        {
209
+            radioButton_ascii.Checked = true;
210
+            radioButton_hex.Checked = false;
211
+        }
212
+        public void Debug_Main_Form_Get(object frm)
213
+        {
214
+            this.main_form = (JdasMbic)frm;
215
+        }
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+        //public string Serial_Name { get => serialPort.PortName;  set => serialPort.PortName = value;}
224
+        Data_Handler data_Handler = new Data_Handler();
225
+        //FileDownload fileDownload;
226
+        Update_Serial fileDownload = null;
227
+        public void SetPortNameValues(object obj)
228
+        {
229
+            string[] ports = SerialPort.GetPortNames(); // load all name of com ports to string
230
+            try
231
+            {
232
+                ((ComboBox)obj).Items.Clear(); //delete previous names in combobox items
233
+            }
234
+            catch { }
235
+           ((ComboBox)obj).DataSource = null;
236
+            foreach (string port in ports) //add this names to comboboxPort items
237
+            {
238
+                ((ComboBox)obj).Items.Add(port); //if there are some com ports ,select first
239
+            }
240
+            if (((ComboBox)obj).Items.Count > 0)
241
+            {
242
+                ((ComboBox)obj).SelectedIndex = 0;
243
+            }
244
+            else
245
+            {
246
+                ((ComboBox)obj).Text = " "; //if there are no com ports ,write Empty
247
+            }
248
+        }
249
+        public void Serial_Initialize(ref ComboBox cb_port)
250
+        {
251
+            
252
+            this.serialPort = new System.IO.Ports.SerialPort();
253
+            this.serialPort.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.Serial_DataRecvFunction);
254
+
255
+            cb_port.BeginUpdate();
256
+            foreach (string comport in SerialPort.GetPortNames())//foreach (string comport in SerialPort_TestProgram.GetPortNames())
257
+            {
258
+                cb_port.Items.Add(comport);
259
+            }
260
+            cb_port.EndUpdate();
261
+            //SerialPort 초기 설정.
262
+         //  serialPort.Encoding = Encoding.GetEncoding("Windows-1252");
263
+            cb_port.DataSource =  SerialPort.GetPortNames();
264
+            try
265
+            {
266
+                serialPort_JdasMbic.PortName =  cb_port.SelectedItem.ToString();
267
+                serialPort_JdasMbic.BaudRate = (int)921600;
268
+                serialPort_JdasMbic.DataBits = (int)8;
269
+                serialPort_JdasMbic.Parity = System.IO.Ports.Parity.None;
270
+                serialPort_JdasMbic.StopBits = StopBits.One;
271
+            }
272
+            catch { }
273
+
274
+        }
275
+        private delegate void StringSend(string Text);
276
+        private delegate void ByteSend(byte[] Text);
277
+
278
+        public string Str2hex(string strData,Boolean Compotable)
279
+        {
280
+            string resultHex = string.Empty;
281
+            byte[] arr_byteStr = Encoding.Default.GetBytes(strData);
282
+
283
+            foreach (byte byteStr in arr_byteStr)
284
+            {
285
+                if(Compotable == true)
286
+                    resultHex += string.Format("{0:X2}", byteStr) + " ";
287
+                else
288
+                    resultHex += string.Format("{0:X2}", byteStr);
289
+            }
290
+
291
+            return resultHex;
292
+        }
293
+
294
+        static public byte[] Str2bytes(string byteData)
295
+        {
296
+
297
+#if false
298
+            System.Text.ASCIIEncoding asencoding = new System.Text.ASCIIEncoding();
299
+            return Encoding.Default.GetBytes(byteData);
300
+#else 
301
+            byte[] arr_byteStr = Encoding.Default.GetBytes(byteData);
302
+            return arr_byteStr;
303
+#endif
304
+        }
305
+        private delegate void BoolSet();
306
+        public void Serial_DataRecvFunction(object sender, SerialDataReceivedEventArgs e)
307
+        {
308
+            string tmpSTR = "";
309
+            Data_Handler data_Handler = new Data_Handler();
310
+            int nLnegth = serialPort.BytesToRead;
311
+            byte[] btdata = new byte[nLnegth];
312
+
313
+            serialPort.Read(btdata, 0, nLnegth);
314
+
315
+            main_form.Invoke(new BoolSet(main_form.RX_Light_ON));
316
+            main_form.TX_RX_Light = true;
317
+            if (this.Debug.Created && Debug.RadioButton_ascii.Checked == true)
318
+            {
319
+                string data = Encoding.Default.GetString(btdata);
320
+                // string data = serialPort.ReadExisting();
321
+
322
+                if (Debug.RadioButton_ascii.Checked == true)
323
+                    Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
324
+                else
325
+                    Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(data, true));
326
+               
327
+                data_Handler.Recv_dataCheck(this,this.main_form,this.fileDownload, btdata);
328
+            }
329
+            else
330
+            {
331
+                // 리스트 두개 사용
332
+                if (nLnegth > 0)
333
+                {
334
+                    if (this.Debug.Created)
335
+                    {
336
+                        if (this.Debug.radioButton_ascii.Checked == true)
337
+                        {
338
+                            tmpSTR = Encoding.Default.GetString(btdata).TrimEnd('\0');
339
+                            Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(tmpSTR, true));
340
+                        }
341
+                        else
342
+                        {
343
+                            Debug.Invoke(new ByteSend(Debug.Data_Recv_Hex), btdata);
344
+                        }
345
+                    }
346
+                    else
347
+                    {
348
+                        if (this.Debug.Created)
349
+                            Debug.Invoke(new ByteSend(Debug.Data_Recv_Hex), btdata);
350
+                    }
351
+                    // 이부분에서 데이타 처리하는 부분으로 전송하여 사용하면 됨
352
+                }
353
+
354
+                data_Handler.Recv_dataCheck(this, this.main_form,this.fileDownload, btdata);
355
+            }
356
+            /****
357
+             *메모리 누수 방지용 코드
358
+             */
359
+            System.GC.Collect(0, GCCollectionMode.Forced);
360
+            System.GC.WaitForFullGCComplete();
361
+        }
362
+        public Boolean Serial_PortOpen(ref Button Btn_Portonoff,ref ComboBox cb)
363
+        {
364
+            Boolean ret = false;
365
+            try
366
+            {
367
+                if (serialPort.IsOpen) { //When the port is open
368
+                    serialPort.Close();
369
+                    Btn_Portonoff.Text = "Port Open";
370
+                    ret = true;
371
+                }
372
+                else//When the port is close
373
+                {
374
+                    if (cb.Text != "")
375
+                    {
376
+                        serialPort.Open();
377
+                        Btn_Portonoff.Text = "Port Close";
378
+                        Debug.Debug_Main_Form_Get(this.main_form);
379
+                    }
380
+                    else
381
+                    {
382
+                        MessageBox.Show("Port is not set");
383
+                        ret = true;
384
+                    }
385
+                }
386
+            }
387
+            catch
388
+            {
389
+                MessageBox.Show("already port open " + Serial_Name);
390
+               
391
+            }
392
+            return ret;
393
+        }
394
+        public void Serial_TerminalOpen(object serial)
395
+        {
396
+            this.Debug.Serial_ClassSet(serial);
397
+            try
398
+            {
399
+                this.Debug.Show();
400
+            }
401
+            catch
402
+            {
403
+                Debug = new Debug();
404
+                this.Debug.Show();
405
+            }
406
+        }
407
+        public void Serial_DataSend(byte[] data)
408
+        {
409
+            try
410
+            {
411
+                serialPort.Write(data,0,data.Length);
412
+                main_form.pictureBox_R_TX.Visible = false;
413
+                main_form.pictureBox_G_TX.Visible = true;
414
+            }
415
+            catch (System.Exception ex)
416
+            {
417
+                MessageBox.Show(ex.Message);
418
+            }
419
+        }
420
+        public void Serial_DataSend(byte[] buffer, int count)
421
+        {
422
+            try {
423
+                serialPort.Write(buffer, 0, count);
424
+                main_form.Invoke(new BoolSet(main_form.TX_Light_ON));
425
+                main_form.TX_RX_Light = true;
426
+            }
427
+            catch
428
+            {
429
+                System.Diagnostics.Process.GetCurrentProcess().Kill();
430
+                MessageBox.Show("Port Open Failed!!!");
431
+            }
432
+        }
433
+       
434
+        public void FileDownloadClass_Set(object filedownload)
435
+        {
436
+            this.fileDownload = (Update_Serial)filedownload;
437
+        }
438
+        public object FileDownloadClass_Get()
439
+        {
440
+            return this.fileDownload;
441
+        }
442
+        public void Test_Serial()
443
+        {
444
+            byte[] tempdata = new byte[1024];
445
+            for (int i = 0; i < 255; i++)
446
+            {
447
+
448
+                tempdata[i] = Convert.ToByte(i);
449
+                
450
+                
451
+            }
452
+            this.serialPort.Write(tempdata, 0, 255);
453
+            //this.serialPort.Write(tempdata.ToString());
454
+
455
+        }
456
+        public void debug_hextoasciiConvert()
457
+        {
458
+            if(this.Debug.Created)
459
+                this.Debug.hex_to_ascii_radiobuttonConvert();
460
+        }
461
+        public void debug_asciitohexConvert()
462
+        {
463
+            if (this.Debug.Created)
464
+                this.Debug.ascii_to_hex_radiobuttonConvert();
465
+        }
466
+        
467
+        public void Serial_Main_Form_Get(object frm)
468
+        {
469
+            this.main_form = (Main_Form)frm;
470
+        }
471
+
24 472
     }
25 473
 }

二進制
Jdas_Mbic/bin/Debug/Jdas_Mbic.exe


二進制
Jdas_Mbic/bin/Debug/Jdas_Mbic.pdb


二進制
Jdas_Mbic/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache


+ 1 - 1
Jdas_Mbic/obj/Debug/Jdas_Mbic.csproj.CoreCompileInputs.cache

@@ -1 +1 @@
1
-dc6033e67fe295d45a9ff8b4bc602f92f9046681
1
+c5715ee6603524e81f8c9e064b293d8a0d06fab0

二進制
Jdas_Mbic/obj/Debug/Jdas_Mbic.csproj.GenerateResource.cache


二進制
Jdas_Mbic/obj/Debug/Jdas_Mbic.exe


二進制
Jdas_Mbic/obj/Debug/Jdas_Mbic.pdb