LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
engine_cmd_msg.c File Reference
Include dependency graph for engine_cmd_msg.c:

Macros

#define ENGINE_CMD_MSG_PIPE_ASSERT_API(ptArray, ...)   if(ptArray->ptApi != &gtEngineCmdMsgPipeApi) { __VA_ARGS__; }
 Asserts the api is for the pipe.
 

Functions

static JUNO_STATUS_T EngineCmdMsg_Copy (JUNO_POINTER_T tDest, const JUNO_POINTER_T tSrc)
 
static JUNO_STATUS_T EngineCmdMsg_Reset (JUNO_POINTER_T tPointer)
 
static JUNO_STATUS_T SetAt (JUNO_DS_ARRAY_ROOT_T *ptArray, JUNO_POINTER_T tItem, size_t iIndex)
 Set the value at an index.
 
static JUNO_RESULT_POINTER_T GetAt (JUNO_DS_ARRAY_ROOT_T *ptArray, size_t iIndex)
 Get the value at an index.
 
static JUNO_STATUS_T RemoveAt (JUNO_DS_ARRAY_ROOT_T *ptArray, size_t iIndex)
 Remove a value at an index.
 
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
 
static const JUNO_DS_ARRAY_API_T gtEngineCmdMsgPipeApi
 

Macro Definition Documentation

◆ ENGINE_CMD_MSG_PIPE_ASSERT_API

#define ENGINE_CMD_MSG_PIPE_ASSERT_API (   ptArray,
  ... 
)    if(ptArray->ptApi != &gtEngineCmdMsgPipeApi) { __VA_ARGS__; }

Asserts the api is for the pipe.

DOC

Pipe Api Assert

We also define a macro to easily assert that the pipe type matches our implementation. This is done by checking the pipe api pointer.

Function Documentation

◆ EngineCmdMsg_ArrayInit()

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 
)

DOC

Pipe Init

We also implement the pipe init function, which sets the API pointer as well as the message buffer and capacity.

◆ EngineCmdMsg_Copy()

static JUNO_STATUS_T EngineCmdMsg_Copy ( JUNO_POINTER_T  tDest,
const JUNO_POINTER_T  tSrc 
)
static

DOC

Engine Command Pipe Implementation

In .c source file we will need to implement the following functions for the pointer and queue api:

DOC

Pointer Copy

The pointer copy function is responsible for copy memory from one pointer of the same type to another. We verify the pointers are implemented and are of the same type by checking the alignment, size, and api pointer. We then dereference the pointer and copy the values since we have verified the type

◆ EngineCmdMsg_Reset()

static JUNO_STATUS_T EngineCmdMsg_Reset ( JUNO_POINTER_T  tPointer)
static

DOC

Pointer Reset

The reset function will reinitialize the memory of a pointer of this message type. In this case, it means setting the memory to 0. Similar to the copy function, we verify the pointer type and api before dereferencing the pointer.

◆ GetAt()

static JUNO_RESULT_POINTER_T GetAt ( JUNO_DS_ARRAY_ROOT_T ptArray,
size_t  iIndex 
)
static

Get the value at an index.

◆ RemoveAt()

static JUNO_STATUS_T RemoveAt ( JUNO_DS_ARRAY_ROOT_T ptArray,
size_t  iIndex 
)
static

Remove a value at an index.

◆ SetAt()

static JUNO_STATUS_T SetAt ( JUNO_DS_ARRAY_ROOT_T ptArray,
JUNO_POINTER_T  tItem,
size_t  iIndex 
)
static

Set the value at an index.

DOC

Pipe Queue Implementation

Finally we implement the SetAt, GetAt, and RemoveAt functions. These functions provide a type-safe interface to setting, getting, and removing values within the command buffer at specific indicies. It essentially acts as an API to the array.

Variable Documentation

◆ gtEngineCmdMsgPipeApi

const JUNO_DS_ARRAY_API_T gtEngineCmdMsgPipeApi
static
Initial value:
=
{
}
static JUNO_STATUS_T SetAt(JUNO_DS_ARRAY_ROOT_T *ptArray, JUNO_POINTER_T tItem, size_t iIndex)
Set the value at an index.
Definition engine_cmd_msg.c:131
static JUNO_STATUS_T RemoveAt(JUNO_DS_ARRAY_ROOT_T *ptArray, size_t iIndex)
Remove a value at an index.
Definition engine_cmd_msg.c:176
static JUNO_RESULT_POINTER_T GetAt(JUNO_DS_ARRAY_ROOT_T *ptArray, size_t iIndex)
Get the value at an index.
Definition engine_cmd_msg.c:153

◆ gtEngineCmdMsgPointerApi

const JUNO_POINTER_API_T gtEngineCmdMsgPointerApi
Initial value:
=
{
}
static JUNO_STATUS_T EngineCmdMsg_Reset(JUNO_POINTER_T tPointer)
Definition engine_cmd_msg.c:88
static JUNO_STATUS_T EngineCmdMsg_Copy(JUNO_POINTER_T tDest, const JUNO_POINTER_T tSrc)
Definition engine_cmd_msg.c:69

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.