= Lua = Lua is an open source scripting language whose main purpose is being embedded in C applications. More can be learned by viewing their website at http://www.lua.org . = Using Lua in RTEMS = For now, you can find the lua rtems files at http://gwu.webhop.net/~cssmith/GSOC/index.html = Calling Lua Functions in C = This operates exactly as it would in the host operating system. {{{ #include #include #include //This is the reference to the lua interpreter lua_State* L; rtems_task Init( rtems_task_argument ignored ) { L = lua_open(); luaL_openlibs(L); //Test of basic lua functionality lua_getglobal(L, "print"); lua_pushstring(L, "Hello, Lua!"); lua_call(L, 1, 0); lua_close(L); } }}} = Spawning a Lua Shell = `_Lua_Main(int argc, char** argv)` is a standard `C` main function. Lua spawns a shell whenever it is called without a script as an argument. Therefore, the end user can spawn a lua shell by modifying the code below: {{{ #include #include #include rtems_task Init( rtems_task_argument ignored ) { _Lua_spawn_shell(); } }}} = Spawning a RTEMS Shell = This creates a lua shell that allows for the execution of RTEMS commands. {{{ #include #include #include rtems_task Init( rtems_task_argument ignored ) { _Lua_spawn_RTEMS_shell(); } }}} = Executing a Standalone Lua Script = Since `_Lua_Main(int argc, char** argv)` is a standard `C` main function, executing lua scripts are as simple as notifying the interpreter where the file is located. ''Note:'' This currently has only been tested with the [wiki:File_Systems#IMFS_File_System_ IMFS] in RTEMS. Technically speaking, it should work agnostic to the underlying filesystem. {{{ #include #include #include rtems_task Init( rtems_task_argument ignored ) { char** program_args = NULL; /* Setup arguments for the lua script, if any */ _Lua_run_script("path-to-program.lua", num_arguments, program_args); } }}}