修复了大气压传感器损坏导致采集失败卡死程序的BUG

This commit is contained in:
95384 2024-12-12 16:55:09 +08:00
parent f4c1863621
commit 04d3a7085c
4 changed files with 14 additions and 12 deletions

View File

@ -883,12 +883,12 @@ void my_update_mcs_param(float new_wind_speed, float new_wind_dirction)
win_10min.speed_data[win_10min.index] = g_stMcs_Para.instantaneous_wind_speed; //添加新数据 win_10min.speed_data[win_10min.index] = g_stMcs_Para.instantaneous_wind_speed; //添加新数据
win_10min.direction_data[win_10min.index] = g_stMcs_Para.instantaneous_wind_direction; win_10min.direction_data[win_10min.index] = g_stMcs_Para.instantaneous_wind_direction;
if(win_10min.count < g_usrConfigInfo.speed_average_time /*AVE_TIME*/) if(win_10min.count < g_usrConfigInfo.speed_average_time)
{ {
win_10min.count++; win_10min.count++;
} }
if(win_10min.count > g_usrConfigInfo.speed_average_time/*AVE_TIME*/){win_10min.count = /*AVE_TIME*/g_usrConfigInfo.speed_average_time;} if(win_10min.count > g_usrConfigInfo.speed_average_time){win_10min.count = g_usrConfigInfo.speed_average_time;}
//计算10min风速滑动平均值 //计算10min风速滑动平均值
win_10min.ave_speed_data[win_10min.index] = sum(win_10min.speed_data, win_10min.count) / win_10min.count; win_10min.ave_speed_data[win_10min.index] = sum(win_10min.speed_data, win_10min.count) / win_10min.count;
//计算10min风向滑动平均值风向滑动平均值需要过零算法 //计算10min风向滑动平均值风向滑动平均值需要过零算法
@ -966,7 +966,7 @@ void my_update_mcs_param(float new_wind_speed, float new_wind_dirction)
g_stMcs_Para.trough_wind_direction = temp_trough_min_direction; g_stMcs_Para.trough_wind_direction = temp_trough_min_direction;
g_stMcs_Para.peak_wind_direction = temp_peak_max_direction; g_stMcs_Para.peak_wind_direction = temp_peak_max_direction;
win_10min.index = (win_10min.index + 1) % /*AVE_TIME*/g_usrConfigInfo.speed_average_time;//更新索引 win_10min.index = (win_10min.index + 1) % g_usrConfigInfo.speed_average_time;//更新索引
} }
void tem_hum_update_task(void const * argument) void tem_hum_update_task(void const * argument)

View File

@ -64,7 +64,7 @@
#define configTICK_RATE_HZ ((TickType_t)40) #define configTICK_RATE_HZ ((TickType_t)40)
#define configMAX_PRIORITIES ( 7 ) #define configMAX_PRIORITIES ( 7 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128) #define configMINIMAL_STACK_SIZE ((uint16_t)128)
#define configTOTAL_HEAP_SIZE ((size_t)20*1024) #define configTOTAL_HEAP_SIZE ((size_t)30*1024)
#define configMAX_TASK_NAME_LEN ( 16 ) #define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0
#define configUSE_MUTEXES 1 #define configUSE_MUTEXES 1

View File

@ -115,14 +115,14 @@ void MX_FREERTOS_Init(void) {
/* Create the thread(s) */ /* Create the thread(s) */
/* definition and creation of defaultTask */ /* definition and creation of defaultTask */
osThreadDef(defaultTask, StartDefaultTask, osPriorityRealtime, 0, 2048);//ͨѶ osThreadDef(defaultTask, StartDefaultTask, osPriorityRealtime, 0, 2*1024);//ͨѶ
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
osThreadDef(ledTask, LEDTask, osPriorityIdle, 0, 128);//LED osThreadDef(ledTask, LEDTask, osPriorityIdle, 0, 128);//LED
ledTaskHandle = osThreadCreate(osThread(ledTask), NULL); ledTaskHandle = osThreadCreate(osThread(ledTask), NULL);
/* USER CODE BEGIN RTOS_THREADS */ /* USER CODE BEGIN RTOS_THREADS */
osThreadDef(anemometer, wind_task, osPriorityHigh, 0, 2048);// ·çËÙ·çÏò osThreadDef(anemometer, wind_task, osPriorityHigh, 0, 2*1024);// ·çËÙ·çÏò
anemometerHandle = osThreadCreate(osThread(anemometer), NULL); anemometerHandle = osThreadCreate(osThread(anemometer), NULL);
osThreadDef(temhum_update_task, tem_hum_update_task, osPriorityAboveNormal, 0, 512);//温湿度,大气压更新 osThreadDef(temhum_update_task, tem_hum_update_task, osPriorityAboveNormal, 0, 512);//温湿度,大气压更新

View File

@ -100,17 +100,18 @@ BOOL get_HP203_data(float* tempdata, float* press)
} }
osDelay(1); osDelay(1);
} }
if(press_error_time >= COLLECT_HB203_DATA_NUM)
{
goto error_return;
}
U_DataType tmp_press = filter_middle(collect_pressure, COLLECT_HB203_DATA_NUM - press_error_time, FILTER_DATA_TYPE_FLOAT); U_DataType tmp_press = filter_middle(collect_pressure, COLLECT_HB203_DATA_NUM - press_error_time, FILTER_DATA_TYPE_FLOAT);
if(tmp_press.fValue < 300) if(tmp_press.fValue < 300)
{ {
tmp_press.fValue = 300;
// return FALSE; // return FALSE;
goto error_return; goto error_return;
} }
if(tmp_press.fValue > 1200) if(tmp_press.fValue > 1200)
{ {
tmp_press.fValue = 1200;
// return FALSE; // return FALSE;
goto error_return; goto error_return;
} }
@ -125,17 +126,18 @@ BOOL get_HP203_data(float* tempdata, float* press)
} }
osDelay(1); osDelay(1);
} }
if(temp_error_time >= COLLECT_HB203_DATA_NUM)
{
goto error_return;
}
U_DataType tmp_tempture = filter_middle(collect_tempture, COLLECT_HB203_DATA_NUM - temp_error_time, FILTER_DATA_TYPE_FLOAT); U_DataType tmp_tempture = filter_middle(collect_tempture, COLLECT_HB203_DATA_NUM - temp_error_time, FILTER_DATA_TYPE_FLOAT);
if(tmp_tempture.fValue < -40) if(tmp_tempture.fValue < -40)
{ {
tmp_tempture.fValue = -40;
// return FALSE; // return FALSE;
goto error_return; goto error_return;
} }
if(tmp_tempture.fValue > 85) if(tmp_tempture.fValue > 85)
{ {
tmp_tempture.fValue = 85;
// return FALSE; // return FALSE;
goto error_return; goto error_return;
} }