广播方式升级从机成功
This commit is contained in:
@@ -234,6 +234,7 @@ int selfdev_slaveupdate::dolater(int cmd, myarray data)
|
||||
mystring name=data.mid(1,len_filename);
|
||||
prot_slave *slave=protSlave();
|
||||
mycfg *cfg_=syscfg();
|
||||
busy=1;
|
||||
qInfo()<<"slave_app name:"<<name<<endl;
|
||||
data.remove(0,len_filename+1);
|
||||
|
||||
@@ -249,6 +250,7 @@ int selfdev_slaveupdate::dolater(int cmd, myarray data)
|
||||
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);
|
||||
@@ -258,12 +260,14 @@ int selfdev_slaveupdate::dolater(int cmd, myarray data)
|
||||
}
|
||||
|
||||
void selfdev_slaveupdate::timeout(){
|
||||
|
||||
busy=0;
|
||||
qDebug("slave update timeout");
|
||||
}
|
||||
|
||||
void selfdev_slaveupdate::slave_end_slot(int addr,int ack, myarray data)
|
||||
{
|
||||
qDebug("slave update end,ack=%d",ack);
|
||||
busy=0;
|
||||
}
|
||||
|
||||
static HandlePc *get_selfdev_slaveupdate(){
|
||||
@@ -276,3 +280,86 @@ protpc_export(0xfe, get_selfdev_slaveupdate);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int selfdev_update_scheme::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();
|
||||
check_cfg *ccfg_=check_plan();
|
||||
uint8_t rw=data[0];
|
||||
data.remove(0,1);
|
||||
|
||||
busy=1;
|
||||
if(rw==0)
|
||||
{
|
||||
// 读方案
|
||||
r.append(char(0));
|
||||
r.append(rw);
|
||||
r.append(ccfg_->scheme_to_jstring());
|
||||
emit send_data_signal(0x22,r);
|
||||
busy=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 写方案
|
||||
bool ack=ccfg_->updata(QString(data));
|
||||
r.append(ack?char(0):char(1));
|
||||
r.append(rw);
|
||||
if(ack){
|
||||
// 检测数据保存
|
||||
// if(comm_f_!=nullptr){
|
||||
// delete comm_f_;
|
||||
// comm_f_=nullptr;
|
||||
// }
|
||||
// 自动给小板升级
|
||||
HandleBoardCast *b=new boardcast_updata_scheme();
|
||||
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_update_scheme::slave_end_slot);
|
||||
b->start(data);
|
||||
}
|
||||
}
|
||||
else{
|
||||
r.append("方案解析失败");
|
||||
qWarning("scheme check failed.");
|
||||
}
|
||||
emit send_data_signal(0x22,r);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void selfdev_update_scheme::timeout(){
|
||||
busy=0;
|
||||
qDebug("slave update timeout");
|
||||
}
|
||||
|
||||
void selfdev_update_scheme::slave_end_slot(int addr,int ack, myarray data)
|
||||
{
|
||||
qDebug("slave update end,ack=%d",ack);
|
||||
busy=0;
|
||||
}
|
||||
|
||||
static HandlePc *get_selfdev_update_scheme(){
|
||||
return new selfdev_update_scheme();
|
||||
}
|
||||
|
||||
protpc_export(0x22, get_selfdev_update_scheme);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user