MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / arming_checks

Method arming_checks

libraries/AP_Scripting/AP_Scripting.cpp:422–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420}
421
422bool AP_Scripting::arming_checks(size_t buflen, char *buffer) const
423{
424 if (!enabled() || option_is_set(DebugOption::DISABLE_PRE_ARM)) {
425 return true;
426 }
427
428 if (_thread_failed) {
429 hal.util->snprintf(buffer, buflen, "Scripting: %s", "failed to start");
430 return false;
431 }
432
433 if (_init_failed) {
434 hal.util->snprintf(buffer, buflen, "Scripting: %s", "out of memory");
435 return false;
436 }
437
438 lua_scripts::get_last_error_semaphore()->take_blocking();
439 const char *error_buf = lua_scripts::get_last_error_message();
440 if (error_buf != nullptr) {
441 hal.util->snprintf(buffer, buflen, "Scripting: %s", error_buf);
442 lua_scripts::get_last_error_semaphore()->give();
443 return false;
444 }
445 lua_scripts::get_last_error_semaphore()->give();
446
447 // Use -1 for disabled, this means we don't have to avoid 0 in the CRC, the sign bit is masked off anyway
448 if (_required_loaded_checksum != -1) {
449 const uint32_t expected_loaded = (uint32_t)_required_loaded_checksum.get() & checksum_param_mask;
450 const uint32_t loaded = lua_scripts::get_loaded_checksum() & checksum_param_mask;
451 if (expected_loaded != loaded) {
452 hal.util->snprintf(buffer, buflen, "Scripting: loaded CRC incorrect want: 0x%x", (unsigned int)loaded);
453 return false;
454 }
455 }
456
457 if (_required_running_checksum != -1) {
458 const uint32_t expected_running = (uint32_t)_required_running_checksum.get() & checksum_param_mask;
459 const uint32_t running = lua_scripts::get_running_checksum() & checksum_param_mask;
460 if (expected_running != running) {
461 hal.util->snprintf(buffer, buflen, "Scripting: running CRC incorrect want: 0x%x", (unsigned int)running);
462 return false;
463 }
464 }
465
466 return true;
467}
468
469void AP_Scripting::restart_all()
470{

Callers

nothing calls this directly

Calls 4

snprintfMethod · 0.45
take_blockingMethod · 0.45
giveMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected