参数下载丢失问题修复,增加单独读取的逻辑
This commit is contained in:
@@ -1204,6 +1204,14 @@ void MavLinkNode::StatusParse(mavlink_message_t msg)
|
|||||||
ccmstate_csv.append(QString::number(vehicle.ccmstate.echo_seq)); ccmstate_csv.append('\n');
|
ccmstate_csv.append(QString::number(vehicle.ccmstate.echo_seq)); ccmstate_csv.append('\n');
|
||||||
|
|
||||||
|
|
||||||
|
}break;
|
||||||
|
case MAVLINK_MSG_ID_STATUSTEXT: {
|
||||||
|
mavlink_statustext_t statustext;
|
||||||
|
mavlink_msg_statustext_decode(&msg,&statustext);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}break;
|
}break;
|
||||||
case MAVLINK_MSG_ID_ENCAPSULATED_DATA: {
|
case MAVLINK_MSG_ID_ENCAPSULATED_DATA: {
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public:
|
|||||||
mavlink_ccmstate_t ccmstate;
|
mavlink_ccmstate_t ccmstate;
|
||||||
mavlink_serial_control_t serial_control;
|
mavlink_serial_control_t serial_control;
|
||||||
|
|
||||||
|
mavlink_statustext_t statustext;
|
||||||
|
|
||||||
}_vehicle;
|
}_vehicle;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ void ParameterProcess::Parse(mavlink_message_t msg)
|
|||||||
status.recieve.isWaitingforValue = false;
|
status.recieve.isWaitingforValue = false;
|
||||||
status.transmit.isWaitingforValue = false;
|
status.transmit.isWaitingforValue = false;
|
||||||
|
|
||||||
|
indexlist.append(param_value.param_index);
|
||||||
|
|
||||||
|
|
||||||
qDebug() << "param_value" << param_value.param_index << param_value.param_value;
|
qDebug() << "param_value" << param_value.param_index << param_value.param_value;
|
||||||
}break;
|
}break;
|
||||||
case MAVLINK_MSG_ID_PARAM_EXT_ACK:{
|
case MAVLINK_MSG_ID_PARAM_EXT_ACK:{
|
||||||
@@ -152,7 +155,7 @@ void ParameterProcess::ReadStateMachine(void)//一整列
|
|||||||
{
|
{
|
||||||
qDebug() << "start reading parameter";
|
qDebug() << "start reading parameter";
|
||||||
status.recieve.isWaitingforValue = true;
|
status.recieve.isWaitingforValue = true;
|
||||||
|
indexlist.clear();
|
||||||
request_list();//一整列
|
request_list();//一整列
|
||||||
|
|
||||||
step++;
|
step++;
|
||||||
@@ -179,7 +182,7 @@ void ParameterProcess::ReadStateMachine(void)//一整列
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
step = 2;
|
step = 3;
|
||||||
qDebug() << "parameter read fail";
|
qDebug() << "parameter read fail";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,6 +203,94 @@ void ParameterProcess::ReadStateMachine(void)//一整列
|
|||||||
request_read("xxx",param_value.param_index+1);//读取
|
request_read("xxx",param_value.param_index+1);//读取
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//整理丢失的包,下一次循环需要读取回来
|
||||||
|
int last = 0;
|
||||||
|
lostIndex.clear();
|
||||||
|
for(QList<int>::iterator i = indexlist.begin();i != indexlist.end();i++) {
|
||||||
|
|
||||||
|
int var = *i;
|
||||||
|
|
||||||
|
if(var - last > 1)
|
||||||
|
{
|
||||||
|
//lost
|
||||||
|
for(int size = var - last -1;size > 0 ;size--)
|
||||||
|
{
|
||||||
|
last ++;
|
||||||
|
lostIndex.append(last);
|
||||||
|
qDebug() << "lost" << last;
|
||||||
|
emit showMessage(tr("parameter lost, index : %1").arg(last));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "var" << var;
|
||||||
|
|
||||||
|
last = var;
|
||||||
|
}
|
||||||
|
|
||||||
|
step ++;
|
||||||
|
|
||||||
|
if(lostIndex.size() > 0)
|
||||||
|
{
|
||||||
|
status.recieve.isWaitingforValue = true;
|
||||||
|
time = QTime::currentTime().msecsSinceStartOfDay();
|
||||||
|
request_read("xxx",lostIndex.at(0));//读取
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(step == 2)//(检查丢失的项,继续单项请求)
|
||||||
|
{
|
||||||
|
if(lostIndex.size() == 0)
|
||||||
|
{
|
||||||
|
step ++;
|
||||||
|
}
|
||||||
|
else//have lost item
|
||||||
|
{
|
||||||
|
//如果超时,那么结束
|
||||||
|
if((QTime::currentTime().msecsSinceStartOfDay() - time) > readTimeout)
|
||||||
|
{
|
||||||
|
qDebug() << "parameter item read one time out,try again ";
|
||||||
|
timeout_count ++;
|
||||||
|
|
||||||
|
if(timeout_count < 3)
|
||||||
|
{
|
||||||
|
status.recieve.isWaitingforValue = true;
|
||||||
|
time = QTime::currentTime().msecsSinceStartOfDay();
|
||||||
|
if(lostIndex.size() > 0)
|
||||||
|
{
|
||||||
|
request_read("xxx",lostIndex.at(0));//读取
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
step = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
step = 3;
|
||||||
|
qDebug() << "parameter read fail";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else//如果没有超时
|
||||||
|
{
|
||||||
|
if(status.recieve.isWaitingforValue == false)//收到item
|
||||||
|
{
|
||||||
|
//qDebug() << "parameter item reccieved";
|
||||||
|
timeout_count = 0;
|
||||||
|
time = QTime::currentTime().msecsSinceStartOfDay();
|
||||||
|
//如果参数count 大于当前index,那么继续等待
|
||||||
|
|
||||||
|
lostIndex.removeAt(0);//移除第一个,因为第一个已经收到了
|
||||||
|
if(lostIndex.size() > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
status.recieve.isWaitingforValue = true;
|
||||||
|
request_read("xxx",lostIndex.at(0));//读取
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -208,7 +299,8 @@ void ParameterProcess::ReadStateMachine(void)//一整列
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(step == 2)//传输结束
|
}
|
||||||
|
else if(step == 3)//传输结束
|
||||||
{
|
{
|
||||||
qDebug() << "step" << step << "recieve complete";
|
qDebug() << "step" << step << "recieve complete";
|
||||||
step = 0;
|
step = 0;
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ private:
|
|||||||
mavlink_param_ext_request_list_t param_ext_request_list;
|
mavlink_param_ext_request_list_t param_ext_request_list;
|
||||||
mavlink_param_ext_request_read_t param_ext_request_read;
|
mavlink_param_ext_request_read_t param_ext_request_read;
|
||||||
|
|
||||||
|
QList<int> indexlist;
|
||||||
|
QList<int> lostIndex;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user