移植与电子模块通信相关代码

This commit is contained in:
andy
2023-10-06 18:47:05 +08:00
parent bf440a35bc
commit 8e3a140bec
77 changed files with 13331 additions and 1168 deletions

View File

@@ -12,7 +12,6 @@
#include "signal.h"
#include "prot_mcu.h"
#include "debug.h"
#include "handle.h"
#include "prot_uc.h"
#include "transmit.h"
#include "commend.h"
@@ -20,7 +19,6 @@
#include "mymisc.h"
#include "dev_backup.h"
#include "compiler_info.h"
#include "moter.h"
@@ -121,70 +119,9 @@ commend_export(scheme,scheme_info,"print scheme info")
typedef struct{
int updata_run;
}updata_def;
static updata_def g_updata;
static int updata_slave(list_def *argv)
{
void *ptr=flash_get_slave();
tran_def *tran=app_variable("tran",0,0);
uint8_t *data=ptr;
data+=FLASH_FILE_HEAD_SIZE;
flash_file *file=ptr;
if(tran==0){
DBG_WARN("can not find variable \"tran\"");
return -1;
}
if(list_length(argv)<2){
cmd_print("param num too less.");
return -1;
}
list_def *addrs=str_atod_list(list_get_str(argv,1),',');
for(int i=0;i<list_length(addrs);i++)
{
int addr=list_get_int(addrs,i);
port_mcu *mcu=tran_get_portm(tran,addr-1);
if(mcu){
port_start(mcu,updata_creat(data,file->file_size));
g_updata.updata_run++;
}
}
cmd_print("start updata,addr=%s",str_temp(list_string(addrs)));
return 0;
}
static void cmd_end_slot(void *obj,port_mcu *src,void *data,int ack,char *err_str)
{
updata_def *self=obj;
if(self->updata_run>0)
{
cmd_print("addr:%d %s",port_get_addr(src),err_str);
self->updata_run--;
}
}
// 挂载命令行槽函数
static int cmd_slot_init(void)
{
void *tr=app_variable("tran",0,0);
if(tr){
for(int i=0;i<20;i++){
port_mcu *mcu=tran_get_portm(tr,i);
// 连接操作结束信号
if(mcu)
connect(mcu,port_end_signal,0,&g_updata,cmd_end_slot);
}
}
else{
app_valid_call("tran",(void (*)(void *))cmd_slot_init,0);
}
return 0;
}
app_init_export(cmd_slot_init);
commend_export(updatas,updata_slave,"updata slave")
@@ -219,23 +156,6 @@ commend_export(reboot,reboot,"reboot mcu")
static int moter(list_def *argv)
{
const sys_param_def *par=sys_param();
cmd_print("moter ctl");
if(list_length(argv)<3){
cmd_print("param num too less.");
return -1;
}
int fre=str_atoi(list_get_str(argv,1));
int count=str_atoi(list_get_str(argv,2));
moter_start(fre,count);
cmd_print("moter start,fre=%d,count=%d",fre,count);
return 0;
}
commend_export(moter,moter,"control moter up or down|use:moter [frequency] [count]")