From 9861b4f2d6bd24cc989020a8311339da7f77ed9c Mon Sep 17 00:00:00 2001 From: Bob Long Date: Mon, 30 Dec 2024 09:57:30 +1100 Subject: [PATCH] CarbonixCommon: CX_BIT: add prearm bypass mask --- Tools/autotest/carbonix.py | 14 +++++++++ .../hwdef/CarbonixCommon/defaults.parm | 4 +-- .../scripts/cx_built_in_test.lua | 31 +++++++++++++++++-- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/Tools/autotest/carbonix.py b/Tools/autotest/carbonix.py index ebacad331f..7e803260c4 100644 --- a/Tools/autotest/carbonix.py +++ b/Tools/autotest/carbonix.py @@ -74,6 +74,13 @@ def TestESCTelemetry(index): self.wait_text(lost_text, check_context=True) self.progress("'" + lost_text + "':" + ' Success!') + # Check that the prearm disable parameter works + self.progress('Checking prearm disable parameter') + self.set_parameter('BIT_PREARM_DIS', 0b1) + self.wait_ready_to_arm() + self.set_parameter('BIT_PREARM_DIS', 0) + self.wait_not_ready_to_arm() + # Clear the failure self.progress(f'Clearing ESC telemetry failure for ESC {index}') self.context_clear_collection('STATUSTEXT') @@ -164,6 +171,13 @@ def TestGPSPrearm(index): self.set_parameter(this_numsats, 6) self.wait_not_ready_to_arm() + # Check that the prearm disable parameter works + self.progress('Checking prearm disable parameter') + self.set_parameter('BIT_PREARM_DIS', 0b10) + self.wait_ready_to_arm() + self.set_parameter('BIT_PREARM_DIS', 0) + self.wait_not_ready_to_arm() + # Restore the number of satellites self.progress(f'Restoring number of satellites for GPS {index}') self.set_parameter(this_numsats, 30) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/defaults.parm b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/defaults.parm index 275549223b..10f6c78b44 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/defaults.parm +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/defaults.parm @@ -118,8 +118,8 @@ RTL_RADIUS,200 SCHED_LOOP_RATE,200 # Loop Rate for Control in flight Controller set to 200Hz from 400Hz Results SW-171. SCR_ENABLE,1 SCR_HEAP_SIZE,200000 -SCR_LD_CHECKSUM,1341533 -SCR_RUN_CHECKSUM,1341533 +SCR_LD_CHECKSUM,907762 +SCR_RUN_CHECKSUM,907762 SCR_VM_I_COUNT,100000 SERVO1_FUNCTION,33 # Motor 1 SERVO10_FUNCTION,4 # Aileron R diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_built_in_test.lua b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_built_in_test.lua index 3106a3da65..ed38de54aa 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_built_in_test.lua +++ b/libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_built_in_test.lua @@ -36,6 +36,29 @@ local function clear_prearm_error() arming:set_aux_auth_passed(auth_id) end +local function bind_param(name) + local p = Parameter() + assert(p:init(name), string.format('could not find %s parameter', name)) + return p +end + +local function bind_add_param(name, idx, default_value) + assert(param:add_param(PARAM_TABLE_KEY, idx, name, default_value), string.format('could not add param %s', name)) + return bind_param(PARAM_TABLE_PREFIX .. name) +end + +-- Set up EFI parameters +PARAM_TABLE_PREFIX = 'BIT_' +PARAM_TABLE_KEY = 1 +assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 1), 'could not add ' .. string.sub(PARAM_TABLE_PREFIX, 1, -2) .. ' param table') +--[[ + // @Param: BIT_PREARM_DIS + // @DisplayName: Built-In-Test Prearm Bypass Mask + // @Description: Allows bypassing prearm checks for individual subsystems + // @Bitmask: 0:ESC, 1:GPS +--]] +local PREARM_BYPASS = bind_add_param('PREARM_DIS', 1, 0) + -- initialize function local function init() -- initialize all subsystems that are part of constructor @@ -54,8 +77,12 @@ local function check_prearm_status() -- Track errors in subsystems local subsystems_with_errors = {} local msg = "" - for _, subsystem in pairs(subsystems) do - local errors = subsystem:check_for_errors() + local disabled_mask = PREARM_BYPASS:get() or 0 + for i, subsystem in pairs(subsystems) do + local errors = {} + if disabled_mask & (1 << (i - 1)) == 0 then + errors = subsystem:check_for_errors() + end if #errors > 0 then table.insert(subsystems_with_errors, subsystem.name) for _, error in pairs(errors) do