添加写三码验三码任务,实现0x20任务,完成任务插槽机制
添加文件 tran_for_broadcast.c
This commit is contained in:
@@ -293,3 +293,9 @@
|
|||||||
解决ew写配置错误的bug,升级ew程序不更改配置区
|
解决ew写配置错误的bug,升级ew程序不更改配置区
|
||||||
2023.12.16
|
2023.12.16
|
||||||
解决ew充末电流异常的bug,解决ew快速配置2比对数据错误的bug
|
解决ew充末电流异常的bug,解决ew快速配置2比对数据错误的bug
|
||||||
|
2023.12.18
|
||||||
|
添加写三码验三码任务,实现0x20任务,完成任务插槽机制
|
||||||
|
添加文件 tran_for_broadcast.c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -411,14 +411,13 @@ static int elec_code_load_param(array_def *uid_psw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检测 准备参数
|
// 检测 准备参数
|
||||||
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)
|
int elec_check_load_task_param(uint8_t task_index)
|
||||||
{
|
{
|
||||||
self_def *s=&g_self;
|
self_def *s=&g_self;
|
||||||
uint8_t taskid;
|
uint8_t taskid;
|
||||||
CheckerTask_Info_st *task_par;
|
CheckerTask_Info_st *task_par;
|
||||||
taskid=s->taskid_table[task_index];
|
taskid=s->taskid_table[task_index];
|
||||||
s->task_fun=elec_get_task_fun(s->tasks_fun_table,s->chip_type,taskid);
|
s->task_fun=elec_get_task_fun(taskid);
|
||||||
task_par= s->task_info_array[task_index];
|
task_par= s->task_info_array[task_index];
|
||||||
memset(&checker_runcfg.task_info,0,sizeof(CheckerTask_Info_st));
|
memset(&checker_runcfg.task_info,0,sizeof(CheckerTask_Info_st));
|
||||||
memset(checker_runcfg.params,0,20);
|
memset(checker_runcfg.params,0,20);
|
||||||
@@ -490,9 +489,12 @@ int elec_task_env_restore(void)
|
|||||||
|
|
||||||
|
|
||||||
// 根据任务id获取检测函数
|
// 根据任务id获取检测函数
|
||||||
CheckerTask elec_get_task_fun(CheckerTask *tasks_fun_table[],uint8_t chip_type,uint8_t taskid)
|
CheckerTask elec_get_task_fun(uint8_t taskid)
|
||||||
{
|
{
|
||||||
|
self_def *s=&g_self;
|
||||||
CheckerTask task_fun=0;
|
CheckerTask task_fun=0;
|
||||||
|
CheckerTask **tasks_fun_table=s->tasks_fun_table;
|
||||||
|
uint8_t chip_type=s->chip_type;
|
||||||
if(taskid<CHECKER_MAXID_COUNT){
|
if(taskid<CHECKER_MAXID_COUNT){
|
||||||
task_fun=tasks_fun_table[chip_type][taskid];
|
task_fun=tasks_fun_table[chip_type][taskid];
|
||||||
}else if((taskid>=CHECKER_MAXID_COUNT)&&
|
}else if((taskid>=CHECKER_MAXID_COUNT)&&
|
||||||
@@ -500,6 +502,7 @@ CheckerTask elec_get_task_fun(CheckerTask *tasks_fun_table[],uint8_t chip_type,u
|
|||||||
{
|
{
|
||||||
task_fun=exttaskArray[taskid-CHECKER_MAXID_COUNT];
|
task_fun=exttaskArray[taskid-CHECKER_MAXID_COUNT];
|
||||||
}
|
}
|
||||||
|
s->task_fun=task_fun;
|
||||||
return task_fun;
|
return task_fun;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,9 +523,22 @@ void elec_exe_task(void)
|
|||||||
if(checker_runcfg.excue_rtv==0)
|
if(checker_runcfg.excue_rtv==0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
char *str=malloc(200);
|
||||||
|
int str_len=0;
|
||||||
|
for(int i=0;i<checker_runcfg.rtv_count;i++)
|
||||||
|
{
|
||||||
|
str_len+=sprintf(str+str_len,"%d,",checker_runcfg.Test_Rtv[checker_runcfg.rtv_index+i]);
|
||||||
|
}
|
||||||
checker_runcfg.rtv_index+=checker_runcfg.rtv_count;
|
checker_runcfg.rtv_index+=checker_runcfg.rtv_count;
|
||||||
|
if(checker_runcfg.rtv_count>0){
|
||||||
DBG_LOG("task_index:%d,taskid:%d,ret=%d,rtv_index=%d.",s->task_index,
|
DBG_LOG("task_index:%d,taskid:%d,ret=%d,rtv_index=%d.",s->task_index,
|
||||||
s->task_par->taskid,checker_runcfg.excue_rtv,checker_runcfg.rtv_index);
|
s->task_par->taskid,checker_runcfg.excue_rtv,checker_runcfg.rtv_index);
|
||||||
|
DBG_LOG("rets:%s\n",str);
|
||||||
|
}else{
|
||||||
|
DBG_LOG("task_index:%d,taskid:%d,ret=%d,rtv_index=%d.\n",s->task_index,
|
||||||
|
s->task_par->taskid,checker_runcfg.excue_rtv,checker_runcfg.rtv_index);
|
||||||
|
}
|
||||||
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "bytearray.h"
|
#include "bytearray.h"
|
||||||
|
#include "interface/basechecker.h"
|
||||||
|
|
||||||
int elec_init(void);
|
int elec_init(void);
|
||||||
|
|
||||||
@@ -48,6 +48,8 @@ int elec_task_env_back(void);
|
|||||||
|
|
||||||
int elec_task_env_restore(void);
|
int elec_task_env_restore(void);
|
||||||
|
|
||||||
|
CheckerTask elec_get_task_fun(uint8_t taskid);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#include "mystring.h"
|
#include "mystring.h"
|
||||||
#include "elec_judge.h"
|
#include "elec_judge.h"
|
||||||
#include "interface/CheckerExt.h"
|
#include "interface/CheckerExt.h"
|
||||||
|
#include "elec_task_slot.h"
|
||||||
|
|
||||||
|
|
||||||
// 通用异常判定逻辑
|
// 通用异常判定逻辑
|
||||||
@@ -354,6 +355,19 @@ int elec_report_err(elec_judge_def *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void elec_add_slot_err(elec_judge_def *e)
|
||||||
|
{
|
||||||
|
void *slot=task_slot_init();
|
||||||
|
int len=0;
|
||||||
|
uint8_t *table=0;
|
||||||
|
len=task_slot_err_table(slot,&table);
|
||||||
|
for(int i=0;i<len;i++)
|
||||||
|
{
|
||||||
|
elec_add_errcode(e,table[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 异常判断
|
// 异常判断
|
||||||
// task_num,要判断的任务数
|
// task_num,要判断的任务数
|
||||||
@@ -391,6 +405,9 @@ void elec_judge(elec_judge_def *e,int task_num,uint8_t *exe_ack,
|
|||||||
}
|
}
|
||||||
data+=task->item_num*2;
|
data+=task->item_num*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elec_add_slot_err(e);
|
||||||
|
|
||||||
DBG_LOG("err_table:%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
|
DBG_LOG("err_table:%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
|
||||||
e->err_list[0],e->err_list[1],e->err_list[2],e->err_list[3],e->err_list[4],
|
e->err_list[0],e->err_list[1],e->err_list[2],e->err_list[3],e->err_list[4],
|
||||||
e->err_list[5],e->err_list[6],e->err_list[7],e->err_list[8],e->err_list[9]
|
e->err_list[5],e->err_list[6],e->err_list[7],e->err_list[8],e->err_list[9]
|
||||||
|
@@ -57,6 +57,7 @@ void *task_slot_init(void)
|
|||||||
t=calloc(1,sizeof(task_slot_def));
|
t=calloc(1,sizeof(task_slot_def));
|
||||||
app_variable("task_slot",t,0);
|
app_variable("task_slot",t,0);
|
||||||
}
|
}
|
||||||
|
t->current=t->head;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,18 +91,35 @@ task_def *task_slot_next(void *context,uint8_t slot_index)
|
|||||||
if(t==0){
|
if(t==0){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
task_node *n;
|
task_def *n;
|
||||||
while(t->current){
|
while(n=task_slot_next_item(t),n!=0){
|
||||||
n=t->current;
|
if(n->slot_index==slot_index){
|
||||||
t->current=n->next;
|
return n;
|
||||||
if(n->task.slot_index==slot_index){
|
|
||||||
return &n->task;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
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)
|
int task_slot_add_err(void *context,uint8_t err)
|
||||||
{
|
{
|
||||||
task_slot_def *t=context;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@ typedef struct{
|
|||||||
uint8_t par_count;// 参数个数
|
uint8_t par_count;// 参数个数
|
||||||
uint8_t ret_count;// 返回值个数
|
uint8_t ret_count;// 返回值个数
|
||||||
uint8_t errcode;
|
uint8_t errcode;
|
||||||
|
uint8_t task_index;
|
||||||
uint8_t params[20];
|
uint8_t params[20];
|
||||||
uint8_t rets[20];
|
uint8_t rets[20];
|
||||||
}task_def;
|
}task_def;
|
||||||
@@ -18,12 +19,17 @@ typedef struct{
|
|||||||
|
|
||||||
void *task_slot_init(void);
|
void *task_slot_init(void);
|
||||||
|
|
||||||
|
void task_slot_delete(void);
|
||||||
|
|
||||||
int task_slot_add_item(void *context,task_def *item);
|
int task_slot_add_item(void *context,task_def *item);
|
||||||
|
|
||||||
task_def *task_slot_next(void *context,uint8_t slot_index);
|
task_def *task_slot_next(void *context,uint8_t slot_index);
|
||||||
|
|
||||||
|
task_def *task_slot_next_item(void *context);
|
||||||
|
|
||||||
int task_slot_add_err(void *context,uint8_t err);
|
int task_slot_add_err(void *context,uint8_t err);
|
||||||
|
|
||||||
|
int task_slot_err_table(void *context,uint8_t **table);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -119,6 +119,26 @@ static int calc_skip_num(int index)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*rc{
|
||||||
|
设置UID和密码到小板内存,三码绑定函数使用此数据
|
||||||
|
输入参数[0]=uid长度,[1]=pwd长度,[uid][pwd]
|
||||||
|
}*/
|
||||||
|
void CheckerExt_SetUID(void)
|
||||||
|
{
|
||||||
|
uint8_t pwd_len=0,uid_len=0;
|
||||||
|
uint8_t *uid_psw=(uint8_t *)checker_runcfg.params;
|
||||||
|
uint8_t ret=0;
|
||||||
|
uid_len = uid_psw[0];
|
||||||
|
pwd_len = uid_psw[1];
|
||||||
|
if(uid_len==0||pwd_len==0){
|
||||||
|
ret=1;
|
||||||
|
}
|
||||||
|
checker_runcfg.uid_len=uid_len;
|
||||||
|
checker_runcfg.pwd_len=pwd_len;
|
||||||
|
memcpy(checker_runcfg.writeuid,uid_psw+2,uid_len);
|
||||||
|
memcpy(checker_runcfg.writepwd,uid_psw+2+uid_len,pwd_len);
|
||||||
|
Checker_MaskResult(ret,checker_runcfg.task_info.runindex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*rc{
|
/*rc{
|
||||||
@@ -132,9 +152,11 @@ void CheckerExt_Slot(void)
|
|||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
uint16_t ret=0;
|
uint16_t ret=0;
|
||||||
|
uint16_t exe_ret=0;
|
||||||
int self_index=checker_runcfg.task_info.runindex;
|
int self_index=checker_runcfg.task_info.runindex;
|
||||||
task_def *t=0;
|
task_def *t=0;
|
||||||
void *task_slot=0;
|
void *task_slot=0;
|
||||||
|
CheckerTask fun=0;
|
||||||
if(checker_runcfg.param_count<1){
|
if(checker_runcfg.param_count<1){
|
||||||
ret=1;
|
ret=1;
|
||||||
goto end;
|
goto end;
|
||||||
@@ -149,12 +171,37 @@ void CheckerExt_Slot(void)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
while(t=task_slot_next(task_slot,(uint8_t)index),t){
|
while(t=task_slot_next(task_slot,(uint8_t)index),t){
|
||||||
// t->
|
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;
|
||||||
|
|
||||||
|
checker_runcfg.task_info.runindex=self_index;
|
||||||
|
checker_runcfg.param_count = t->par_count;
|
||||||
|
checker_runcfg.rtv_count = t->ret_count;
|
||||||
|
memcpy(checker_runcfg.params,t->params,checker_runcfg.param_count*2);
|
||||||
|
fun=elec_get_task_fun(t->task_id);
|
||||||
|
checker_runcfg.excue_rtv=1;
|
||||||
|
if(fun){
|
||||||
|
fun();
|
||||||
|
checker_runcfg.rtv_index-=checker_runcfg.rtv_count;
|
||||||
|
}
|
||||||
|
exe_ret|=checker_runcfg.excue_rtv;
|
||||||
|
memcpy(t->rets,&checker_runcfg.Test_Rtv[checker_runcfg.rtv_index],checker_runcfg.rtv_count*2);
|
||||||
|
memset(&checker_runcfg.Test_Rtv[checker_runcfg.rtv_index],0,checker_runcfg.rtv_count*2);
|
||||||
|
if(checker_runcfg.excue_rtv){
|
||||||
|
task_slot_add_err(task_slot,t->errcode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(elec_task_env_restore()){
|
if(elec_task_env_restore()){
|
||||||
ret=5;
|
ret=3;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
if(exe_ret){
|
||||||
|
ret=4;
|
||||||
|
}
|
||||||
end:
|
end:
|
||||||
Checker_MaskResult(ret,self_index);
|
Checker_MaskResult(ret,self_index);
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,9 @@ void CheckerExt_CalcErr(void);
|
|||||||
|
|
||||||
void CheckerExt_Repeat(void);
|
void CheckerExt_Repeat(void);
|
||||||
|
|
||||||
|
void CheckerExt_SetUID(void);
|
||||||
|
|
||||||
|
void CheckerExt_Slot(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -353,7 +353,7 @@ void EW_Test_VerifyThreedCode(void)
|
|||||||
}
|
}
|
||||||
if(uc_rtv > 0)
|
if(uc_rtv > 0)
|
||||||
{
|
{
|
||||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
Checker_MaskResult(1,checker_runcfg.task_info.runindex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EW_ReadMTP(checker_runcfg.netid,0x20,EW_RunBuf,checker_runcfg.uid_len+1);
|
EW_ReadMTP(checker_runcfg.netid,0x20,EW_RunBuf,checker_runcfg.uid_len+1);
|
||||||
@@ -367,7 +367,7 @@ void EW_Test_VerifyThreedCode(void)
|
|||||||
}
|
}
|
||||||
if(uc_rtv > 0)
|
if(uc_rtv > 0)
|
||||||
{
|
{
|
||||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
Checker_MaskResult(2,checker_runcfg.task_info.runindex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,7 +383,7 @@ void EW_Test_VerifyThreedCode(void)
|
|||||||
}
|
}
|
||||||
if(uc_rtv > 0)
|
if(uc_rtv > 0)
|
||||||
{
|
{
|
||||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
Checker_MaskResult(3,checker_runcfg.task_info.runindex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EW_ReadMTP(checker_runcfg.netid,0x24,EW_RunBuf,checker_runcfg.pwd_len+1);
|
EW_ReadMTP(checker_runcfg.netid,0x24,EW_RunBuf,checker_runcfg.pwd_len+1);
|
||||||
@@ -397,7 +397,7 @@ void EW_Test_VerifyThreedCode(void)
|
|||||||
}
|
}
|
||||||
if(uc_rtv > 0)
|
if(uc_rtv > 0)
|
||||||
{
|
{
|
||||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
Checker_MaskResult(4,checker_runcfg.task_info.runindex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,30 +409,34 @@ void EW_Test_VerifyThreedCode(void)
|
|||||||
}
|
}
|
||||||
if(uc_rtv > 0)
|
if(uc_rtv > 0)
|
||||||
{
|
{
|
||||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
Checker_MaskResult(5,checker_runcfg.task_info.runindex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//验证PWD
|
//验证PWD
|
||||||
memcpy(EW_RunBuf,EW_Test_PWD,checker_runcfg.pwd_len);
|
memcpy(EW_RunBuf,EW_Test_PWD,checker_runcfg.pwd_len);
|
||||||
|
delay_ms(200);
|
||||||
uc_rtv = EW_VerfyPWD(checker_runcfg.netid,EW_RunBuf,checker_runcfg.pwd_len);
|
uc_rtv = EW_VerfyPWD(checker_runcfg.netid,EW_RunBuf,checker_runcfg.pwd_len);
|
||||||
if(uc_rtv > 0)
|
if(uc_rtv > 0)
|
||||||
{
|
{
|
||||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
Checker_MaskResult(6,checker_runcfg.task_info.runindex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//读状态
|
//读状态
|
||||||
|
delay_ms(200);
|
||||||
uc_rtv = EW_ReadState(checker_runcfg.netid,(uint8_t*)state.datas);
|
uc_rtv = EW_ReadState(checker_runcfg.netid,(uint8_t*)state.datas);
|
||||||
if(uc_rtv > 0 || state.State_st.erprom_error >0 || state.State_st.pswd_flag == 0)
|
// if(uc_rtv > 0 || state.State_st.erprom_error >0 || state.State_st.pswd_flag == 0)
|
||||||
|
if(uc_rtv > 0 || state.State_st.pswd_flag == 0)
|
||||||
{
|
{
|
||||||
Checker_MaskResult(1,checker_runcfg.task_info.runindex);
|
Checker_MaskResult(7,checker_runcfg.task_info.runindex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Checker_MaskResult(1,checker_runcfg.task_info.runindex);
|
Checker_MaskResult(0,checker_runcfg.task_info.runindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@brief 自检
|
@brief 自检
|
||||||
@param 自检模式
|
@param 自检模式
|
||||||
|
@param1 自检时间ms
|
||||||
@rtv 自检模式0x08的回读数据
|
@rtv 自检模式0x08的回读数据
|
||||||
*/
|
*/
|
||||||
void EW_Test_CheckSelf()
|
void EW_Test_CheckSelf()
|
||||||
@@ -441,8 +445,9 @@ void EW_Test_CheckSelf()
|
|||||||
uint32_t ul_temp;
|
uint32_t ul_temp;
|
||||||
uint8_t uc_mode = checker_runcfg.params[0];
|
uint8_t uc_mode = checker_runcfg.params[0];
|
||||||
uc_rtv = EW_ChecSelf(checker_runcfg.netid,uc_mode,(uint8_t*)&ul_temp);
|
uc_rtv = EW_ChecSelf(checker_runcfg.netid,uc_mode,(uint8_t*)&ul_temp);
|
||||||
|
delay_ms(checker_runcfg.params[1]);
|
||||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||||
|
Checker_SetRtv((uint16_t*)ul_temp,checker_runcfg.rtv_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -702,9 +707,9 @@ void EW_Test_EnBoom(void)
|
|||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@brief 起爆
|
@brief 起爆
|
||||||
@param0 采样超时
|
@param0 采样超时 0.01ms
|
||||||
@param1 起爆电流AD
|
@param1 起爆电流AD
|
||||||
@param2 延迟采样
|
@param2 延迟采样ms
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void EW_Test_Boom()
|
void EW_Test_Boom()
|
||||||
@@ -814,6 +819,147 @@ void EW_Test_PowerOFF(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
@brief 写三码数据
|
||||||
|
*/
|
||||||
|
void EW_Test_WriteUID(void)
|
||||||
|
{
|
||||||
|
uint8_t uc_rtv = 0;
|
||||||
|
if(JQXT_Test_IsNeedBind() == 0)
|
||||||
|
{
|
||||||
|
Checker_MaskResult(0,checker_runcfg.task_info.runindex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(EW_RunBuf,checker_runcfg.writeuid,checker_runcfg.uid_len);
|
||||||
|
EW_RunBuf[checker_runcfg.uid_len] = CheckCRC_8(EW_RunBuf,checker_runcfg.uid_len);
|
||||||
|
uc_rtv |= EW_WriteMTP(checker_runcfg.netid,0x00,EW_RunBuf,checker_runcfg.uid_len+1);
|
||||||
|
delay_os_ms(50);
|
||||||
|
uc_rtv |= EW_WriteMTP(checker_runcfg.netid,0x20,EW_RunBuf,checker_runcfg.uid_len+1);
|
||||||
|
delay_os_ms(50);
|
||||||
|
memcpy(EW_RunBuf,checker_runcfg.writepwd,checker_runcfg.pwd_len);
|
||||||
|
EW_RunBuf[checker_runcfg.pwd_len] = CheckCRC_8(EW_RunBuf,checker_runcfg.pwd_len);
|
||||||
|
uc_rtv |= EW_WriteMTP(checker_runcfg.netid,0x04,EW_RunBuf,checker_runcfg.pwd_len+1);
|
||||||
|
delay_os_ms(50);
|
||||||
|
uc_rtv |= EW_WriteMTP(checker_runcfg.netid,0x24,EW_RunBuf,checker_runcfg.pwd_len+1);
|
||||||
|
|
||||||
|
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@breif 验证写入的三码数据
|
||||||
|
*/
|
||||||
|
void EW_Test_VerifyUID(void)
|
||||||
|
{
|
||||||
|
uint8_t uc_rtv = 0;
|
||||||
|
System_State_un state;
|
||||||
|
//读UID MTP
|
||||||
|
memset(EW_RunBuf,0,sizeof(EW_RunBuf));
|
||||||
|
EW_ReadMTP(checker_runcfg.netid,0x00,EW_RunBuf,checker_runcfg.uid_len+1);
|
||||||
|
if(EW_RunBuf[checker_runcfg.uid_len] != CheckCRC_8(EW_RunBuf,checker_runcfg.uid_len))
|
||||||
|
{
|
||||||
|
uc_rtv = 1;
|
||||||
|
}
|
||||||
|
if(0 != memcmp(EW_RunBuf,checker_runcfg.writeuid,checker_runcfg.uid_len))
|
||||||
|
{
|
||||||
|
uc_rtv = 1;
|
||||||
|
}
|
||||||
|
if(uc_rtv > 0)
|
||||||
|
{
|
||||||
|
Checker_MaskResult(1,checker_runcfg.task_info.runindex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memset(EW_RunBuf,0,sizeof(EW_RunBuf));
|
||||||
|
EW_ReadMTP(checker_runcfg.netid,0x20,EW_RunBuf,checker_runcfg.uid_len+1);
|
||||||
|
if(EW_RunBuf[checker_runcfg.uid_len] != CheckCRC_8(EW_RunBuf,checker_runcfg.uid_len))
|
||||||
|
{
|
||||||
|
uc_rtv = 1;
|
||||||
|
}
|
||||||
|
if(0 != memcmp(EW_RunBuf,checker_runcfg.writeuid,checker_runcfg.uid_len))
|
||||||
|
{
|
||||||
|
uc_rtv = 1;
|
||||||
|
}
|
||||||
|
if(uc_rtv > 0)
|
||||||
|
{
|
||||||
|
Checker_MaskResult(2,checker_runcfg.task_info.runindex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//读PWD MTP
|
||||||
|
memset(EW_RunBuf,0,sizeof(EW_RunBuf));
|
||||||
|
EW_ReadMTP(checker_runcfg.netid,0x04,EW_RunBuf,checker_runcfg.pwd_len+1);
|
||||||
|
if(EW_RunBuf[checker_runcfg.pwd_len] != CheckCRC_8(EW_RunBuf,checker_runcfg.pwd_len))
|
||||||
|
{
|
||||||
|
uc_rtv = 1;
|
||||||
|
}
|
||||||
|
if(0 != memcmp(EW_RunBuf,checker_runcfg.writepwd,checker_runcfg.pwd_len))
|
||||||
|
{
|
||||||
|
uc_rtv = 1;
|
||||||
|
}
|
||||||
|
if(uc_rtv > 0)
|
||||||
|
{
|
||||||
|
Checker_MaskResult(3,checker_runcfg.task_info.runindex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memset(EW_RunBuf,0,sizeof(EW_RunBuf));
|
||||||
|
EW_ReadMTP(checker_runcfg.netid,0x24,EW_RunBuf,checker_runcfg.pwd_len+1);
|
||||||
|
if(EW_RunBuf[checker_runcfg.pwd_len] != CheckCRC_8(EW_RunBuf,checker_runcfg.pwd_len))
|
||||||
|
{
|
||||||
|
uc_rtv = 1;
|
||||||
|
}
|
||||||
|
if(0 != memcmp(EW_RunBuf,checker_runcfg.writepwd,checker_runcfg.pwd_len))
|
||||||
|
{
|
||||||
|
uc_rtv = 1;
|
||||||
|
}
|
||||||
|
if(uc_rtv > 0)
|
||||||
|
{
|
||||||
|
Checker_MaskResult(4,checker_runcfg.task_info.runindex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//读UID
|
||||||
|
memset(EW_RunBuf,0,sizeof(EW_RunBuf));
|
||||||
|
uc_rtv = EW_ReadUID(checker_runcfg.netid,EW_RunBuf,checker_runcfg.uid_len);
|
||||||
|
if(0 != memcmp(EW_RunBuf,checker_runcfg.writeuid,checker_runcfg.uid_len))
|
||||||
|
{
|
||||||
|
uc_rtv = 1;
|
||||||
|
}
|
||||||
|
if(uc_rtv > 0)
|
||||||
|
{
|
||||||
|
Checker_MaskResult(5,checker_runcfg.task_info.runindex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//验证PWD
|
||||||
|
memcpy(EW_RunBuf,checker_runcfg.writepwd,checker_runcfg.pwd_len);
|
||||||
|
delay_ms(200);
|
||||||
|
uc_rtv = EW_VerfyPWD(checker_runcfg.netid,EW_RunBuf,checker_runcfg.pwd_len);
|
||||||
|
if(uc_rtv > 0)
|
||||||
|
{
|
||||||
|
Checker_MaskResult(6,checker_runcfg.task_info.runindex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//读状态
|
||||||
|
delay_ms(200);
|
||||||
|
uc_rtv = EW_ReadState(checker_runcfg.netid,(uint8_t*)state.datas);
|
||||||
|
// if(uc_rtv > 0 || state.State_st.erprom_error >0 || state.State_st.pswd_flag == 0)
|
||||||
|
if(uc_rtv > 0 || state.State_st.pswd_flag == 0)
|
||||||
|
{
|
||||||
|
Checker_MaskResult(7,checker_runcfg.task_info.runindex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Checker_MaskResult(0,checker_runcfg.task_info.runindex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void EW_Empty(void)
|
void EW_Empty(void)
|
||||||
{
|
{
|
||||||
Checker_RunCfg_st *cfg=&checker_runcfg;
|
Checker_RunCfg_st *cfg=&checker_runcfg;
|
||||||
@@ -863,6 +1009,10 @@ EW_Updata, //27 升级
|
|||||||
EW_Test_ChgEnergy, //28 充能统计
|
EW_Test_ChgEnergy, //28 充能统计
|
||||||
CheckerExt_CalcErr, //29 计算异常
|
CheckerExt_CalcErr, //29 计算异常
|
||||||
CheckerExt_Repeat, //30 重新执行一次指定任务
|
CheckerExt_Repeat, //30 重新执行一次指定任务
|
||||||
|
EW_Test_WriteUID, //31 写入三码数据
|
||||||
|
EW_Test_VerifyUID, //32 验证三码数据
|
||||||
|
CheckerExt_SetUID, //33 配置三码数据到小板
|
||||||
|
CheckerExt_Slot, //34 任务插槽
|
||||||
(void*)0 //数组结束
|
(void*)0 //数组结束
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define BUILD_DATE "2023-12-13 13:46:48"
|
#define BUILD_DATE "2023-12-18 18:02:16"
|
||||||
#define SOFT_VERSION "2.08"
|
#define SOFT_VERSION "2.08"
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#include "prot_mcu.h"
|
#include "prot_mcu.h"
|
||||||
#include "prot_uc.h"
|
#include "prot_uc.h"
|
||||||
#include "transmit.h"
|
#include "transmit.h"
|
||||||
|
#include "tran_for_broadcast.h"
|
||||||
#include "tran_for_coder2ch.h"
|
#include "tran_for_coder2ch.h"
|
||||||
#include "tran_for_slave.h"
|
#include "tran_for_slave.h"
|
||||||
|
|
||||||
|
202
source/task/tran_for_broadcast.c
Normal file
202
source/task/tran_for_broadcast.c
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
#include "tran_for_broadcast.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "mymisc.h"
|
||||||
|
#include "mystdlib.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "dev_flash.h"
|
||||||
|
#include "prot_uc.h"
|
||||||
|
#include "coder_lib.h"
|
||||||
|
#include "JQ_PSDGenerate.h"
|
||||||
|
#include "mystring.h"
|
||||||
|
#include "coder_judge.h"
|
||||||
|
#include "JQ_UIDGenerate.h"
|
||||||
|
#include "transmit.h"
|
||||||
|
#include "elec_det.h"
|
||||||
|
#include "crc.h"
|
||||||
|
#include "dev_backup.h"
|
||||||
|
#include "elec_task_slot.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
执行任务命令格式
|
||||||
|
[0]=总包数,[1]=当前包数(1开始)
|
||||||
|
[2...n]=数据
|
||||||
|
|
||||||
|
数据域格式
|
||||||
|
[0]=小板地址,[1]=数据长度,[2...n]=数据
|
||||||
|
|
||||||
|
单个任务数据格式
|
||||||
|
[0]=插槽序号,[1]=任务id,[2]=参数个数(u16)
|
||||||
|
[3]=返回值个数(u16),[4]=异常代码,[5]=任务序号
|
||||||
|
[6...n]=参数
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
返回数据域格式
|
||||||
|
[0]=任务序号,[1]=返回数据长度(u16)
|
||||||
|
[2...n]=参数
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
ucport_def u;
|
||||||
|
rt_timer_t timer;
|
||||||
|
array_def *data;
|
||||||
|
int pack_all;
|
||||||
|
int pack_curr;
|
||||||
|
}slave_def;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static slave_def *slave_creat(void)
|
||||||
|
{
|
||||||
|
slave_def *u=calloc(1,sizeof(slave_def));
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void slave_del(ucport_def *u)
|
||||||
|
{
|
||||||
|
slave_def *s=(slave_def *)u;
|
||||||
|
CHECK_DO(s->timer,rt_timer_delete);
|
||||||
|
CHECK_DO(s->data,arr_delete);
|
||||||
|
free(u);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 找到自己的数据
|
||||||
|
static void slave_get_self(slave_def *s)
|
||||||
|
{
|
||||||
|
int len=arr_length(s->data);
|
||||||
|
int off=0;
|
||||||
|
int addr,slave_len;
|
||||||
|
array_def *expat=arr_creat();
|
||||||
|
uint8_t *d;
|
||||||
|
while(off<len){
|
||||||
|
addr=arr_get(s->data,off);
|
||||||
|
slave_len=arr_get(s->data,off+1);
|
||||||
|
if(addr==elec_local_addr()){
|
||||||
|
d=arr_data(s->data)+off+2;
|
||||||
|
arr_appends(expat,d,slave_len);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
off+=slave_len+2;
|
||||||
|
}
|
||||||
|
arr_delete(s->data);
|
||||||
|
s->data=expat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 添加任务
|
||||||
|
static void slave_adds(slave_def *s)
|
||||||
|
{
|
||||||
|
task_def *t=calloc(1,sizeof(task_def));
|
||||||
|
void *slot=0;
|
||||||
|
int off=0;
|
||||||
|
int len=arr_length(s->data);
|
||||||
|
task_slot_delete();
|
||||||
|
slot=task_slot_init();
|
||||||
|
while(off<len){
|
||||||
|
t->slot_index=arr_get(s->data,0);
|
||||||
|
t->task_id=arr_get(s->data,1);
|
||||||
|
t->par_count=arr_get(s->data,2);
|
||||||
|
t->ret_count=arr_get(s->data,3);
|
||||||
|
t->errcode=arr_get(s->data,4);
|
||||||
|
t->task_index=arr_get(s->data,5);
|
||||||
|
memcpy(t->params,arr_data(s->data)+6,t->par_count*2);
|
||||||
|
task_slot_add_item(slot,t);
|
||||||
|
off+=6+t->par_count*2;
|
||||||
|
}
|
||||||
|
free(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 生成返回数据
|
||||||
|
static array_def *slave_creat_retdata(slave_def *s,array_def *r)
|
||||||
|
{
|
||||||
|
void *slot=task_slot_init();
|
||||||
|
task_def *t=0;
|
||||||
|
while(t=task_slot_next_item(slot),t!=0)
|
||||||
|
{
|
||||||
|
arr_append(r,t->task_index);
|
||||||
|
arr_append(r,t->ret_count);
|
||||||
|
arr_appends(r,t->rets,t->ret_count*2);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 执行任务
|
||||||
|
static int run_task_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *err_str)
|
||||||
|
{
|
||||||
|
slave_def *s=(slave_def *)u;
|
||||||
|
int pack_curr=0,pack_all=0;
|
||||||
|
array_def *r=0;
|
||||||
|
array_def *check=0;
|
||||||
|
uint8_t *d;
|
||||||
|
pack_all=arr_get(data,0);
|
||||||
|
pack_curr=arr_get(data,1);
|
||||||
|
s->pack_all=pack_all;
|
||||||
|
if(pack_curr==1){
|
||||||
|
// 第一个数据包重置接收
|
||||||
|
CHECK_DO(s->data,arr_delete);
|
||||||
|
s->data=arr_creat();
|
||||||
|
}
|
||||||
|
if(pack_curr==s->pack_curr+1){
|
||||||
|
s->pack_curr++;
|
||||||
|
d=arr_data(data)+2;
|
||||||
|
arr_appends(s->data,d,arr_length(data)-2);
|
||||||
|
if(s->pack_curr<s->pack_all){
|
||||||
|
r=arr_creat();
|
||||||
|
arr_append(r,0);
|
||||||
|
emit tran_reply_signal(u->p,arr_temp(r));
|
||||||
|
}else{
|
||||||
|
// 接收完成后执行命令
|
||||||
|
r=arr_creat();
|
||||||
|
slave_get_self(s);
|
||||||
|
slave_adds(s);
|
||||||
|
check=elec_check_with_scheme(0);
|
||||||
|
arr_append(r,arr_get(check,0));
|
||||||
|
slave_creat_retdata(s,r);
|
||||||
|
emit tran_reply_signal(u->p,arr_temp(r));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
static ucport_def *run_task(tran_def *t, uint8_t cmd,array_def *data)
|
||||||
|
{
|
||||||
|
int ret=0;
|
||||||
|
slave_def *u=slave_creat();
|
||||||
|
u->u.p=t;
|
||||||
|
u->u.del=slave_del;
|
||||||
|
u->u.dolater=run_task_dolater;
|
||||||
|
u->u.dolater(&u->u,cmd,data,"ok");
|
||||||
|
return (ucport_def *)u;
|
||||||
|
}
|
||||||
|
transmit_export(ym_slave,0x20,run_task)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
18
source/task/tran_for_broadcast.h
Normal file
18
source/task/tran_for_broadcast.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
#ifndef tran_for_broadcast_h__
|
||||||
|
#define tran_for_broadcast_h__
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user