广播方式升级从机成功
This commit is contained in:
@@ -218,7 +218,7 @@ void boardcast_updata::timeout()
|
||||
|
||||
int boardcast_updata::start(myarray data)
|
||||
{
|
||||
int timeout=50000;
|
||||
int timeout=5000;
|
||||
busy=1;
|
||||
qWarning()<<"addr "<<addr<<" updata start.";
|
||||
timeout_start(timeout);
|
||||
@@ -231,8 +231,7 @@ int boardcast_updata::start(myarray data)
|
||||
|
||||
int boardcast_updata::dolater(int cmd, myarray data)
|
||||
{
|
||||
timeout_stop_retry();
|
||||
timeout_start(50000);
|
||||
timeout_start(5000);
|
||||
if(step==0){
|
||||
if(send_packet()==true){
|
||||
step=1;
|
||||
@@ -257,6 +256,8 @@ int boardcast_updata::dolater(int cmd, myarray data)
|
||||
send_data(0xfb,s,10);
|
||||
step=2;
|
||||
}else if(step==2){
|
||||
timeout_stop();
|
||||
timeout_stop_retry();
|
||||
qDebug("slave updata end.");
|
||||
end(0,data);
|
||||
busy=0;
|
||||
@@ -268,7 +269,7 @@ bool boardcast_updata::send_packet()
|
||||
{
|
||||
if(count_sent<data.size()){
|
||||
uint32_t addr=MCU_APP_ADDR_BASE+count_sent;
|
||||
int pack_size=240;
|
||||
int pack_size=236;
|
||||
myarray s;
|
||||
if(pack_size>data.size()-count_sent){
|
||||
pack_size=data.size()-count_sent;
|
||||
@@ -280,6 +281,7 @@ bool boardcast_updata::send_packet()
|
||||
s+=data.mid(count_sent,pack_size);
|
||||
count_sent+=pack_size;
|
||||
send_data(0xfc,s,10);
|
||||
rate(count_sent*100/data.size(),"slave_updata");
|
||||
}
|
||||
if(count_sent<data.size()){
|
||||
return false;
|
||||
@@ -289,3 +291,95 @@ bool boardcast_updata::send_packet()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void boardcast_updata_scheme::timeout()
|
||||
{
|
||||
timeout_stop();
|
||||
qWarning("slave updata timeout.");
|
||||
end(1,myarray());
|
||||
busy=0;
|
||||
}
|
||||
|
||||
int boardcast_updata_scheme::start(myarray data)
|
||||
{
|
||||
int timeout=5000;
|
||||
busy=1;
|
||||
base_addr=MCU_TASKID_ADDR_BASE;
|
||||
qWarning()<<"addr "<<addr<<" updata start.";
|
||||
timeout_start(timeout);
|
||||
// 擦除
|
||||
step=0;
|
||||
this->data=data;
|
||||
send_packet();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int boardcast_updata_scheme::dolater(int cmd, myarray data)
|
||||
{
|
||||
timeout_start(5000);
|
||||
if(step==0){
|
||||
if(send_packet()==true){
|
||||
step=1;
|
||||
}
|
||||
}else if(step==1){
|
||||
send_data(0x15,myarray(),10);
|
||||
step=2;
|
||||
}else if(step==2){
|
||||
timeout_stop();
|
||||
timeout_stop_retry();
|
||||
qDebug("slave updata scheme end.");
|
||||
end(0,data);
|
||||
busy=0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool boardcast_updata_scheme::send_packet()
|
||||
{
|
||||
if(count_sent<data.size()){
|
||||
uint32_t addr=base_addr+count_sent;
|
||||
int pack_size=236;
|
||||
myarray s;
|
||||
if(pack_size>data.size()-count_sent){
|
||||
pack_size=data.size()-count_sent;
|
||||
}
|
||||
s.append((addr)&0xff);
|
||||
s.append((addr>>8)&0xff);
|
||||
s.append((addr>>16)&0xff);
|
||||
s.append((addr>>24)&0xff);
|
||||
s+=data.mid(count_sent,pack_size);
|
||||
count_sent+=pack_size;
|
||||
send_data(0x11,s,10);
|
||||
rate(count_sent*100/data.size(),"slave_updata_scheme");
|
||||
}
|
||||
if(count_sent<data.size()){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int boardcast_updata_jwt::start(myarray data)
|
||||
{
|
||||
int timeout=5000;
|
||||
busy=1;
|
||||
base_addr=MCU_JWT_ADDR_BASE;
|
||||
qWarning()<<"addr "<<addr<<" updata start.";
|
||||
timeout_start(timeout);
|
||||
// 擦除
|
||||
step=0;
|
||||
this->data=data;
|
||||
send_packet();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user