Ardupilot2/libraries/AP_DAL/AP_DAL_Airspeed.cpp
Andrew Tridgell e116b1ff0a AP_DAL: added data access layer library
This provides a wrapper around sensor and system calls to allow for
logging for replay in EKF2 and EKF3

Co-authored-by: Peter Barker <pbarker@barker.dropbear.id.au>
2020-11-10 16:15:45 +11:00

37 lines
1014 B
C++

#include "AP_DAL_Airspeed.h"
#include "AP_DAL.h"
#include <AP_Logger/AP_Logger.h>
AP_DAL_Airspeed::AP_DAL_Airspeed()
{
for (uint8_t i=0; i<ARRAY_SIZE(_RASI); i++) {
_RASI[i].instance = i;
}
}
void AP_DAL_Airspeed::start_frame()
{
const auto *airspeed = AP::airspeed();
if (airspeed == nullptr) {
return;
}
const log_RASH old = _RASH;
_RASH.num_sensors = airspeed->get_num_sensors();
_RASH.primary = airspeed->get_primary();
WRITE_REPLAY_BLOCK_IFCHANGD(RASH, _RASH, old);
for (uint8_t i=0; i<ARRAY_SIZE(_RASI); i++) {
log_RASI &RASI = _RASI[i];
log_RASI old_RASI = RASI;
const uint32_t last_update_ms = airspeed->last_update_ms(i);
_last_logged_update_ms[i] = last_update_ms;
RASI.last_update_ms = last_update_ms;
RASI.healthy = airspeed->healthy(i);
RASI.use = airspeed->use(i);
RASI.airspeed = airspeed->get_airspeed(i);
WRITE_REPLAY_BLOCK_IFCHANGD(RASI, RASI, old_RASI);
}
}