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

Fix #42, add script engine CFS lib #46

Merged
merged 1 commit into from
Apr 20, 2023
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
8 changes: 8 additions & 0 deletions cfecfs/missionlib/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ if (LUALIB_FOUND)
target_link_libraries(cfe_missionlib_lua_softwarebus edslib_lua cfe_missionlib cfe_missionlib_runtime_static)
add_dependencies(cfe_missionlib_lua_softwarebus edstool-execute)

add_library(cfe_missionlib_lua_softwarebus_pic OBJECT
src/cfe_missionlib_lua_softwarebus.c
)
set_target_properties(cfe_missionlib_lua_softwarebus_pic PROPERTIES
POSITION_INDEPENDENT_CODE TRUE
)
target_include_directories(cfe_missionlib_lua_softwarebus_pic PUBLIC inc ${LUALIB_INCLUDE_DIRS})

endif()
6 changes: 4 additions & 2 deletions cfecfs/missionlib/lua/inc/cfe_missionlib_lua_softwarebus.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

#include <lua.h>
#include "cfe_missionlib_api.h"

#include "cfe_sb_eds_typedefs.h"

typedef struct
{
Expand All @@ -47,5 +47,7 @@ typedef struct

void CFE_MissionLib_Lua_SoftwareBus_Attach(lua_State *lua, const CFE_MissionLib_SoftwareBus_Interface_t *IntfDB);

#endif /* _CFE_MISSIONLIB_LUA_SOFTWAREBUS_H_ */
void CFE_MissionLib_Lua_MapPubSubParams(CFE_SB_SoftwareBus_PubSub_Interface_t *PubSub, const CFE_MissionLib_Lua_Interface_Userdata_t *IntfObj);
void CFE_MissionLib_Lua_UnmapPubSubParams(CFE_MissionLib_Lua_Interface_Userdata_t *IntfObj, const CFE_SB_SoftwareBus_PubSub_Interface_t *PubSub);

#endif /* _CFE_MISSIONLIB_LUA_SOFTWAREBUS_H_ */
4 changes: 2 additions & 2 deletions cfecfs/missionlib/lua/src/cfe_missionlib_lua_softwarebus.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

static const char CFE_MISSIONLIB_INTFDB_KEY;

static void CFE_MissionLib_Lua_MapPubSubParams(CFE_SB_SoftwareBus_PubSub_Interface_t *PubSub, const CFE_MissionLib_Lua_Interface_Userdata_t *IntfObj)
void CFE_MissionLib_Lua_MapPubSubParams(CFE_SB_SoftwareBus_PubSub_Interface_t *PubSub, const CFE_MissionLib_Lua_Interface_Userdata_t *IntfObj)
{
switch (IntfObj->IntfId)
{
Expand Down Expand Up @@ -81,7 +81,7 @@ static void CFE_MissionLib_Lua_MapPubSubParams(CFE_SB_SoftwareBus_PubSub_Interfa
}
}

static void CFE_MissionLib_Lua_UnmapPubSubParams(CFE_MissionLib_Lua_Interface_Userdata_t *IntfObj, const CFE_SB_SoftwareBus_PubSub_Interface_t *PubSub)
void CFE_MissionLib_Lua_UnmapPubSubParams(CFE_MissionLib_Lua_Interface_Userdata_t *IntfObj, const CFE_SB_SoftwareBus_PubSub_Interface_t *PubSub)
{
switch(IntfObj->IntfId)
{
Expand Down
25 changes: 25 additions & 0 deletions cfecfs/scriptengine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
project(CFE_SCRIPTENGINE C)

# Create the app module
add_cfe_app(scriptengine
fsw/src/scriptengine.c
$<TARGET_OBJECTS:edslib_lua_pic>
$<TARGET_OBJECTS:cfe_missionlib_lua_softwarebus_pic>
)

target_include_directories(scriptengine PUBLIC fsw/inc)
target_include_directories(scriptengine PRIVATE
$<TARGET_PROPERTY:edslib_lua_pic,INTERFACE_INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:cfe_missionlib_lua_softwarebus_pic,INTERFACE_INCLUDE_DIRECTORIES>
)

if (ENABLE_UNIT_TESTS)
add_subdirectory(ut-stubs)
endif (ENABLE_UNIT_TESTS)

# Install the executables to a staging area for test in cross environments
if (INSTALL_TARGET_LIST)
foreach(TGT ${INSTALL_TARGET_LIST})
install(FILES scripts/testscript.lua DESTINATION ${TGT}/${INSTALL_SUBDIR})
endforeach()
endif()
62 changes: 62 additions & 0 deletions cfecfs/scriptengine/fsw/inc/scriptengine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2020 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
************************************************************************/

/**
* \file
* Specification for the sample library functions.
*/
#ifndef SCRIPTENGINE_H
#define SCRIPTENGINE_H

/************************************************************************
** Includes
*************************************************************************/
#include "cfe.h"

/************************************************************************
** Type Definitions
*************************************************************************/

/*************************************************************************
** Exported Functions
*************************************************************************/

/************************************************************************/
/** \brief Library Initialization Function
**
** \par Description
** This function is required by CFE to initialize the library
** It should be specified in the cfe_es_startup.scr file as part
** of loading this library. It is not directly invoked by
** applications.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \return Execution status, see \ref CFEReturnCodes
**
**
*************************************************************************/
int32 SCRIPTENGINE_Init(void);

int32 SCRIPTENGINE_LoadFile(const char *Filename);

int32 SCRIPTENGINE_CallFunctionVoid(const char *FunctionName);
int32 SCRIPTENGINE_CallFunctionArg(const char *FunctionName, void *ArgData, uint16 AppIdx, uint16 FormatIdx);

#endif
Loading