Pārlūkot izejas kodu

MBIC CRC CHECK 함수 추가.

PYJ 5 gadi atpakaļ
vecāks
revīzija
e33006fde5
1 mainītis faili ar 3 papildinājumiem un 1 dzēšanām
  1. 3 1
      Bluecell_Src/uart.c

+ 3 - 1
Bluecell_Src/uart.c

@@ -71,6 +71,7 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
71
     volatile static int cnt;
71
     volatile static int cnt;
72
     bool chksumret = 0;
72
     bool chksumret = 0;
73
     uint16_t Length = 0;
73
     uint16_t Length = 0;
74
+    uint16_t CrcChk = 0;
74
     UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hTest:&hTerminal);
75
     UART_HandleTypeDef *dst = (huart->Instance == USART2 ? &hTest:&hTerminal);
75
 //    UART_HandleTypeDef *dst = &hTerminal;
76
 //    UART_HandleTypeDef *dst = &hTerminal;
76
     pUARTQUEUE pQueue = &TerminalQueue;
77
     pUARTQUEUE pQueue = &TerminalQueue;
@@ -106,7 +107,8 @@ void GetDataFromUartQueue(UART_HandleTypeDef *huart)
106
                    
107
                    
107
                if(Chksum_Check(uart_buf,MBIC_HEADER_SIZE - 4,uart_buf[MBIC_CHECKSHUM_INDEX])){
108
                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
                 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
+                CrcChk = ((uart_buf[MBIC_PAYLOADSTART + Length + 1] << 8) | (uart_buf[MBIC_PAYLOADSTART + Length + 2]));
111
+                    if((CRC16_Check(&uart_buf[MBIC_PAYLOADSTART], Length,CrcChk)
110
                         MBIC_Operate(uart_buf);
112
                         MBIC_Operate(uart_buf);
111
                }
113
                }
112
                else{
114
                else{