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) {