Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Scripting: Applets: MissionSelector: fix error on file open and checker errors #28520

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 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()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unreachable.

end

function update()
Expand All @@ -88,4 +84,6 @@ function update()
return update, 1000
end

gcs:send_text(5,"Loaded MissionSelector.lua")

return update, 5000
Loading