mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
OP-273 - UAVTalk - prevent object update-bursts caused by involuntary synchronization in case of long delays or time-jumps
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2450 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
115a581d7c
commit
75a6b406cd
@ -310,6 +310,7 @@ static int32_t processPeriodicUpdates()
|
|||||||
PeriodicObjectList* objEntry;
|
PeriodicObjectList* objEntry;
|
||||||
int32_t timeNow;
|
int32_t timeNow;
|
||||||
int32_t timeToNextUpdate;
|
int32_t timeToNextUpdate;
|
||||||
|
int32_t offset;
|
||||||
|
|
||||||
// Get lock
|
// Get lock
|
||||||
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
|
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
|
||||||
@ -327,7 +328,8 @@ static int32_t processPeriodicUpdates()
|
|||||||
if (objEntry->timeToNextUpdateMs <= timeNow)
|
if (objEntry->timeToNextUpdateMs <= timeNow)
|
||||||
{
|
{
|
||||||
// Reset timer
|
// Reset timer
|
||||||
objEntry->timeToNextUpdateMs = timeNow + objEntry->updatePeriodMs;
|
offset = ( timeNow - objEntry->timeToNextUpdateMs ) % objEntry->updatePeriodMs;
|
||||||
|
objEntry->timeToNextUpdateMs = timeNow + objEntry->updatePeriodMs - offset;
|
||||||
// Invoke callback, if one
|
// Invoke callback, if one
|
||||||
if ( objEntry->evInfo.cb != 0)
|
if ( objEntry->evInfo.cb != 0)
|
||||||
{
|
{
|
||||||
|
@ -437,6 +437,7 @@ void Telemetry::processPeriodicUpdates()
|
|||||||
ObjectTimeInfo objinfo;
|
ObjectTimeInfo objinfo;
|
||||||
qint32 elapsedMs = 0;
|
qint32 elapsedMs = 0;
|
||||||
QTime time;
|
QTime time;
|
||||||
|
qint32 offset;
|
||||||
for (int n = 0; n < objList.length(); ++n)
|
for (int n = 0; n < objList.length(); ++n)
|
||||||
{
|
{
|
||||||
objinfo = objList[n];
|
objinfo = objList[n];
|
||||||
@ -448,7 +449,8 @@ void Telemetry::processPeriodicUpdates()
|
|||||||
if (objinfo.timeToNextUpdateMs <= 0)
|
if (objinfo.timeToNextUpdateMs <= 0)
|
||||||
{
|
{
|
||||||
// Reset timer
|
// Reset timer
|
||||||
objinfo.timeToNextUpdateMs = objinfo.updatePeriodMs;
|
offset = (-objinfo.timeToNextUpdateMs) % objinfo.updatePeriodMs;
|
||||||
|
objinfo.timeToNextUpdateMs = objinfo.updatePeriodMs - offset;
|
||||||
// Send object
|
// Send object
|
||||||
time.start();
|
time.start();
|
||||||
processObjectUpdates(objinfo.obj, EV_UPDATED_MANUAL, true, false);
|
processObjectUpdates(objinfo.obj, EV_UPDATED_MANUAL, true, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user