AP_Logger: handle instance types in rate limiting
This commit is contained in:
parent
575c76bdd0
commit
4dfe750d71
@ -3,6 +3,7 @@
|
||||
#include "LoggerMessageWriter.h"
|
||||
|
||||
#include <AP_InternalError/AP_InternalError.h>
|
||||
#include <AP_Scheduler/AP_Scheduler.h>
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
@ -672,5 +673,20 @@ bool AP_Logger_RateLimiter::should_log(uint8_t msgid)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return should_log_streaming(msgid);
|
||||
|
||||
// if we've already decided on sending this msgid in this tick then use the
|
||||
// same decision again
|
||||
const uint16_t sched_ticks = AP::scheduler().ticks();
|
||||
if (sched_ticks == last_sched_count[msgid]) {
|
||||
return last_return.get(msgid);
|
||||
}
|
||||
last_sched_count[msgid] = sched_ticks;
|
||||
|
||||
bool ret = should_log_streaming(msgid);
|
||||
if (ret) {
|
||||
last_return.set(msgid);
|
||||
} else {
|
||||
last_return.clear(msgid);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -23,8 +23,17 @@ private:
|
||||
// time in ms we last sent this message
|
||||
uint16_t last_send_ms[256];
|
||||
|
||||
// mask of message types that are not streaming
|
||||
// the last scheduler counter when we sent a msg. this allows us
|
||||
// to detect when we are sending a multi-instance message
|
||||
uint16_t last_sched_count[256];
|
||||
|
||||
// mask of message types that are not streaming. This is a cache
|
||||
// to avoid costly calls to structure_for_msg_type
|
||||
Bitmask<256> not_streaming;
|
||||
|
||||
// result of last decision for a message. Used for multi-instance
|
||||
// handling
|
||||
Bitmask<256> last_return;
|
||||
};
|
||||
|
||||
class AP_Logger_Backend
|
||||
|
Loading…
Reference in New Issue
Block a user