diff --git a/libraries/AP_Scripting/drivers/INF_Inject.lua b/libraries/AP_Scripting/drivers/INF_Inject.lua index 068dcf258a..8685ba52a3 100644 --- a/libraries/AP_Scripting/drivers/INF_Inject.lua +++ b/libraries/AP_Scripting/drivers/INF_Inject.lua @@ -32,7 +32,7 @@ assert(param:add_table(PARAM_TABLE_KEY, PARAM_TABLE_PREFIX, 8), 'could not add p // @Values: 0:Disabled,1:Enabled // @User: Standard --]] -EFI_INF_ENABLE = bind_add_param("ENABLE", 1, 0) +EFI_INF_ENABLE = bind_add_param("ENABLE", 1, 1) if EFI_INF_ENABLE:get() ~= 1 then return @@ -70,16 +70,6 @@ local function read_bytes(n) return ret end ---[[ - discard pending bytes ---]] -local function discard_pending() - local n = uart:available():toint() - for _ = 1, n do - uart:read() - end -end - --[[ convert grams of fuel to cm3 --]] @@ -97,40 +87,43 @@ end check for input and parse data --]] local function check_input() + local packet_size = 83 local n_bytes = uart:available():toint() - if n_bytes < 83 then - return - end - if n_bytes > 83 then - discard_pending() - return + if n_bytes < packet_size then + return false end local tus = micros() state.chk0 = 0 state.chk1 = 0 - -- look for basic data table 2 - header0, header1, source, target, dtype, num, id, ack = string.unpack("= packet_size and not header_ok do + local header0 = string.unpack("