Skip to content

Commit

Permalink
AP_Scripting: no warning if no ./scripts and no real filesystem
Browse files Browse the repository at this point in the history
it is possible to build for boards without storage (so no Posix, no Fatafs), but still have scripts in ROMFS.

In this case we will use the backend AP_Filesystem_backend base class when doing file operations.  This will alway fail to open directories, so when we try to load scripts from SCRIPTS_DIRECTORY it will always fail.

This leads to a warning being emitted:

Lua: State memory usage: 2796 + 5227
AP: Lua: open directory (./scripts) failed
AP: hello, world
Time has wrapped

Which isn't great.

Detect we are working on this filesystem and don't warn.
  • Loading branch information
peterbarker authored and tridge committed Sep 9, 2024
1 parent 61de480 commit 777aab6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libraries/AP_Scripting/lua_scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,13 @@ void lua_scripts::load_all_scripts_in_dir(lua_State *L, const char *dirname) {
if (dirname == nullptr) {
return;
}

auto *d = AP::FS().opendir(dirname);
if (d == nullptr) {
GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "Lua: open directory (%s) failed", dirname);
// this disk_space check will return 0 if we don't have a real
// filesystem (ie. no Posix or FatFs). Do not warn in this case.
if (AP::FS().disk_space(dirname) != 0) {
GCS_SEND_TEXT(MAV_SEVERITY_WARNING, "Lua: open directory (%s) failed", dirname);
}
return;
}

Expand Down

0 comments on commit 777aab6

Please sign in to comment.