Browse Source

DAC 계산 입력 수정 / ACK Enum 추가 / Download Bar 게이지 100% 까지 분할 하도록 수정 / ASCII모드에서 Data Recv 하도록 수정 / DATA RECV 시 Message Box Open 하도록 수정 /

YJ 6 years ago
parent
commit
a765e05dd7

+ 34 - 23
Basic_Terminal/Func/Bluecell_BootProtocol.cs

@@ -39,6 +39,8 @@ namespace RF_TRIO_PLL_ZIG
39 39
         TYPE_BLUECELL_RESET = 0,
40 40
         TYPE_BLUECELL_SET   = 1,
41 41
         TYPE_BLUECELL_GET   = 2,
42
+        TYPE_BLUECELL_SAVE  = 3,
43
+        TYPE_BLUECELL_ACK   = 4,
42 44
     };
43 45
     enum Bluecell_TypeIndex_t
44 46
     {
@@ -449,18 +451,16 @@ namespace RF_TRIO_PLL_ZIG
449 451
             temp_buf[(int)Bluecell_TypeIndex_t._T_SYNC_UL] = main_Form.Tdd_T_Sync;//Convert.ToByte(PLL_ON_OFF_3_5G_L_Get_Func());
450 452
 
451 453
 
452
-
454
+            /***********************DAC A Sector**********************************/
453 455
             double double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_A.Text) * 4095;
454 456
             UInt16 temp = Convert.ToUInt16(double_temp / 4);
455 457
             temp = Convert.ToUInt16(temp & 0x0FFF);
456 458
 
457
-
458 459
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_H]
459 460
                 = Convert.ToByte(0x00 + Convert.ToByte((temp & 0xFF00) >> 8));
460
-
461
-            temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_L] 
462
-                = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_A.Text) * 4095) / 4) & 0x00FF);
463
-
461
+            temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_A_L]
462
+                = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
463
+            /***********************DAC B Sector**********************************/
464 464
             double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_B.Text) * 4095;
465 465
             temp = Convert.ToUInt16(double_temp / 4);
466 466
             temp = Convert.ToUInt16(temp & 0x0FFF);
@@ -468,8 +468,8 @@ namespace RF_TRIO_PLL_ZIG
468 468
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_H]
469 469
                 = Convert.ToByte(0x10 + Convert.ToByte((temp & 0xFF00) >> 8));
470 470
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_B_L]
471
-                = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_B.Text) * 4095) / 4) & 0x00FF);
472
-
471
+                = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
472
+            /***********************DAC C Sector**********************************/
473 473
             double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_C.Text) * 4095;
474 474
             temp = Convert.ToUInt16(double_temp / 4);
475 475
             temp = Convert.ToUInt16(temp & 0x0FFF);
@@ -477,9 +477,9 @@ namespace RF_TRIO_PLL_ZIG
477 477
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_H]
478 478
                 = Convert.ToByte(0x20 + Convert.ToByte((temp & 0xFF00) >> 8));
479 479
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_C_L]
480
-                = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_C.Text) * 4095) / 4) & 0x00FF);
481
-
480
+                = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
482 481
 
482
+            /***********************DAC D Sector**********************************/
483 483
             double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_D.Text) * 4095;
484 484
             temp = Convert.ToUInt16(double_temp / 4);
485 485
             temp = Convert.ToUInt16(temp & 0x0FFF);
@@ -488,8 +488,8 @@ namespace RF_TRIO_PLL_ZIG
488 488
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_H]
489 489
                 = Convert.ToByte(0x30 + Convert.ToByte((temp & 0xFF00) >> 8));
490 490
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_D_L]
491
-                = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_D.Text) * 4095) / 4) & 0x00FF); ;
492
-
491
+                = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
492
+            /***********************DAC E Sector**********************************/
493 493
             double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_E.Text) * 4095;
494 494
             temp = Convert.ToUInt16(double_temp / 4);
495 495
             temp = Convert.ToUInt16(temp & 0x0FFF);
@@ -497,19 +497,19 @@ namespace RF_TRIO_PLL_ZIG
497 497
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_H]
498 498
                 = Convert.ToByte(0x40 + Convert.ToByte((temp & 0xFF00) >> 8));
499 499
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_E_L]
500
-                = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_E.Text) * 4095) / 4) & 0x00FF);
501
-
500
+                = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
502 501
 
502
+            /***********************DAC F Sector**********************************/
503 503
             double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_F.Text) * 4095;
504 504
             temp = Convert.ToUInt16(double_temp / 4);
505 505
             temp = Convert.ToUInt16(temp & 0x0FFF);
