mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14: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;
|
||||
int32_t timeNow;
|
||||
int32_t timeToNextUpdate;
|
||||
int32_t offset;
|
||||
|
||||
// Get lock
|
||||
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
|
||||
@ -327,7 +328,8 @@ static int32_t processPeriodicUpdates()
|
||||
if (objEntry->timeToNextUpdateMs <= timeNow)
|
||||
{
|
||||
// Reset timer
|
||||
objEntry->timeToNextUpdateMs = timeNow + objEntry->updatePeriodMs;
|
||||
offset = ( timeNow - objEntry->timeToNextUpdateMs ) % objEntry->updatePeriodMs;
|
||||
objEntry->timeToNextUpdateMs = timeNow + objEntry->updatePeriodMs - offset;
|
||||
// Invoke callback, if one
|
||||
if ( objEntry->evInfo.cb != 0)
|
||||
{
|
||||
|
@ -437,6 +437,7 @@ void Telemetry::processPeriodicUpdates()
|
||||
ObjectTimeInfo objinfo;
|
||||
qint32 elapsedMs = 0;
|
||||
QTime time;
|
||||
qint32 offset;
|
||||
for (int n = 0; n < objList.length(); ++n)
|
||||
{
|
||||
objinfo = objList[n];
|
||||
@ -448,7 +449,8 @@ void Telemetry::processPeriodicUpdates()
|
||||
if (objinfo.timeToNextUpdateMs <= 0)
|
||||
{
|
||||
// Reset timer
|
||||
objinfo.timeToNextUpdateMs = objinfo.updatePeriodMs;
|
||||
offset = (-objinfo.timeToNextUpdateMs) % objinfo.updatePeriodMs;
|
||||
objinfo.timeToNextUpdateMs = objinfo.updatePeriodMs - offset;
|
||||
// Send object
|
||||
time.start();
|
||||
processObjectUpdates(objinfo.obj, EV_UPDATED_MANUAL, true, false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user