与上位机测试通过
This commit is contained in:
@@ -201,6 +201,16 @@ static int protu_init(void)
|
||||
const sys_param_def *par=sys_param();
|
||||
protu_def *protu=protu_creat(dev_get(par->host_if));
|
||||
app_variable("protu",protu,0);
|
||||
|
||||
// 如果通信接口不是用的串口,则增加一个串口的通信
|
||||
if(strcmp(par->host_if,"uart4")==0)
|
||||
{
|
||||
app_variable("protu2",protu,0);
|
||||
}else
|
||||
{
|
||||
protu_def *protu2=protu_creat(dev_get("uart4"));
|
||||
app_variable("protu2",protu2,0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
app_init_export(protu_init)
|
||||
@@ -237,7 +247,7 @@ protu_def *protu_creat(uart_def *uart)
|
||||
|
||||
int protu_send(protu_def *p,array_def *data)
|
||||
{
|
||||
//DBG_LOG("send:%s",str_temp(arr_string(data)));
|
||||
DBG_LOG("send:%s",str_temp(arr_string(data)));
|
||||
return p->uart->write(p->uart,arr_data(data),arr_length(data));
|
||||
}
|
||||
|
||||
@@ -297,13 +307,14 @@ array_def *protu_decode_str(protu_def *p,array_def *data)
|
||||
DBG_LOG("decode for command");
|
||||
str_set(p->str_err,"ok");
|
||||
p->cmd=0;
|
||||
arr_append(data,0);
|
||||
if(str_is_print_str((const char *)arr_data(data))==1)
|
||||
if(str_is_print_str((const char *)arr_data(data),arr_length(data))==1)
|
||||
{
|
||||
arr_append(data,0);
|
||||
arr_appends_from(r,data);
|
||||
}else{
|
||||
DBG_WARN("data not a string");
|
||||
str_set(p->str_err,"not string");
|
||||
//arr_remove(data,arr_length(data)-1,1);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -320,6 +331,7 @@ array_def *protu_encode_str(protu_def *p,array_def *data)
|
||||
}
|
||||
|
||||
|
||||
protuc_codec_export(string,protu_decode_str,protu_encode_str);
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user