From 45da99e06a5d3ea25d30ad5c1ed9a427b51a838a Mon Sep 17 00:00:00 2001 From: 95384 <664090429@qq.com> Date: Sat, 7 Jun 2025 17:24:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=B3=E5=8C=97=E7=A8=B3=E6=8E=A7=E8=83=BD?= =?UTF-8?q?=E7=94=A8=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Src/anemometer_dev.c | 2 +- App/Src/frt_protocol.c | 7 ++++--- App/Src/uart_dev.c | 2 +- Drivers/RainLight/rain.c | 18 +++++++++++++----- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/App/Src/anemometer_dev.c b/App/Src/anemometer_dev.c index d96ebe5..5c54c3f 100644 --- a/App/Src/anemometer_dev.c +++ b/App/Src/anemometer_dev.c @@ -1074,7 +1074,7 @@ static void getTempHumiPress(void) float backupTemperature1; float temp; //采集MS5607并判错 - if(get_HP203_data(&temp, &g_stMcs_Para.pressure) != HAL_OK) + if(get_HP203_data(&temp, &g_stMcs_Para.pressure) != TRUE) { //置错误标志位 g_error_log.temp_error_HP203B = 1; diff --git a/App/Src/frt_protocol.c b/App/Src/frt_protocol.c index c884f6a..c8a83eb 100644 --- a/App/Src/frt_protocol.c +++ b/App/Src/frt_protocol.c @@ -411,7 +411,7 @@ static u_int16_t FRT_ReadRegPressure(void *pMsg) */ static u_int16_t FRT_ReadRegRain(void *pMsg) { - u_int16_t value=(u_int16_t)(g_stMcs_Para.precipitation); + u_int16_t value=(u_int16_t)(g_stMcs_Para.lightIntensity);//存的10倍 return FRT_swap_endian_16(value); } @@ -422,8 +422,9 @@ static u_int16_t FRT_ReadRegRain(void *pMsg) */ static u_int16_t FRT_ReadRegirradiance(void *pMsg) { - u_int16_t value = g_stMcs_Para.lightIntensity/10.0f; - return FRT_swap_endian_16(value); +// u_int16_t value = g_stMcs_Para.lightIntensity/10.0f; + u_int16_t value = 0; + return FRT_swap_endian_16(value); } ///** diff --git a/App/Src/uart_dev.c b/App/Src/uart_dev.c index 1173fd7..5a17b24 100644 --- a/App/Src/uart_dev.c +++ b/App/Src/uart_dev.c @@ -54,7 +54,7 @@ uart_device_info uart_devices[]={ [3] = { .init = 0, .uart_index = RAIN_RS485_UART_INDEX, - .uart_baudrate = 9600, + .uart_baudrate = 115200, }, }; diff --git a/Drivers/RainLight/rain.c b/Drivers/RainLight/rain.c index a1c8cc6..929404b 100644 --- a/Drivers/RainLight/rain.c +++ b/Drivers/RainLight/rain.c @@ -26,7 +26,7 @@ void getRainData(void) //ָ void clearRainData(void) { - uint8_t getRainDataCmd[] = {0x01, 0x06, 0x01, 0x05, 0x00, 0x00, 0x98, 0x37}; + uint8_t getRainDataCmd[] = {0x01, 0x06, 0x00, 0x49, 0x00, 0x00, 0x58, 0x1C, 0x01, 0x06, 0x00, 0x48, 0x00, 0x00, 0x09, 0xDC}; uart_dev_write(g_rain_uart_handle, getRainDataCmd, sizeof(getRainDataCmd)); } @@ -37,10 +37,17 @@ void getLightData(void) uart_dev_write(g_rain_uart_handle, getRainDataCmd, sizeof(getRainDataCmd)); } -//ͬʱȡָһգĸֽڣʮֽ +////ͬʱȡָһգĸֽڣʮֽ +//void getLightRainData(void) +//{ +// uint8_t getRainDataCmd[] = {0x01, 0x03, 0x00, 0x03, 0x00, 0x04, 0xB4, 0x09}; +// uart_dev_write(g_rain_uart_handle, getRainDataCmd, sizeof(getRainDataCmd)); +//} + +//ӱȿأȡ void getLightRainData(void) { - uint8_t getRainDataCmd[] = {0x01, 0x03, 0x00, 0x03, 0x00, 0x04, 0xB4, 0x09}; + uint8_t getRainDataCmd[] = {0x01, 0x03, 0x00, 0x48, 0x00, 0x02, 0x44, 0x1D}; uart_dev_write(g_rain_uart_handle, getRainDataCmd, sizeof(getRainDataCmd)); } @@ -109,9 +116,10 @@ static int read_rain_pack(device_handle uart_handle,u_int8_t *buff, u_int32_t bu * @param * @retval */ +/* 10 */ static void processLightData(u_int8_t *pMsg) { - uint32_t lightVal = pMsg[0]<<24|pMsg[1]<<16|pMsg[2]<<8|pMsg[3]; + uint32_t lightVal = pMsg[0]<<24|pMsg[1]<<16|pMsg[2]<<8|pMsg[3]*2;//0.2 g_stMcs_Para.lightIntensity = lightVal; // term_printf("lightVal:%d", lightVal); } @@ -182,7 +190,7 @@ static unsigned short CRC16(unsigned char *arr_buff, unsigned char len) * @retval */ #define RAIN_BUFF_CRC16(x) ((x[MsgLen - 2]) | (x[MsgLen - 1] << 8)) -static void rainMsgHandler(device_handle device, u_int8_t *pMsg, u_int32_t MsgLen) +void rainMsgHandler(device_handle device, u_int8_t *pMsg, u_int32_t MsgLen) { if(CRC16(pMsg, MsgLen-2) != RAIN_BUFF_CRC16(pMsg)) {