|
LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
|
#include "juno/log/log_api.h"#include "juno/sb/broker_api.h"#include "juno/status.h"#include "juno/module.h"#include "juno/app/app_api.h"#include "engine_app/engine_cmd_msg.h"#include "juno/time/time_api.h"

Go to the source code of this file.
Macros | |
| #define | ENGINE_CMD_MSG_PIPE_DEPTH (1) |
Typedefs | |
| typedef struct ENGINE_APP_TAG | ENGINE_APP_T |
Functions | |
| struct ENGINE_APP_TAG | JUNO_MODULE_DERIVE (JUNO_APP_ROOT_T, const JUNO_LOG_ROOT_T *ptLogger;const JUNO_TIME_ROOT_T *ptTime;JUNO_SB_BROKER_ROOT_T *ptBroker;ENGINE_CMD_MSG_T ptArrCmdBuffer[ENGINE_CMD_MSG_PIPE_DEPTH];ENGINE_CMD_MSG_ARRAY_T tCmdArray;JUNO_SB_PIPE_T tCmdPipe;float fCurrentRpm;) |
| JUNO_STATUS_T | EngineApp_Init (ENGINE_APP_T *ptEngineApp, const JUNO_LOG_ROOT_T *ptLogger, const JUNO_TIME_ROOT_T *ptTime, JUNO_SB_BROKER_ROOT_T *ptBroker, JUNO_FAILURE_HANDLER_T pfcnFailureHandler, JUNO_USER_DATA_T *pvUserData) |
| #define ENGINE_CMD_MSG_PIPE_DEPTH (1) |
| typedef struct ENGINE_APP_TAG ENGINE_APP_T |
This API has been generated by LibJuno: https://www.robinonsay.com/libjuno/ This header contains the engine_app library API
Next we will be going over a typical LibJuno application. For this tutorial project we are defining an engine application that manages the engine hardware for our car. In this example the engine needs to receive a command for the RPM and telemeter the actual RPM of the engine.
Applications in LibJuno are derived from the application root. This provides a common API for applications to utilize. A standard application has three lifecycle functions:
Within the derived application users are expected to place pointers to dependencies they require from the main runtime and hold resources the application needs to own and pass from one lifecycle event to the next. In this case the engine app needs the following from the runtime: Logger Time Broker
And the application needs to allocate: A command buffer for engine commands. This is a memory allocation for commands that will be received by the application A command pipe. This is the module that manages the command buffer The current RPM. This is the current state of our engine.
| JUNO_STATUS_T EngineApp_Init | ( | ENGINE_APP_T * | ptJunoApp, |
| const JUNO_LOG_ROOT_T * | ptLogger, | ||
| const JUNO_TIME_ROOT_T * | ptTime, | ||
| JUNO_SB_BROKER_ROOT_T * | ptBroker, | ||
| JUNO_FAILURE_HANDLER_T | pfcnFailureHandler, | ||
| JUNO_USER_DATA_T * | pvFailureUserData | ||
| ) |
DOC
The application also needs to provide a concrete application initialization function. This function sets dependencies and the API pointers within the application. The application has an internal "Verify" function that checks if any of these dependencies are null.
DOC
The init function's primary responsibility is to assign dependencies. This function enables the main.c project composition root to pass application dependencies to the application. This function is a concrete implementation because it depends entirely on application specifics.
This function asserts the module pointer exists, assigns the dependency pointers, and finally calls the verification function. The verification function is called last because it assumes the pointers have been instantiated.
| struct ENGINE_APP_TAG JUNO_MODULE_DERIVE | ( | JUNO_APP_ROOT_T | , |
| const JUNO_LOG_ROOT_T *ptLogger;const JUNO_TIME_ROOT_T *ptTime;JUNO_SB_BROKER_ROOT_T *ptBroker;ENGINE_CMD_MSG_T ptArrCmdBuffer;ENGINE_CMD_MSG_ARRAY_T tCmdArray;JUNO_SB_PIPE_T tCmdPipe;float fCurrentRpm; | [ENGINE_CMD_MSG_PIPE_DEPTH] | ||
| ) |