From 5b0e5817dce62c62d523d5193fb4b1f28af18f2f Mon Sep 17 00:00:00 2001 From: Lokesh-Ramina Date: Mon, 5 Feb 2024 14:04:09 -0800 Subject: [PATCH] Lua scripting: EFI monitor addition SW-61 --- .../scripts/cx_sanity_script.lua | 29 ++++++++++++++----- .../generator/description/bindings.desc | 3 ++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_sanity_script.lua b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_sanity_script.lua index c2877893ef..021d23ee6c 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_sanity_script.lua +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCubeOrange/scripts/cx_sanity_script.lua @@ -131,7 +131,7 @@ function init_param() return 0 end -function actuator_telemetry_check() +function all_telemetry_check() local escs = {M1, M2, M3, M4, M5} if aircraft_type == UNKNOWN then @@ -143,17 +143,26 @@ function actuator_telemetry_check() local current_ts = tostring(esc_telem:get_last_telem_data_ms(escs[i])) current_ts = tonumber(current_ts) if (i < 5 or aircraft_type == VOLANTI) and (current_ts == 0 or current_ts == esc_prev_ts[i]) then - esc_prev_ts[i] = current_ts return i end + if i == 5 and aircraft_type == OTTANO then + current_ts = tostring(efi.get_last_update_ms()) + current_ts = tonumber(current_ts) + if current_ts == 0 or current_ts == esc_prev_ts[i] then + return i + end + end + esc_prev_ts[i] = current_ts end return 0 end function pre_arm_check() if pre_arm_init then - local act_return = actuator_telemetry_check() - if act_return ~= 0 then + local act_return = all_telemetry_check() + if act_return == 5 and aircraft_type == OTTANO then + arming:set_aux_auth_failed(auth_id, "EFI Not Responding") + elseif act_return ~= 0 then arming:set_aux_auth_failed(auth_id, "ESC " .. act_return .. " Not Responding") else arming:set_aux_auth_passed(auth_id) @@ -187,10 +196,16 @@ local last_msg_time = 0 local esc_telem_failure = false function during_arm_check() - local act_return = actuator_telemetry_check() + local act_return = all_telemetry_check() local current_time = get_time_sec() - if act_return ~= 0 then + if act_return == 5 and aircraft_type == OTTANO then + if current_time - last_msg_time >= 15 then + gcs_msg(MSG_NORMAL, MAV_SEVERITY_CRITICAL, "EFI Telemetry Not Responding") + last_msg_time = current_time + end + + else if act_return ~= 0 then if current_time - last_msg_time >= 15 then gcs_msg(MSG_NORMAL, MAV_SEVERITY_CRITICAL, "ESC " .. act_return .. " Telemetry Not Responding") last_msg_time = current_time @@ -198,7 +213,7 @@ function during_arm_check() end else if esc_telem_failure then - gcs_msg(MSG_NORMAL, MAV_SEVERITY_CRITICAL, "ESC Telemetry Recovered") + gcs_msg(MSG_NORMAL, MAV_SEVERITY_CRITICAL, "Telemetry Recovered") clear_msg_sent = false end end diff --git a/libraries/AP_Scripting/generator/description/bindings.desc b/libraries/AP_Scripting/generator/description/bindings.desc index 55f92488e4..654bd5ffc5 100644 --- a/libraries/AP_Scripting/generator/description/bindings.desc +++ b/libraries/AP_Scripting/generator/description/bindings.desc @@ -575,6 +575,9 @@ ap_object AP_EFI_Backend method handle_scripting boolean EFI_State singleton AP_EFI depends (AP_EFI_SCRIPTING_ENABLED == 1) singleton AP_EFI rename efi singleton AP_EFI method get_backend AP_EFI_Backend uint8_t 0 UINT8_MAX +singleton AP_EFI method get_last_update_ms uint32_t + + -- ----END EFI Library----