AP_IOMCU: fixed a race in event trigger on startup

this fixes the issue with initial safety option state, and with
initial safety mask
This commit is contained in:
Andrew Tridgell 2018-11-03 17:27:10 +11:00
parent 7c86ce4d81
commit cab5199da8
2 changed files with 6 additions and 0 deletions

View File

@ -78,6 +78,7 @@ void AP_IOMCU::event_failed(uint8_t event)
void AP_IOMCU::thread_main(void)
{
thread_ctx = chThdGetSelfX();
chEvtSignal(thread_ctx, initial_event_mask);
uart.begin(1500*1000, 256, 256);
uart.set_blocking_writes(false);
@ -465,6 +466,9 @@ void AP_IOMCU::trigger_event(uint8_t event)
{
if (thread_ctx != nullptr) {
chEvtSignal(thread_ctx, EVENT_MASK(event));
} else {
// thread isn't started yet, trigger this event once it is started
initial_event_mask |= EVENT_MASK(event);
}
}

View File

@ -114,6 +114,8 @@ private:
// IOMCU thread
thread_t *thread_ctx;
eventmask_t initial_event_mask;
// time when we last read various pages
uint32_t last_status_read_ms;
uint32_t last_rc_read_ms;