From f2b08b80fed6f9d0cfecaae6ae1a50529d337841 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 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Scripting/drivers/EFI_Halo6000.lua b/libraries/AP_Scripting/drivers/EFI_Halo6000.lua index b353ff2d5d206e..c739449f2620e2 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)