Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Scription: added CANF logging to Halo6000 EFI driver #27261

Merged
merged 1 commit into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion libraries/AP_Scripting/drivers/EFI_Halo6000.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
local efi_backend = nil

-- Setup EFI Parameters
assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 6), 'could not add EFI_H6K param table')
assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 10), 'could not add EFI_H6K param table')

--[[
// @Param: EFI_H6K_ENABLE
Expand Down Expand Up @@ -102,6 +102,17 @@ local EFI_H6K_TELEM_RT = bind_add_param('TELEM_RT', 4, 2)
--]]
local EFI_H6K_FUELTOT = bind_add_param('FUELTOT', 5, 20)

--[[
// @Param: EFI_H6K_OPTIONS
// @DisplayName: Halo6000 options
// @Description: Halo6000 options
// @Bitmask: 0:LogAllCanPackets
// @User: Standard
--]]
local EFI_H6K_OPTIONS = bind_add_param('OPTIONS', 6, 0)

local OPTION_LOGALLFRAMES = 0x01

if EFI_H6K_ENABLE:get() == 0 then
return
end
Expand All @@ -121,6 +132,20 @@ if not driver1 then
return
end

local frame_count = 0

--[[
frame logging - can be replayed with Tools/scripts/CAN/CAN_playback.py
--]]
local function log_can_frame(frame)
logger.write("CANF",'Id,DLC,FC,B0,B1,B2,B3,B4,B5,B6,B7','IBIBBBBBBBB',
frame:id(),
frame:dlc(),
frame_count,
frame:data(0), frame:data(1), frame:data(2), frame:data(3),
frame:data(4), frame:data(5), frame:data(6), frame:data(7))
frame_count = frame_count + 1
end

--[[
EFI Engine Object
Expand Down Expand Up @@ -158,6 +183,10 @@ local function engine_control()
break
end

if EFI_H6K_OPTIONS:get() & OPTION_LOGALLFRAMES ~= 0 then
log_can_frame(frame)
end

-- All Frame IDs for this EFI Engine are in the 11-bit address space
if not frame:isExtended() then
self.handle_packet(frame)
Expand Down
10 changes: 10 additions & 0 deletions libraries/AP_Scripting/drivers/EFI_Halo6000.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ control.
This is the rate in Hz at which NAMED_VALUE_FLOAT messages are used to
send additional telemetry data to the GCS for display to the operator.

## EFI_H6K_FUELTOT

This is the total fuel tank capacity in litres

## EFI_H6K_OPTIONS

This provides additional options. Currently just one option is
available. If you set EFI_H6K_OPTIONS to 1 then all CAN frames will be
logged in the message CANF.

# Operation

This driver should be loaded by placing the lua script in the
Expand Down
Loading