适配Ew开头的协议

注释iic相关命令,添加命令jwtcrc用于验证jwt程序是否正常
    EW_Updata 添加错误12表示小板中无jwt程序
This commit is contained in:
ranchuan
2023-12-29 18:13:00 +08:00
parent c676f81758
commit a51722b54a
12 changed files with 192 additions and 168 deletions

View File

@@ -18,14 +18,32 @@
#include "elec_det.h"
#include "dev_flash.h"
#include "mystring.h"
#include "prot_uc.h"
#include "board.h"
#include "transmit.h"
#include "mystdlib.h"
#include "elec_io.h"
// 此文件实现elec模块的输入输出接口
typedef struct{
tran_def *tran;
}self_def;
static self_def g_self;
int ConsoleUsart_send_bytes(uint8_t *d,int len)
{
self_def *s=&g_self;
if(s->tran){
array_def *r=arr_creat();
arr_appends(r,d,len);
emit tran_reply_signal(s->tran,arr_temp(r));
}
return 0;
}
@@ -64,7 +82,43 @@ void Ye_RunPlanCheckTest(void)
// 小板ew协议解码
array_def *protew_decode(protu_def *p,array_def *data)
{
if((arr_get(data,0)=='E')&&(arr_get(data,1)=='w')){
str_set(p->str_err,"ok");
p->cmd=0x01;
return arr_duplicate(data);
}
str_set(p->str_err,"decode for Ew failed.");
return arr_creat();
}
array_def *protew_encode(protu_def *p,array_def *data)
{
array_def *r;
r=arr_duplicate(data);
return r;
}
protuc_codec_export(ew_slave,protew_decode,protew_encode);
static int ew_slave_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *err_str)
{
void EW_UsartApp_Push_Cmd(uint8_t* buf, uint16_t len);
EW_UsartApp_Push_Cmd(arr_data(data),arr_length(data));
return 0;
}
static ucport_def *ew_slave_fun(tran_def *t, uint8_t cmd,array_def *data)
{
int ret=0;
self_def *s=&g_self;
s->tran=t;
ucport_def *u=calloc(1,sizeof(ucport_def));
u->p=t;
u->dolater=ew_slave_dolater;
u->dolater(u,cmd,data,"ok");
return (ucport_def *)u;
}
transmit_export(ew_slave,0x01,ew_slave_fun)