Browse Source

AP_Arming: regularise CAN pre-arm failure messages

AP_Arming tacks on the sub-system bit.

Remove PiccoloCAN's silly nullptr check

Require the library to supply the failure message (no default message)

Remove default cases so authors know to think about places they should
add things.
c415-sdk
Peter Barker 5 years ago committed by Andrew Tridgell
parent
commit
b38d2c6194
  1. 21
      libraries/AP_Arming/AP_Arming.cpp

21
libraries/AP_Arming/AP_Arming.cpp

@ -823,9 +823,8 @@ bool AP_Arming::can_checks(bool report) @@ -823,9 +823,8 @@ bool AP_Arming::can_checks(bool report)
// To be replaced with macro saying if KDECAN library is included
#if APM_BUILD_TYPE(APM_BUILD_ArduCopter) || APM_BUILD_TYPE(APM_BUILD_ArduPlane) || APM_BUILD_TYPE(APM_BUILD_ArduSub)
AP_KDECAN *ap_kdecan = AP_KDECAN::get_kdecan(i);
snprintf(fail_msg, ARRAY_SIZE(fail_msg), "KDECAN failed");
if (ap_kdecan != nullptr && !ap_kdecan->pre_arm_check(fail_msg, ARRAY_SIZE(fail_msg))) {
check_failed(ARMING_CHECK_SYSTEM, report, "%s", fail_msg);
check_failed(ARMING_CHECK_SYSTEM, report, "KDECAN: %s", fail_msg);
return false;
}
#endif
@ -836,12 +835,7 @@ bool AP_Arming::can_checks(bool report) @@ -836,12 +835,7 @@ bool AP_Arming::can_checks(bool report)
AP_PiccoloCAN *ap_pcan = AP_PiccoloCAN::get_pcan(i);
if (ap_pcan != nullptr && !ap_pcan->pre_arm_check(fail_msg, ARRAY_SIZE(fail_msg))) {
if (fail_msg == nullptr) {
check_failed(ARMING_CHECK_SYSTEM, report, "PiccoloCAN failed");
} else {
check_failed(ARMING_CHECK_SYSTEM, report, "%s", fail_msg);
}
check_failed(ARMING_CHECK_SYSTEM, report, "PiccoloCAN: %s", fail_msg);
return false;
}
@ -853,15 +847,20 @@ bool AP_Arming::can_checks(bool report) @@ -853,15 +847,20 @@ bool AP_Arming::can_checks(bool report)
}
case AP_BoardConfig_CAN::Protocol_Type_UAVCAN:
{
snprintf(fail_msg, ARRAY_SIZE(fail_msg), "UAVCAN failed");
if (!AP::uavcan_dna_server().prearm_check(fail_msg, ARRAY_SIZE(fail_msg))) {
check_failed(ARMING_CHECK_SYSTEM, report, "%s", fail_msg);
check_failed(ARMING_CHECK_SYSTEM, report, "UAVCAN: %s", fail_msg);
return false;
}
break;
}
case AP_BoardConfig_CAN::Protocol_Type_ToshibaCAN:
{
// toshibacan doesn't currently have any prearm
// checks. Theres scope for adding a "not
// initialised" prearm check.
break;
}
case AP_BoardConfig_CAN::Protocol_Type_None:
default:
break;
}
}

Loading…
Cancel
Save