SYSTEM MONITOR¶
1. Overview¶
The SDK built-in component system monitoring is a particularly important component in the system. It is responsible for monitoring and controlling every task that is added to the monitoring queue, in case of any exception to a task, and to avoid losses caused by failure to handle exceptions in a timely manner. This component is based on the hardware watchdog, and on this basis, it realizes the monitoring strategy of monitoring multiple tasks at the same time to ensure the normal and stable operation of the system.
2. Source file¶
| Filename | Description |
|---|---|
| ci130x_task_monitor.c | Specific implementation |
| ci130x_task_monitor.h | User API |
3. Flow Chart¶
Figure 3-1 Flowchart
- The related macro configuration is described as follows:
/*The maximum number of monitoring tasks is 23*/
#define MONITOR_TAST_MAX_COUNT (23)/* Range: 0 - 23 Reasonable setting according to the actual situation*/
/*Monitoring cycle (unit: MS)*/
#define MONITOR_PERIOD (1000)
- Relevant API interfaces are as follows:
| Function | Description |
|---|---|
| monitor_Create | Monitoring event group creation function |
| join_Monitor | Add monitoring functions to tasks |
| exit_Monitor | Task exit monitoring |
| task_alive | Monitored task reporting function |
| task_Monitor | Monitoring task function |
4. Example:¶
#include "ci130x_task_monitor.h"
uint8_t vTask_test1_id,vTask_test2_id,vTask_test3_id;
void vTask_test1(void *pvParameters)
{
int count = 0;
for(;;)
{
vTaskDelay(pdMS_TO_TICKS(500));
count++;
task_alive(vTask_test1_id);
}
}
void vTask_test2(void *pvParameters)
{
int count = 0;
for(;;)
{
vTaskDelay(pdMS_TO_TICKS(4000));
count++;
task_alive(vTask_test2_id);
}
}
void vTask_test3(void *pvParameters)
{
int count = 0;
for(;;)
{
vTaskDelay(pdMS_TO_TICKS(12000));
count++;
task_alive(vTask_test3_id);
}
}
void call_back(void)
{
mprintf("call back func\n");
}
void iwdg_test(void)
{
monitor_creat(call_back);
TaskHandle_t task1_handle = NULL,task2_handle = NULL,task3_handle = NULL;
xTaskCreate(vTask_test1,"vTask_test1",256,NULL,1,&task1_handle);
join_monitor(&vTask_test1_id,1000,task1_handle);
xTaskCreate(vTask_test2,"vTask_test2",256,NULL,2,&task2_handle);
join_monitor(&vTask_test2_id,5000,task2_handle);
xTaskCreate(vTask_test3,"vTask_test3",256,NULL,3,&task3_handle);
join_monitor(&vTask_test3_id,10000,task3_handle);
xTaskCreate(task_monitor,"task_monitor",256,NULL,4,NULL);
}
