添加发送失败信息记录

This commit is contained in:
ranchuan
2024-01-13 11:52:04 +08:00
parent bd2a270fae
commit c3c172717d
6 changed files with 57 additions and 19 deletions

View File

@@ -299,7 +299,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
<IsCurrentTarget>0</IsCurrentTarget>
</OPTFL>
<CpuCode>18</CpuCode>
<DebugOpt>
@@ -476,6 +476,16 @@
<pszMrulep></pszMrulep>
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<SystemViewers>
<Entry>
<Name>System Viewer\TIM4</Name>
<WinId>35905</WinId>
</Entry>
<Entry>
<Name>System Viewer\TIM5</Name>
<WinId>35904</WinId>
</Entry>
</SystemViewers>
<DebugDescription>
<Enable>1</Enable>
<EnableFlashSeq>1</EnableFlashSeq>
@@ -540,7 +550,7 @@
<OPTFL>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>0</IsCurrentTarget>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>18</CpuCode>
<DebugOpt>

View File

@@ -333,4 +333,5 @@
调试版本不弹出上传提示框
2024.1.10
在槽任务失败且异常代码不为0时才会导致 CheckerExt_Slot 任务失败
2024.1.12
添加发送失败信息记录

View File

@@ -8,7 +8,7 @@
static int init(timer_def *t){
static int inited=0;
// if(inited!=0) return 0;
if(inited!=0) return 0;
inited=1;
TIM_TimeBaseInitTypeDef timer;
@@ -24,7 +24,7 @@ static int init(timer_def *t){
TIM_SetCounter(TIM4,0);
TIM_ARRPreloadConfig(TIM4, ENABLE);
TIM_SelectOutputTrigger(TIM4,TIM_TRGOSource_Update);
TIM_Cmd(TIM4, ENABLE);
// TIM_Cmd(TIM4, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE );
NVIC_DisableIRQ(TIM5_IRQn);
@@ -38,7 +38,7 @@ static int init(timer_def *t){
TIM_SetCounter(TIM5,0);
TIM_ARRPreloadConfig(TIM5, ENABLE);
TIM_ITRxExternalClockConfig(TIM5, TIM_TS_ITR2);
TIM_Cmd(TIM5, ENABLE);
// TIM_Cmd(TIM5, ENABLE);
return 0;
@@ -75,9 +75,19 @@ static int write(timer_def *t,const uint32_t value)
return 0;
}
static int start(timer_def *t)
{
TIM_Cmd(TIM4,ENABLE);
TIM_Cmd(TIM5,ENABLE);
return 0;
}
static int stop(timer_def *t)
{
TIM_Cmd(TIM4,DISABLE);
TIM_Cmd(TIM5,DISABLE);
return 0;
}
timer_init_export(timer,init,deinit,read,write,0);
timer_init_export(timer,init,deinit,read,write,stop,start,0);

View File

@@ -6,7 +6,7 @@
#define BUILD_DATE "2024-01-10 17:56:38"
#define BUILD_DATE "2024-01-12 15:13:50"
#define SOFT_VERSION "2.13"

View File

@@ -64,6 +64,8 @@ typedef struct __timer_def{
int (*deinit)(struct __timer_def *u);
uint32_t (*read)(struct __timer_def *u);
int (*write)(struct __timer_def *u,const uint32_t value);
int (*stop)(struct __timer_def *u);
int (*start)(struct __timer_def *u);
void *private_data;
}timer_def;
@@ -150,7 +152,7 @@ typedef struct __timer_def{
#define timer_init_export(name_,init_,deinit_,read_,write_,priv_) \
#define timer_init_export(name_,init_,deinit_,read_,write_,stop_,start_,priv_) \
const static char __dev_##name_##_name[] SECTION(".rodata.devstr") = #name_; \
RT_USED static timer_def _timer_##name_={\
.name=__dev_##name_##_name,\
@@ -158,6 +160,8 @@ typedef struct __timer_def{
.deinit=deinit_,\
.read=read_,\
.write=write_,\
.stop=stop_,\
.start=start_,\
.private_data=priv_,\
};\
RT_USED static const struct dev_struct __dev_##name_ SECTION("devstruct")= \

View File

@@ -281,8 +281,13 @@ int protu_send(protu_def *p,array_def *data,int timeout_ms)
typedef struct{
protu_def *p;
array_def *t;
protu_def *p;
array_def *t;
int wnd_tick;// 窗口时间
int gap;// 发送循环时间
int send_failed_times;// 失败次数
uint32_t send_tick_ms;// 发送时的定时器值
uint32_t send_end_tick_ms;// 发送时的定时器值
}send_pkt_def;
static void protu_send_later(void *ptr)
@@ -309,6 +314,7 @@ static int protu_send_ontime(protu_def *p,send_pkt_def *s)
int wnd_tick=((arr_length(s->t)+4)/5+2);
int delay=tick%(wnd_tick*(p->num));
int gap=p->rank*wnd_tick;
int ret=0;
if(delay<=gap){
delay=gap-delay;
}else{
@@ -317,10 +323,14 @@ static int protu_send_ontime(protu_def *p,send_pkt_def *s)
if(p->silent!=0){
// 广播命令在指定时间窗口发送
//later_execute(protu_send_later,s,delay);
g_send_pkt.wnd_tick=wnd_tick;
g_send_pkt.gap=gap;
while(p->timer->read(p->timer)<(tick+delay));
// protu_send_later(s);
return protu_send(s->p,s->t,wnd_tick-1);
g_send_pkt.send_tick_ms=p->timer->read(p->timer);
ret= protu_send(s->p,s->t,wnd_tick-1);
g_send_pkt.send_end_tick_ms=p->timer->read(p->timer);
return ret;
}else{
// 单播命令直接发送
protu_send_later(s);
@@ -328,7 +338,6 @@ static int protu_send_ontime(protu_def *p,send_pkt_def *s)
}
}
static int g_send_failed_times;
static int protu_send_ontime_loop(protu_def *p,send_pkt_def *s,int retry)
{
// g_send_failed_times=0;
@@ -337,7 +346,7 @@ static int protu_send_ontime_loop(protu_def *p,send_pkt_def *s,int retry)
if(protu_send_ontime(p,s)!=0){
break;
}else{
g_send_failed_times++;
g_send_pkt.send_failed_times++;
}
}
arr_delete(s->t);
@@ -345,11 +354,15 @@ static int protu_send_ontime_loop(protu_def *p,send_pkt_def *s,int retry)
}
static int send_failed(list_def *argv)
{
cmd_print("send failed times=%d",g_send_failed_times);
cmd_print("send failed times=%d",g_send_pkt.send_failed_times);
cmd_print("send_start_tick_ms=%d",g_send_pkt.send_tick_ms);
cmd_print("send_end_tick_ms=%d",g_send_pkt.send_end_tick_ms);
cmd_print("send_wnd_tick_ms=%d",g_send_pkt.wnd_tick);
cmd_print("send_gap_ms=%d",g_send_pkt.gap);
return 0;
}
commend_export(send_failed,send_failed,"print send_failed times")
commend_export(send_failed,send_failed,"print send_pkt info")