AP_Scripting: remove support for REPL

This commit is contained in:
Iampete1 authored and Andrew Tridgell committed 2024-05-28 10:10:14 +10:00
1 parent 061d610965
commit f5e7bfcc48
6 files changed
+6 -368

No files matched your search

+3 -39
View File
@@ -224,10 +224,9 @@ void AP_Scripting::init(void) {
MAV_RESULT AP_Scripting::handle_command_int_packet(const mavlink_command_int_t &packet) {
switch ((SCRIPTING_CMD)packet.param1) {
case SCRIPTING_CMD_REPL_START:
return repl_start() ? MAV_RESULT_ACCEPTED : MAV_RESULT_FAILED;
case SCRIPTING_CMD_REPL_STOP:
repl_stop();
return MAV_RESULT_ACCEPTED;
return MAV_RESULT_DENIED;
case SCRIPTING_CMD_STOP:
_restart = false;
_stop = true;
@@ -244,41 +243,6 @@ MAV_RESULT AP_Scripting::handle_command_int_packet(const mavlink_command_int_t &
}
#endif
bool AP_Scripting::repl_start(void) {
if (terminal.session) { // it's already running, this is fine
return true;
}
// nuke the old folder and all contents
struct stat st;
if ((AP::FS().stat(REPL_DIRECTORY, &st) == -1) &&
(AP::FS().unlink(REPL_DIRECTORY) == -1) &&
(errno != EEXIST)) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Scripting: Unable to delete old REPL %s", strerror(errno));
}
// create a new folder
AP::FS().mkdir(REPL_DIRECTORY);
// delete old files in case we couldn't
AP::FS().unlink(REPL_DIRECTORY "/in");
AP::FS().unlink(REPL_DIRECTORY "/out");
// make the output pointer
terminal.output_fd = AP::FS().open(REPL_OUT, O_WRONLY|O_CREAT|O_TRUNC);
if (terminal.output_fd == -1) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Scripting: %s", "Unable to make new REPL");
return false;
}
terminal.session = true;
return true;
}
void AP_Scripting::repl_stop(void) {
terminal.session = false;
// can't do any more cleanup here, closing the open FD's is the REPL's responsibility
}
/*
avoid optimisation of the thread function. This avoids nasty traps
where setjmp/longjmp does not properly handle save/restore of
@@ -295,7 +259,7 @@ void AP_Scripting::thread(void) {
_restart = false;
_init_failed = false;
lua_scripts *lua = new lua_scripts(_script_vm_exec_count, _script_heap_size, _debug_options, terminal);
lua_scripts *lua = new lua_scripts(_script_vm_exec_count, _script_heap_size, _debug_options);
if (lua == nullptr || !lua->heap_allocated()) {
GCS_SEND_TEXT(MAV_SEVERITY_CRITICAL, "Scripting: %s", "Unable to allocate memory");
_init_failed = true;