Solaris Software
Loading...
Searching...
No Matches
pubsub.h
Go to the documentation of this file.
1/**
2 * @file pubsub.h
3 * @brief Publish-subscribe packet router.
4 */
5
6#ifndef SPP_PUBSUB_H
7#define SPP_PUBSUB_H
8
9#include "spp/core/packet.h"
10#include "spp/core/types.h"
13#include "spp/util/macros.h"
14
15
16/* ----------------------------------------------------------------
17 * CONSTANTS
18 * ---------------------------------------------------------------- */
19#define K_SPP_SERVICES_PUBSUB_MAX_PRODUCERS (5U)
20#define K_SPP_SERVICES_PUBSUB_MAX_CONSUMERS (5U)
21#define K_SPP_SERVICES_PUBSUB_BUFFER_SIZE (128U) /**< Internal packet buffer depth. */
22#define K_SPP_SERVICES_PUBSUB_PREEMPT_PRIORITY (1U)
23
24#define K_SPP_SERVICES_PUBSUB_STEP (1U) /**< Step to increment circular buffer index. */
25#define K_SPP_SERVICES_PUBSUB_SORT_START_INDEX (1U) /**< Starting index for insertion sort. */
26#define K_SPP_SERVICES_PUBSUB_OFFSET (1U) /**< Array index offset. */
27#define K_SPP_SERVICES_PUBSUB_ZERO_INDEX (0) /**< Zero index/value for comparisons. */
28
29/* ----------------------------------------------------------------
30 * PUBLIC FUNCTIONS
31 * ---------------------------------------------------------------- */
32
34 SPP_Kpid_t *p_assignedKpid);
36 SPP_Kpid_t subscription);
37
39
40/**
41 * @brief Copies a packet into the internal buffer and returns it to the databank.
42 *
43 * Called by producers after filling a packet. The packet is copied by value
44 * into the next free slot of the internal circular buffer; the original is
45 * returned to the databank pool immediately. Returns K_SPP_ERROR if the
46 * buffer is full (packet is still returned to the pool).
47 *
48 * @param p_pkt Packet to publish (ownership transferred — do not use after this call).
49 * @return K_SPP_OK on success, K_SPP_ERROR_NULL_POINTER if p_pkt is NULL,
50 * K_SPP_ERROR if the buffer is full.
51 */
53
54/**
55 * @brief Calls acquireData on every registered producer.
56 */
58
59/**
60 * @brief Routes all buffered packets to matching consumer mailboxes, then clears the buffer.
61 */
62
64
65/**
66 * @brief Returns the number of packets currently held in the internal FIFO buffer.
67 */
69
70/**
71 * @brief Signals that a producer has new data pending.
72 *
73 * Must be called from within acquireData() as soon as a DRDY flag is detected,
74 * so that callConsumers() can preempt consumers with priority > K_SPP_SERVICES_PUBSUB_PREEMPT_PRIORITY.
75 */
77
79 SPP_RetVal_t *p_initResult);
80
82 SPP_RetVal_t *p_initResult);
83#endif /* SPP_PUBSUB_H */
Compile-time configuration flags and utility macros for SPP.
Solaris Packet Protocol (SPP) packet structure definitions.
SPP_Packet_t
Definition packet.h:79
SPP_RetVal_t SPP_SERVICES_PUBSUB_getConsumerInitResult(const SPP_SERVICE_ConsumerContract_t *p_consumerData, SPP_RetVal_t *p_initResult)
Definition pubsub.c:239
void SPP_SERVICES_PUBSUB_signalProducerReady(void)
Signals that a producer has new data pending.
Definition pubsub.c:177
void SPP_SERVICES_PUBSUB_callConsumers(void)
Routes all buffered packets to matching consumer mailboxes, then clears the buffer.
Definition pubsub.c:152
SPP_RetVal_t SPP_SERVICES_PUBSUB_init(void)
Definition pubsub.c:182
spp_uint8_t SPP_SERVICES_PUBSUB_queueDepth(void)
Returns the number of packets currently held in the internal FIFO buffer.
Definition pubsub.c:172
void SPP_SERVICES_PUBSUB_callProducers(void)
Calls acquireData on every registered producer.
Definition pubsub.c:119
SPP_RetVal_t SPP_SERVICES_PUBSUB_getProducerInitResult(const SPP_SERVICE_ProducerContract_t *p_producerData, SPP_RetVal_t *p_initResult)
Definition pubsub.c:220
SPP_RetVal_t SPP_SERVICES_PUBSUB_registerProducer(const SPP_SERVICE_ProducerContract_t *p_producerData, SPP_Kpid_t *p_assignedKpid)
Definition pubsub.c:58
SPP_RetVal_t SPP_SERVICES_PUBSUB_publish(SPP_Packet_t *p_pkt)
Copies a packet into the internal buffer and returns it to the databank.
Definition pubsub.c:128
SPP_RetVal_t SPP_SERVICES_PUBSUB_registerConsumer(const SPP_SERVICE_ConsumerContract_t *p_consumerData, SPP_Kpid_t subscription)
Definition pubsub.c:94
Standard return-value type used across all SPP modules.
SPP_RetVal_t
Unified return type for all SPP API functions.
Definition returnTypes.h:24
SPP module descriptor and registry API.
Describes the contract of a consumer module. This module needs to have:
Definition service.h:43
Describes the contract of a producer module. This module needs to have:
Definition service.h:28
Portable integer types and SPI/storage configuration types for SPP.
uint8_t spp_uint8_t
Definition types.h:27