LibJuno 1.0.4
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
udp_msg_api.h
Go to the documentation of this file.
1/*
2 MIT License
3
4 Copyright (c) 2025 Robin A. Onsay
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16*/
17
27#ifndef UDP_MSG_API_H
28#define UDP_MSG_API_H
29
30#include "udp_api.h"
31#include "juno/ds/array_api.h"
33#include "juno/sb/broker_api.h"
34
35#ifdef __cplusplus
36extern "C"
37{
38#endif
39
40/* --------------------------------------------------------------------------
41 * Constants
42 * -------------------------------------------------------------------------- */
43
45#define UDPTH_PIPE_CAPACITY 8u
46
48#define UDPTH_MSG_MID ((JUNO_SB_MID_T)1u)
49
50/* --------------------------------------------------------------------------
51 * UDPTH_MSG_ARRAY_T — concrete array for pipe queue backing storage
52 * -------------------------------------------------------------------------- */
53
61struct UDPTH_MSG_ARRAY_TAG JUNO_MODULE_DERIVE(JUNO_DS_ARRAY_ROOT_T,
63);
64typedef struct UDPTH_MSG_ARRAY_TAG UDPTH_MSG_ARRAY_T;
65
66/* --------------------------------------------------------------------------
67 * Globals
68 * -------------------------------------------------------------------------- */
69
72
75
76/* --------------------------------------------------------------------------
77 * Macros and helpers
78 * -------------------------------------------------------------------------- */
79
85#define UdpThreadMsg_PointerInit(addr) \
86 JunoMemory_PointerInit(&g_udpThreadMsgPointerApi, UDP_THREAD_MSG_T, (addr))
87
97 UDPTH_MSG_ARRAY_T *ptArr,
98 JUNO_FAILURE_HANDLER_T pfcnHandler,
99 JUNO_USER_DATA_T *pvUserData)
100{
101 return JunoDs_ArrayInit(&ptArr->tRoot, &g_udpThreadMsgArrayApi,
102 UDPTH_PIPE_CAPACITY, pfcnHandler, pvUserData);
103}
104
105#ifdef __cplusplus
106}
107#endif
108
109#endif /* UDP_MSG_API_H */
Abstract fixed-capacity array interface for DS modules.
struct JUNO_DS_ARRAY_ROOT_TAG JUNO_DS_ARRAY_ROOT_T
Opaque array root carrying capacity and API pointer.
Definition array_api.h:58
Software Bus (SB) broker for single-threaded message fan-out.
static JUNO_STATUS_T JunoDs_ArrayInit(JUNO_DS_ARRAY_ROOT_T *ptArray, const JUNO_DS_ARRAY_API_T *ptArrayApi, size_t iCapacity, JUNO_FAILURE_HANDLER_T pfcnFailureHdlr, JUNO_USER_DATA_T *pvUserData)
Initialize an array root with capacity and API.
Definition array_api.h:164
#define JUNO_MODULE_DERIVE(ROOT_T,...)
Implement a derived module embedding the root as the first member.
Definition module.h:161
void(* JUNO_FAILURE_HANDLER_T)(JUNO_STATUS_T tStatus, const char *pcCustomMessage, JUNO_USER_DATA_T *pvUserData)
Failure handler callback signature.
Definition status.h:110
int32_t JUNO_STATUS_T
Canonical status type for LibJuno functions.
Definition status.h:51
void JUNO_USER_DATA_T
Opaque user data type for failure callbacks.
Definition status.h:101
Pointer trait and helpers for memory operations.
Array API vtable.
Definition array_api.h:75
Pointer operations API (copy/reset).
Definition pointer_api.h:75
Fixed-size UDP datagram message transferred between sender and receiver.
Definition udp_api.h:101
Freestanding C11 interface for the UDP socket module (udp-threads example).
struct UDPTH_MSG_ARRAY_TAG UDPTH_MSG_ARRAY_T
Definition udp_msg_api.h:64
static JUNO_STATUS_T UdpThreadMsgArray_Init(UDPTH_MSG_ARRAY_T *ptArr, JUNO_FAILURE_HANDLER_T pfcnHandler, JUNO_USER_DATA_T *pvUserData)
Initialise a UDPTH_MSG_ARRAY_T with the shared array API.
Definition udp_msg_api.h:96
const JUNO_POINTER_API_T g_udpThreadMsgPointerApi
Pointer API for UDP_THREAD_MSG_T — used with JunoMemory_PointerInit.
Definition udp_thread_msg.cpp:86
const JUNO_DS_ARRAY_API_T g_udpThreadMsgArrayApi
Array API for UDPTH_MSG_ARRAY_T — used with JunoDs_ArrayInit.
Definition udp_thread_msg.cpp:135
#define UDPTH_PIPE_CAPACITY
Definition udp_msg_api.h:45