V2.13 使用新的can帧回复数据

解决ew自检模式 8导致小板死机的bug,自检返回值除以400,单位0.1ms
This commit is contained in:
ranchuan
2024-01-08 18:04:05 +08:00
parent b9224f2293
commit bcbd02a72c
16 changed files with 203 additions and 127 deletions

View File

@@ -13,6 +13,7 @@
#include "dev_flash.h"
#include "mymisc.h"
#include "elec_det.h"
#include "commend.h"
@@ -251,7 +252,7 @@ protu_def *protu_creat(uart_def *uart)
p->cmd=0xff;// 命令字不可能是0xff
protu_set_endecode_fun(p);
sprintf(name,"protu_t#%d",count);
rt_thread_t rt_t=rt_thread_create(name,protu_run,p,1024,5,20);
rt_thread_t rt_t=rt_thread_create(name,protu_run,p,1024,6,20);
rt_thread_startup(rt_t);
int bsp=sys_param()->uartbsp;
if(bsp==9600)
@@ -287,8 +288,8 @@ array_def *t;
static void protu_send_later(void *ptr)
{
send_pkt_def *s=ptr;
protu_send(s->p,s->t,50);
arr_delete(s->t);
protu_send(s->p,s->t,1000);
// arr_delete(s->t);
}
static send_pkt_def g_send_pkt;
@@ -318,7 +319,7 @@ static int protu_send_ontime(protu_def *p,send_pkt_def *s)
//later_execute(protu_send_later,s,delay);
while(p->timer->read(p->timer)<(tick+delay));
// protu_send_later(s);
return protu_send(s->p,s->t,wnd_tick-2);
return protu_send(s->p,s->t,wnd_tick-1);
}else{
// 单播命令直接发送
@@ -327,12 +328,29 @@ static int protu_send_ontime(protu_def *p,send_pkt_def *s)
}
}
static int protu_send_ontime_loop(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)
{
while(protu_send_ontime(p,s)==0);
// g_send_failed_times=0;
for(int i=0;i<retry;i++)
{
if(protu_send_ontime(p,s)!=0){
break;
}else{
g_send_failed_times++;
}
}
arr_delete(s->t);
return 0;
}
static int send_failed(list_def *argv)
{
cmd_print("send failed times=%d",g_send_failed_times);
return 0;
}
commend_export(send_failed,send_failed,"print send_failed times")
@@ -348,7 +366,7 @@ void protu_reply_call(protu_def *p,array_def *data)
if(t){
g_send_pkt.p=p;
g_send_pkt.t=t;
protu_send_ontime_loop(p,&g_send_pkt);
protu_send_ontime_loop(p,&g_send_pkt,3);
}
}
@@ -371,7 +389,7 @@ void protu_send_call(protu_def *p,uint8_t cmd,array_def *data)
if(t){
g_send_pkt.p=p;
g_send_pkt.t=t;
protu_send_ontime_loop(p,&g_send_pkt);
protu_send_ontime_loop(p,&g_send_pkt,3);
}
}

View File

@@ -392,7 +392,7 @@ static int write_data_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *er
addr=g_updata.flash_addr+offset;
ret=flash_write((uint8_t *)addr,&arr_data(data)[4],len);
array_def *r=arr_creat();
arr_append(r,(ret!=0));
arr_append(r,ret);
emit tran_reply_signal(u->p,arr_temp(r));
return 0;
}