Browse Source

Tx Data request 하도록 수정 / Request CRC INDEX 오류 수정

YJ 6 years ago
parent
commit
4d0f8a8a73

+ 4 - 3
Basic_Terminal/Func/Bluecell_BootProtocol.cs

@@ -180,6 +180,7 @@ namespace RF_TRIO_PLL_ZIG
180
             temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1]     = BLUECELL_TAILER;
180
             temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1]     = BLUECELL_TAILER;
181
             this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
181
             this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
182
         }
182
         }
183
+
183
         private byte Bluecell_BDA4601_Calc(double data)
184
         private byte Bluecell_BDA4601_Calc(double data)
184
         {
185
         {
185
             byte ret = 0;
186
             byte ret = 0;
@@ -559,9 +560,9 @@ namespace RF_TRIO_PLL_ZIG
559
             temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
560
             temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
560
             temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = 2;
561
             temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = 2;
561
             temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = Convert.ToByte(temp_buf.Length - 3);
562
             temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = Convert.ToByte(temp_buf.Length - 3);
562
-            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = 5;
563
-            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex + 1] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]);
564
-            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex + 2] = BLUECELL_TAILER;
563
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = Convert.ToByte(temp_buf.Length - 2);
564
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 0] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]);
565
+            temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1] = BLUECELL_TAILER;
565
             this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
566
             this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
566
 
567
 
567
         }
568
         }

+ 3 - 3
Basic_Terminal/Func/Crc16.cs

@@ -121,7 +121,7 @@ namespace RF_TRIO_PLL_ZIG
121
             }
121
             }
122
             return (crc16 == checksum ? EtError.CHECKSUM_ERROR : EtError.NO_ERROR);
122
             return (crc16 == checksum ? EtError.CHECKSUM_ERROR : EtError.NO_ERROR);
123
         }
123
         }
124
-        public byte STH30_CheckCrc(byte[] data, byte nbrOfBytes, byte checksum)
124
+        public bool STH30_CheckCrc(byte[] data, byte nbrOfBytes, byte checksum)
125
         {
125
         {
126
             byte bit;        // bit mask
126
             byte bit;        // bit mask
127
             int crc = 0xFF; // calculated checksum
127
             int crc = 0xFF; // calculated checksum
@@ -138,8 +138,8 @@ namespace RF_TRIO_PLL_ZIG
138
                     else crc = (crc << 1);
138
                     else crc = (crc << 1);
139
                 }
139
                 }
140
             }
140
             }
141
-            if (crc != checksum) return 0;
142
-            else return 1;
141
+            if (crc != checksum) return false;
142
+            else return true;
143
         }
143
         }
144
         public byte STH30_CreateCrc(byte[] data, byte nbrOfBytes)
144
         public byte STH30_CreateCrc(byte[] data, byte nbrOfBytes)
