添加写三码验三码任务,实现0x20任务,完成任务插槽机制

添加文件 tran_for_broadcast.c
This commit is contained in:
ranchuan
2023-12-18 18:17:21 +08:00
parent 8f28200ffe
commit 58c902a94f
13 changed files with 525 additions and 28 deletions

View File

@@ -57,6 +57,7 @@ void *task_slot_init(void)
t=calloc(1,sizeof(task_slot_def));
app_variable("task_slot",t,0);
}
t->current=t->head;
return t;
}
@@ -90,18 +91,35 @@ task_def *task_slot_next(void *context,uint8_t slot_index)
if(t==0){
return 0;
}
task_node *n;
while(t->current){
n=t->current;
t->current=n->next;
if(n->task.slot_index==slot_index){
return &n->task;
task_def *n;
while(n=task_slot_next_item(t),n!=0){
if(n->slot_index==slot_index){
return n;
}
}
return 0;
}
// 找到下一个
task_def *task_slot_next_item(void *context)
{
task_slot_def *t=context;
if(t==0){
return 0;
}
task_node *n=0;
if(t->current){
n=t->current;
t->current=n->next;
return &n->task;
}
return 0;
}
int task_slot_add_err(void *context,uint8_t err)
{
task_slot_def *t=context;
@@ -127,4 +145,16 @@ int task_slot_add_err(void *context,uint8_t err)
// 获取异常代码表
int task_slot_err_table(void *context,uint8_t **table)
{
task_slot_def *t=context;
if(t==0){
return 0;
}
if(table) *table=t->err_table;
return t->err_num;
}