1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

OP-1122 OP-1145 ground side uavtalk and telemetry enhancements

- added more stats (bytes, sync errors, crc errors)
- made error handling more robust
This commit is contained in:
Philippe Renon 2013-12-19 03:19:29 +01:00
parent 5f33fadb1b
commit 02e3970864
6 changed files with 65 additions and 30 deletions

View File

@ -377,7 +377,9 @@ void Telemetry::processObjectQueue()
GCSTelemetryStats::DataFields gcsStats = gcsStatsObj->getData();
if (gcsStats.Status != GCSTelemetryStats::STATUS_CONNECTED) {
objQueue.clear();
if (objInfo.obj->getObjID() != GCSTelemetryStats::OBJID && objInfo.obj->getObjID() != OPLinkSettings::OBJID && objInfo.obj->getObjID() != ObjectPersistence::OBJID) {
if ((objInfo.obj->getObjID() != GCSTelemetryStats::OBJID) &&
(objInfo.obj->getObjID() != OPLinkSettings::OBJID) &&
(objInfo.obj->getObjID() != ObjectPersistence::OBJID)) {
objInfo.obj->emitTransactionCompleted(false);
return;
}
@ -498,15 +500,18 @@ Telemetry::TelemetryStats Telemetry::getStats()
TelemetryStats stats;
stats.txBytes = utalkStats.txBytes;
stats.rxBytes = utalkStats.rxBytes;
stats.txObjectBytes = utalkStats.txObjectBytes;
stats.rxObjectBytes = utalkStats.rxObjectBytes;
stats.rxObjects = utalkStats.rxObjects;
stats.txObjects = utalkStats.txObjects;
stats.txErrors = utalkStats.txErrors + txErrors;
stats.rxErrors = utalkStats.rxErrors;
stats.txRetries = txRetries;
stats.rxBytes = utalkStats.rxBytes;
stats.rxObjectBytes = utalkStats.rxObjectBytes;
stats.rxObjects = utalkStats.rxObjects;
stats.rxErrors = utalkStats.rxErrors;
stats.rxSyncErrors = utalkStats.rxSyncErrors;
stats.rxCrcErrors = utalkStats.rxCrcErrors;
// Done
return stats;
}

View File

@ -60,14 +60,17 @@ class Telemetry : public QObject {
public:
typedef struct {
quint32 txBytes;
quint32 rxBytes;
quint32 txObjectBytes;
quint32 rxObjectBytes;
quint32 rxObjects;
quint32 txObjects;
quint32 txErrors;
quint32 rxErrors;
quint32 txRetries;
quint32 rxBytes;
quint32 rxObjectBytes;
quint32 rxObjects;
quint32 rxErrors;
quint32 rxSyncErrors;
quint32 rxCrcErrors;
} TelemetryStats;
Telemetry(UAVTalk *utalk, UAVObjectManager *objMngr);

View File

@ -199,12 +199,17 @@ void TelemetryMonitor::processStatsUpdates()
tel->resetStats();
// Update stats object
gcsStats.RxDataRate = (float)telStats.rxBytes / ((float)statsTimer->interval() / 1000.0);
gcsStats.TxDataRate = (float)telStats.txBytes / ((float)statsTimer->interval() / 1000.0);
gcsStats.RxFailures += telStats.rxErrors;
gcsStats.TxBytes += telStats.txBytes;
gcsStats.TxFailures += telStats.txErrors;
gcsStats.TxRetries += telStats.txRetries;
gcsStats.RxDataRate = (float)telStats.rxBytes / ((float)statsTimer->interval() / 1000.0);
gcsStats.RxBytes += telStats.rxBytes;
gcsStats.RxFailures += telStats.rxErrors;
gcsStats.RxSyncErrors += telStats.rxSyncErrors;
gcsStats.RxCrcErrors += telStats.rxCrcErrors;
// Check for a connection timeout
bool connectionTimeout;
if (telStats.rxObjects > 0) {

View File

@ -33,7 +33,7 @@
#include <QEventLoop>
#ifdef VERBOSE_UAVTALK
#define VERBOSE_FILTER(objId) if (objId == 0xD23852DC || objId == 0x2472A0AE)
#define VERBOSE_FILTER(objId) if (objId == 0x173E3850 || objId == 0x99C63292)
#endif
#define SYNC_VAL 0x3C
@ -255,7 +255,7 @@ bool UAVTalk::processInputByte(quint8 rxbyte)
if (rxbyte != SYNC_VAL) {
// continue until sync byte is matched
// TODO stats.rxSyncErrror++;
stats.rxSyncErrors++;
break;
}
@ -282,7 +282,7 @@ bool UAVTalk::processInputByte(quint8 rxbyte)
if ((rxbyte & TYPE_MASK) != TYPE_VER) {
qWarning() << "UAVTalk - error : bad type";
// TODO stats.rxSyncErrror++;
stats.rxErrors++;
rxState = STATE_SYNC;
break;
}
@ -421,7 +421,7 @@ bool UAVTalk::processInputByte(quint8 rxbyte)
if (rxCS != rxCSPacket) {
// packet error - faulty CRC
qWarning() << "UAVTalk - error : failed CRC check" << rxObjId;
stats.rxErrors++;
stats.rxCrcErrors++;
rxState = STATE_SYNC;
break;
}
@ -453,8 +453,8 @@ bool UAVTalk::processInputByte(quint8 rxbyte)
default:
qWarning() << "UAVTalk - error : bad state";
stats.rxErrors++;
rxState = STATE_SYNC;
break;
}
// Done
@ -518,7 +518,7 @@ bool UAVTalk::receiveObject(quint8 type, quint32 objId, quint16 instId, quint8 *
#endif
if (obj != NULL) {
// Object updated or created, transmit ACK
transmitObject(TYPE_ACK, objId, instId, obj);
error = !transmitObject(TYPE_ACK, objId, instId, obj);
} else {
error = true;
}
@ -545,7 +545,7 @@ bool UAVTalk::receiveObject(quint8 type, quint32 objId, quint16 instId, quint8 *
if (obj != NULL) {
// Object found, transmit it
// The sent object will ack the object request on the receiver side
transmitObject(TYPE_OBJ, objId, instId, obj);
error = !transmitObject(TYPE_OBJ, objId, instId, obj);
} else {
error = true;
}

View File

@ -48,13 +48,16 @@ public:
typedef struct {
quint32 txBytes;
quint32 rxBytes;
quint32 txObjectBytes;
quint32 rxObjectBytes;
quint32 rxObjects;
quint32 txObjects;
quint32 txErrors;
quint32 rxBytes;
quint32 rxObjectBytes;
quint32 rxObjects;
quint32 rxErrors;
quint32 rxSyncErrors;
quint32 rxCrcErrors;
} ComStats;
UAVTalk(QIODevice *iodev, UAVObjectManager *objMngr);
@ -105,28 +108,41 @@ private:
static const quint8 crc_table[256];
// Types
typedef enum { STATE_SYNC, STATE_TYPE, STATE_SIZE, STATE_OBJID, STATE_INSTID, STATE_DATA, STATE_CS } RxStateType;
typedef enum {
STATE_SYNC, STATE_TYPE, STATE_SIZE, STATE_OBJID, STATE_INSTID, STATE_DATA, STATE_CS
} RxStateType;
// Variables
QPointer<QIODevice> io;
UAVObjectManager *objMngr;
ComStats stats;
QMutex mutex;
QMap<quint32, QMap<quint32, Transaction *> *> transMap;
// quint16 rxReadOffset;
// quint16 rxSyncOffset;
quint8 rxBuffer[MAX_PACKET_LENGTH];
quint8 txBuffer[MAX_PACKET_LENGTH];
// Variables used by the receive state machine
// state machine variables
qint32 rxCount;
qint32 packetSize;
RxStateType rxState;
// data variables
quint8 rxTmpBuffer[4];
quint8 rxType;
quint32 rxObjId;
quint16 rxInstId;
quint16 rxLength;
quint16 rxPacketLength;
quint8 rxCSPacket, rxCS;
qint32 rxCount;
qint32 packetSize;
RxStateType rxState;
ComStats stats;
quint8 rxCSPacket;
quint8 rxCS;
bool useUDPMirror;
QUdpSocket *udpSocketTx;

View File

@ -1,12 +1,18 @@
<xml>
<object name="GCSTelemetryStats" singleinstance="true" settings="false" category="System">
<description>The telemetry statistics from the ground computer</description>
<field name="Status" units="" type="enum" elements="1" options="Disconnected,HandshakeReq,HandshakeAck,Connected"/>
<field name="TxDataRate" units="bytes/sec" type="float" elements="1"/>
<field name="RxDataRate" units="bytes/sec" type="float" elements="1"/>
<field name="TxBytes" units="bytes" type="uint32" 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"/>
<field name="RxDataRate" units="bytes/sec" type="float" elements="1"/>
<field name="RxBytes" units="bytes" type="uint32" elements="1"/>
<field name="RxFailures" units="count" type="uint32" elements="1"/>
<field name="RxSyncErrors" units="count" type="uint32" elements="1"/>
<field name="RxCrcErrors" units="count" type="uint32" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="periodic" period="5000"/>
<telemetryflight acked="false" updatemode="manual" period="0"/>