mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-4 GCS/Telemetry Flush telemetry queues while connection is not yet established (to remove stale data)
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@604 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
dafdac14e2
commit
85e5d74710
@ -49,6 +49,8 @@ Telemetry::Telemetry(UAVTalk* utalk, UAVObjectManager* objMngr)
|
|||||||
connect(objMngr, SIGNAL(newInstance(UAVObject*)), this, SLOT(newInstance(UAVObject*)));
|
connect(objMngr, SIGNAL(newInstance(UAVObject*)), this, SLOT(newInstance(UAVObject*)));
|
||||||
// Listen to transaction completions
|
// Listen to transaction completions
|
||||||
connect(utalk, SIGNAL(transactionCompleted(UAVObject*)), this, SLOT(transactionCompleted(UAVObject*)));
|
connect(utalk, SIGNAL(transactionCompleted(UAVObject*)), this, SLOT(transactionCompleted(UAVObject*)));
|
||||||
|
// Get GCS stats object
|
||||||
|
gcsStatsObj = GCSTelemetryStats::GetInstance(objMngr);
|
||||||
// Setup transaction timer
|
// Setup transaction timer
|
||||||
transPending = false;
|
transPending = false;
|
||||||
transTimer = new QTimer(this);
|
transTimer = new QTimer(this);
|
||||||
@ -296,6 +298,7 @@ void Telemetry::processObjectUpdates(UAVObject* obj, EventMask event, bool allIn
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
++txErrors;
|
++txErrors;
|
||||||
|
obj->emitTransactionCompleted(false);
|
||||||
qxtLog->warning(tr("Telemetry: priority event queue is full, event lost (%1)").arg(obj->getName()));
|
qxtLog->warning(tr("Telemetry: priority event queue is full, event lost (%1)").arg(obj->getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -308,6 +311,7 @@ void Telemetry::processObjectUpdates(UAVObject* obj, EventMask event, bool allIn
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
++txErrors;
|
++txErrors;
|
||||||
|
obj->emitTransactionCompleted(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,6 +349,19 @@ void Telemetry::processObjectQueue()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if a connection has been established, only process GCSTelemetryStats updates
|
||||||
|
// (used to establish the connection)
|
||||||
|
GCSTelemetryStats::DataFields gcsStats = gcsStatsObj->getData();
|
||||||
|
if ( gcsStats.Status != GCSTelemetryStats::STATUS_CONNECTED )
|
||||||
|
{
|
||||||
|
objQueue.clear();
|
||||||
|
if ( objInfo.obj->getObjID() != GCSTelemetryStats::OBJID )
|
||||||
|
{
|
||||||
|
objInfo.obj->emitTransactionCompleted(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Setup transaction (skip if unpack event)
|
// Setup transaction (skip if unpack event)
|
||||||
if ( objInfo.event != EV_UNPACKED )
|
if ( objInfo.event != EV_UNPACKED )
|
||||||
{
|
{
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include "uavtalk.h"
|
#include "uavtalk.h"
|
||||||
#include "uavobjects/uavobjectmanager.h"
|
#include "uavobjects/uavobjectmanager.h"
|
||||||
|
#include "uavobjects/gcstelemetrystats.h"
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -74,7 +75,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
// Constants
|
// Constants
|
||||||
static const int REQ_TIMEOUT_MS = 250;
|
static const int REQ_TIMEOUT_MS = 250;
|
||||||
static const int MAX_RETRIES = 3;
|
static const int MAX_RETRIES = 2;
|
||||||
static const int MAX_UPDATE_PERIOD_MS = 1000;
|
static const int MAX_UPDATE_PERIOD_MS = 1000;
|
||||||
static const int MIN_UPDATE_PERIOD_MS = 1;
|
static const int MIN_UPDATE_PERIOD_MS = 1;
|
||||||
static const int MAX_QUEUE_SIZE = 20;
|
static const int MAX_QUEUE_SIZE = 20;
|
||||||
@ -113,6 +114,7 @@ private:
|
|||||||
// Variables
|
// Variables
|
||||||
UAVObjectManager* objMngr;
|
UAVObjectManager* objMngr;
|
||||||
UAVTalk* utalk;
|
UAVTalk* utalk;
|
||||||
|
GCSTelemetryStats* gcsStatsObj;
|
||||||
QList<ObjectTimeInfo> objList;
|
QList<ObjectTimeInfo> objList;
|
||||||
QQueue<ObjectQueueInfo> objQueue;
|
QQueue<ObjectQueueInfo> objQueue;
|
||||||
QQueue<ObjectQueueInfo> objPriorityQueue;
|
QQueue<ObjectQueueInfo> objPriorityQueue;
|
||||||
|
@ -186,12 +186,11 @@ void TelemetryMonitor::processStatsUpdates()
|
|||||||
gcsStats.TxRetries += telStats.txRetries;
|
gcsStats.TxRetries += telStats.txRetries;
|
||||||
|
|
||||||
// Update connection state
|
// Update connection state
|
||||||
|
int oldStatus = gcsStats.Status;
|
||||||
if ( gcsStats.Status == GCSTelemetryStats::STATUS_DISCONNECTED )
|
if ( gcsStats.Status == GCSTelemetryStats::STATUS_DISCONNECTED )
|
||||||
{
|
{
|
||||||
// Request connection
|
// Request connection
|
||||||
gcsStats.Status = GCSTelemetryStats::STATUS_HANDSHAKEREQ;
|
gcsStats.Status = GCSTelemetryStats::STATUS_HANDSHAKEREQ;
|
||||||
statsTimer->setInterval(STATS_CONNECT_PERIOD_MS);
|
|
||||||
qxtLog->info("Trying to connect to the autopilot");
|
|
||||||
}
|
}
|
||||||
else if ( gcsStats.Status == GCSTelemetryStats::STATUS_HANDSHAKEREQ )
|
else if ( gcsStats.Status == GCSTelemetryStats::STATUS_HANDSHAKEREQ )
|
||||||
{
|
{
|
||||||
@ -199,9 +198,6 @@ void TelemetryMonitor::processStatsUpdates()
|
|||||||
if ( flightStats.Status == FlightTelemetryStats::STATUS_HANDSHAKEACK )
|
if ( flightStats.Status == FlightTelemetryStats::STATUS_HANDSHAKEACK )
|
||||||
{
|
{
|
||||||
gcsStats.Status = GCSTelemetryStats::STATUS_CONNECTED;
|
gcsStats.Status = GCSTelemetryStats::STATUS_CONNECTED;
|
||||||
statsTimer->setInterval(STATS_UPDATE_PERIOD_MS);
|
|
||||||
qxtLog->info("Connection with the autopilot established");
|
|
||||||
startRetrievingObjects();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( gcsStats.Status == GCSTelemetryStats::STATUS_CONNECTED )
|
else if ( gcsStats.Status == GCSTelemetryStats::STATUS_CONNECTED )
|
||||||
@ -210,7 +206,6 @@ void TelemetryMonitor::processStatsUpdates()
|
|||||||
if (flightStats.Status == FlightTelemetryStats::STATUS_DISCONNECTED || telStats.rxBytes == 0)
|
if (flightStats.Status == FlightTelemetryStats::STATUS_DISCONNECTED || telStats.rxBytes == 0)
|
||||||
{
|
{
|
||||||
gcsStats.Status = GCSTelemetryStats::STATUS_DISCONNECTED;
|
gcsStats.Status = GCSTelemetryStats::STATUS_DISCONNECTED;
|
||||||
qxtLog->info("Connection with the autopilot lost");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,5 +218,19 @@ void TelemetryMonitor::processStatsUpdates()
|
|||||||
{
|
{
|
||||||
gcsStatsObj->updated();
|
gcsStatsObj->updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Act on new connections or disconnections
|
||||||
|
if (gcsStats.Status == GCSTelemetryStats::STATUS_CONNECTED && gcsStats.Status != oldStatus)
|
||||||
|
{
|
||||||
|
statsTimer->setInterval(STATS_UPDATE_PERIOD_MS);
|
||||||
|
qxtLog->info("Connection with the autopilot established");
|
||||||
|
startRetrievingObjects();
|
||||||
|
}
|
||||||
|
if (gcsStats.Status == GCSTelemetryStats::STATUS_DISCONNECTED && gcsStats.Status != oldStatus)
|
||||||
|
{
|
||||||
|
statsTimer->setInterval(STATS_CONNECT_PERIOD_MS);
|
||||||
|
qxtLog->info("Connection with the autopilot lost");
|
||||||
|
qxtLog->info("Trying to connect to the autopilot");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user