|
LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
|
#include "juno/ds/array_api.h"#include "juno/memory/pointer_api.h"#include "juno/module.h"#include "juno/sb/broker_api.h"#include "juno/status.h"

Go to the source code of this file.
Data Structures | |
| struct | ENGINE_CMD_MSG_TAG |
Macros | |
| #define | ENGINE_CMD_MSG_MID (0x1800) |
| #define | EngineCmdMsg_PointerInit(addr) JunoMemory_PointerInit(>EngineCmdMsgPointerApi, ENGINE_CMD_MSG_T, addr) |
| #define | EngineCmdMsg_PointerVerify(tPointer) JunoMemory_PointerVerifyType(tPointer, ENGINE_CMD_MSG_T, gtEngineCmdMsgPointerApi) |
Typedefs | |
| typedef struct ENGINE_CMD_MSG_TAG | ENGINE_CMD_MSG_T |
Functions | |
| struct ENGINE_CMD_MSG_ARRAY_TAG | JUNO_MODULE_DERIVE (JUNO_DS_ARRAY_ROOT_T, ENGINE_CMD_MSG_T *ptArrEngineCmdMsgBuffer;) ENGINE_CMD_MSG_ARRAY_T |
| JUNO_STATUS_T | EngineCmdMsg_ArrayInit (ENGINE_CMD_MSG_ARRAY_T *ptEngineCmdMsgPipe, ENGINE_CMD_MSG_T *ptArrEngineCmdMsgBuffer, size_t iCapacity, JUNO_FAILURE_HANDLER_T pfcnFailureHdlr, JUNO_USER_DATA_T *pvUserData) |
Variables | |
| const JUNO_POINTER_API_T | gtEngineCmdMsgPointerApi |
| #define ENGINE_CMD_MSG_MID (0x1800) |
DOC This file is auto-generated from a LibJuno script (scripts/create_msg.py). Similarly the engine_tlm_msg.h and engine_tlm_msg.c files are also auto-generated. We will only go over the command file since it's identical to the telemetry file in terms of architecture.
In LibJuno the software bus is operated on a single thread. A single broker is implemented for each thread of execution and the broker distributes messages to various queues that are subscribed on the software bus. These queues are called pipes. Pipes are derived LibJuno queues with a message ID subscription.
The message ID is a unique identifier for the type of message. Each message type will have its own message ID. In this example the engine command MID is 0x1800. This number can be arbitrary. The only requirement is the MIDs are unique for every message type.
| #define EngineCmdMsg_PointerInit | ( | addr | ) | JunoMemory_PointerInit(>EngineCmdMsgPointerApi, ENGINE_CMD_MSG_T, addr) |
DOC We also define convenience macros for initializing and verifying this type of pointer. This makes working with LibJuno pointers easy.
| #define EngineCmdMsg_PointerVerify | ( | tPointer | ) | JunoMemory_PointerVerifyType(tPointer, ENGINE_CMD_MSG_T, gtEngineCmdMsgPointerApi) |
| typedef struct ENGINE_CMD_MSG_TAG ENGINE_CMD_MSG_T |
DOC The command message contains the RPM. Another application can send this command on the software bus and tell the engine what RPM it should be set to. The engine app will then control the engine so it's set to the new RPM.
| JUNO_STATUS_T EngineCmdMsg_ArrayInit | ( | ENGINE_CMD_MSG_ARRAY_T * | ptEngineCmdMsgPipe, |
| ENGINE_CMD_MSG_T * | ptArrEngineCmdMsgBuffer, | ||
| size_t | iCapacity, | ||
| JUNO_FAILURE_HANDLER_T | pfcnFailureHdlr, | ||
| JUNO_USER_DATA_T * | pvUserData | ||
| ) |
| struct ENGINE_CMD_MSG_ARRAY_TAG JUNO_MODULE_DERIVE | ( | JUNO_DS_ARRAY_ROOT_T | , |
| ENGINE_CMD_MSG_T *ptArrEngineCmdMsgBuffer; | |||
| ) |
DOC
Below is the definition for the engine command pipe. This is derived from the JUNO_SB_PIPE_T using the DERIVE_WITH_API macro. This macro enables users to specify which API they are using. The inheritance for a pipe is as follows:
Because this is a longer chain of inheritance, it's convenient to specify the API for ease-of-use. In this case we are specifying the QUEUE api.
The pipe holds a pointer to a command buffer, which is specific to the command message type defined earlier. This enables the derived pipe to have specific type information (vs using a void pointer in the pipe).
|
extern |
DOC The queue api relies on LibJuno pointers. This enables the modules to write generic code safely without specific type information. As a result, we need to specify a pointer API implementation for this command type.
DOC These function will provide an interface to our specific message type and enable users to write type-safe code within LibJuno.
We need to forward-declare these API functions so we can use the API pointer to verify the type of the queue and pointer.
Below we will instantiate the pointer and pipe API tables.