SITL: SIM_RichenPower sets MaintenanceRequired error flag

Turns out the generator does set this flag when the generator reaches
its maintenance required state.
This commit is contained in:
Peter Barker 2022-05-04 10:05:17 +10:00 committed by Andrew Tridgell
parent 1934b4a738
commit c496985e37
2 changed files with 8 additions and 0 deletions

View File

@ -198,11 +198,15 @@ void RichenPower::update_send()
u.packet.runtime_seconds = runtime_seconds_remainder;
const int32_t seconds_until_maintenance = (original_seconds_until_maintenance - _runtime_ms/1000.0f);
uint16_t errors = htobe16(u.packet.errors);
if (seconds_until_maintenance <= 0) {
u.packet.seconds_until_maintenance = htobe32(0);
errors |= (1U<<(uint8_t(Errors::MaintenanceRequired)));
} else {
u.packet.seconds_until_maintenance = htobe32(seconds_until_maintenance);
errors &= ~(1U<<(uint8_t(Errors::MaintenanceRequired)));
}
u.packet.errors = htobe16(errors);
switch (_state) {
case State::IDLE:

View File

@ -96,6 +96,10 @@ private:
uint32_t last_rpm_update_ms;
enum class Errors {
MaintenanceRequired = 0,
};
// packet to send:
struct PACKED RichenPacket {
uint8_t magic1;