批检仪检测流程验证成功
This commit is contained in:
@@ -201,11 +201,19 @@ protpc_export(0x31, get_selfdev_checkend);
|
||||
int selfdev_moter::dolater(int cmd, myarray data)
|
||||
{
|
||||
prot_m4 *m4 = protM4();
|
||||
mycfg *cfg_=syscfg();
|
||||
connect(this, &selfdev_moter::send_to_m4_signal, m4, &prot_m4::send_data_slot);
|
||||
if(data[0]==0x02){
|
||||
emit send_to_m4_signal(moter_ctrl("up"));
|
||||
}else if(data[0]==0x03){
|
||||
emit send_to_m4_signal(moter_ctrl("down"));
|
||||
}else if(data[0]==0x01){
|
||||
if(data.size()>=3){
|
||||
int count=(data[1])|(data[2]<<8);
|
||||
cfg_->moter_count=20000+count;
|
||||
qDebug("moter count=%d",cfg_->moter_count);
|
||||
cfg_->save();
|
||||
}
|
||||
}
|
||||
emit send_data_signal(0x40,myarray(1,char(0)));
|
||||
return 0;
|
||||
@@ -281,7 +289,7 @@ protpc_export(0xfe, get_selfdev_slaveupdate);
|
||||
|
||||
|
||||
|
||||
|
||||
// 方案升级
|
||||
int selfdev_update_scheme::dolater(int cmd, myarray data)
|
||||
{
|
||||
myarray r;
|
||||
@@ -358,6 +366,229 @@ protpc_export(0x22, get_selfdev_update_scheme);
|
||||
|
||||
|
||||
|
||||
// 本机升级
|
||||
int selfdev_hostupdate::dolater(int cmd, myarray data)
|
||||
{
|
||||
myarray r;
|
||||
int len_filename=data[0];
|
||||
mystring name=data.mid(1,len_filename);
|
||||
prot_slave *slave=protSlave();
|
||||
mycfg *cfg_=syscfg();
|
||||
busy=1;
|
||||
qInfo()<<"host_app name:"<<name<<endl;
|
||||
data.remove(0,len_filename+1);
|
||||
|
||||
// TODO 校验主板程序
|
||||
|
||||
r.append(uint8_t(0));
|
||||
cfg_->save_file(name,data);
|
||||
emit send_data_signal(0xfd,myarray(1,char(0)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static HandlePc *get_selfdev_hostupdata(){
|
||||
return new selfdev_hostupdate();
|
||||
}
|
||||
|
||||
protpc_export(0xfd, get_selfdev_hostupdata);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// jwt升级
|
||||
int selfdev_jwtupdate::dolater(int cmd, myarray data)
|
||||
{
|
||||
myarray r;
|
||||
int len_filename=data[0];
|
||||
mystring name=data.mid(1,len_filename);
|
||||
prot_slave *slave=protSlave();
|
||||
mycfg *cfg_=syscfg();
|
||||
busy=1;
|
||||
qInfo()<<"jwt_app name:"<<name<<endl;
|
||||
data.remove(0,len_filename+1);
|
||||
|
||||
// TODO 校验小板程序
|
||||
|
||||
r.append(uint8_t(0));
|
||||
cfg_->save_file(name,data);
|
||||
emit send_data_signal(0xfe,myarray(1,char(0)));
|
||||
|
||||
// 自动给小板升级
|
||||
// start_updata_mcu(cfg_->config_path+name,slave_addrs);
|
||||
HandleBoardCast *b=new boardcast_updata_jwt();
|
||||
bool ack=slave->set_boardcast_handle(cfg_->calc_slave_addrs(),b);
|
||||
if(ack==false){
|
||||
qWarning("handle is busy.");
|
||||
busy=0;
|
||||
}else{
|
||||
connect(b,&HandleBoardCast::end_signal,this,&selfdev_slaveupdate::slave_end_slot);
|
||||
b->start(data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static HandlePc *get_selfdev_jwtupdate(){
|
||||
return new selfdev_jwtupdate();
|
||||
}
|
||||
|
||||
protpc_export(0x27, get_selfdev_jwtupdate);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 自研批检仪自检
|
||||
int selfdev_bootinfo::dolater(int cmd, myarray data)
|
||||
{
|
||||
prot_slave *slave=protSlave();
|
||||
mycfg *cfg=syscfg();
|
||||
busy=1;
|
||||
// 这里开始检测
|
||||
qDebug("get bootinfo.");
|
||||
emit send_data_signal(cmd,myarray(1,0));
|
||||
QList<int> addrs=cfg->calc_slave_addrs();
|
||||
foreach(int addr, addrs){
|
||||
HandleSlave *s=new slave_check();
|
||||
bool ack=slave->set_slave_handle(addr,s);
|
||||
if(ack==false){
|
||||
qWarning("addr %d handle is busy.",addr);
|
||||
}else{
|
||||
connect(s,&HandleSlave::end_signal,this,&selfdev_bootinfo::slave_end_slot);
|
||||
s->start(myarray());
|
||||
}
|
||||
}
|
||||
slave_acked.clear();
|
||||
for(int i=0;i<cfg->slave_num;i++){
|
||||
slave_acked.append(myarray());
|
||||
}
|
||||
slave_acked_num=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void selfdev_bootinfo::timeout()
|
||||
{
|
||||
busy=0;
|
||||
}
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct{
|
||||
char build_time[20];
|
||||
char softverion[8];
|
||||
int runtime;
|
||||
uint8_t wdog;
|
||||
char devicetype[12];
|
||||
uint8_t localip[4];
|
||||
uint8_t hostip[4];
|
||||
uint16_t hostport;
|
||||
uint8_t localid;
|
||||
uint32_t schemeid;
|
||||
uint32_t slave_online;
|
||||
}local_bootinfo;
|
||||
#pragma pack()
|
||||
|
||||
#pragma pack(1)
|
||||
typedef struct{
|
||||
uint8_t app_state;
|
||||
uint8_t slaver_addr;
|
||||
uint16_t chip_tmper;
|
||||
uint16_t ad_2v5;
|
||||
uint16_t ad_1v25;
|
||||
uint16_t ad_wave;
|
||||
uint16_t ad_5v5_just;
|
||||
uint16_t ad_26v_just;
|
||||
uint16_t hard_version;
|
||||
uint16_t soft_version;
|
||||
uint16_t res_just;
|
||||
uint32_t scheme_id;
|
||||
}bootinfo_data;
|
||||
#pragma pack()
|
||||
|
||||
// 填充本机自检信息
|
||||
myarray bootinfo_fill_local(void)
|
||||
{
|
||||
int tick=-1;
|
||||
uint8_t wdog=0;
|
||||
uint32_t temp32=0;
|
||||
uint16_t temp16=0;
|
||||
uint8_t temp8=0;
|
||||
uint8_t ip[4]={0};
|
||||
QStringList iplist;
|
||||
mycfg *cfg_=syscfg();
|
||||
check_cfg *ccfg_=check_plan();
|
||||
uint8_t *d=(uint8_t *)calloc(1,sizeof(local_bootinfo));
|
||||
memcpy(d,cfg_->build_date.toLocal8Bit(),cfg_->build_date.size()+1);d+=20;
|
||||
memcpy(d,cfg_->soft_version.toLocal8Bit(),cfg_->soft_version.size()+1);d+=8;
|
||||
memcpy(d,&tick,4);d+=4;
|
||||
memcpy(d,&wdog,1);d+=1;
|
||||
memcpy(d,cfg_->device_type.toLocal8Bit(),cfg_->device_type.size()+1);d+=12;
|
||||
iplist=cfg_->local_ip.split('.');
|
||||
ip[0]=iplist[0].toInt();
|
||||
ip[1]=iplist[1].toInt();
|
||||
ip[2]=iplist[2].toInt();
|
||||
ip[3]=iplist[3].toInt();
|
||||
memcpy(d,ip,4);d+=4;
|
||||
iplist=cfg_->server_ip.split('.');
|
||||
ip[0]=iplist[0].toInt();
|
||||
ip[1]=iplist[1].toInt();
|
||||
ip[2]=iplist[2].toInt();
|
||||
ip[3]=iplist[3].toInt();
|
||||
memcpy(d,ip,4);d+=4;
|
||||
temp16=cfg_->server_port;
|
||||
memcpy(d,&temp16,2);d+=2;
|
||||
temp8=cfg_->local_id;
|
||||
memcpy(d,&temp8,1);d+=1;
|
||||
temp32=ccfg_->get_plan_id();
|
||||
memcpy(d,&temp32,4);d+=4;
|
||||
temp32=0;
|
||||
for(int i=0;i<cfg_->slave_num;i++){
|
||||
temp32|=1<<i;
|
||||
}
|
||||
memcpy(d,&temp32,4);d+=4;
|
||||
myarray arry((char *)d,sizeof(local_bootinfo));
|
||||
free(d);
|
||||
return arry;
|
||||
}
|
||||
|
||||
|
||||
static myarray slave_to_bootinfo_byte(myarray data){
|
||||
data.append(sizeof(bootinfo_data)-data.size(),0);
|
||||
return data;
|
||||
}
|
||||
|
||||
void selfdev_bootinfo::slave_end_slot(int addr,int ack, myarray data)
|
||||
{
|
||||
if(addr<=0||addr>slave_acked.size()){
|
||||
qWarning("slave addr err:%d",addr);
|
||||
return;
|
||||
}
|
||||
slave_acked.replace(addr-1,data);
|
||||
slave_acked_num++;
|
||||
if(slave_acked_num>=slave_acked.size()){
|
||||
myarray r;
|
||||
r.append(char(0));
|
||||
r+=bootinfo_fill_local();
|
||||
for(int i=0;i<slave_acked.size();i++){
|
||||
r.append(slave_to_bootinfo_byte(slave_acked[i]));
|
||||
}
|
||||
emit send_data_signal(0x34,r);
|
||||
busy=0;
|
||||
}
|
||||
}
|
||||
|
||||
static HandlePc *get_selfdev_bootinfo(){
|
||||
return new selfdev_bootinfo();
|
||||
}
|
||||
protpc_export(0x34, get_selfdev_bootinfo);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user