|
OpenLcbCLib 1.0 Alpha
OpenSource C Library to create OpenLcb/Lcc Nodes
|
FIFO queue for OpenLCB message pointers. More...
Data Structures | |
| struct | openlcb_msg_fifo_t |
| Circular buffer of message pointers with head/tail indices. More... | |
Macros | |
| #define | LEN_MESSAGE_FIFO_BUFFER (LEN_MESSAGE_BUFFER + 1) |
| FIFO buffer size (one extra slot for full detection without additional state) | |
Functions | |
| void | OpenLcbBufferFifo_initialize (void) |
| Initializes the FIFO. | |
| openlcb_msg_t * | OpenLcbBufferFifo_push (openlcb_msg_t *new_msg) |
| Adds a message pointer to the tail of the FIFO. | |
| openlcb_msg_t * | OpenLcbBufferFifo_pop (void) |
| Removes and returns the oldest message from the FIFO. | |
| bool | OpenLcbBufferFifo_is_empty (void) |
| Returns true if the FIFO contains no messages. | |
| void | OpenLcbBufferFifo_check_and_invalidate_messages_by_source_alias (uint16_t alias) |
| Marks all queued incoming messages from a released alias as invalid. | |
| openlcb_msg_t * | OpenLcbBufferFifo_push_to_head (openlcb_msg_t *new_msg) |
| Inserts a message pointer at the head of the FIFO. | |
| uint16_t | OpenLcbBufferFifo_get_allocated_count (void) |
| Returns the number of messages currently held in the FIFO. | |
FIFO queue for OpenLCB message pointers.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Circular buffer with one wasted slot for full/empty detection. Head = next insertion, tail = next removal. Empty when head == tail.
| #define LEN_MESSAGE_FIFO_BUFFER (LEN_MESSAGE_BUFFER + 1) |
FIFO buffer size (one extra slot for full detection without additional state)
| void OpenLcbBufferFifo_initialize | ( | void | ) |
Initializes the FIFO.
Initializes the FIFO to an empty state.
Algorithm:
| openlcb_msg_t * OpenLcbBufferFifo_push | ( | openlcb_msg_t * | new_msg | ) |
Adds a message pointer to the tail of the FIFO.
Algorithm:
* @param new_msg Pointer to @ref openlcb_msg_t allocated from OpenLcbBufferStore *
| openlcb_msg_t * OpenLcbBufferFifo_pop | ( | void | ) |
Removes and returns the oldest message from the FIFO.
Algorithm:
| bool OpenLcbBufferFifo_is_empty | ( | void | ) |
Returns true if the FIFO contains no messages.
| void OpenLcbBufferFifo_check_and_invalidate_messages_by_source_alias | ( | uint16_t | alias | ) |
Marks all queued incoming messages from a released alias as invalid.
Walks the FIFO from tail to head and sets state.invalid on any message whose source_alias matches the released alias. These are completed incoming messages from a node that has gone away — processing them could generate replies to a stale alias that may now belong to a different node. The pop-phase guard or TX guard will discard them.
Does not remove messages from the FIFO — the circular buffer head/tail pointers stay untouched.
* @param alias 12-bit CAN alias that was released. If 0, returns immediately. *
| openlcb_msg_t * OpenLcbBufferFifo_push_to_head | ( | openlcb_msg_t * | new_msg | ) |
Inserts a message pointer at the head of the FIFO.
Algorithm:
* @param new_msg Pointer to @ref openlcb_msg_t allocated from OpenLcbBufferStore *
| uint16_t OpenLcbBufferFifo_get_allocated_count | ( | void | ) |
Returns the number of messages currently held in the FIFO.
Copyright (c) 2026 Jim Kueneman all rights reserved. See the License