145
         {
145
         {

+ 21 - 16
Basic_Terminal/Func/Data_Handler.cs

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

+ 22 - 7
Basic_Terminal/Func/Serial.cs

@@ -18,7 +18,7 @@ namespace RF_TRIO_PLL_ZIG
18
         public string Serial_Name { get => serialPort.PortName;  set => serialPort.PortName = value;}
18
         public string Serial_Name { get => serialPort.PortName;  set => serialPort.PortName = value;}
19
         Data_Handler data_Handler = new Data_Handler();
19
         Data_Handler data_Handler = new Data_Handler();
20
         //FileDownload fileDownload;
20
         //FileDownload fileDownload;
21
-        Update_Serial fileDownload;
21
+        Update_Serial fileDownload = null;
22
         public void Serial_Initialize(ref ComboBox cb_port)
22
         public void Serial_Initialize(ref ComboBox cb_port)
23
         {
23
         {
24
             
24
             
@@ -79,9 +79,21 @@ namespace RF_TRIO_PLL_ZIG
79
         public void Serial_DataRecvFunction(object sender, SerialDataReceivedEventArgs e)
79
         public void Serial_DataRecvFunction(object sender, SerialDataReceivedEventArgs e)
80
         {
80
         {
81
             string tmpSTR = "";
81
             string tmpSTR = "";
82
-            //this.main_form.RX_Light_ON();
82
+            Data_Handler data_Handler = new Data_Handler();
83
+            int nLnegth = serialPort.BytesToRead;
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
+
92
+
83
             main_form.Invoke(new BoolSet(main_form.RX_Light_ON));
93
             main_form.Invoke(new BoolSet(main_form.RX_Light_ON));
84
-            if (this.Debug.Created && Debug.RadioButton_ascii.Checked == true)
94
+            main_form.TX_RX_Light = true;
95
+            if (this.Debug.Created && Debug.RadioButton_ascii.Checked == true
96
+              /*  && data_check == false*/)
85
             {
97
             {
86
                 string data = serialPort.ReadExisting();
98
                 string data = serialPort.ReadExisting();
87
                 if (Debug.Created)
99
                 if (Debug.Created)
@@ -95,8 +107,7 @@ namespace RF_TRIO_PLL_ZIG
95
             else
107
             else
96
             {
108
             {
97
                 // 리스트 두개 사용
109
                 // 리스트 두개 사용
98
-                int nLnegth = serialPort.BytesToRead;
99
-                byte[] btdata = new byte[nLnegth];
110
+
100
                 serialPort.Read(btdata, 0, nLnegth);
111
                 serialPort.Read(btdata, 0, nLnegth);
101
                 
112
                 
102
                 if (nLnegth > 0)
113
                 if (nLnegth > 0)
@@ -193,16 +204,20 @@ namespace RF_TRIO_PLL_ZIG
193
             try {
204
             try {
194
                 serialPort.Write(buffer, 0, count);
205
                 serialPort.Write(buffer, 0, count);
195
                 main_form.Invoke(new BoolSet(main_form.TX_Light_ON));
206
                 main_form.Invoke(new BoolSet(main_form.TX_Light_ON));
207
+                main_form.TX_RX_Light = true;
196
             }
208
             }
197
             catch { MessageBox.Show("Port Open Failed!!!"); }
209
             catch { MessageBox.Show("Port Open Failed!!!"); }
198
             
210
             
199
 
211
 
200
         }
212
         }
201
-        public void FileDownloadClass_Get(object filedownload)
213
+        public void FileDownloadClass_Set(object filedownload)
202
         {
214
         {
203
-            //this.fileDownload = (FileDownload)filedownload;
204
             this.fileDownload = (Update_Serial)filedownload;
215
             this.fileDownload = (Update_Serial)filedownload;
205
         }
216
         }
217
+        public object FileDownloadClass_Get()
218
+        {
219
+            return this.fileDownload;
220
+        }
206
         public void Test_Serial()
221
         public void Test_Serial()
207
         {
222
         {
208
             byte[] tempdata = new byte[1024];
223
             byte[] tempdata = new byte[1024];

+ 1 - 1
Basic_Terminal/Func/Update_Serial.cs

@@ -80,7 +80,7 @@ namespace RF_TRIO_PLL_ZIG
80
                 // label2.Text = "Full Name  : " + fileFullName;
80
                 // label2.Text = "Full Name  : " + fileFullName;
81
                 // label3.Text = "File Path  : " + filePath;`
81
                 // label3.Text = "File Path  : " + filePath;`
82
                 //File경로 + 파일명 리턴
82
                 //File경로 + 파일명 리턴
83
-                this.serial.FileDownloadClass_Get(this);
83
+                this.serial.FileDownloadClass_Set(this);
84
                 Data_Request_Func = 1;
84
                 Data_Request_Func = 1;
85
 
85
 
86
                 Firmware_byte_load = File.ReadAllBytes(this.ofd.FileName);
86
                 Firmware_byte_load = File.ReadAllBytes(this.ofd.FileName);

+ 2 - 2
Basic_Terminal/Wnd/Main_Form.Designer.cs

@@ -1611,7 +1611,7 @@
1611
             // 
1611
             // 
1612
             // timer
1612
             // timer
1613
             // 
1613
             // 
1614
-            this.timer.Interval = 1;
1614
+            this.timer.Interval = 500;
1615
             this.timer.Tick += new System.EventHandler(this.timer_Tick);
1615
             this.timer.Tick += new System.EventHandler(this.timer_Tick);
1616
             // 
1616
             // 
1617
             // groupBox12
1617
             // groupBox12
@@ -2584,7 +2584,6 @@
2584
         private System.Windows.Forms.GroupBox groupBox16;
2584
         private System.Windows.Forms.GroupBox groupBox16;
2585
         private System.Windows.Forms.Label label49;
2585
         private System.Windows.Forms.Label label49;
2586
         private System.Windows.Forms.Label label50;
2586
         private System.Windows.Forms.Label label50;
2587
-        private System.Windows.Forms.Timer timer;
2588
         public System.Windows.Forms.NumericUpDown numericUpDown_ATT_1_8G_DL1;
2587
         public System.Windows.Forms.NumericUpDown numericUpDown_ATT_1_8G_DL1;
2589
         public System.Windows.Forms.NumericUpDown numericUpDown_ATT_3_5G_UL;
2588
         public System.Windows.Forms.NumericUpDown numericUpDown_ATT_3_5G_UL;
2590
         public System.Windows.Forms.NumericUpDown numericUpDown_ATT_3_5G_DL;
2589
         public System.Windows.Forms.NumericUpDown numericUpDown_ATT_3_5G_DL;
@@ -2698,6 +2697,7 @@
2698
         private System.Windows.Forms.Label label38;
2697
         private System.Windows.Forms.Label label38;
2699
         private System.Windows.Forms.Label label23;
2698
         private System.Windows.Forms.Label label23;
2700
         private System.Windows.Forms.Button button_Save;
2699
         private System.Windows.Forms.Button button_Save;
2700
+        public System.Windows.Forms.Timer timer;
2701
     }
2701
     }
2702
 }
2702
 }
2703
 
2703
 

+ 47 - 3
Basic_Terminal/Wnd/Main_Form.cs

@@ -104,11 +104,34 @@ namespace RF_TRIO_PLL_ZIG
104
             this.pictureBox_R_RX.Visible = true;
104
             this.pictureBox_R_RX.Visible = true;
105
             this.pictureBox_G_RX.Visible = false;
105
             this.pictureBox_G_RX.Visible = false;
106
         }
106
         }
107
-        Int64 TimerCnt = 0;
107
+
108
+        Int64 Timer_Cnt = 0;
109
+        Int32 ReqTimer_Cnt = 0;
110
+        public bool TX_RX_Light = false;
111
+       
112
+        
108
         private void timer_Tick(object sender, EventArgs e)
113
         private void timer_Tick(object sender, EventArgs e)
109
         {
114
         {
110
-            TimerCnt++;
111
-            if (TimerCnt > 500)
115
+            Update_Serial update_Serial = null;
116
+            bool req_set = false;
117
+
118
+            if(update_Serial == null)
119
+            {
120
+                update_Serial = (Update_Serial)serial.FileDownloadClass_Get();
121
+                if (update_Serial == null)
122
+                    req_set = true;
123
+                else if(update_Serial.Update_ready == false)
124
+                    req_set = true;
125
+            }
126
+            if (req_set)
127
+            {
128
+                ReqTimer_Cnt++;
129
+            }
130
+            if (TX_RX_Light == true)
131
+            {
132
+                Timer_Cnt++;
133
+            }
134
+            if (Timer_Cnt < 1000)
112
             {
135
             {
113
                 if (this.pictureBox_G_TX.Visible == true)
136
                 if (this.pictureBox_G_TX.Visible == true)
114
                 {
137
                 {
@@ -118,6 +141,13 @@ namespace RF_TRIO_PLL_ZIG
118
                 {
141
                 {
119
                     RX_Light_OFF();
142
                     RX_Light_OFF();
120
                 }
143
                 }
144
+                Timer_Cnt = 0;
145
+                TX_RX_Light = false;
146
+            }
147
+          if(ReqTimer_Cnt > 6)
148
+            {
149
+                bluecell_BootProtocol.Bluecell_RF_Status_Req(serial);
150
+                ReqTimer_Cnt = 0;
121
             }
151
             }
122
         }
152
         }
123
         private void Main_Form_Load(object sender, EventArgs e)
153
         private void Main_Form_Load(object sender, EventArgs e)
@@ -475,6 +505,16 @@ namespace RF_TRIO_PLL_ZIG
475
                     {
505
                     {
476
                         this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
506
                         this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
477
                     }
507
                     }
508
+
509
+                    if (data[(int)Bluecell_TypeIndex_t.T_SYNC_DL] > 0)
510
+                    {
511
+                        TDD_T_SYNC_Get();
512
+                        //this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, true);
513
+                    }
514
+                    else
515
+                    {
516
+                        //this.Invoke(new PictureBoxSend(PictureBox_On_OFF_Set), pic_on, pic_off, false);
517
+                    }
478
                     // this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2]);
518
                     // this.Invoke(new StringSend(numeric_Text_Set), numericUpDown_ATT_1_8G_DL2, data[(int)Bluecell_TypeIndex_t.ATT_1_8G_DL2]);
479
 
519
 
480
                 }
520
                 }
@@ -545,6 +585,10 @@ namespace RF_TRIO_PLL_ZIG
545
 
585
 
546
             pictureBox_TDD_T_SYNC_UL_ON.Visible = !pictureBox_TDD_T_SYNC_UL_ON.Visible;
586
             pictureBox_TDD_T_SYNC_UL_ON.Visible = !pictureBox_TDD_T_SYNC_UL_ON.Visible;
547
             pictureBox_TDD_T_SYNC_DL_OFF.Visible = !pictureBox_TDD_T_SYNC_DL_OFF.Visible;
587
             pictureBox_TDD_T_SYNC_DL_OFF.Visible = !pictureBox_TDD_T_SYNC_DL_OFF.Visible;
588
+        }
589
+        private void TDD_T_SYNC_Get()
590
+        {
591
+
548
         }
592
         }
549
         const byte PATH_1_8G_DL_ON = 1;
593
         const byte PATH_1_8G_DL_ON = 1;
550
         const byte PATH_1_8G_DL_OFF = 2;
594
         const byte PATH_1_8G_DL_OFF = 2;