From c783f632c148336df60c6754ef9a33fba905cfeb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 Jun 2024 06:25:44 +1000 Subject: [PATCH] AP_Scription: added CANF logging to Halo6000 EFI driver allows for easier debugging --- .../AP_Scripting/drivers/EFI_Halo6000.lua | 31 ++++++++++++++++++- .../AP_Scripting/drivers/EFI_Halo6000.md | 10 ++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Scripting/drivers/EFI_Halo6000.lua b/libraries/AP_Scripting/drivers/EFI_Halo6000.lua index b353ff2d5d206..c739449f2620e 100644 --- a/libraries/AP_Scripting/drivers/EFI_Halo6000.lua +++ b/libraries/AP_Scripting/drivers/EFI_Halo6000.lua @@ -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 @@ -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 @@ -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 @@ -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) diff --git a/libraries/AP_Scripting/drivers/EFI_Halo6000.md b/libraries/AP_Scripting/drivers/EFI_Halo6000.md index d27d304c1592a..f31853d5d665e 100644 --- a/libraries/AP_Scripting/drivers/EFI_Halo6000.md +++ b/libraries/AP_Scripting/drivers/EFI_Halo6000.md @@ -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