AP_RPM: add explicit RPM_TYPE_SITL

Old behaviour is that anything that wasn't claimed (or failed to
allocate) would become a SITL RPM sensor.  This meant we always had at
least one RPM sensor which was allocated but never provided valid data.

New behaviour is that if you want a SITL RPM sensor you have to set type
to 10.
This commit is contained in:
Peter Barker 2021-02-25 17:21:52 +11:00 committed by Peter Barker
parent eb499ff731
commit 370db00096
2 changed files with 5 additions and 2 deletions

View File

@ -132,7 +132,7 @@ void AP_RPM::init(void)
drivers[i] = new AP_RPM_HarmonicNotch(*this, i, state[i]);
}
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
if (drivers[i] == nullptr) {
if (type == RPM_TYPE_SITL) {
drivers[i] = new AP_RPM_SITL(*this, i, state[i]);
}
#endif

View File

@ -41,7 +41,10 @@ public:
RPM_TYPE_PWM = 1,
RPM_TYPE_PIN = 2,
RPM_TYPE_EFI = 3,
RPM_TYPE_HNTCH = 4
RPM_TYPE_HNTCH = 4,
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
RPM_TYPE_SITL = 10,
#endif
};
// The RPM_State structure is filled in by the backend driver