ソースを参照

DTC - BLUECELL Protocol 연동 Test 종료

PYJ 5 年 前
コミット
af2a0336f2
共有6 個のファイルを変更した827 個の追加714 個の削除を含む
  1. 23 20
      Bluecell_Inc/Bluecell_operate.h
  2. 2 0
      Bluecell_Inc/uart.h
  3. 724 643
      Bluecell_Src/Bluecell_operate.c
  4. 46 43
      Bluecell_Src/CRC.c
  5. 24 7
      Bluecell_Src/uart.c
  6. 8 1
      Src/main.c

+ 23 - 20
Bluecell_Inc/Bluecell_operate.h

@@ -116,7 +116,7 @@ typedef enum{
116 116
 };
117 117
 
118 118
 typedef enum{
119
-	Alarm_Bit_List = 0xE000,
119
+	Alarm_Bit_List = 0x00,
120 120
 	Alarm_Mask,
121 121
 	Alarm_Test_Mode,
122 122
 	Alarm_Test_Dummy,
@@ -134,7 +134,7 @@ typedef enum{
134 134
 	Factory_Set_Initialization,
135 135
 }SERIAL_ModuleINFORMATION;
136 136
 typedef enum{
137
-    Temperature = 0xE010,
137
+    Temperature = 0x10,
138 138
     Temperature_Offset,
139 139
     Temp_High_Threshold,
140 140
     Temp_High_Threshold_Default,
@@ -152,7 +152,7 @@ typedef enum{
152 152
     Carrier_ON_OFF,
153 153
 }SERIAL_ENVIRONMENT_INVENTORY_t;
154 154
 typedef enum{
155
-    DLI_P1_Level = 0xE020,
155
+    DLI_P1_Level = 0x20,
156 156
     DLI_P2_Level,
157 157
     DLI_P3_Level,
158 158
     DLI_P4_Level,
@@ -162,6 +162,8 @@ typedef enum{
162 162
     ULO_P4_Level,
163 163
 
164 164
 }SERIAL_Current_Volt_t;
165
+
166
+
165 167
 typedef struct{
166 168
     bool AGC1_En;
167 169
     bool AGC2_En;
@@ -320,7 +322,7 @@ typedef struct{
320 322
     int8_t DET_UL_45;
321 323
 }ALC_dBm_t;
322 324
 typedef enum{
323
-DLI_RF_Path1_ON_OFF = 0xE030,
325
+DLI_RF_Path1_ON_OFF = 0x30,
324 326
 DLI_RF_Path2_ON_OFF,
325 327
 DLI_RF_Path3_ON_OFF,
326 328
 DLI_RF_Path4_ON_OFF,
@@ -336,7 +338,7 @@ DLI_Level_High_Threshold,
336 338
 DLI_Level_Low_Threshold,
337 339
 DLI_Level_High_Low_Threshold_default,
338 340
 DLI_Level,
339
-DLI_Level_High_Alarm1=0xE040,
341
+DLI_Level_High_Alarm1=0x40,
340 342
 DLI_Level_High_Alarm2,
341 343
 DLI_Level_High_Alarm3,
342 344
 DLI_Level_High_Alarm4,
@@ -348,7 +350,7 @@ SERIAL_DL_NULL0,
348 350
 DLI_FRBT_Atten,
349 351
 DLI_FRBT_D_Day,
350 352
 DLI_FRBT_Status,
351
-DLI_AGC_ON_OFF=0xE050,
353
+DLI_AGC_ON_OFF=0x50,
352 354
 DLI_AGC_Threshold,
353 355
 DLI_AGC_Threshold_Default,
354 356
 DLI_Shutdown_ON_OFF,
@@ -367,10 +369,10 @@ DLI_Shutdown_Alarm4,
367 369
 
368 370
 }SERIAL_DL_t;
369 371
 typedef enum{
370
-ULO_RF_Path1_ON_OFF1 = 0xE060,
371
-ULO_RF_Path2_ON_OFF2,
372
-ULO_RF_Path3_ON_OFF3,
373
-ULO_RF_Path4_ON_OFF4,
372
+ULO_RF_Path1_ON_OFF = 0x60,
373
+ULO_RF_Path2_ON_OFF,
374
+ULO_RF_Path3_ON_OFF,
375
+ULO_RF_Path4_ON_OFF,
374 376
 ULO_Gain_Atten1,
375 377
 ULO_Gain_Atten2,
376 378
 ULO_Gain_Atten3,
@@ -383,12 +385,12 @@ ULO_Level_High_Threshold,
383 385
 SERIAL_UL_NULL0,
384 386
 ULO_Level_High_Threshold_default,
385 387
 ULO_Level,
386
-ULO_Level_High_Alarm1=0xE070,
388
+ULO_Level_High_Alarm1=0x70,
387 389
 ULO_Level_High_Alarm2,
388 390
 ULO_Level_High_Alarm3,
389 391
 ULO_Level_High_Alarm4,
390 392
 SERIAL_UL_NULL1,
391
-ULO_ALC_ON_OFF=0xE080,
393
+ULO_ALC_ON_OFF=0x80,
392 394
 ULO_ALC_Threshold,
393 395
 ULO_ALC_Threshold_Default,
394 396
 ULO_Shutdown_ON_OFF,
@@ -410,7 +412,7 @@ ULO_Shutdown_Alarm4,
410 412
 #define RETRYCNT_MAX 4
411 413
 
412 414
 
413
-#define MBIC_HEADER_SIZE 18
415
+#define MBIC_HEADER_SIZE 22
414 416
 #define MBIC_PREAMBLE0 0x16
415 417
 #define MBIC_PREAMBLE1 0x16
416 418
 #define MBIC_PREAMBLE2 0x16
@@ -425,10 +427,11 @@ ULO_Shutdown_Alarm4,
425 427
 #define MBIC_ERRRESPONSE 0x00
426 428
 #define MBIC_CMD
427 429
 #define MBIC_LENGTH
428
-#define MBIC_CHECKSHUM_INDEX MBIC_HEADER_SIZE - 2 //CheckSUM REMOVE INDEX
430
+#define MBIC_CHECKSHUM_INDEX MBIC_HEADER_SIZE - 1 //CheckSUM REMOVE INDEX
429 431
 #define MBIC_ETX 0x03
430 432
 #define MBIC_NODE_MU 0x80
431 433
 
434
+#define MBIC_CPUVERSION 0x000000
432 435
 
433 436
 
434 437
 enum DATATYPE
@@ -719,10 +722,16 @@ typedef struct{
719 722
     uint8_t ALARM_ULO_Level;
720 723
     uint8_t ALARM_ULO_SHTUTDOWN;
721 724
     uint8_t ALARM_MASK1;
725
+    uint8_t ALARM_MASK2;
726
+    uint8_t ALARM_MASK3;
727
+    uint8_t ALARM_MASK4;
728
+    uint8_t ALARM_MASK5;
722 729
     uint8_t ALARM_TESTMODE;
723 730
     uint8_t ALARM_Test_Dummy1;
724 731
     uint8_t ALARM_Test_Dummy2;
725 732
     uint8_t ALARM_Test_Dummy3;
733
+    uint8_t ALARM_Test_Dummy4;
734
+    uint8_t ALARM_Test_Dummy5;    
726 735
     uint8_t CPUVERSION1;
727 736
     uint8_t CPUVERSION2;
728 737
     uint8_t CPUVERSION3;
@@ -801,12 +810,6 @@ typedef struct{
801 810
     uint8_t ULO_Level_High_Threshold_H;
802 811
     uint8_t ULO_Level_High_Threshold_L;
803 812
     uint8_t ULO_Level_High_Threshold_default;
804
-    uint8_t BLUECELL_RESERVE22;//ADC3   5
805
-    uint8_t BLUECELL_RESERVE23;//ADC3   5
806
-    uint8_t BLUECELL_RESERVE24;//ADC3   6 
807
-    uint8_t BLUECELL_RESERVE25;//ADC3   6
808
-    uint8_t BLUECELL_RESERVE26;//ADC3   7
809
-    uint8_t BLUECELL_RESERVE27;//ADC3   7
810 813
     uint8_t BLUECELL_RESERVE28;//ADC3   8   
811 814
     uint8_t BLUECELL_RESERVE29;//ADC3   8
812 815
     uint8_t BLUECELL_RESERVE30;//ADC1   4  

+ 2 - 0
Bluecell_Inc/uart.h

@@ -11,6 +11,8 @@
11 11
 #include <stdbool.h>
12 12
 #include "main.h"
13 13
 #define hTerminal    huart1
14
+#define hTest    huart2
15
+
14 16
 
15 17
 #define QUEUE_BUFFER_LENGTH 1024
16 18
 

File diff suppressed because it is too large
+ 724 - 643
Bluecell_Src/Bluecell_operate.c


+ 46 - 43
Bluecell_Src/CRC.c

@@ -10,40 +10,42 @@
10 10
 /*---------------------------------------------------------------------------------------*/
11 11
 #include <CRC.h>
12 12
 #include "uart.h"
13
-const unsigned short Table_CRC16[]  = {
14
-	0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
15
-	0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
16
-	0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
17
-	0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
18
-	0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
19
-	0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
20
-	0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
21
-	0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
22
-	0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
23
-	0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
24
-	0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
25
-	0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
26
-	0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
27
-	0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
28
-	0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
29
-	0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
30
-	0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
31
-	0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
32
-	0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
33
-	0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
34
-	0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
35
-	0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
36
-	0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
37
-	0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
38
-	0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
39
-	0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
40
-	0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
41
-	0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
42
-	0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
43
-	0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
44
-	0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
45
-	0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
46
-};
13
+	
14
+uint16_t crc16_tab[256] = {				
15
+    0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,				
16
+    0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,				
17
+    0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,				
18
+    0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,				
19
+    0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,				
20
+    0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,				
21
+    0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,				
22
+    0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,				
23
+    0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,				
24
+    0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,				
25
+    0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,				
26
+    0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,				
27
+    0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,				
28
+    0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,				
29
+    0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,				
30
+    0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,				
31
+    0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,				
32
+    0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,				
33
+    0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,				
34
+    0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,				
35
+    0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,				
36
+    0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,				
37
+    0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,				
38
+    0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,				
39
+    0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,				
40
+    0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,				
41
+    0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,				
42
+    0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,				
43
+    0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,				
44
+    0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,				
45
+    0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,				
46
+    0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0				
47
+};				
48
+
47 49
 
48 50
 //-----------------------------------------------
49 51
 //UART CRC üũ �Լ�
@@ -56,7 +58,7 @@ unsigned short genCRC16(char *buf_ptr, int len)
56 58
 	len *= 8;
57 59
 	for(crc16 = (unsigned short)0x0000; len >= 8; len -= 8, buf_ptr++)
58 60
 	{
59
-		crc16 = (unsigned short)(Table_CRC16[(crc16>>8) ^ (unsigned short)(*buf_ptr)] ^ (crc16<<8));
61
+		crc16 = (unsigned short)(crc16_tab[(crc16>>8) ^ (unsigned short)(*buf_ptr)] ^ (crc16<<8));
60 62
 	}
61 63
 
62 64
 	if(len != 0)
@@ -128,23 +130,24 @@ bool Chksum_Check(uint8_t *data, uint32_t leng,uint8_t chkdata)
128 130
 {
129 131
    uint8_t dataret = 0;
130 132
    bool ret = false;
131
-   for(int i = 0; i < leng; i++){
133
+   for(int i = MBIC_SUBUID_0; i < MBIC_HEADERCHECKSUM_0; i++){
132 134
         dataret += data[i];
133 135
    }
134 136
    if(dataret == chkdata){
135 137
         ret = true;
136 138
    }
137
-    
139
+//    printf("dataret : %x   chkdata : %x \r\n",dataret,chkdata);
138 140
     return ret;
139 141
 }
140
-uint8_t Chksum_Create(uint8_t *data, uint32_t leng)
142
+uint8_t Chksum_Create(uint8_t *data)
141 143
 {
142 144
    uint8_t dataret = 0;
143 145
 
144
-   for(int i = 0; i < leng; i++){
146
+   for(int i = MBIC_SUBUID_0; i < MBIC_HEADERCHECKSUM_0; i++){
145 147
         dataret += data[i];
148
+//        printf("dataret : %x data[%d] : %x \r\n",dataret,i,data[i]);
146 149
    }
147
-    
150
+//    printf("dataret : %x \r\n",dataret);
148 151
     return dataret;
149 152
 }
150 153
 
@@ -154,7 +157,7 @@ etError CRC16_Check(uint8_t* buf_ptr, int len,uint16_t checksum)
154 157
 {
155 158
     uint16_t crc = 0;
156 159
     for (uint32_t counter = 0; counter < len; counter++)
157
-        crc = (uint16_t)((crc << 8) ^ Table_CRC16[(uint32_t)(((crc >> 8) ^ buf_ptr[counter]) & 0x00FF)]);
160
+        crc = (uint16_t)((crc << 8) ^ crc16_tab[(uint32_t)(((crc >> 8) ^ buf_ptr[counter]) & 0x00FF)]);
158 161
 
159 162
     return (crc == checksum ? CHECKSUM_ERROR : NO_ERROR);
160 163
 }
@@ -162,8 +165,8 @@ uint16_t CRC16_Generate(uint8_t* buf_ptr, int len)
162 165
 {
163 166
     uint16_t crc = 0;
164 167
     for (uint32_t counter = 0; counter < len; counter++)
165
-        crc = (uint16_t)((crc << 8) ^ Table_CRC16[(uint32_t)(((crc >> 8) ^ buf_ptr[counter]) & 0x00FF)]);
166
-
168
+        crc = (uint16_t)((crc << 8) ^ crc16_tab[(uint32_t)(((crc >> 8) ^ buf_ptr[counter]) & 0x00FF)]);
169
+//    printf("len : %d \r\n",len);
167 170
     return crc;
168 171
 }   
169 172
 

+ 24 - 7
Bluecell_Src/uart.c

@@ -24,6 +24,10 @@ void InitUartQueue(pUARTQUEUE pQueue)
24 24
   uart_hal_tx.output_p = uart_hal_tx.input_p = 0;
25 25
   if (HAL_UART_Receive_DMA(&hTerminal, TerminalQueue.Buffer, 1) != HAL_OK)
26 26
   {
27
+//    _Error_Handler(__FILE__, __LINE__);
28
+  }  
29
+  if (HAL_UART_Receive_DMA(&hTest, TerminalQueue.Buffer, 1) != HAL_OK)
30
+  {
27 31
 //    _Error_Handler(__FILE__, __LINE__);
28 32
   }
29 33
   //HAL_UART_Receive_DMA(&hTerminal,  TerminalQueue.Buffer, 1);
@@ -32,8 +36,10 @@ void InitUartQueue(pUARTQUEUE pQueue)
32 36
 
33 37
 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
34 38
 {
39
+//    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hTest:&hTerminal);
35 40
     pUARTQUEUE pQueue;
36 41
    // printf("Function : %s : \r\n",__func__);
42
+    //printf("%02x ",uart_buf[i]);
37 43
     UartRxTimerCnt = 0;
38 44
     pQueue = &TerminalQueue;
39 45
     pQueue->head++;
@@ -42,6 +48,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
42 48
     if (pQueue->data >= QUEUE_BUFFER_LENGTH)
43 49
         GetDataFromUartQueue(huart);
44 50
     HAL_UART_Receive_DMA(&hTerminal, pQueue->Buffer + pQueue->head, 1);
51
+    HAL_UART_Receive_DMA(&hTest, pQueue->Buffer + pQueue->head, 1);
45 52
    // Set_UartRcv(true);
46 53
 }
47 54
 
@@ -62,9 +69,9 @@ volatile uint8_t uart_buf[QUEUE_BUFFER_LENGTH];
62 69
 void GetDataFromUartQueue(UART_HandleTypeDef *huart)
63 70
 {
64 71
     volatile static int cnt;
65
-
66
-    
67
-//    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hWifi:&hTerminal);
72
+    bool chksumret = 0;
73
+    uint16_t Length = 0;
74
+    UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hTest:&hTerminal);
68 75
 //    UART_HandleTypeDef *dst = &hTerminal;
69 76
     pUARTQUEUE pQueue = &TerminalQueue;
70 77
 //    if (HAL_UART_Transmit(dst, pQueue->Buffer + pQueue->tail, 1, 3000) != HAL_OK)
@@ -84,11 +91,11 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
84 91
 //        printf("data cnt zero !!!  \r\n");
85 92
         //RF_Ctrl_Main(&uart_buf[Header]);
86 93
 //        HAL_UART_Transmit(dst, &temp_buf[BLUECELL_HEADER00], 11, 3000);
87
-#if 0 // PYJ.2019.07.15_BEGIN --
94
+#if 1 // PYJ.2019.07.15_BEGIN --
88 95
             for(int i = 0; i < cnt; i++){
89 96
                 printf("%02x ",uart_buf[i]);
90 97
             }
91
-            printf("CNT : %d",cnt);
98
+            printf("                       CNT : %d \r\n",cnt);
92 99
 #endif // PYJ.2019.07.15_END --
93 100
             if(uart_buf[0] == 0xbe){
94 101
             	Bluecell_Operate(uart_buf);
@@ -96,8 +103,11 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
96 103
                    &&uart_buf[1] == MBIC_PREAMBLE1
97 104
                    &&uart_buf[2] == MBIC_PREAMBLE2
98 105
                    &&uart_buf[3] == MBIC_PREAMBLE3){
99
-               if(Chksum_Check(uart_buf,MBIC_HEADER_SIZE - 1,uart_buf[MBIC_CHECKSHUM_INDEX])){
100
-                    MBIC_Operate(uart_buf);
106
+                   
107
+               if(Chksum_Check(uart_buf,MBIC_HEADER_SIZE - 4,uart_buf[MBIC_CHECKSHUM_INDEX])){
108
+                Length = ((uart_buf[MBIC_LENGTH_0] << 8) | uart_buf[MBIC_LENGTH_1]);
109
+//                    if((CRC16_Check(&uart_buf[MBIC_PAYLOADSTART], Length,uart_buf[MBIC_PAYLOADSTART + Length]);  
110
+                        MBIC_Operate(uart_buf);
101 111
                }
102 112
                else{
103 113
                     printf("CHECK SUM ERR \r\n");
@@ -117,5 +127,12 @@ void Uart_Check(void){
117 127
 
118 128
 void Uart1_Data_Send(uint8_t* data,uint16_t size){
119 129
     HAL_UART_Transmit_DMA(&hTerminal, data,size); 
130
+    
131
+    printf("\r\n [TX]  ");
132
+    for(int i = 0; i< size; i++)
133
+        printf(" %02x",data[i]);
134
+    printf("COUNT : %d",size);
135
+    printf("\r\n");
136
+    
120 137
 }
121 138
 

+ 8 - 1
Src/main.c

@@ -147,7 +147,7 @@ void Pol_Delay_us(volatile uint32_t microseconds)
147 147
 
148 148
 int _write (int file, uint8_t *ptr, uint16_t len)
149 149
 {
150
-    HAL_UART_Transmit(&hTerminal, ptr, len,10);
150
+    HAL_UART_Transmit(&hTest, ptr, len,10);
151 151
     return len;
152 152
 }
153 153
 uint16_t adc1cnt = 0 ;
@@ -383,6 +383,11 @@ int main(void)
383 383
 //    eepromtest_j1();
384 384
 //        eepromtest_j1();
385 385
 
386
+//  uint8_t retdate[10] = {0,1,2,3,4,5,6,7,8,9};
387
+//    uint16_t rrrrrr = 0;
388
+//  rrrrrr = ((CRC16_Generate(&retdate[0], 10)));  
389
+  
390
+//  printf("CRC : %x \r\n",rrrrrr);
386 391
 
387 392
   while (1)
388 393
   {
@@ -395,6 +400,8 @@ int main(void)
395 400
     ALC_Function();    /*ALC Function*/
396 401
     AGC_Function();    /*AGC Function*/
397 402
     Alarm_Check();     /*Function to check all alarm status variables*/
403
+//    Uart1_Data_Send("A",1);
404
+//    HAL_Delay(500);
398 405
 
399 406
     /* USER CODE END WHILE */
400 407