mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 06:33:33 +08:00
Merge pull request #1399 from PX4/safety
Enable IO safety parameter to disable safety on boot
This commit is contained in:
@@ -817,6 +817,11 @@ PX4IO::init()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set safety to off if circuit breaker enabled */
|
||||||
|
if (circuit_breaker_enabled("CBRK_IO_SAFETY", CBRK_IO_SAFETY_KEY)) {
|
||||||
|
(void)io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_FORCE_SAFETY_OFF, PX4IO_FORCE_SAFETY_MAGIC);
|
||||||
|
}
|
||||||
|
|
||||||
/* try to claim the generic PWM output device node as well - it's OK if we fail at this */
|
/* try to claim the generic PWM output device node as well - it's OK if we fail at this */
|
||||||
ret = register_driver(PWM_OUTPUT_DEVICE_PATH, &fops, 0666, (void *)this);
|
ret = register_driver(PWM_OUTPUT_DEVICE_PATH, &fops, 0666, (void *)this);
|
||||||
|
|
||||||
|
|||||||
@@ -706,7 +706,7 @@ int prearm_check(const struct vehicle_status_s *status, const int mavlink_fd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fabsf(airspeed.indicated_airspeed_m_s > 6.0f)) {
|
if (fabsf(airspeed.indicated_airspeed_m_s > 6.0f)) {
|
||||||
mavlink_log_critical(mavlink_fd, "AIRSPEED WARNING: WIND OR CALIBRATION MISSING");
|
mavlink_log_critical(mavlink_fd, "AIRSPEED WARNING: WIND OR CALIBRATION ISSUE");
|
||||||
// XXX do not make this fatal yet
|
// XXX do not make this fatal yet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -353,12 +353,16 @@ static unsigned mixer_text_length = 0;
|
|||||||
int
|
int
|
||||||
mixer_handle_text(const void *buffer, size_t length)
|
mixer_handle_text(const void *buffer, size_t length)
|
||||||
{
|
{
|
||||||
/* do not allow a mixer change while safety off */
|
/* do not allow a mixer change while safety off and FMU armed */
|
||||||
if ((r_status_flags & PX4IO_P_STATUS_FLAGS_SAFETY_OFF)) {
|
if ((r_status_flags & PX4IO_P_STATUS_FLAGS_SAFETY_OFF) &&
|
||||||
|
(r_setup_arming & PX4IO_P_SETUP_ARMING_FMU_ARMED)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* abort if we're in the mixer */
|
/* disable mixing, will be enabled once load is complete */
|
||||||
|
r_status_flags &= ~(PX4IO_P_STATUS_FLAGS_MIXER_OK);
|
||||||
|
|
||||||
|
/* abort if we're in the mixer - the caller is expected to retry */
|
||||||
if (in_mixer) {
|
if (in_mixer) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -367,17 +371,16 @@ mixer_handle_text(const void *buffer, size_t length)
|
|||||||
|
|
||||||
isr_debug(2, "mix txt %u", length);
|
isr_debug(2, "mix txt %u", length);
|
||||||
|
|
||||||
if (length < sizeof(px4io_mixdata))
|
if (length < sizeof(px4io_mixdata)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned text_length = length - sizeof(px4io_mixdata);
|
unsigned text_length = length - sizeof(px4io_mixdata);
|
||||||
|
|
||||||
switch (msg->action) {
|
switch (msg->action) {
|
||||||
case F2I_MIXER_ACTION_RESET:
|
case F2I_MIXER_ACTION_RESET:
|
||||||
isr_debug(2, "reset");
|
isr_debug(2, "reset");
|
||||||
|
|
||||||
/* FIRST mark the mixer as invalid */
|
|
||||||
r_status_flags &= ~PX4IO_P_STATUS_FLAGS_MIXER_OK;
|
|
||||||
/* THEN actually delete it */
|
/* THEN actually delete it */
|
||||||
mixer_group.reset();
|
mixer_group.reset();
|
||||||
mixer_text_length = 0;
|
mixer_text_length = 0;
|
||||||
@@ -386,9 +389,6 @@ mixer_handle_text(const void *buffer, size_t length)
|
|||||||
case F2I_MIXER_ACTION_APPEND:
|
case F2I_MIXER_ACTION_APPEND:
|
||||||
isr_debug(2, "append %d", length);
|
isr_debug(2, "append %d", length);
|
||||||
|
|
||||||
/* disable mixing during the update */
|
|
||||||
r_status_flags &= ~PX4IO_P_STATUS_FLAGS_MIXER_OK;
|
|
||||||
|
|
||||||
/* check for overflow - this would be really fatal */
|
/* check for overflow - this would be really fatal */
|
||||||
if ((mixer_text_length + text_length + 1) > sizeof(mixer_text)) {
|
if ((mixer_text_length + text_length + 1) > sizeof(mixer_text)) {
|
||||||
r_status_flags &= ~PX4IO_P_STATUS_FLAGS_MIXER_OK;
|
r_status_flags &= ~PX4IO_P_STATUS_FLAGS_MIXER_OK;
|
||||||
|
|||||||
@@ -407,10 +407,11 @@ registers_set(uint8_t page, uint8_t offset, const uint16_t *values, unsigned num
|
|||||||
|
|
||||||
/* handle text going to the mixer parser */
|
/* handle text going to the mixer parser */
|
||||||
case PX4IO_PAGE_MIXERLOAD:
|
case PX4IO_PAGE_MIXERLOAD:
|
||||||
if (!(r_status_flags & PX4IO_P_STATUS_FLAGS_SAFETY_OFF) ||
|
/* do not change the mixer if FMU is armed and IO's safety is off
|
||||||
(r_status_flags & PX4IO_P_STATUS_FLAGS_OUTPUTS_ARMED)) {
|
* this state defines an active system. This check is done in the
|
||||||
return mixer_handle_text(values, num_values * sizeof(*values));
|
* text handling function.
|
||||||
}
|
*/
|
||||||
|
return mixer_handle_text(values, num_values * sizeof(*values));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -583,8 +584,10 @@ registers_set_one(uint8_t page, uint8_t offset, uint16_t value)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PX4IO_P_SETUP_REBOOT_BL:
|
case PX4IO_P_SETUP_REBOOT_BL:
|
||||||
if ((r_status_flags & PX4IO_P_STATUS_FLAGS_SAFETY_OFF) ||
|
// do not reboot if FMU is armed and IO's safety is off
|
||||||
(r_status_flags & PX4IO_P_STATUS_FLAGS_OUTPUTS_ARMED)) {
|
// this state defines an active system.
|
||||||
|
if ((r_status_flags & PX4IO_P_STATUS_FLAGS_SAFETY_OFF) &&
|
||||||
|
(r_status_flags & PX4IO_P_SETUP_ARMING_FMU_ARMED)) {
|
||||||
// don't allow reboot while armed
|
// don't allow reboot while armed
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -631,9 +634,11 @@ registers_set_one(uint8_t page, uint8_t offset, uint16_t value)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* do not allow a RC config change while outputs armed
|
* do not allow a RC config change while outputs armed
|
||||||
|
* = FMU is armed and IO's safety is off
|
||||||
|
* this state defines an active system.
|
||||||
*/
|
*/
|
||||||
if ((r_status_flags & PX4IO_P_STATUS_FLAGS_SAFETY_OFF) ||
|
if ((r_status_flags & PX4IO_P_STATUS_FLAGS_SAFETY_OFF) &&
|
||||||
(r_status_flags & PX4IO_P_STATUS_FLAGS_OUTPUTS_ARMED)) {
|
(r_status_flags & PX4IO_P_SETUP_ARMING_FMU_ARMED)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user