制定任务执行命令

This commit is contained in:
ranchuan
2023-12-19 18:14:35 +08:00
parent a908698e2e
commit bf4b4b45ea
12 changed files with 315 additions and 22 deletions

View File

@@ -475,14 +475,42 @@ int slave_bootinfo::dolater(int cmd, myarray data)
int slave_cmd::start(myarray data)
{
int timeout=5000;
int timeout;
busy=1;
timeout=check_plan()->get_check_time_out()*1000;
qDebug("addr %d start ,timeout=%d",addr,timeout);
send_data(cmd,data,3);
this->data=data;
send_pack_num=0;
send_bytes=0;
send_next();
timeout_start(timeout);
return 0;
}
// 发送下一包,返回true完成
bool slave_cmd::send_next()
{
int pack_size=236;
int data_size=data.size();
if(send_bytes<data_size){
if(pack_size>data_size-send_bytes){
pack_size=data_size-send_bytes;
}
myarray d;
d.append(uint8_t(data_size&0xff));
d.append(uint8_t((data_size>>8)&0xff));
d.append(uint8_t((send_pack_num)&0xff));
d.append(uint8_t(pack_size&0xff));
d.append(data.mid(send_bytes,pack_size));
send_data(cmd,d,3);
send_bytes+=pack_size;
send_pack_num++;
return false;
}else{
return true;
}
}
void slave_cmd::timeout()
{
timeout_stop();
@@ -496,10 +524,12 @@ int slave_cmd::dolater(int cmd, myarray data)
this->addr_response=0;
timeout_stop_retry();
if(cmd==this->cmd){
qDebug("cmd end success.");
busy=0;
end(0,ret_data);
timeout_stop();
if(send_next()==true){
qDebug("cmd end success.");
busy=0;
end(0,ret_data);
timeout_stop();
}
}else{
qWarning("cmd:%02x err.",cmd);
}