Solaris Software
Loading...
Searching...
No Matches
pubsub.h File Reference

Publish-subscribe packet router. More...

Include dependency graph for pubsub.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define K_SPP_SERVICES_PUBSUB_MAX_PRODUCERS   (5U)
#define K_SPP_SERVICES_PUBSUB_MAX_CONSUMERS   (5U)
#define K_SPP_SERVICES_PUBSUB_BUFFER_SIZE   (128U)
#define K_SPP_SERVICES_PUBSUB_PREEMPT_PRIORITY   (1U)
#define K_SPP_SERVICES_PUBSUB_STEP   (1U)
#define K_SPP_SERVICES_PUBSUB_SORT_START_INDEX   (1U)
#define K_SPP_SERVICES_PUBSUB_OFFSET   (1U)
#define K_SPP_SERVICES_PUBSUB_ZERO_INDEX   (0)

Functions

SPP_RetVal_t SPP_SERVICES_PUBSUB_registerProducer (const SPP_SERVICE_ProducerContract_t *p_producerData, SPP_Kpid_t *p_assignedKpid)
SPP_RetVal_t SPP_SERVICES_PUBSUB_registerConsumer (const SPP_SERVICE_ConsumerContract_t *p_consumerData, SPP_Kpid_t subscription)
SPP_RetVal_t SPP_SERVICES_PUBSUB_init (void)
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.
void SPP_SERVICES_PUBSUB_callProducers (void)
 Calls acquireData on every registered producer.
void SPP_SERVICES_PUBSUB_callConsumers (void)
 Routes all buffered packets to matching consumer mailboxes, then clears the buffer.
spp_uint8_t SPP_SERVICES_PUBSUB_queueDepth (void)
 Returns the number of packets currently held in the internal FIFO buffer.
void SPP_SERVICES_PUBSUB_signalProducerReady (void)
 Signals that a producer has new data pending.
SPP_RetVal_t SPP_SERVICES_PUBSUB_getProducerInitResult (const SPP_SERVICE_ProducerContract_t *p_producerData, SPP_RetVal_t *p_initResult)
SPP_RetVal_t SPP_SERVICES_PUBSUB_getConsumerInitResult (const SPP_SERVICE_ConsumerContract_t *p_consumerData, SPP_RetVal_t *p_initResult)

Detailed Description

Publish-subscribe packet router.

Definition in file pubsub.h.

Macro Definition Documentation

◆ K_SPP_SERVICES_PUBSUB_MAX_PRODUCERS

#define K_SPP_SERVICES_PUBSUB_MAX_PRODUCERS   (5U)

Definition at line 19 of file pubsub.h.

Referenced by SPP_SERVICES_PUBSUB_registerProducer().

◆ K_SPP_SERVICES_PUBSUB_MAX_CONSUMERS

#define K_SPP_SERVICES_PUBSUB_MAX_CONSUMERS   (5U)

Definition at line 20 of file pubsub.h.

Referenced by SPP_SERVICES_PUBSUB_registerConsumer().

◆ K_SPP_SERVICES_PUBSUB_BUFFER_SIZE

#define K_SPP_SERVICES_PUBSUB_BUFFER_SIZE   (128U)

Internal packet buffer depth.

Definition at line 21 of file pubsub.h.

Referenced by SPP_SERVICES_PUBSUB_publish(), and SPP_SERVICES_PUBSUB_sendToMailbox().

◆ K_SPP_SERVICES_PUBSUB_PREEMPT_PRIORITY

#define K_SPP_SERVICES_PUBSUB_PREEMPT_PRIORITY   (1U)

Definition at line 22 of file pubsub.h.

Referenced by SPP_SERVICES_PUBSUB_callConsumers().

◆ K_SPP_SERVICES_PUBSUB_STEP

#define K_SPP_SERVICES_PUBSUB_STEP   (1U)

Step to increment circular buffer index.

Definition at line 24 of file pubsub.h.

Referenced by SPP_SERVICES_PUBSUB_publish(), and SPP_SERVICES_PUBSUB_sendToMailbox().

◆ K_SPP_SERVICES_PUBSUB_SORT_START_INDEX

#define K_SPP_SERVICES_PUBSUB_SORT_START_INDEX   (1U)

