SYS 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¶
File name | Description |
---|---|
ci110x_ task_ monitor. C | Specific implementation |
ci110x_ 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 "ci110x_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);
}