Skip to content

Commit

Permalink
AP_Scripting: Applets: MissionSelector: fix error on file open and ch…
Browse files Browse the repository at this point in the history
…ecker errors
  • Loading branch information
IamPete1 committed Nov 5, 2024
1 parent 7f04c82 commit ff624aa
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions libraries/AP_Scripting/applets/MissionSelector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
-- Must have Mission Reset switch assigned, it will function normally when armed or disarmed
-- but also on the disarm to arm transition, it will load (if file exists) a file in the root named
-- missionH.txt, missionM.txt, or missionH.txt corresponding to the the Mission Reset switch position of High/Mid/Low
-- luacheck: only 0
---@diagnostic disable: need-check-nil


local mission_loaded = false
local rc_switch = rc:find_channel_for_option(24) --AUX FUNC sw for mission restart
Expand All @@ -15,12 +12,12 @@ end

local function read_mission(file_name)

-- Open file try and read header
-- Open file try and read header
local file = io.open(file_name,"r")
local header = file:read('l')
if not header then
if not file then
return update, 1000 --could not read, file probably does not exist
end
local header = file:read('l')

-- check header
assert(string.find(header,'QGC WPL 110') == 1, file_name .. ': incorrect format')
Expand Down Expand Up @@ -64,7 +61,6 @@ local function read_mission(file_name)
end
index = index + 1
end
file:close()
end

function update()
Expand Down

0 comments on commit ff624aa

Please sign in to comment.