Starting index for insertion sort.

Definition at line 25 of file pubsub.h.

Referenced by SPP_SERVICES_PUBSUB_sortConsumers().

◆ K_SPP_SERVICES_PUBSUB_OFFSET

#define K_SPP_SERVICES_PUBSUB_OFFSET   (1U)

Array index offset.

Definition at line 26 of file pubsub.h.

Referenced by SPP_SERVICES_PUBSUB_sortConsumers().

◆ K_SPP_SERVICES_PUBSUB_ZERO_INDEX

#define K_SPP_SERVICES_PUBSUB_ZERO_INDEX   (0)

Zero index/value for comparisons.

Definition at line 27 of file pubsub.h.

Referenced by SPP_SERVICES_PUBSUB_sortConsumers().

Function Documentation

◆ SPP_SERVICES_PUBSUB_registerProducer()

SPP_RetVal_t SPP_SERVICES_PUBSUB_registerProducer ( const SPP_SERVICE_ProducerContract_t * p_producerData,
SPP_Kpid_t * p_assignedKpid )

Definition at line 58 of file pubsub.c.

References SPP_SERVICES_PUBSUB_Producer_t::initResult, K_SPP_ERROR, K_SPP_ERROR_NOT_INITIALIZED, K_SPP_ERROR_NULL_POINTER, K_SPP_ERROR_REGISTRY_FULL, K_SPP_OK, K_SPP_SERVICES_PUBSUB_MAX_PRODUCERS, SPP_SERVICES_PUBSUB_Producer_t::kpid, SPP_SERVICES_PUBSUB_Producer_t::p_contract, s_producers, s_registeredProducers, SPP_SERVICES_PUBSUB_registerProducer(), and SPP_Kpid_t::value.

Referenced by CUSTOM_registerConsumerProducer(), and SPP_SERVICES_PUBSUB_registerProducer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_PUBSUB_registerConsumer()

SPP_RetVal_t SPP_SERVICES_PUBSUB_registerConsumer ( const SPP_SERVICE_ConsumerContract_t * p_consumerData,
SPP_Kpid_t subscription )

Definition at line 94 of file pubsub.c.

References SPP_SERVICES_PUBSUB_Consumer_t::initResult, K_SPP_ERROR, K_SPP_ERROR_NOT_INITIALIZED, K_SPP_ERROR_NULL_POINTER, K_SPP_ERROR_REGISTRY_FULL, K_SPP_OK, K_SPP_SERVICES_PUBSUB_MAX_CONSUMERS, SPP_SERVICES_PUBSUB_Consumer_t::p_contract, s_consumers, s_registeredConsumers, SPP_SERVICES_PUBSUB_registerConsumer(), and SPP_SERVICES_PUBSUB_Consumer_t::subcription.

Referenced by SPP_SERVICES_PUBSUB_registerConsumer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_PUBSUB_init()

SPP_RetVal_t SPP_SERVICES_PUBSUB_init ( void )

Definition at line 182 of file pubsub.c.

References SPP_SERVICE_ConsumerContract_t::init, SPP_SERVICE_ProducerContract_t::init, SPP_SERVICES_PUBSUB_Consumer_t::initResult, SPP_SERVICES_PUBSUB_Producer_t::initResult, K_SPP_ERROR, K_SPP_OK, SPP_SERVICES_PUBSUB_Consumer_t::p_contract, SPP_SERVICES_PUBSUB_Producer_t::p_contract, s_consumers, s_producers, s_registeredConsumers, s_registeredProducers, SPP_SERVICES_PUBSUB_init(), and SPP_SERVICES_PUBSUB_sortConsumers().

Referenced by SPP_CORE_init(), and SPP_SERVICES_PUBSUB_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_PUBSUB_publish()

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.

Called by producers after filling a packet. The packet is copied by value into the next free slot of the internal circular buffer; the original is returned to the databank pool immediately. Returns K_SPP_ERROR if the buffer is full (packet is still returned to the pool).

Parameters
p_pktPacket to publish (ownership transferred — do not use after this call).
Returns
K_SPP_OK on success, K_SPP_ERROR_NULL_POINTER if p_pkt is NULL, K_SPP_ERROR if the buffer is full.

