mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
OP-4 GCS/Telemetry Create new objects to report statistics of the telemetry link (plus a few bug fixes, heap size was also increased)
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@516 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
89a6dd30d1
commit
fdbcc1921f
@ -113,7 +113,7 @@ bool UAVObjectGenerator::processAll()
|
||||
sout << "Generating code for object: " << name << endl;
|
||||
// Check for object ID conflicts
|
||||
quint32 id = parser->getObjectID(objidx);
|
||||
if ( objIDList.contains(id) )
|
||||
if ( objIDList.contains(id) || id == 0 )
|
||||
{
|
||||
sout << "Error: Object ID collision found in object " << name << ", modify object name" << endl;
|
||||
return false;
|
||||
|
87
ground/src/plugins/uavobjects/flighttelemetrystats.cpp
Normal file
87
ground/src/plugins/uavobjects/flighttelemetrystats.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file flighttelemetrystats.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the FlightTelemetryStats object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: flighttelemetrystats.xml.
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "flighttelemetrystats.h"
|
||||
#include "uavobjectfields.h"
|
||||
|
||||
const QString FlightTelemetryStats::NAME = QString("FlightTelemetryStats");
|
||||
|
||||
FlightTelemetryStats::FlightTelemetryStats(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||
{
|
||||
// Create fields
|
||||
QList<UAVObjectField*> fields;
|
||||
QStringList ConnectedEnumOptions;
|
||||
ConnectedEnumOptions.append("True");
|
||||
ConnectedEnumOptions.append("False");
|
||||
fields.append(new UAVObjectFieldEnum(QString("Connected"), QString("bool"), 1, ConnectedEnumOptions));
|
||||
fields.append(new UAVObjectFieldFloat(QString("TxDataRate"), QString("bytes/sec"), 1));
|
||||
fields.append(new UAVObjectFieldFloat(QString("RxDataRate"), QString("bytes/sec"), 1));
|
||||
fields.append(new UAVObjectFieldUInt32(QString("TxFailures"), QString("count"), 1));
|
||||
fields.append(new UAVObjectFieldUInt32(QString("RxFailures"), QString("count"), 1));
|
||||
fields.append(new UAVObjectFieldUInt32(QString("TxRetries"), QString("count"), 1));
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||
}
|
||||
|
||||
UAVObject::Metadata FlightTelemetryStats::getDefaultMetadata()
|
||||
{
|
||||
UAVObject::Metadata metadata;
|
||||
metadata.gcsTelemetryAcked = 1;
|
||||
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_NEVER;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.flightTelemetryAcked = 1;
|
||||
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.flightTelemetryUpdatePeriod = 5000;
|
||||
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.loggingUpdatePeriod = 5000;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
FlightTelemetryStats::DataFields FlightTelemetryStats::getData()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return data;
|
||||
}
|
||||
|
||||
void FlightTelemetryStats::setData(DataFields& data)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
this->data = data;
|
||||
emit objectUpdatedAuto(this); // trigger object updated event
|
||||
emit objectUpdated(this);
|
||||
}
|
||||
|
||||
UAVDataObject* FlightTelemetryStats::clone(quint32 instID)
|
||||
{
|
||||
FlightTelemetryStats* obj = new FlightTelemetryStats();
|
||||
obj->initialize(instID, this->getMetaObject());
|
||||
return obj;
|
||||
}
|
76
ground/src/plugins/uavobjects/flighttelemetrystats.h
Normal file
76
ground/src/plugins/uavobjects/flighttelemetrystats.h
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file flighttelemetrystats.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the FlightTelemetryStats object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: flighttelemetrystats.xml.
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef FLIGHTTELEMETRYSTATS_H
|
||||
#define FLIGHTTELEMETRYSTATS_H
|
||||
|
||||
#include "uavdataobject.h"
|
||||
|
||||
class UAVOBJECTS_EXPORT FlightTelemetryStats: public UAVDataObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
quint8 Connected;
|
||||
float TxDataRate;
|
||||
float RxDataRate;
|
||||
quint32 TxFailures;
|
||||
quint32 RxFailures;
|
||||
quint32 TxRetries;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Enumeration types
|
||||
typedef enum { CONNECTED_TRUE=0, CONNECTED_FALSE=1, } ConnectedEnum;
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 766280320U;
|
||||
static const QString NAME;
|
||||
static const bool ISSINGLEINST = 1;
|
||||
static const bool ISSETTINGS = 0;
|
||||
static const quint32 NUMBYTES = sizeof(DataFields);
|
||||
|
||||
// Functions
|
||||
FlightTelemetryStats();
|
||||
|
||||
DataFields getData();
|
||||
void setData(DataFields& data);
|
||||
Metadata getDefaultMetadata();
|
||||
UAVDataObject* clone(quint32 instID);
|
||||
|
||||
private:
|
||||
DataFields data;
|
||||
|
||||
};
|
||||
|
||||
#endif // FLIGHTTELEMETRYSTATS_H
|
87
ground/src/plugins/uavobjects/gcstelemetrystats.cpp
Normal file
87
ground/src/plugins/uavobjects/gcstelemetrystats.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gcstelemetrystats.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the GCSTelemetryStats object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: gcstelemetrystats.xml.
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "gcstelemetrystats.h"
|
||||
#include "uavobjectfields.h"
|
||||
|
||||
const QString GCSTelemetryStats::NAME = QString("GCSTelemetryStats");
|
||||
|
||||
GCSTelemetryStats::GCSTelemetryStats(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||
{
|
||||
// Create fields
|
||||
QList<UAVObjectField*> fields;
|
||||
QStringList ConnectedEnumOptions;
|
||||
ConnectedEnumOptions.append("True");
|
||||
ConnectedEnumOptions.append("False");
|
||||
fields.append(new UAVObjectFieldEnum(QString("Connected"), QString("bool"), 1, ConnectedEnumOptions));
|
||||
fields.append(new UAVObjectFieldFloat(QString("TxDataRate"), QString("bytes/sec"), 1));
|
||||
fields.append(new UAVObjectFieldFloat(QString("RxDataRate"), QString("bytes/sec"), 1));
|
||||
fields.append(new UAVObjectFieldUInt32(QString("TxFailures"), QString("count"), 1));
|
||||
fields.append(new UAVObjectFieldUInt32(QString("RxFailures"), QString("count"), 1));
|
||||
fields.append(new UAVObjectFieldUInt32(QString("TxRetries"), QString("count"), 1));
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||
}
|
||||
|
||||
UAVObject::Metadata GCSTelemetryStats::getDefaultMetadata()
|
||||
{
|
||||
UAVObject::Metadata metadata;
|
||||
metadata.gcsTelemetryAcked = 1;
|
||||
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_NEVER;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.flightTelemetryAcked = 1;
|
||||
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_NEVER;
|
||||
metadata.flightTelemetryUpdatePeriod = 0;
|
||||
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_NEVER;
|
||||
metadata.loggingUpdatePeriod = 0;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
GCSTelemetryStats::DataFields GCSTelemetryStats::getData()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return data;
|
||||
}
|
||||
|
||||
void GCSTelemetryStats::setData(DataFields& data)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
this->data = data;
|
||||
emit objectUpdatedAuto(this); // trigger object updated event
|
||||
emit objectUpdated(this);
|
||||
}
|
||||
|
||||
UAVDataObject* GCSTelemetryStats::clone(quint32 instID)
|
||||
{
|
||||
GCSTelemetryStats* obj = new GCSTelemetryStats();
|
||||
obj->initialize(instID, this->getMetaObject());
|
||||
return obj;
|
||||
}
|
76
ground/src/plugins/uavobjects/gcstelemetrystats.h
Normal file
76
ground/src/plugins/uavobjects/gcstelemetrystats.h
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file gcstelemetrystats.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the GCSTelemetryStats object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: gcstelemetrystats.xml.
|
||||
* This is an automatically generated file.
|
||||
* DO NOT modify manually.
|
||||
*
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef GCSTELEMETRYSTATS_H
|
||||
#define GCSTELEMETRYSTATS_H
|
||||
|
||||
#include "uavdataobject.h"
|
||||
|
||||
class UAVOBJECTS_EXPORT GCSTelemetryStats: public UAVDataObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
quint8 Connected;
|
||||
float TxDataRate;
|
||||
float RxDataRate;
|
||||
quint32 TxFailures;
|
||||
quint32 RxFailures;
|
||||
quint32 TxRetries;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Enumeration types
|
||||
typedef enum { CONNECTED_TRUE=0, CONNECTED_FALSE=1, } ConnectedEnum;
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 607270704U;
|
||||
static const QString NAME;
|
||||
static const bool ISSINGLEINST = 1;
|
||||
static const bool ISSETTINGS = 0;
|
||||
static const quint32 NUMBYTES = sizeof(DataFields);
|
||||
|
||||
// Functions
|
||||
GCSTelemetryStats();
|
||||
|
||||
DataFields getData();
|
||||
void setData(DataFields& data);
|
||||
Metadata getDefaultMetadata();
|
||||
UAVDataObject* clone(quint32 instID);
|
||||
|
||||
private:
|
||||
DataFields data;
|
||||
|
||||
};
|
||||
|
||||
#endif // GCSTELEMETRYSTATS_H
|
@ -24,7 +24,9 @@ HEADERS += uavobjects_global.h \
|
||||
uavobjectfielduint32.h \
|
||||
uavobjectfields.h \
|
||||
settingspersistence.h \
|
||||
gpsobject.h
|
||||
gpsobject.h \
|
||||
gcstelemetrystats.h \
|
||||
flighttelemetrystats.h
|
||||
SOURCES += uavobject.cpp \
|
||||
uavmetaobject.cpp \
|
||||
uavobjectmanager.cpp \
|
||||
@ -45,6 +47,8 @@ SOURCES += uavobject.cpp \
|
||||
uavobjectfielduint16.cpp \
|
||||
uavobjectfielduint32.cpp \
|
||||
settingspersistence.cpp \
|
||||
gpsobject.cpp
|
||||
gpsobject.cpp \
|
||||
gcstelemetrystats.cpp \
|
||||
flighttelemetrystats.cpp
|
||||
DEFINES += UAVOBJECTS_LIBRARY
|
||||
OTHER_FILES += UAVObjects.pluginspec
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include "exampleobject1.h"
|
||||
#include "exampleobject2.h"
|
||||
#include "examplesettings.h"
|
||||
#include "flighttelemetrystats.h"
|
||||
#include "gcstelemetrystats.h"
|
||||
#include "gpsobject.h"
|
||||
#include "settingspersistence.h"
|
||||
|
||||
@ -46,6 +48,8 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
|
||||
objMngr->registerObject( new ExampleObject1() );
|
||||
objMngr->registerObject( new ExampleObject2() );
|
||||
objMngr->registerObject( new ExampleSettings() );
|
||||
objMngr->registerObject( new FlightTelemetryStats() );
|
||||
objMngr->registerObject( new GCSTelemetryStats() );
|
||||
objMngr->registerObject( new GpsObject() );
|
||||
objMngr->registerObject( new SettingsPersistence() );
|
||||
|
||||
|
@ -58,7 +58,13 @@ Telemetry::Telemetry(UAVTalk* utalk, UAVObjectManager* objMngr)
|
||||
updateTimer = new QTimer(this);
|
||||
connect(updateTimer, SIGNAL(timeout()), this, SLOT(processPeriodicUpdates()));
|
||||
updateTimer->start(1000);
|
||||
|
||||
// Setup and start the stats timer
|
||||
statsObj = dynamic_cast<GCSTelemetryStats*>( objMngr->getObject(GCSTelemetryStats::NAME) );
|
||||
txErrors = 0;
|
||||
txRetries = 0;
|
||||
statsTimer = new QTimer(this);
|
||||
connect(statsTimer, SIGNAL(timeout()), this, SLOT(processStatsUpdates()));
|
||||
statsTimer->start(STATS_UPDATE_PERIOD_MS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -227,6 +233,7 @@ void Telemetry::transactionTimeout()
|
||||
{
|
||||
--transInfo.retriesRemaining;
|
||||
processObjectTransaction();
|
||||
++txRetries;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -235,6 +242,7 @@ void Telemetry::transactionTimeout()
|
||||
transPending = false;
|
||||
// Process new object updates from queue
|
||||
processObjectQueue();
|
||||
++txErrors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -375,6 +383,34 @@ void Telemetry::processPeriodicUpdates()
|
||||
updateTimer->start(timeToNextUpdateMs);
|
||||
}
|
||||
|
||||
void Telemetry::processStatsUpdates()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
||||
// Get UAVTalk stats
|
||||
UAVTalk::ComStats utalkStats = utalk->getStats();
|
||||
utalk->resetStats();
|
||||
|
||||
// Update stats object
|
||||
GCSTelemetryStats::DataFields stats = statsObj->getData();
|
||||
if (utalkStats.rxBytes > 0)
|
||||
{
|
||||
stats.Connected = GCSTelemetryStats::CONNECTED_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
stats.Connected = GCSTelemetryStats::CONNECTED_FALSE;
|
||||
}
|
||||
stats.RxDataRate = (float)utalkStats.rxBytes / ((float)STATS_UPDATE_PERIOD_MS/1000.0);
|
||||
stats.TxDataRate = (float)utalkStats.txBytes / ((float)STATS_UPDATE_PERIOD_MS/1000.0);
|
||||
stats.RxFailures += utalkStats.rxErrors;
|
||||
stats.TxFailures += txErrors;
|
||||
stats.TxRetries += txRetries;
|
||||
txErrors = 0;
|
||||
txRetries = 0;
|
||||
statsObj->setData(stats);
|
||||
}
|
||||
|
||||
void Telemetry::objectUpdatedAuto(UAVObject* obj)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "uavtalk.h"
|
||||
#include "uavobjects/uavobjectmanager.h"
|
||||
#include "uavobjects/gcstelemetrystats.h"
|
||||
#include <QMutex>
|
||||
#include <QMutexLocker>
|
||||
#include <QTimer>
|
||||
@ -55,6 +56,7 @@ private slots:
|
||||
void processPeriodicUpdates();
|
||||
void transactionCompleted(UAVObject* obj);
|
||||
void transactionTimeout();
|
||||
void processStatsUpdates();
|
||||
|
||||
private:
|
||||
// Constants
|
||||
@ -62,6 +64,7 @@ private:
|
||||
static const int MAX_RETRIES = 3;
|
||||
static const int MAX_UPDATE_PERIOD_MS = 1000;
|
||||
static const int MIN_UPDATE_PERIOD_MS = 1;
|
||||
static const int STATS_UPDATE_PERIOD_MS = 5000;
|
||||
|
||||
// Types
|
||||
/**
|
||||
@ -103,7 +106,11 @@ private:
|
||||
QMutex* mutex;
|
||||
QTimer* updateTimer;
|
||||
QTimer* transTimer;
|
||||
QTimer* statsTimer;
|
||||
qint32 timeToNextUpdateMs;
|
||||
quint32 txErrors;
|
||||
quint32 txRetries;
|
||||
GCSTelemetryStats* statsObj;
|
||||
|
||||
// Methods
|
||||
void registerObject(UAVObject* obj);
|
||||
|
@ -38,9 +38,28 @@ UAVTalk::UAVTalk(QIODevice* iodev, UAVObjectManager* objMngr)
|
||||
rxState = STATE_SYNC;
|
||||
mutex = new QMutex(QMutex::Recursive);
|
||||
respObj = NULL;
|
||||
memset(&stats, 0, sizeof(ComStats));
|
||||
connect(io, SIGNAL(readyRead()), this, SLOT(processInputStream()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the statistics counters
|
||||
*/
|
||||
void UAVTalk::resetStats()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
memset(&stats, 0, sizeof(ComStats));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the statistics counters
|
||||
*/
|
||||
UAVTalk::ComStats UAVTalk::getStats()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called each time there are data in the input buffer
|
||||
*/
|
||||
@ -140,6 +159,8 @@ bool UAVTalk::objectTransaction(UAVObject* obj, quint8 type, bool allInstances)
|
||||
*/
|
||||
bool UAVTalk::processInputByte(quint8 rxbyte)
|
||||
{
|
||||
// Update stats
|
||||
++stats.rxBytes;
|
||||
// Receive state machine
|
||||
switch (rxState) {
|
||||
case STATE_SYNC:
|
||||
@ -161,6 +182,7 @@ bool UAVTalk::processInputByte(quint8 rxbyte)
|
||||
if (rxObj == NULL)
|
||||
{
|
||||
rxState = STATE_SYNC;
|
||||
++stats.rxErrors;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -179,6 +201,7 @@ bool UAVTalk::processInputByte(quint8 rxbyte)
|
||||
if (rxLength >= MAX_PAYLOAD_LENGTH)
|
||||
{
|
||||
rxState = STATE_SYNC;
|
||||
++stats.rxErrors;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -242,13 +265,20 @@ bool UAVTalk::processInputByte(quint8 rxbyte)
|
||||
{
|
||||
mutex->lock();
|
||||
receiveObject(rxType, rxObjId, rxInstId, rxBuffer, rxLength);
|
||||
stats.rxObjectBytes += rxLength;
|
||||
++stats.rxObjects;
|
||||
mutex->unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
++stats.rxErrors;
|
||||
}
|
||||
rxState = STATE_SYNC;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rxState = STATE_SYNC;
|
||||
++stats.rxErrors;
|
||||
}
|
||||
|
||||
// Done
|
||||
@ -541,6 +571,11 @@ bool UAVTalk::transmitSingleObject(UAVObject* obj, quint8 type, bool allInstance
|
||||
// Send buffer
|
||||
io->write((const char*)txBuffer, dataOffset+length+CHECKSUM_LENGTH);
|
||||
|
||||
// Update stats
|
||||
++stats.txObjects;
|
||||
stats.txBytes += dataOffset+length+CHECKSUM_LENGTH;
|
||||
stats.txObjectBytes += length;
|
||||
|
||||
// Done
|
||||
return true;
|
||||
}
|
||||
|
@ -39,11 +39,24 @@ class UAVTalk: public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef struct {
|
||||
quint32 txBytes;
|
||||
quint32 rxBytes;
|
||||
quint32 txObjectBytes;
|
||||
quint32 rxObjectBytes;
|
||||
quint32 rxObjects;
|
||||
quint32 txObjects;
|
||||
quint32 txErrors;
|
||||
quint32 rxErrors;
|
||||
} ComStats;
|
||||
|
||||
UAVTalk(QIODevice* iodev, UAVObjectManager* objMngr);
|
||||
|
||||
bool sendObject(UAVObject* obj, bool acked, bool allInstances);
|
||||
bool sendObjectRequest(UAVObject* obj, bool allInstances);
|
||||
void cancelTransaction();
|
||||
ComStats getStats();
|
||||
void resetStats();
|
||||
|
||||
signals:
|
||||
void transactionCompleted(UAVObject* obj);
|
||||
@ -84,6 +97,7 @@ private:
|
||||
quint16 rxCSPacket, rxCS;
|
||||
qint32 rxCount;
|
||||
RxStateType rxState;
|
||||
ComStats stats;
|
||||
|
||||
// Methods
|
||||
bool objectTransaction(UAVObject* obj, quint8 type, bool allInstances);
|
||||
|
@ -1,15 +1,15 @@
|
||||
<xml>
|
||||
<object name="ExampleObject1" singleinstance="false" settings="false">
|
||||
<field name="Field1" units="unit1" type="int8" elements="1"/>
|
||||
<field name="Field2" units="unit2" type="int16" elements="1"/>
|
||||
<field name="Field3" units="unit3" type="int32" elements="1"/>
|
||||
<field name="Field4" units="unit4" type="float" elements="4"/>
|
||||
<field name="Field5" units="unit5" type="uint8" elements="1"/>
|
||||
<field name="Field6" units="unit6" type="uint16" elements="1"/>
|
||||
<field name="Field7" units="unit7" type="uint32" elements="1"/>
|
||||
<field name="Field8" units="unit8" type="enum" elements="1" options="Option1, Option2"/>
|
||||
<telemetrygcs acked="true" updatemode="periodic" period="200"/>
|
||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
<field name="Field1" units="unit1" type="int8" elements="1"/>
|
||||
<field name="Field2" units="unit2" type="int16" elements="1"/>
|
||||
<field name="Field3" units="unit3" type="int32" elements="1"/>
|
||||
<field name="Field4" units="unit4" type="float" elements="4"/>
|
||||
<field name="Field5" units="unit5" type="uint8" elements="1"/>
|
||||
<field name="Field6" units="unit6" type="uint16" elements="1"/>
|
||||
<field name="Field7" units="unit7" type="uint32" elements="1"/>
|
||||
<field name="Field8" units="unit8" type="enum" elements="1" options="Option1, Option2"/>
|
||||
<telemetrygcs acked="true" updatemode="periodic" period="200"/>
|
||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
</object>
|
||||
</xml>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<xml>
|
||||
<object name="ExampleObject2" singleinstance="false" settings="false">
|
||||
<field name="Field1" units="unit1" type="int8" elements="1"/>
|
||||
<field name="Field2" units="unit2" type="int16" elements="1"/>
|
||||
<field name="Field3" units="unit3" type="int32" elements="1"/>
|
||||
<field name="Field4" units="unit4" type="float" elements="4"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="periodic" period="100"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
<field name="Field1" units="unit1" type="int8" elements="1"/>
|
||||
<field name="Field2" units="unit2" type="int16" elements="1"/>
|
||||
<field name="Field3" units="unit3" type="int32" elements="1"/>
|
||||
<field name="Field4" units="unit4" type="float" elements="4"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="periodic" period="100"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
</object>
|
||||
</xml>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<xml>
|
||||
<object name="ExampleSettings" singleinstance="true" settings="true">
|
||||
<field name="UpdatePeriod" units="ms" type="int32" elements="1"/>
|
||||
<field name="StepSize" units="" type="int32" elements="1"/>
|
||||
<field name="StepDirection" units="" type="enum" elements="1" options="up,down"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
<field name="UpdatePeriod" units="ms" type="int32" elements="1"/>
|
||||
<field name="StepSize" units="" type="int32" elements="1"/>
|
||||
<field name="StepDirection" units="" type="enum" elements="1" options="up,down"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
</object>
|
||||
</xml>
|
||||
</xml>
|
||||
|
@ -0,0 +1,13 @@
|
||||
<xml>
|
||||
<object name="FlightTelemetryStats" singleinstance="true" settings="false">
|
||||
<field name="Connected" units="bool" type="enum" elements="1" options="True, False"/>
|
||||
<field name="TxDataRate" units="bytes/sec" type="float" elements="1"/>
|
||||
<field name="RxDataRate" units="bytes/sec" type="float" elements="1"/>
|
||||
<field name="TxFailures" units="count" type="uint32" elements="1"/>
|
||||
<field name="RxFailures" units="count" type="uint32" elements="1"/>
|
||||
<field name="TxRetries" units="count" type="uint32" elements="1"/>
|
||||
<telemetrygcs acked="true" updatemode="never" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="periodic" period="5000"/>
|
||||
<logging updatemode="periodic" period="5000"/>
|
||||
</object>
|
||||
</xml>
|
13
ground/src/shared/uavobjectdefinition/gcstelemetrystats.xml
Normal file
13
ground/src/shared/uavobjectdefinition/gcstelemetrystats.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<xml>
|
||||
<object name="GCSTelemetryStats" singleinstance="true" settings="false">
|
||||
<field name="Connected" units="bool" type="enum" elements="1" options="True, False"/>
|
||||
<field name="TxDataRate" units="bytes/sec" type="float" elements="1"/>
|
||||
<field name="RxDataRate" units="bytes/sec" type="float" elements="1"/>
|
||||
<field name="TxFailures" units="count" type="uint32" elements="1"/>
|
||||
<field name="RxFailures" units="count" type="uint32" elements="1"/>
|
||||
<field name="TxRetries" units="count" type="uint32" elements="1"/>
|
||||
<telemetrygcs acked="true" updatemode="never" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="never" period="0"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
</object>
|
||||
</xml>
|
@ -1,8 +1,8 @@
|
||||
<xml>
|
||||
<object name="SettingsPersistence" singleinstance="true" settings="false">
|
||||
<field name="Operation" units="" type="enum" elements="1" options="Load,Save"/>
|
||||
<telemetrygcs acked="true" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="manual" period="0"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
<field name="Operation" units="" type="enum" elements="1" options="Load,Save"/>
|
||||
<telemetrygcs acked="true" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="manual" period="0"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
</object>
|
||||
</xml>
|
||||
|
Loading…
x
Reference in New Issue
Block a user