506 506
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_H]
507 507
                 = Convert.ToByte(0x50 + Convert.ToByte((temp & 0xFF00) >> 8));
508 508
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_F_L]
509
-                = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_F.Text) * 4095) / 4) & 0x00FF);
510
-
509
+                = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
511 510
 
512 511
 
512
+            /***********************DAC G Sector**********************************/
513 513
             double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_G.Text) * 4095;
514 514
             temp = Convert.ToUInt16(double_temp / 4);
515 515
             temp = Convert.ToUInt16(temp & 0x0FFF);
@@ -517,18 +517,18 @@ namespace RF_TRIO_PLL_ZIG
517 517
 
518 518
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_H]
519 519
                 = Convert.ToByte(0x60 + Convert.ToByte((temp & 0xFF00) >> 8));
520
-            temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_L] 
521
-                = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_G.Text) * 4095) / 4) & 0x00FF);
522
-
520
+            temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_G_L]
521
+                = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
523 522
 
523
+            /***********************DAC H Sector**********************************/
524 524
             double_temp = Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_H.Text) * 4095;
525 525
             temp = Convert.ToUInt16(double_temp / 4);
526 526
             temp = Convert.ToUInt16(temp & 0x0FFF);
527 527
             
528 528
             temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_H]
529 529
                 = Convert.ToByte(0x70 + Convert.ToByte((temp & 0xFF00) >> 8));
530
-            temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L] 
531
-                = Convert.ToByte(Convert.ToUInt16((Convert.ToDouble(main_Form.numericUpDown_DAC_VoltCtrl_H.Text) * 4095) / 4) & 0x00FF);
530
+            temp_buf[(int)Bluecell_TypeIndex_t.DAC_VCtrl_H_L]
531
+                = Convert.ToByte(Convert.ToUInt16(temp) & 0x00FF);
532 532
 
533 533
 
534 534
             /* * * * * * FIX DATA * * * * * */
@@ -545,8 +545,19 @@ namespace RF_TRIO_PLL_ZIG
545 545
         {
546 546
             this.main_Form = (Main_Form)main_form;
547 547
             this.serial = (Serial)serial;
548
-          //  main_Form.Invoke(new ByteSend(this.main_Form.ReSetting_Values),(temp_buf));
549
-            this.main_Form.ADC_Voltage_Value_Set(temp_buf);
548
+            byte type = temp_buf[(byte)Bluecell_TypeIndex_t.BLUE_TYPE];
549
+            //  main_Form.Invoke(new ByteSend(this.main_Form.ReSetting_Values),(temp_buf));
550
+            switch (type)
551
+            {
552
+                case (byte)Bluecell_Prot_t.TYPE_BLUECELL_GET:
553
+                    this.main_Form.ADC_Voltage_Value_Set(temp_buf);
554
+                    break;
555
+                case (byte)Bluecell_Prot_t.TYPE_BLUECELL_ACK:
556
+                    this.main_Form.Message_Box_Open();
557
+                    break;
558
+
559
+
560
+            }
550 561
             //Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
551 562
             //main_Form.label1_8GHz_DL_OUT.Text = Convert.ToString(temp_val);
552 563
 

+ 11 - 21
Basic_Terminal/Func/Serial.cs

@@ -82,34 +82,26 @@ namespace RF_TRIO_PLL_ZIG
82 82
             Data_Handler data_Handler = new Data_Handler();
83 83
             int nLnegth = serialPort.BytesToRead;
84 84
             byte[] btdata = new byte[nLnegth];
85
-            bool data_check = false;
86
-/*
87
-            serialPort.Read(btdata, 0, nLnegth);
88
-            data_check = data_Handler.HeaderCheck(btdata);
89
-            data_check = data_Handler.CrcCheck(btdata);*/
90
-
91 85
 
86
+            serialPort.Read(btdata, 0, nLnegth);
92 87
 
93 88
             main_form.Invoke(new BoolSet(main_form.RX_Light_ON));
94 89
             main_form.TX_RX_Light = true;
95
-            if (this.Debug.Created && Debug.RadioButton_ascii.Checked == true
96
-              /*  && data_check == false*/)
90
+            if (this.Debug.Created && Debug.RadioButton_ascii.Checked == true)
97 91
             {
98
-                string data = serialPort.ReadExisting();
99
-                if (Debug.Created)
100
-                    if (Debug.RadioButton_ascii.Checked == true)
101
-                        Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
102
-                    else
103
-                        Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(data, true));
92
+                string data = Encoding.Default.GetString(btdata);
93
+                // string data = serialPort.ReadExisting();
104 94
 
105
-                data_Handler.Recv_dataCheck(this,this.main_form,this.fileDownload, Str2bytes(data));
95
+                if (Debug.RadioButton_ascii.Checked == true)
96
+                    Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
97
+                else
98
+                    Debug.Invoke(new StringSend(Debug.Data_Recv_Str), Str2hex(data, true));
99
+               
100
+                data_Handler.Recv_dataCheck(this,this.main_form,this.fileDownload, btdata);
106 101
             }
