Skip to content

Commit

Permalink
AP_Scription: added CANF logging to Halo6000 EFI driver
Browse files Browse the repository at this point in the history
allows for easier debugging
  • Loading branch information
tridge committed Jun 8, 2024
1 parent 1c5c80d commit c783f63
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
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

0 comments on commit c783f63

Please sign in to comment.