新广播命令测试检测,注码正常,加宽了数据上报的时间片
添加异常代码9,槽任务未执行
This commit is contained in:
@@ -299,7 +299,7 @@
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>18</CpuCode>
|
||||
<DebugOpt>
|
||||
@@ -382,14 +382,14 @@
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>checker_runcfg</ItemText>
|
||||
<ItemText>g_task_slot</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
<WinNumber>1</WinNumber>
|
||||
<SubType>10</SubType>
|
||||
<ItemText>0x20006924</ItemText>
|
||||
<SubType>8</SubType>
|
||||
<ItemText>file</ItemText>
|
||||
<AccSizeX>0</AccSizeX>
|
||||
</Mm>
|
||||
</MemoryWindow1>
|
||||
@@ -523,7 +523,7 @@
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>18</CpuCode>
|
||||
<DebugOpt>
|
||||
@@ -1565,7 +1565,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>rt_thread</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
BIN
doc/CSMZM_V0.13.bin
Normal file
BIN
doc/CSMZM_V0.13.bin
Normal file
Binary file not shown.
Binary file not shown.
@@ -301,5 +301,6 @@
|
||||
添加文件 tran_for_coder.c
|
||||
2023.12.20
|
||||
V2.09 使用任务插槽设置电阻校准值成功
|
||||
|
||||
|
||||
2023.12.21
|
||||
新广播命令测试检测,注码正常,加宽了数据上报的时间片
|
||||
添加异常代码9,槽任务未执行
|
||||
|
@@ -340,7 +340,7 @@ int elec_err_classify(int err)
|
||||
// 找到异常代码序号
|
||||
int elec_report_err(elec_judge_def *e)
|
||||
{
|
||||
static const uint8_t pro_table[]={1,3,7,8,2,4,5,6,20,0};
|
||||
static const uint8_t pro_table[]={1,3,7,8,2,4,5,6,9,20,0};
|
||||
uint8_t index=0;
|
||||
for (int i=0;i<sizeof(pro_table);i++){
|
||||
for(int j=0;j<ERR_LIST_LEN;j++){
|
||||
|
@@ -12,6 +12,7 @@ typedef struct{
|
||||
uint8_t ret_count;// 返回值个数
|
||||
uint8_t errcode;
|
||||
uint8_t task_index;
|
||||
uint8_t exe_flag;// 此项为1则已执行
|
||||
uint8_t params[20];
|
||||
uint8_t rets[20];
|
||||
}task_def;
|
||||
|
@@ -187,6 +187,7 @@ void CheckerExt_Slot(void)
|
||||
if(fun){
|
||||
fun();
|
||||
checker_runcfg.rtv_index-=checker_runcfg.rtv_count;
|
||||
t->exe_flag=1;
|
||||
}
|
||||
exe_ret|=checker_runcfg.excue_rtv;
|
||||
memcpy(t->rets,&checker_runcfg.Test_Rtv[checker_runcfg.rtv_index],checker_runcfg.rtv_count*2);
|
||||
|
@@ -835,18 +835,36 @@ void EW_Test_WriteUID(void)
|
||||
return;
|
||||
}
|
||||
|
||||
delay_os_ms(50);
|
||||
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);
|
||||
uc_rtv = EW_WriteMTP(checker_runcfg.netid,0x00,EW_RunBuf,checker_runcfg.uid_len+1);
|
||||
if(uc_rtv){
|
||||
uc_rtv=1;
|
||||
goto end;
|
||||
}
|
||||
delay_os_ms(50);
|
||||
uc_rtv |= EW_WriteMTP(checker_runcfg.netid,0x20,EW_RunBuf,checker_runcfg.uid_len+1);
|
||||
uc_rtv = EW_WriteMTP(checker_runcfg.netid,0x20,EW_RunBuf,checker_runcfg.uid_len+1);
|
||||
if(uc_rtv){
|
||||
uc_rtv=2;
|
||||
goto end;
|
||||
}
|
||||
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);
|
||||
uc_rtv = EW_WriteMTP(checker_runcfg.netid,0x04,EW_RunBuf,checker_runcfg.pwd_len+1);
|
||||
if(uc_rtv){
|
||||
uc_rtv=3;
|
||||
goto end;
|
||||
}
|
||||
delay_os_ms(50);
|
||||
uc_rtv |= EW_WriteMTP(checker_runcfg.netid,0x24,EW_RunBuf,checker_runcfg.pwd_len+1);
|
||||
uc_rtv = EW_WriteMTP(checker_runcfg.netid,0x24,EW_RunBuf,checker_runcfg.pwd_len+1);
|
||||
if(uc_rtv){
|
||||
uc_rtv=4;
|
||||
goto end;
|
||||
}
|
||||
|
||||
end:
|
||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
@@ -859,10 +877,11 @@ void EW_Test_VerifyUID(void)
|
||||
System_State_un state;
|
||||
if(JQXT_Test_IsNeedBind() == 0)
|
||||
{
|
||||
Checker_MaskResult(0,checker_runcfg.task_info.runindex);
|
||||
return;
|
||||
uc_rtv=0;
|
||||
goto end;
|
||||
}
|
||||
//读UID MTP
|
||||
delay_ms(50);
|
||||
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))
|
||||
@@ -875,11 +894,11 @@ void EW_Test_VerifyUID(void)
|
||||
}
|
||||
if(uc_rtv > 0)
|
||||
{
|
||||
Checker_MaskResult(1,checker_runcfg.task_info.runindex);
|
||||
return;
|
||||
uc_rtv=1;
|
||||
goto end;
|
||||
}
|
||||
memset(EW_RunBuf,0,sizeof(EW_RunBuf));
|
||||
delay_ms(50);
|
||||
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))
|
||||
{
|
||||
@@ -891,8 +910,8 @@ void EW_Test_VerifyUID(void)
|
||||
}
|
||||
if(uc_rtv > 0)
|
||||
{
|
||||
Checker_MaskResult(2,checker_runcfg.task_info.runindex);
|
||||
return;
|
||||
uc_rtv=2;
|
||||
goto end;
|
||||
}
|
||||
|
||||
//读PWD MTP
|
||||
@@ -909,8 +928,8 @@ void EW_Test_VerifyUID(void)
|
||||
}
|
||||
if(uc_rtv > 0)
|
||||
{
|
||||
Checker_MaskResult(3,checker_runcfg.task_info.runindex);
|
||||
return;
|
||||
uc_rtv=3;
|
||||
goto end;
|
||||
}
|
||||
memset(EW_RunBuf,0,sizeof(EW_RunBuf));
|
||||
delay_ms(50);
|
||||
@@ -925,8 +944,8 @@ void EW_Test_VerifyUID(void)
|
||||
}
|
||||
if(uc_rtv > 0)
|
||||
{
|
||||
Checker_MaskResult(4,checker_runcfg.task_info.runindex);
|
||||
return;
|
||||
uc_rtv=4;
|
||||
goto end;
|
||||
}
|
||||
|
||||
//读UID
|
||||
@@ -939,8 +958,8 @@ void EW_Test_VerifyUID(void)
|
||||
}
|
||||
if(uc_rtv > 0)
|
||||
{
|
||||
Checker_MaskResult(5,checker_runcfg.task_info.runindex);
|
||||
return;
|
||||
uc_rtv=5;
|
||||
goto end;
|
||||
}
|
||||
//验证PWD
|
||||
memcpy(EW_RunBuf,checker_runcfg.writepwd,checker_runcfg.pwd_len);
|
||||
@@ -948,8 +967,8 @@ void EW_Test_VerifyUID(void)
|
||||
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;
|
||||
uc_rtv=6;
|
||||
goto end;
|
||||
}
|
||||
//读状态
|
||||
delay_ms(200);
|
||||
@@ -957,10 +976,12 @@ void EW_Test_VerifyUID(void)
|
||||
// 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;
|
||||
uc_rtv=7;
|
||||
goto end;
|
||||
}
|
||||
Checker_MaskResult(0,checker_runcfg.task_info.runindex);
|
||||
|
||||
end:
|
||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
|
||||
@@ -973,7 +994,7 @@ void EW_Test_ReadMTP(void)
|
||||
uint8_t addr=checker_runcfg.params[0];
|
||||
uint8_t len=checker_runcfg.params[1];
|
||||
delay_ms(50);
|
||||
uc_rtv|EW_ReadMTP(checker_runcfg.netid,addr,EW_RunBuf,len);
|
||||
uc_rtv|=EW_ReadMTP(checker_runcfg.netid,addr,EW_RunBuf,len);
|
||||
Checker_SetRtv((uint16_t *)EW_RunBuf,checker_runcfg.rtv_count);
|
||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
@@ -993,6 +1014,80 @@ void EW_Test_WriteMTP(void)
|
||||
|
||||
|
||||
|
||||
// 读流水号
|
||||
void EW_Test_ReadSN(void)
|
||||
{
|
||||
uint8_t uc_rtv=0;
|
||||
uint8_t addr=9;
|
||||
uint8_t len=4;
|
||||
typedef union{
|
||||
uint8_t arr[4];
|
||||
uint32_t data;
|
||||
}temp_def;
|
||||
temp_def temp={0};
|
||||
uint32_t sn;
|
||||
sn=checker_runcfg.params[0]|(checker_runcfg.params[1]<<16);
|
||||
if(sn>=134217728)
|
||||
{
|
||||
// 如果流水号超过了2^27 则失败
|
||||
uc_rtv=1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
delay_ms(50);
|
||||
uc_rtv|=EW_ReadMTP(checker_runcfg.netid,addr,temp.arr,len);
|
||||
if(uc_rtv){
|
||||
uc_rtv=2;
|
||||
goto end;
|
||||
}
|
||||
// 流水号域如果不为要设置的流水号则失败
|
||||
temp.data>>=5;
|
||||
if((temp.data)!=sn){
|
||||
uc_rtv=3;
|
||||
}
|
||||
end:
|
||||
Checker_SetRtv((uint16_t *)&temp,checker_runcfg.rtv_count);
|
||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
// 写流水号,读改写
|
||||
void EW_Test_WriteSN(void)
|
||||
{
|
||||
uint8_t uc_rtv=0;
|
||||
uint8_t addr=9;
|
||||
uint8_t len=4;
|
||||
typedef union{
|
||||
uint8_t arr[4];
|
||||
uint32_t data;
|
||||
}temp_def;
|
||||
temp_def temp={0};
|
||||
uint32_t sn;
|
||||
delay_ms(50);
|
||||
uc_rtv|=EW_ReadMTP(checker_runcfg.netid,addr,temp.arr,len);
|
||||
if(uc_rtv){
|
||||
uc_rtv=1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if(sn>=134217728)
|
||||
{
|
||||
// 如果流水号超过了2^27 则失败
|
||||
uc_rtv=2;
|
||||
goto end;
|
||||
}
|
||||
temp.data=(temp.data&0x1f)|(sn<<5);
|
||||
uc_rtv |= EW_WriteMTP(checker_runcfg.netid,addr,temp.arr,len);
|
||||
if(uc_rtv){
|
||||
uc_rtv=3;
|
||||
goto end;
|
||||
}
|
||||
end:
|
||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void EW_Empty(void)
|
||||
{
|
||||
@@ -1054,6 +1149,8 @@ CheckerExt_Slot, //34 任务插槽
|
||||
EW_Test_ReadMTP, //35 读取mtp
|
||||
EW_Test_WriteMTP, //36 写入mtp
|
||||
CheckerExt_SetCbv, //37 设置电阻校准值
|
||||
EW_Test_ReadSN, //38 读取流水号
|
||||
EW_Test_WriteSN, //39 写入流水号
|
||||
(void*)0 //数组结束
|
||||
};
|
||||
|
||||
|
@@ -1221,6 +1221,121 @@ void JQ_Test_Toggle(void)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*rc{
|
||||
写入流水号,使用读改写
|
||||
par0,par1,流水号,小端存储
|
||||
}*/
|
||||
void JQ_Test_WriteSN(void)
|
||||
{
|
||||
uint8_t uc_rtv = 0;
|
||||
uint8_t uc_ack;
|
||||
uint8_t uc_otpAddr = 20;
|
||||
uint8_t uc_writeCount = 4;
|
||||
typedef union{
|
||||
uint8_t arr[4];
|
||||
uint32_t data;
|
||||
}temp_def;
|
||||
temp_def temp={0};
|
||||
uint32_t sn=0;
|
||||
JQ_EnWOTP();
|
||||
JQ_EnWOTP();
|
||||
for(int i = 0; i < uc_writeCount;i++)
|
||||
{
|
||||
uc_ack = JQ_ReadOTP(CHECKER_NET_ID,uc_otpAddr+i,1,temp.arr+i);
|
||||
if(uc_ack < 1)
|
||||
{
|
||||
uc_rtv = 1;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
sn=checker_runcfg.params[0]|(checker_runcfg.params[1]<<16);
|
||||
if(sn>=134217728)
|
||||
{
|
||||
// 如果流水号超过了2^27 则失败
|
||||
uc_rtv=2;
|
||||
goto end;
|
||||
}
|
||||
// 流水号域如果有值且不为要设置的流水号则失败
|
||||
if((temp.data&(~0x1f))!=0){
|
||||
if((temp.data>>5)!=sn){
|
||||
uc_rtv=3;
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
temp.data=temp.data|(sn<<5);
|
||||
for(int i = 0; i < uc_writeCount;i++)
|
||||
{
|
||||
uc_ack = JQ_WriteOTP(uc_otpAddr+i,1,temp.arr+i);
|
||||
if(uc_ack != 1)
|
||||
{
|
||||
uc_rtv = 4;
|
||||
goto end;
|
||||
}
|
||||
|
||||
}
|
||||
end:
|
||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*rc{
|
||||
校验流水号
|
||||
par0,par1,流水号,小端存储
|
||||
ret,校验失败则此任务失败
|
||||
rtv,返回读取的流水号数据
|
||||
}*/
|
||||
void JQ_Test_ReadSN(void)
|
||||
{
|
||||
uint8_t uc_rtv = 0;
|
||||
uint8_t uc_ack;
|
||||
uint8_t uc_otpAddr = 20;
|
||||
uint8_t uc_writeCount = 4;
|
||||
typedef union{
|
||||
uint8_t arr[4];
|
||||
uint32_t data;
|
||||
}temp_def;
|
||||
temp_def temp={0};
|
||||
uint32_t sn=0;
|
||||
JQ_EnWOTP();
|
||||
JQ_EnWOTP();
|
||||
for(int i = 0; i < uc_writeCount;i++)
|
||||
{
|
||||
uc_ack = JQ_ReadOTP(CHECKER_NET_ID,uc_otpAddr+i,1,temp.arr+i);
|
||||
if(uc_ack < 1)
|
||||
{
|
||||
uc_rtv = 1;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
sn=checker_runcfg.params[0]|(checker_runcfg.params[1]<<16);
|
||||
if(sn>=134217728)
|
||||
{
|
||||
// 如果流水号超过了2^27 则失败
|
||||
uc_rtv=2;
|
||||
goto end;
|
||||
}
|
||||
// 流水号域如果不为要设置的流水号则失败
|
||||
temp.data>>=5;
|
||||
if((temp.data)!=sn){
|
||||
uc_rtv=3;
|
||||
}
|
||||
|
||||
end:
|
||||
Checker_MaskResult(uc_rtv,checker_runcfg.task_info.runindex);
|
||||
Checker_SetRtv((uint16_t *)&temp,checker_runcfg.rtv_count);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CheckerTask jqtaskArray[CHECKER_MAXID_COUNT] ={
|
||||
Checker_PowerPrapare, //0 电源准备
|
||||
JQ_Test_PowerOn, //1 上电充能
|
||||
@@ -1266,6 +1381,8 @@ CheckerExt_Repeat ,//40 重新执行任务
|
||||
CheckerExt_SetUID ,//41 设置uid数据到小板
|
||||
CheckerExt_Slot ,//42 任务插槽
|
||||
CheckerExt_SetCbv ,//43 设置电阻校准值
|
||||
JQ_Test_WriteSN ,//44 写入流水号
|
||||
JQ_Test_ReadSN ,//45 读取流水号
|
||||
(void*)0 //数组结束
|
||||
};
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
#define BUILD_DATE "2023-12-20 17:27:12"
|
||||
#define BUILD_DATE "2023-12-21 18:25:05"
|
||||
#define SOFT_VERSION "2.09"
|
||||
|
||||
|
||||
|
@@ -301,7 +301,7 @@ static void protu_send_ontime(protu_def *p,send_pkt_def *s)
|
||||
uint32_t tick=p->timer->read(p->timer);
|
||||
// 根据返回的数据长度计算发送需要的时间,添加1ms的余量
|
||||
// 根据协议,每个指令从机的返回数据长度等长,所以需要的时间窗口也相等
|
||||
int wnd_tick=((arr_length(s->t)+15)/16+1);
|
||||
int wnd_tick=((arr_length(s->t)+12)/13+2);
|
||||
int delay=tick%(wnd_tick*(p->num));
|
||||
int gap=p->rank*wnd_tick;
|
||||
if(delay<=gap){
|
||||
|
@@ -52,11 +52,16 @@
|
||||
typedef struct{
|
||||
ucport_def u;
|
||||
rt_timer_t timer;
|
||||
array_def *data;
|
||||
}slave_def;
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
array_def *data;
|
||||
}self_def;
|
||||
static self_def g_self;
|
||||
|
||||
|
||||
|
||||
static slave_def *slave_creat(void)
|
||||
{
|
||||
@@ -70,13 +75,13 @@ 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);
|
||||
// CHECK_DO(s->data,arr_delete);
|
||||
free(u);
|
||||
}
|
||||
|
||||
|
||||
// 找到自己的数据
|
||||
static void slave_get_self(slave_def *s)
|
||||
static void slave_get_self(self_def *s)
|
||||
{
|
||||
int len=arr_length(s->data);
|
||||
int off=0;
|
||||
@@ -99,7 +104,7 @@ static void slave_get_self(slave_def *s)
|
||||
|
||||
|
||||
// 添加任务
|
||||
static void slave_adds(slave_def *s)
|
||||
static void slave_adds(self_def *s)
|
||||
{
|
||||
task_def *t=calloc(1,sizeof(task_def));
|
||||
void *slot=0;
|
||||
@@ -113,6 +118,7 @@ static void slave_adds(slave_def *s)
|
||||
t->par_count=arr_get(s->data,2);
|
||||
t->ret_count=arr_get(s->data,3);
|
||||
t->errcode=arr_get(s->data,4);
|
||||
t->exe_flag=0;
|
||||
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);
|
||||
@@ -124,53 +130,72 @@ static void slave_adds(slave_def *s)
|
||||
|
||||
|
||||
// 生成返回数据
|
||||
static array_def *slave_creat_retdata(slave_def *s,array_def *r)
|
||||
// 如果ret不为0,则存在未执行的槽任务
|
||||
static array_def *slave_creat_retdata(slave_def *s,array_def *r,int *ret)
|
||||
{
|
||||
void *slot=task_slot_init();
|
||||
task_def *t=0;
|
||||
int err=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);
|
||||
if(t->exe_flag==0){
|
||||
err|=1;
|
||||
}
|
||||
if(r){
|
||||
arr_append(r,t->task_index);
|
||||
arr_append(r,t->ret_count);
|
||||
arr_appends(r,t->rets,t->ret_count*2);
|
||||
}
|
||||
}
|
||||
if(ret) *ret=err;
|
||||
return r;
|
||||
}
|
||||
|
||||
// 重新设置异常代码,异常代码9未执行的槽任务
|
||||
#define SET_ERRCODE(arr){\
|
||||
if(slot_exe_flag){\
|
||||
if(arr_get(arr,0)==0){\
|
||||
arr_reset(arr,9,0);\
|
||||
}\
|
||||
}}
|
||||
|
||||
|
||||
|
||||
|
||||
// 执行任务
|
||||
static int run_task_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *err_str)
|
||||
{
|
||||
slave_def *s=(slave_def *)u;
|
||||
self_def *g=&g_self;
|
||||
int pack_curr=0,pack_all=0,pack_size=0;
|
||||
array_def *r=0;
|
||||
array_def *check=0;
|
||||
uint8_t *d;
|
||||
uint8_t ret_mode=0;
|
||||
int slot_exe_flag=0;
|
||||
pack_all=arr_get(data,0)|(arr_get(data,1)<<8);
|
||||
pack_curr=arr_get(data,2);
|
||||
pack_size=arr_get(data,3);
|
||||
if(pack_curr==0){
|
||||
// 第一个数据包重置接收
|
||||
CHECK_DO(s->data,arr_delete);
|
||||
s->data=arr_creat();
|
||||
CHECK_DO(g->data,arr_delete);
|
||||
g->data=arr_creat();
|
||||
}
|
||||
if(arr_length(s->data)<pack_all){
|
||||
if(arr_length(g->data)<pack_all){
|
||||
d=arr_data(data)+4;
|
||||
arr_appends(s->data,d,arr_length(data)-4);
|
||||
}
|
||||
if(arr_length(s->data)<pack_all){
|
||||
arr_appends(g->data,d,arr_length(data)-4);
|
||||
r=arr_creat();
|
||||
arr_append(r,0);
|
||||
emit tran_reply_signal(u->p,arr_temp(r));
|
||||
}
|
||||
else if(arr_length(s->data)==pack_all){
|
||||
if(arr_length(g->data)==pack_all){
|
||||
// 延时以保证正常回复到上位机
|
||||
rt_thread_mdelay(50);
|
||||
// 接收完成后执行命令
|
||||
ret_mode=arr_get(s->data,0);
|
||||
arr_remove(s->data,0,1);
|
||||
slave_get_self(s);
|
||||
slave_adds(s);
|
||||
ret_mode=arr_get(g->data,0);
|
||||
arr_remove(g->data,0,1);
|
||||
slave_get_self(g);
|
||||
slave_adds(g);
|
||||
if(ret_mode!=3){
|
||||
check=elec_check_with_scheme(0);
|
||||
}else{
|
||||
@@ -178,16 +203,20 @@ static int run_task_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *err_
|
||||
}
|
||||
if(ret_mode==0){
|
||||
// 模式0,只返回检测数据
|
||||
slave_creat_retdata(s,0,&slot_exe_flag);
|
||||
SET_ERRCODE(check);
|
||||
emit tran_reply_signal(u->p,arr_temp(check));
|
||||
}else if((ret_mode==1)||(ret_mode==3)){
|
||||
// 模式1,返回异常代码和任务插槽数据
|
||||
r=arr_creat();
|
||||
arr_append(r,arr_get(check,0));
|
||||
slave_creat_retdata(s,r);
|
||||
slave_creat_retdata(s,r,&slot_exe_flag);
|
||||
SET_ERRCODE(r);
|
||||
emit tran_reply_signal(u->p,arr_temp(r));
|
||||
}else if(ret_mode==2){
|
||||
// 模式2,返回检测数据和任务插槽数据
|
||||
slave_creat_retdata(s,check);
|
||||
slave_creat_retdata(s,check,&slot_exe_flag);
|
||||
SET_ERRCODE(check);
|
||||
emit tran_reply_signal(u->p,arr_temp(check));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user