Skip to content

Commit

Permalink
CarbonixCommon: CX_BIT: add prearm bypass mask
Browse files Browse the repository at this point in the history
  • Loading branch information
robertlong13 authored and loki077 committed Jan 2, 2025
1 parent b1e2236 commit 9861b4f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
14 changes: 14 additions & 0 deletions Tools/autotest/carbonix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/defaults.parm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9861b4f

Please sign in to comment.