From 17379dd00e3576370596ecd2ef6076f72a1d7d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zeng=20wei=20=28=E6=9B=BE=E5=A8=81=29?= Date: Sat, 11 May 2024 11:05:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9crc=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=EF=BC=8Chmi=E4=BD=BF=E7=94=A8=E5=86=85=E7=BD=AE=E7=9A=84crc?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HARDWARE/rs485.c | 8 ++++---- myfreertos/myfreertos.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/HARDWARE/rs485.c b/HARDWARE/rs485.c index b40d20c..39d9271 100644 --- a/HARDWARE/rs485.c +++ b/HARDWARE/rs485.c @@ -533,9 +533,9 @@ void RS485_1_Upload_Params(void) // bufcut_Init(sendbuf_crc, sendbuf, 3, 31); // GetCRC16(sendbuf_crc, 28, &crc_num1, &crc_num2); - GetCRC16(sendbuf, 56, &crc_num1, &crc_num2); - sendbuf[56] = crc_num1; - sendbuf[57] = crc_num2; + GetCRC16(sendbuf + 1, 55, &crc_num1, &crc_num2); + sendbuf[56] = crc_num2; + sendbuf[57] = crc_num1; // u8 tmpabc[] = {0xAA, 0xBB, 0xCC}; // RS485_1_Send_Data(tmpabc, 3); @@ -562,7 +562,7 @@ void RS485_1_sync_env_params(void) NUM += 1; if (NUM > 6) NUM = 1; - GetCRC16(batchbuf, 4, batchbuf + 4, batchbuf + 5); + GetCRC16(batchbuf + 1, 3, batchbuf + 5, batchbuf + 4); for (t = 0; t < 10; t++) { while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) diff --git a/myfreertos/myfreertos.c b/myfreertos/myfreertos.c index 67bd4e7..3ec827f 100644 --- a/myfreertos/myfreertos.c +++ b/myfreertos/myfreertos.c @@ -322,6 +322,7 @@ void Sensor_Communication_task(void *pvParameters) RS485_1_Send_Data_1(RS485_DATA_TMP, 22); RX_BUF_Transfer(0, 18); 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) {