添加扩展任务 用于小板端执行异常判定
ew程序下载批量验证成功
This commit is contained in:
@@ -266,3 +266,7 @@
|
||||
2023.11.16
|
||||
完成方案中updata调试,支持不处于bootloader中时自动跳转至bootloader
|
||||
单块板验证成功,批量验证失败
|
||||
2023.11.17
|
||||
添加扩展任务 用于小板端执行异常判定
|
||||
ew程序下载批量验证成功
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include "interface/JQChecker.h"
|
||||
#include "interface/XTChecker.h"
|
||||
#include "interface/EWChecker.h"
|
||||
#include "interface/CheckerExt.h"
|
||||
|
||||
|
||||
#define PLAN_MAX_TASK 64
|
||||
@@ -31,13 +32,22 @@
|
||||
|
||||
typedef struct{
|
||||
CheckerTask_Info_st* task_info_array[PLAN_MAX_TASK];//方案参数结构体指针
|
||||
const uint8_t* taskid_table;
|
||||
CheckerTask *tasks_fun_table[3];
|
||||
CheckerTask_Info_st *task_par;
|
||||
CheckerTask task_fun;
|
||||
uint8_t chip_type;
|
||||
int task_index;
|
||||
int task_num;
|
||||
int scheme_inited;
|
||||
array_def *data;
|
||||
}self_def;
|
||||
|
||||
|
||||
static self_def g_self;
|
||||
static self_def g_self={
|
||||
.taskid_table=(uint8_t*)(APP_TEST_PLAN_ADDR+4),
|
||||
.tasks_fun_table={jqtaskArray,xttaskArray,ewtaskArray},
|
||||
};
|
||||
|
||||
|
||||
static int elec_check_scheme(void);
|
||||
@@ -378,16 +388,22 @@ static int elec_code_load_param(array_def *uid_psw)
|
||||
}
|
||||
|
||||
// 检测 准备参数
|
||||
static int elec_check_load_task_param(uint8_t taskid,
|
||||
CheckerTask_Info_st *task_par,CheckerTask task_fun)
|
||||
CheckerTask elec_get_task_fun(CheckerTask *tasks_fun_table[],uint8_t chip_type,uint8_t taskid);
|
||||
int elec_check_load_task_param(uint8_t task_index)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
uint8_t taskid;
|
||||
CheckerTask_Info_st *task_par;
|
||||
taskid=s->taskid_table[task_index];
|
||||
s->task_fun=elec_get_task_fun(s->tasks_fun_table,s->chip_type,taskid);
|
||||
task_par= s->task_info_array[task_index];
|
||||
memset(&checker_runcfg.task_info,0,sizeof(CheckerTask_Info_st));
|
||||
memset(checker_runcfg.params,0,20);
|
||||
checker_runcfg.param_count = 0;//参数个数
|
||||
checker_runcfg.rtv_count = 0;//返回值个数
|
||||
checker_runcfg.excue_rtv = 0;
|
||||
checker_runcfg.task_info.retry_time = 0;
|
||||
if(taskid>=CHECKER_MAXID_COUNT){
|
||||
if(taskid>=(CHECKER_MAXID_COUNT+CHECKER_EXTID_COUNT)){
|
||||
DBG_WARN("taskid=%d out of bound.",taskid);
|
||||
return 1;
|
||||
}
|
||||
@@ -395,7 +411,7 @@ static int elec_check_load_task_param(uint8_t taskid,
|
||||
DBG_WARN("can not find task params.");
|
||||
return 2;
|
||||
}
|
||||
if(task_fun==0){
|
||||
if(s->task_fun==0){
|
||||
DBG_WARN("can not find task fun.");
|
||||
return 3;
|
||||
}
|
||||
@@ -407,6 +423,40 @@ static int elec_check_load_task_param(uint8_t taskid,
|
||||
memcpy(checker_runcfg.params,checker_runcfg.task_info.params,checker_runcfg.param_count*2);
|
||||
return 0;
|
||||
}
|
||||
// 根据任务id获取检测函数
|
||||
CheckerTask elec_get_task_fun(CheckerTask *tasks_fun_table[],uint8_t chip_type,uint8_t taskid)
|
||||
{
|
||||
CheckerTask task_fun=0;
|
||||
if(taskid<CHECKER_MAXID_COUNT){
|
||||
task_fun=tasks_fun_table[chip_type][taskid];
|
||||
}else if((taskid>=CHECKER_MAXID_COUNT)&&
|
||||
(taskid<(CHECKER_MAXID_COUNT+CHECKER_EXTID_COUNT)))
|
||||
{
|
||||
task_fun=exttaskArray[taskid-CHECKER_MAXID_COUNT];
|
||||
}
|
||||
return task_fun;
|
||||
}
|
||||
|
||||
// 执行任务
|
||||
void elec_exe_task(void)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
if(s->task_fun==0){
|
||||
return;
|
||||
}
|
||||
for(int i=0;i<1+s->task_par->retry_time;i++)
|
||||
{
|
||||
checker_runcfg.excue_rtv=1;
|
||||
s->task_fun();
|
||||
Checker_Excueindex(s->task_index);
|
||||
checker_runcfg.rtv_index-=checker_runcfg.rtv_count;
|
||||
if(checker_runcfg.excue_rtv==0)
|
||||
break;
|
||||
}
|
||||
checker_runcfg.rtv_index+=checker_runcfg.rtv_count;
|
||||
DBG_LOG("task_index:%d,taskid:%d,ret=%d,rtv_index=%d.",s->task_index,taskid,checker_runcfg.excue_rtv,
|
||||
checker_runcfg.rtv_index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -414,13 +464,11 @@ static int elec_check_load_task_param(uint8_t taskid,
|
||||
array_def *elec_check_with_scheme(array_def *uid_psw)
|
||||
{
|
||||
self_def *s=&g_self;
|
||||
const uint8_t* taskid_table = (uint8_t*)(APP_TEST_PLAN_ADDR+4);
|
||||
CheckerTask *tasks_fun_table[]={jqtaskArray,xttaskArray,ewtaskArray};
|
||||
CheckerTask_Info_st *task_par=0;
|
||||
uint8_t chip_type=0;
|
||||
s->task_par=0;
|
||||
s->chip_type=0;
|
||||
uint8_t taskid=0;
|
||||
CheckerTask task_fun=0;
|
||||
uint8_t res=0;
|
||||
s->task_index=0;
|
||||
array_def *r=arr_creat();
|
||||
if(s->scheme_inited==0){
|
||||
DBG_WARN("scheme not init.");
|
||||
@@ -430,50 +478,33 @@ array_def *elec_check_with_scheme(array_def *uid_psw)
|
||||
res=checker_runcfg.power_prapare_exe;
|
||||
memset(&checker_runcfg,0,sizeof(Checker_RunCfg_st));
|
||||
checker_runcfg.power_prapare_exe=res;
|
||||
chip_type=(board_st.plan_id >> 12 ) & 0x0F;
|
||||
s->chip_type=(board_st.plan_id >> 12 ) & 0x0F;
|
||||
if(elec_code_param_check(uid_psw)==1){
|
||||
elec_code_load_param(uid_psw);
|
||||
}
|
||||
|
||||
if(chip_type>=LENGTH(tasks_fun_table)){
|
||||
if(s->chip_type>=LENGTH(s->tasks_fun_table)){
|
||||
DBG_WARN("unknown chip type.");
|
||||
arr_append(r,2);
|
||||
return arr_temp(r);
|
||||
}
|
||||
int task_index=0;
|
||||
LED1_Out_Off;
|
||||
while(task_index<s->task_num){
|
||||
taskid=taskid_table[task_index];
|
||||
task_fun=tasks_fun_table[chip_type][taskid];
|
||||
task_par= s->task_info_array[task_index];
|
||||
if(elec_check_load_task_param(taskid,task_par,task_fun)){
|
||||
while(s->task_index<s->task_num){
|
||||
if(elec_check_load_task_param(s->task_index)){
|
||||
break;
|
||||
}
|
||||
|
||||
// 执行任务
|
||||
for(int i=0;i<1+task_par->retry_time;i++)
|
||||
{
|
||||
checker_runcfg.excue_rtv=1;
|
||||
task_fun();
|
||||
Checker_Excueindex(task_index);
|
||||
checker_runcfg.rtv_index-=checker_runcfg.rtv_count;
|
||||
if(checker_runcfg.excue_rtv==0)
|
||||
break;
|
||||
}
|
||||
checker_runcfg.rtv_index+=checker_runcfg.rtv_count;
|
||||
DBG_LOG("task_index:%d,taskid:%d,ret=%d,rtv_index=%d.",task_index,taskid,checker_runcfg.excue_rtv,
|
||||
checker_runcfg.rtv_index);
|
||||
elec_exe_task();
|
||||
|
||||
// 找寻下一个任务
|
||||
task_index++;
|
||||
s->task_index++;
|
||||
if(checker_runcfg.excue_rtv != 0){
|
||||
uint8_t err_to=checker_runcfg.task_info.error_jumpto;
|
||||
uint8_t temp;
|
||||
if(err_to==0xff) continue;
|
||||
if(err_to>s->task_num-1) err_to=s->task_num-1;
|
||||
for(;task_index<err_to;task_index++){
|
||||
Checker_MaskResult(1,task_index);
|
||||
temp=(s->task_info_array[task_index]->param_rtv_count >> 4) & 0x0F;
|
||||
for(;s->task_index<err_to;s->task_index++){
|
||||
Checker_MaskResult(1,s->task_index);
|
||||
temp=(s->task_info_array[s->task_index]->param_rtv_count >> 4) & 0x0F;
|
||||
checker_runcfg.rtv_index+=temp;
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,9 @@ array_def *elec_code(array_def *uid_psw);
|
||||
|
||||
|
||||
|
||||
int elec_check_load_task_param(uint8_t task_index);
|
||||
|
||||
void elec_exe_task(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -5,7 +5,7 @@
|
||||
#include "debug.h"
|
||||
#include "mystring.h"
|
||||
#include "elec_judge.h"
|
||||
|
||||
#include "interface/CheckerExt.h"
|
||||
|
||||
|
||||
// 通用异常判定逻辑
|
||||
@@ -381,6 +381,10 @@ void elec_judge(elec_judge_def *e,int task_num,uint8_t *exe_ack,
|
||||
task=&e->scheme->task[i];
|
||||
if(task->taskid<e->judge_fun_num){
|
||||
e->judge_fun_table[task->taskid](e,i,data);
|
||||
}else if((task->taskid>=CHECKER_MAXID_COUNT)&&
|
||||
(task->taskid<(CHECKER_MAXID_COUNT+CHECKER_EXTID_COUNT)))
|
||||
{
|
||||
// 忽略扩展任务
|
||||
}else{
|
||||
elec_add_errcode(e,6);
|
||||
}
|
||||
|
78
source/elec_det/interface/CheckerExt.c
Normal file
78
source/elec_det/interface/CheckerExt.c
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "dev_flash.h"
|
||||
#include "elec_judge.h"
|
||||
#include "CheckerExt.h"
|
||||
#include "basechecker.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 扩展的检测任务,这个文件下的任务是所有模块通用的
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*rc{
|
||||
计算异常
|
||||
par0:忽略的异常代码1
|
||||
par1:忽略的异常代码2
|
||||
par2~par9:同上
|
||||
return:无
|
||||
exe:如果计算的异常代码为不被忽略的异常,则此任务失败
|
||||
}*/
|
||||
static int calc_contain(uint16_t *arr,int arr_len,uint16_t item);
|
||||
void CheckerExt_CalcErr(void)
|
||||
{
|
||||
const scheme_def *sch=check_scheme();
|
||||
elec_judge_def *e=0;
|
||||
uint8_t marerr=0,suberr=0;
|
||||
if(sch->plan_id==0xffffffff){
|
||||
// 判定任务不存在,返回失败
|
||||
marerr=6;
|
||||
goto end;
|
||||
}
|
||||
e=malloc(sizeof(elec_judge_def));
|
||||
elec_judge(e,sch->task_num,checker_runcfg.Task_Result,
|
||||
checker_runcfg.Task_Excute,
|
||||
(uint8_t *)checker_runcfg.Test_Rtv,&marerr,&suberr);
|
||||
free(e);
|
||||
|
||||
end:
|
||||
if((marerr!=0)&&(calc_contain(checker_runcfg.params,checker_runcfg.param_count,marerr)==0)){
|
||||
Checker_MaskResult(1,checker_runcfg.task_info.runindex);
|
||||
}else{
|
||||
Checker_MaskResult(0,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
}
|
||||
static int calc_contain(uint16_t *arr,int arr_len,uint16_t item)
|
||||
{
|
||||
for(int i=0;i<arr_len;i++){
|
||||
if(arr[i]==item)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*rc{
|
||||
重新执行已执行的任务,
|
||||
任务执行结果会覆盖之前执行的那次,参数也使用之前的那个参数
|
||||
通过此任务调用的任务错误跳转无效
|
||||
par0:要执行的任务序号
|
||||
return:无
|
||||
exe:如果要执行的任务序号不小于此任务则此任务失败
|
||||
}*/
|
||||
//void CheckerExt_Repeat
|
||||
|
||||
|
||||
CheckerTask exttaskArray[CHECKER_EXTID_COUNT]={
|
||||
CheckerExt_CalcErr,
|
||||
};
|
||||
|
29
source/elec_det/interface/CheckerExt.h
Normal file
29
source/elec_det/interface/CheckerExt.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef CheckerExt_h__
|
||||
#define CheckerExt_h__
|
||||
|
||||
#include "basechecker.h"
|
||||
|
||||
|
||||
// 扩展的检测任务,这个文件下的任务是所有模块通用的
|
||||
|
||||
|
||||
#define CHECKER_EXTID_COUNT 10
|
||||
|
||||
|
||||
|
||||
|
||||
extern CheckerTask exttaskArray[CHECKER_EXTID_COUNT];
|
||||
|
||||
|
||||
void CheckerExt_CalcErr(void);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@@ -11,7 +11,7 @@
|
||||
#include "commend.h"
|
||||
#include "mystring.h"
|
||||
#include "mystdlib.h"
|
||||
|
||||
#include "interface/checkerext.h"
|
||||
|
||||
|
||||
#define EW_CHECKER_RUN_BUF 32
|
||||
@@ -857,6 +857,7 @@ EW_Test_VerifyFacBuff, //25验证缓存数据
|
||||
EW_Test_PowerOFF, //26 关总线
|
||||
EW_Updata, //27 升级
|
||||
EW_Test_ChgEnergy, //28 充能统计
|
||||
CheckerExt_CalcErr, //29 计算异常
|
||||
(void*)0 //数组结束
|
||||
};
|
||||
|
||||
|
@@ -403,7 +403,7 @@ void EW_Updata(void)
|
||||
ret=EW_TurnToBoot(&ew_updata);
|
||||
// ret!=1 跳转到bootloader失败
|
||||
if(ret!=1) {
|
||||
DBG_WARN("turn to boot bailed.ret=%d",ret);
|
||||
DBG_WARN("turn to boot failed.ret=%d",ret);
|
||||
ret=1;
|
||||
goto err;
|
||||
}
|
||||
@@ -435,12 +435,12 @@ void EW_Updata(void)
|
||||
ret=EW_EnWriteMTP(0,1);
|
||||
if(ret) {ret=7;goto err;}
|
||||
DBG_LOG("EW_EnWriteMTP success.");
|
||||
delay_ms(1);
|
||||
delay_ms(5);
|
||||
|
||||
ret=EW_WriteMTP(1,(uint8_t)(UPDATA_FLAG_ADDR/4),UPDATA_FLAG,4);
|
||||
if(ret) {ret=8;goto err;}
|
||||
DBG_LOG("EW_WriteMTP success.");
|
||||
delay_ms(1);
|
||||
delay_ms(20);
|
||||
ret=EW_ReadMTP(1,(uint8_t)(UPDATA_FLAG_ADDR/4),read_buf,4);
|
||||
if(ret) {ret=9;goto err;}
|
||||
if(memcmp(read_buf,UPDATA_FLAG,4)!=0){
|
||||
@@ -448,7 +448,7 @@ void EW_Updata(void)
|
||||
ret=10;goto err;
|
||||
}
|
||||
DBG_LOG("EW_ReadMTP check success.");
|
||||
delay_ms(1);
|
||||
delay_ms(5);
|
||||
XTBUS_OFF;
|
||||
delay_ms(ew_updata.time_poweroff);
|
||||
XTBUS_ON;
|
||||
|
@@ -1160,6 +1160,32 @@ void JQ_Test_VerifyFacBuff(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*rc{
|
||||
读延时,与otp中的值相比,不同则此任务失败
|
||||
|
||||
}*/
|
||||
void JQ_Test_VerifyDelay(void)
|
||||
{
|
||||
uint8_t ul_temp[4]={0};
|
||||
uint8_t uc_ack=0,uc_rtv=0;
|
||||
uint16_t us_delaytime=0xffff,us_temp;
|
||||
uc_ack = JQ_ReadOTP(CHECKER_NET_ID,15,2,ul_temp);
|
||||
if(uc_ack<2) {uc_rtv=1;goto end;}
|
||||
uc_ack |= JQ_ReadDelay(CHECKER_NET_ID,&us_delaytime);
|
||||
if(uc_ack<2) {uc_rtv=2;goto end;}
|
||||
if((((us_delaytime >> 8) & 0x0FF)==ul_temp[0])&&
|
||||
(((us_delaytime) & 0x0FF)==ul_temp[1]))
|
||||
{
|
||||
|
||||
}else{
|
||||
uc_rtv=3;goto end;
|
||||
}
|
||||
end:
|
||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
|
||||
CheckerTask jqtaskArray[CHECKER_MAXID_COUNT] ={
|
||||
Checker_PowerPrapare, //0 电源准备
|
||||
JQ_Test_PowerOn, //1 上电充能
|
||||
@@ -1198,6 +1224,7 @@ JQ_Test_WriteVersion ,//33 写模块版本
|
||||
JQ_Test_ReadVersion ,//34 读取版本号
|
||||
JQ_Test_WriteFacBuff ,//35 写缓存数据
|
||||
JQ_Test_VerifyFacBuff ,//36 验证缓存数据
|
||||
JQ_Test_VerifyDelay ,//37 读取延时值和otp数据相比
|
||||
(void*)0 //数组结束
|
||||
};
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
#define BUILD_DATE "2023-11-16 17:26:38"
|
||||
#define BUILD_DATE "2023-11-18 14:06:40"
|
||||
#define SOFT_VERSION "2.06"
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user