diff --git a/src/modules/px4iofirmware/mixer.cpp b/src/modules/px4iofirmware/mixer.cpp index b15ec09610..0a0962367d 100644 --- a/src/modules/px4iofirmware/mixer.cpp +++ b/src/modules/px4iofirmware/mixer.cpp @@ -88,9 +88,6 @@ static int mixer_callback(uintptr_t handle, static MixerGroup mixer_group(mixer_callback, 0); -/* Set the failsafe values of all mixed channels (based on zero throttle, controls centered) */ -static void mixer_set_failsafe(); - void mixer_tick(void) { @@ -479,15 +476,6 @@ mixer_handle_text(const void *buffer, size_t length) /* if anything was parsed */ if (resid != mixer_text_length) { - /* only set mixer ok if no residual is left over */ - if (resid == 0) { - r_status_flags |= PX4IO_P_STATUS_FLAGS_MIXER_OK; - - } else { - /* not yet reached the end of the mixer, set as not ok */ - r_status_flags &= ~PX4IO_P_STATUS_FLAGS_MIXER_OK; - } - isr_debug(2, "used %u", mixer_text_length - resid); /* copy any leftover text to the base of the buffer for re-use */ @@ -496,9 +484,6 @@ mixer_handle_text(const void *buffer, size_t length) } mixer_text_length = resid; - - /* update failsafe values */ - mixer_set_failsafe(); } break; @@ -507,7 +492,7 @@ mixer_handle_text(const void *buffer, size_t length) return 0; } -static void +void mixer_set_failsafe() { /* diff --git a/src/modules/px4iofirmware/px4io.h b/src/modules/px4iofirmware/px4io.h index a5e7a5500c..51ed9c6e40 100644 --- a/src/modules/px4iofirmware/px4io.h +++ b/src/modules/px4iofirmware/px4io.h @@ -190,6 +190,8 @@ extern pwm_limit_t pwm_limit; */ extern void mixer_tick(void); extern int mixer_handle_text(const void *buffer, size_t length); +/* Set the failsafe values of all mixed channels (based on zero throttle, controls centered) */ +extern void mixer_set_failsafe(void); /** * Safety switch/LED. diff --git a/src/modules/px4iofirmware/registers.c b/src/modules/px4iofirmware/registers.c index 46852003c8..18f5db5645 100644 --- a/src/modules/px4iofirmware/registers.c +++ b/src/modules/px4iofirmware/registers.c @@ -469,8 +469,19 @@ registers_set_one(uint8_t page, uint8_t offset, uint16_t value) * Allow FMU override of arming state (to allow in-air restores), * but only if the arming state is not in sync on the IO side. */ - if (!(r_status_flags & PX4IO_P_STATUS_FLAGS_ARM_SYNC)) { + + if (PX4IO_P_STATUS_FLAGS_MIXER_OK & value) { + r_status_flags |= PX4IO_P_STATUS_FLAGS_MIXER_OK; + + } else if (!(r_status_flags & PX4IO_P_STATUS_FLAGS_ARM_SYNC)) { r_status_flags = value; + + } + + if (PX4IO_P_STATUS_FLAGS_MIXER_OK & r_status_flags) { + + /* update failsafe values, now that the mixer is set to ok */ + mixer_set_failsafe(); } break;