修改crc验证,hmi使用内置的crc校验

check
Zeng wei (曾威) 2 years ago
parent a9b22757ef
commit 17379dd00e

@ -533,9 +533,9 @@ void RS485_1_Upload_Params(void)
// bufcut_Init(sendbuf_crc, sendbuf, 3, 31); // bufcut_Init(sendbuf_crc, sendbuf, 3, 31);
// GetCRC16(sendbuf_crc, 28, &crc_num1, &crc_num2); // GetCRC16(sendbuf_crc, 28, &crc_num1, &crc_num2);
GetCRC16(sendbuf, 56, &crc_num1, &crc_num2); GetCRC16(sendbuf + 1, 55, &crc_num1, &crc_num2);
sendbuf[56] = crc_num1; sendbuf[56] = crc_num2;
sendbuf[57] = crc_num2; sendbuf[57] = crc_num1;
// u8 tmpabc[] = {0xAA, 0xBB, 0xCC}; // u8 tmpabc[] = {0xAA, 0xBB, 0xCC};
// RS485_1_Send_Data(tmpabc, 3); // RS485_1_Send_Data(tmpabc, 3);
@ -562,7 +562,7 @@ void RS485_1_sync_env_params(void)
NUM += 1; NUM += 1;
if (NUM > 6) if (NUM > 6)
NUM = 1; NUM = 1;
GetCRC16(batchbuf, 4, batchbuf + 4, batchbuf + 5); GetCRC16(batchbuf + 1, 3, batchbuf + 5, batchbuf + 4);
for (t = 0; t < 10; t++) for (t = 0; t < 10; t++)
{ {
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)

@ -322,6 +322,7 @@ void Sensor_Communication_task(void *pvParameters)
RS485_1_Send_Data_1(RS485_DATA_TMP, 22); RS485_1_Send_Data_1(RS485_DATA_TMP, 22);
RX_BUF_Transfer(0, 18); RX_BUF_Transfer(0, 18);
light_set_all(); light_set_all();
RS485_1_Upload_Params();
} }
else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB6 && RS485_RX_BUF_COPY[2] == 0x03 && CRC16_check(RS485_RX_BUF_COPY, 7) == 1) else if (RS485_RX_BUF_COPY[0] == 0xEE && RS485_RX_BUF_COPY[1] == 0xB6 && RS485_RX_BUF_COPY[2] == 0x03 && CRC16_check(RS485_RX_BUF_COPY, 7) == 1)
{ {

Loading…
Cancel
Save