107 102
             else
108 103
             {
109 104
                 // 리스트 두개 사용
110
-
111
-                serialPort.Read(btdata, 0, nLnegth);
112
-                
113 105
                 if (nLnegth > 0)
114 106
                 {
115 107
                     if (this.Debug.Created)
@@ -121,7 +113,6 @@ namespace RF_TRIO_PLL_ZIG
121 113
                         }
122 114
                         else
123 115
                         {
124
-                            
125 116
                             Debug.Invoke(new ByteSend(Debug.Data_Recv_Hex), btdata);
126 117
                         }
127 118
                     }
@@ -130,10 +121,9 @@ namespace RF_TRIO_PLL_ZIG
130 121
                         if (this.Debug.Created)
131 122
                             Debug.Invoke(new ByteSend(Debug.Data_Recv_Hex), btdata);
132 123
                     }
133
-                    data_Handler.Recv_dataCheck(this, this.main_form,this.fileDownload, btdata);
134
-                   
135 124
                     // 이부분에서 데이타 처리하는 부분으로 전송하여 사용하면 됨
136 125
                 }
126
+                data_Handler.Recv_dataCheck(this, this.main_form,this.fileDownload, btdata);
137 127
             }
138 128
             /****
139 129
              *메모리 누수 방지용 코드

+ 5 - 3
Basic_Terminal/Func/Update_Serial.cs

@@ -117,7 +117,7 @@ namespace RF_TRIO_PLL_ZIG
117 117
 
118 118
             return "";
119 119
         }
120
-
120
+        private int Current_step = 0;
121 121
         public void FirmwareUpdateCheck(byte check)
122 122
         {
123 123
 
@@ -148,6 +148,7 @@ namespace RF_TRIO_PLL_ZIG
148 148
                 }
149 149
                 else
150 150
                 {
151
+                    Current_step = 0;
151 152
                     Update_ready = false;
152 153
                     temp_data[1] = 0xEE;
153 154
                     temp_data[2] = Convert.ToByte(lastlen + 2);
@@ -210,10 +211,11 @@ namespace RF_TRIO_PLL_ZIG
210 211
             this.download_Bar.Update_Percent(Convert.ToString(tempupdateret));
211 212
             if (pretempupdateret != tempupdateret)
212 213
             {
213
-
214
-                for (int i = 0; i <= tempupdateret - this.download_Bar.Update_get(); i++)
214
+                //for (int i = 0; i <= tempupdateret - this.download_Bar.Update_get(); i++)
215
+                for(int i = Current_step; i < tempupdateret; i++)
215 216
                 {
216 217
                     this.download_Bar.PerformStepup(this.download_Bar);
218
+                    Current_step++;
217 219
                     //this.download_Bar.PerformStepinc(tempupdateret);
218 220
                     // progressBar1.PerformStep();
219 221
                 }

+ 1 - 1
Basic_Terminal/Wnd/Download_bar.cs

@@ -45,7 +45,7 @@ namespace RF_TRIO_PLL_ZIG
45 45
         public void Update_Percent(String val)
46 46
         {
47 47
             CheckForIllegalCrossThreadCalls = false;
48
-            Firm_Progressbar.PerformStep();
48
+            //Firm_Progressbar.PerformStep();
49 49
             try
50 50
             {
51 51
                 Update_label.Text = val + "%";

+ 14 - 12
Basic_Terminal/Wnd/Main_Form.Designer.cs

@@ -33,7 +33,7 @@
33 33
             this.groupBox9 = new System.Windows.Forms.GroupBox();
34 34
             this.button3 = new System.Windows.Forms.Button();
35 35
             this.button_terminal = new System.Windows.Forms.Button();
36
-            this.Ascii_checkBox = new System.Windows.Forms.CheckBox();
36
+            this.setcheck_checkBox = new System.Windows.Forms.CheckBox();
37 37
             this.cmCom_Port = new System.Windows.Forms.Label();
38 38
             this.button_PortOpen = new System.Windows.Forms.Button();
39 39
             this.comboBox_Port = new System.Windows.Forms.ComboBox();
@@ -280,7 +280,7 @@
280 280
             // 
281 281
             this.groupBox9.Controls.Add(this.button3);
282 282
             this.groupBox9.Controls.Add(this.button_terminal);
283
-            this.groupBox9.Controls.Add(this.Ascii_checkBox);
283
+            this.groupBox9.Controls.Add(this.setcheck_checkBox);
284 284
             this.groupBox9.Controls.Add(this.cmCom_Port);
285 285
             this.groupBox9.Controls.Add(this.button_PortOpen);
286 286
             this.groupBox9.Controls.Add(this.comboBox_Port);
@@ -314,18 +314,20 @@
314 314
             this.button_terminal.UseVisualStyleBackColor = true;
315 315
             this.button_terminal.Click += new System.EventHandler(this.Button_terminal_Click);
316 316
             // 
317
-            // Ascii_checkBox
317
+            // setcheck_checkBox
318 318
             // 
319
-            this.Ascii_checkBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
319
+            this.setcheck_checkBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
320 320
             | System.Windows.Forms.AnchorStyles.Left) 
321 321
             | System.Windows.Forms.AnchorStyles.Right)));
322
-            this.Ascii_checkBox.AutoSize = true;
323
-            this.Ascii_checkBox.Location = new System.Drawing.Point(14, 69);
324
-            this.Ascii_checkBox.Name = "Ascii_checkBox";
325
-            this.Ascii_checkBox.Size = new System.Drawing.Size(55, 16);
326
-            this.Ascii_checkBox.TabIndex = 92;
327
-            this.Ascii_checkBox.Text = "ASCII";
328
-            this.Ascii_checkBox.UseVisualStyleBackColor = true;
322
+            this.setcheck_checkBox.AutoSize = true;
323
+            this.setcheck_checkBox.Checked = true;
324
+            this.setcheck_checkBox.CheckState = System.Windows.Forms.CheckState.Checked;
325
+            this.setcheck_checkBox.Location = new System.Drawing.Point(14, 69);
326
+            this.setcheck_checkBox.Name = "setcheck_checkBox";
327
+            this.setcheck_checkBox.Size = new System.Drawing.Size(102, 16);
328
+            this.setcheck_checkBox.TabIndex = 92;
329
+            this.setcheck_checkBox.Text = "Setting Check";
330
+            this.setcheck_checkBox.UseVisualStyleBackColor = true;
329 331
             // 
330 332
             // cmCom_Port
331 333
             // 
@@ -2536,7 +2538,7 @@
2536 2538
         private System.Windows.Forms.GroupBox groupBox9;
2537 2539
         private System.Windows.Forms.Button button3;
2538 2540
         private System.Windows.Forms.Button button_terminal;
2539
-        private System.Windows.Forms.CheckBox Ascii_checkBox;
2541
+        private System.Windows.Forms.CheckBox setcheck_checkBox;
2540 2542
         private System.Windows.Forms.Label cmCom_Port;
2541 2543
         private System.Windows.Forms.Button button_PortOpen;
2542 2544
         private System.Windows.Forms.Label cmBaudRate;

+ 14 - 2
Basic_Terminal/Wnd/Main_Form.cs

@@ -31,8 +31,8 @@ namespace RF_TRIO_PLL_ZIG
31 31
         {
32 32
             OpenFileDialog ofd = new OpenFileDialog();
33 33
             //FileDownload file = new FileDownload();
34
-            if (Ascii_checkBox.Checked == true)
35
-                Ascii_checkBox.Checked = false;
34
+            if (setcheck_checkBox.Checked == true)
35
+                setcheck_checkBox.Checked = false;
36 36
             file.ShowFileOpenDialog(ref serial, ofd);
37 37
         }
38 38
         private void Crc16_Check_Click(object sender, EventArgs e)
@@ -759,5 +759,17 @@ namespace RF_TRIO_PLL_ZIG
759 759
             temp_buf[5] = 0xeb;
760 760
             serial.Serial_DataSend(temp_buf, temp_buf[2] + 3);
761 761
         }
762
+        public void Message_Box_Open()
763
+        {
764
+            //blue_MessageBox blue_MessageBox = new Blue_MessageBox();
765
+            //MessageBox.Show("Setting OK");
766
+            if(setcheck_checkBox.Checked == true)
767
+                MessageBox.Show("OK",
768
+                    "Setting",
769
+                    MessageBoxButtons.OK,
770
+                    MessageBoxIcon.None,
771
+                    MessageBoxDefaultButton.Button1,
772
+                    MessageBoxOptions.DefaultDesktopOnly);
773
+        }
762 774
     }
763 775
 }