Definition at line 128 of file pubsub.c.

References K_SPP_ERROR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, K_SPP_SERVICES_PUBSUB_BUFFER_SIZE, K_SPP_SERVICES_PUBSUB_STEP, s_bufferCount, s_bufferTail, s_packetBuffer, SPP_Packet_t, SPP_SERVICES_DATABANK_returnPacket(), and SPP_SERVICES_PUBSUB_publish().

Referenced by action_emitTelemetry(), SPP_SERVICES_BMP390_acquireData(), SPP_SERVICES_BMP390_DUMMY_acquireData(), SPP_SERVICES_ICM20948_acquireData(), and SPP_SERVICES_PUBSUB_publish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_PUBSUB_callProducers()

void SPP_SERVICES_PUBSUB_callProducers ( void )

Calls acquireData on every registered producer.

Definition at line 119 of file pubsub.c.

References SPP_SERVICES_PUBSUB_Producer_t::kpid, s_producerReady, s_producers, s_registeredProducers, and SPP_SERVICES_PUBSUB_callProducers().

Referenced by SPP_SERVICES_PUBSUB_callProducers(), and statefunction_bmpPerformanceLoop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_PUBSUB_callConsumers()

void SPP_SERVICES_PUBSUB_callConsumers ( void )

Routes all buffered packets to matching consumer mailboxes, then clears the buffer.

Definition at line 152 of file pubsub.c.

References K_SPP_SERVICES_PUBSUB_PREEMPT_PRIORITY, s_consumers, s_producerReady, s_registeredConsumers, SPP_SERVICES_PUBSUB_callConsumers(), and SPP_SERVICES_PUBSUB_sendToMailbox().

Referenced by SPP_SERVICES_PUBSUB_callConsumers(), and statefunction_bmpPerformanceLoop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_PUBSUB_queueDepth()

spp_uint8_t SPP_SERVICES_PUBSUB_queueDepth ( void )

Returns the number of packets currently held in the internal FIFO buffer.

Definition at line 172 of file pubsub.c.

References s_bufferCount, and SPP_SERVICES_PUBSUB_queueDepth().

Referenced by SPP_SERVICES_PUBSUB_queueDepth(), and statefunction_bmpPerformanceLoop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_PUBSUB_signalProducerReady()

void SPP_SERVICES_PUBSUB_signalProducerReady ( void )

Signals that a producer has new data pending.

Must be called from within acquireData() as soon as a DRDY flag is detected, so that callConsumers() can preempt consumers with priority > K_SPP_SERVICES_PUBSUB_PREEMPT_PRIORITY.

Definition at line 177 of file pubsub.c.

References s_producerReady, and SPP_SERVICES_PUBSUB_signalProducerReady().

Referenced by SPP_SERVICES_PUBSUB_signalProducerReady().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_PUBSUB_getProducerInitResult()

SPP_RetVal_t SPP_SERVICES_PUBSUB_getProducerInitResult ( const SPP_SERVICE_ProducerContract_t * p_producerData,
SPP_RetVal_t * p_initResult )

Definition at line 220 of file pubsub.c.

References SPP_SERVICES_PUBSUB_Producer_t::initResult, K_SPP_ERROR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, s_producers, s_registeredProducers, and SPP_SERVICES_PUBSUB_getProducerInitResult().

Referenced by CUSTOM_initCheck(), and SPP_SERVICES_PUBSUB_getProducerInitResult().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SPP_SERVICES_PUBSUB_getConsumerInitResult()

SPP_RetVal_t SPP_SERVICES_PUBSUB_getConsumerInitResult ( const SPP_SERVICE_ConsumerContract_t * p_consumerData,
SPP_RetVal_t * p_initResult )

Definition at line 239 of file pubsub.c.

References SPP_SERVICES_PUBSUB_Consumer_t::initResult, K_SPP_ERROR, K_SPP_ERROR_NULL_POINTER, K_SPP_OK, s_consumers, s_registeredConsumers, and SPP_SERVICES_PUBSUB_getConsumerInitResult().

Referenced by SPP_SERVICES_PUBSUB_getConsumerInitResult().

Here is the call graph for this function:
Here is the caller graph for this function: