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

LUA : restructure to manage prearm-checks #261

Merged
merged 7 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Tools/ardupilotwaf/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ def configure_env(self, cfg, env):
# exclude emacs tmp files
continue
fname = root[len(custom_dir)+1:]+"/"+f
if fname.startswith("/"):
fname = fname[1:]
env.ROMFS_FILES += [(fname,root+"/"+f)]

def pre_build(self, bld):
Expand Down
36 changes: 33 additions & 3 deletions Tools/autotest/pysim/vehicleinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,19 +440,49 @@ def __init__(self):
"waf_target": "bin/arduplane",
"model": "quadplane:@ROMFS/models/Ottano.json",
"default_params_filename": "../../build/ottano-headless.parm",
"scripts": ["../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/*.lua"],
"scripts": [
"../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/*.lua",
(
"../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/*.lua",
"modules"
),
(
"../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/aircraft/ottano.lua",
"modules/aircraft.lua"
),
],
},
"volanti-headless": {
"waf_target": "bin/arduplane",
"model": "quadplane:@ROMFS/models/Volanti.json",
"default_params_filename": "../../build/volanti-headless.parm",
"scripts": ["../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/*.lua"],
"scripts": [
"../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/*.lua",
(
"../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/*.lua",
"modules"
),
(
"../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/aircraft/volanti.lua",
"modules/aircraft.lua"
),
],
},
"volanti-realflight": {
"waf_target": "bin/arduplane",
"model": "flightaxis",
"default_params_filename": "../../build/volanti-realflight.parm",
"scripts": ["../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/*.lua"],
"scripts": [
"../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/*.lua",
(
"../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/*.lua",
"modules"
),
(
"../../libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/aircraft/volanti.lua",
"modules/aircraft.lua"
),
],
"external": True,
}
},
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_Filesystem/AP_Filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const AP_Filesystem::Backend AP_Filesystem::backends[] = {
{ nullptr, fs_local },
#if AP_FILESYSTEM_ROMFS_ENABLED
{ "@ROMFS/", fs_romfs },
{ "@ROMFS", fs_romfs },
#endif
#if AP_FILESYSTEM_PARAM_ENABLED
{ "@PARAM/", fs_param },
Expand Down
33 changes: 29 additions & 4 deletions libraries/AP_Filesystem/AP_Filesystem_ROMFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ void *AP_Filesystem_ROMFS::opendir(const char *pathname)
if (!dir[idx].path) {
return nullptr;
}

// Take a sneak peek and reset
const char *name = AP_ROMFS::dir_list(dir[idx].path, dir[idx].ofs);
dir[idx].ofs = 0;
if (!name) {
// Directory does not exist
return nullptr;
}

return (void*)&dir[idx];
}

Expand All @@ -174,12 +183,28 @@ struct dirent *AP_Filesystem_ROMFS::readdir(void *dirp)
return nullptr;
}
const uint32_t plen = strlen(dir[idx].path);
if (strncmp(name, dir[idx].path, plen) != 0 || name[plen] != '/') {
return nullptr;
if (plen > 0) {
// Offset to get just file/directory name
name += plen + 1;
}
name += plen + 1;
dir[idx].de.d_type = DT_REG;

// Copy full name
strncpy(dir[idx].de.d_name, name, sizeof(dir[idx].de.d_name));

const char* slash = strchr(name, '/');
if (slash == nullptr) {
// File
dir[idx].de.d_type = DT_REG;

} else {
// Directory
dir[idx].de.d_type = DT_DIR;

// Add null termination after directory name
const size_t index = slash - name;
dir[idx].de.d_name[index] = 0;
}

return &dir[idx].de;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,17 @@
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_vtol_info.lua</source_path>
<destination_path>cx_vtol_info.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/bit_esc.lua</source_path>
<destination_path>modules/bit_esc.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/msg.lua</source_path>
<destination_path>modules/msg.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/aircraft/ottano.lua</source_path>
<destination_path>modules/aircraft.lua</destination_path>
</lua_script>
</lua_script_list>
</data>
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,17 @@
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_vtol_info.lua</source_path>
<destination_path>cx_vtol_info.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/bit_esc.lua</source_path>
<destination_path>modules/bit_esc.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/msg.lua</source_path>
<destination_path>modules/msg.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/aircraft/ottano.lua</source_path>
<destination_path>modules/aircraft.lua</destination_path>
</lua_script>
</lua_script_list>
</data>
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,17 @@
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_vtol_info.lua</source_path>
<destination_path>cx_vtol_info.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/bit_esc.lua</source_path>
<destination_path>modules/bit_esc.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/msg.lua</source_path>
<destination_path>modules/msg.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/aircraft/volanti.lua</source_path>
<destination_path>modules/aircraft.lua</destination_path>
</lua_script>
</lua_script_list>
</data>
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,17 @@
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_vtol_info.lua</source_path>
<destination_path>cx_vtol_info.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/bit_esc.lua</source_path>
<destination_path>modules/bit_esc.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/msg.lua</source_path>
<destination_path>modules/msg.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/aircraft/volanti.lua</source_path>
<destination_path>modules/aircraft.lua</destination_path>
</lua_script>
</lua_script_list>
</data>
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,17 @@
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/cx_vtol_info.lua</source_path>
<destination_path>cx_vtol_info.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/bit_esc.lua</source_path>
<destination_path>modules/bit_esc.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/modules/msg.lua</source_path>
<destination_path>modules/msg.lua</destination_path>
</lua_script>
<lua_script>
<source_path>libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/scripts/aircraft/volanti.lua</source_path>
<destination_path>modules/aircraft.lua</destination_path>
</lua_script>
</lua_script_list>
</data>
4 changes: 2 additions & 2 deletions libraries/AP_HAL_ChibiOS/hwdef/CarbonixCommon/defaults.parm
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ RTL_RADIUS,200
SCHED_LOOP_RATE,200 # Loop Rate for Control in flight Controller set to 200Hz from 400Hz Results SW-171.
SCR_ENABLE,1
SCR_HEAP_SIZE,200000
SCR_LD_CHECKSUM,8357358
SCR_RUN_CHECKSUM,8357358
SCR_LD_CHECKSUM,1341533
SCR_RUN_CHECKSUM,1341533
SCR_VM_I_COUNT,100000
SERVO1_FUNCTION,33 # Motor 1
SERVO10_FUNCTION,4 # Aileron R
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return "Ottano"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return "Volanti"
Loading
Loading