ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
Loading...
Searching...
No Matches
event_queue.c File Reference
#include "event_queue.h"
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for event_queue.c:

Go to the source code of this file.

Functions

static uint8_t event_queue_count_internal (void)
 
void event_queue_init (void)
 Initialize the event queue storage.
 
bool event_queue_push (const event_t *event_entry)
 Enqueue an event.
 
bool event_queue_pop (event_t *event_out)
 Dequeue an event.
 
bool event_queue_is_empty (void)
 Check whether the queue is empty.
 
bool event_queue_is_full (void)
 Check whether the queue is full.
 
size_t event_queue_get_count (void)
 Get current number of queued events.
 
size_t event_queue_get_high_water_mark (void)
 Get peak queue fill count observed since init.
 
uint32_t event_queue_get_push_drop_count (void)
 Get cumulative number of dropped push attempts.
 
bool event_get_payload_ptr (const event_t *event, size_t required_size, const void **out)
 Resolve payload pointer and validate minimum payload size.
 

Variables

static event_t event_queue [EVENT_QUEUE_CAPACITY]
 
static uint8_t event_queue_write = 0
 
static uint8_t event_queue_read = 0
 
static uint8_t event_queue_high_water_mark = 0
 
static uint32_t event_queue_push_drops = 0
 

Function Documentation

◆ event_get_payload_ptr()

bool event_get_payload_ptr ( const event_t event,
size_t  required_size,
const void **  out 
)

Resolve payload pointer and validate minimum payload size.

Parameters
eventEvent to inspect.
required_sizeMinimum bytes required by caller.
outOutput pointer to payload bytes/object.
Returns
true when payload is valid and large enough.

Definition at line 104 of file event_queue.c.

References event_t::bytes, event_t::data, event_t::data_len, event_t::is_inline, and event_t::ptr.

Referenced by event_dispatch(), and print_net_settings_event().

Here is the caller graph for this function:

◆ event_queue_count_internal()

static uint8_t event_queue_count_internal ( void  )
static

Definition at line 31 of file event_queue.c.

References EVENT_QUEUE_CAPACITY, event_queue_read, and event_queue_write.

Referenced by event_queue_get_count(), and event_queue_push().

Here is the caller graph for this function:

◆ event_queue_get_count()

size_t event_queue_get_count ( void  )

Get current number of queued events.

Returns
Queue fill count.

Definition at line 89 of file event_queue.c.

References event_queue_count_internal().

Referenced by update_statistics().

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

◆ event_queue_get_high_water_mark()

size_t event_queue_get_high_water_mark ( void  )

Get peak queue fill count observed since init.

Returns
High-water mark.

Definition at line 94 of file event_queue.c.

References event_queue_high_water_mark.

Referenced by update_statistics().

Here is the caller graph for this function:

◆ event_queue_get_push_drop_count()

uint32_t event_queue_get_push_drop_count ( void  )

Get cumulative number of dropped push attempts.

Returns
Drop counter.

Definition at line 99 of file event_queue.c.

References event_queue_push_drops.

Referenced by update_statistics().

Here is the caller graph for this function:

◆ event_queue_init()

void event_queue_init ( void  )

Initialize the event queue storage.

Definition at line 40 of file event_queue.c.

References event_queue, event_queue_high_water_mark, event_queue_push_drops, event_queue_read, and event_queue_write.

Referenced by main().

Here is the caller graph for this function:

◆ event_queue_is_empty()

bool event_queue_is_empty ( void  )

Check whether the queue is empty.

Definition at line 78 of file event_queue.c.

References event_queue_read, and event_queue_write.

◆ event_queue_is_full()

bool event_queue_is_full ( void  )

Check whether the queue is full.

Definition at line 83 of file event_queue.c.

References EVENT_QUEUE_CAPACITY, event_queue_read, and event_queue_write.

◆ event_queue_pop()

bool event_queue_pop ( event_t event_out)

Dequeue an event.

Parameters
event_outDestination for the popped event.
Returns
true if an event was popped, false if the queue was empty.

Definition at line 67 of file event_queue.c.

References event_queue, EVENT_QUEUE_CAPACITY, event_queue_read, and event_queue_write.

Referenced by poll_and_dispatch_events().

Here is the caller graph for this function:

◆ event_queue_push()

bool event_queue_push ( const event_t event_entry)

Enqueue an event.

Parameters
event_entryEvent to push; payload pointer ownership stays with caller.
Returns
true if queued, false if the queue was full.

Definition at line 49 of file event_queue.c.

References event_queue, EVENT_QUEUE_CAPACITY, event_queue_count_internal(), event_queue_high_water_mark, event_queue_push_drops, event_queue_read, and event_queue_write.

Referenced by cli_poll(), cmd_mem(), cmd_reboot(), cmd_save(), cmd_status(), cmd_wipe(), dispatch_get_request(), dispatch_get_udp_port(), dispatch_ip(), dispatch_set_udp_port(), dispatch_v24_baudrate(), dispatch_v24_polarities(), event_dispatch(), request_save_config(), and subcmd_set_v24_clockmode().

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

Variable Documentation

◆ event_queue

event_t event_queue[EVENT_QUEUE_CAPACITY]
static

Definition at line 25 of file event_queue.c.

Referenced by event_queue_init(), event_queue_pop(), and event_queue_push().

◆ event_queue_high_water_mark

uint8_t event_queue_high_water_mark = 0
static

◆ event_queue_push_drops

uint32_t event_queue_push_drops = 0
static

◆ event_queue_read

uint8_t event_queue_read = 0
static

◆ event_queue_write

uint8_t event_queue_write = 0
static