ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
Loading...
Searching...
No Matches
event_queue.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "drivers/v24_config.h"
Include dependency graph for event_queue.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  event_queue_data_t
 Generic event payload wrapper for network/V.24 config operations. More...
 
struct  event_t
 Event queue entry. More...
 

Macros

#define EVENT_QUEUE_CAPACITY   16
 Maximum number of event slots in queue storage.
 

Enumerations

enum  event_type_t {
  EV_NONE = 0 , EV_CLI_LINE , EV_UDP_RX , EV_UDP_TX ,
  EV_HDLC_DECODE , EV_SAVE_CONFIG , EV_STATUS , EV_MEM ,
  EV_WIPE_CONFIG , EV_SET_NET_SETTINGS , EV_GET_NET_SETTINGS , EV_SET_V24_SETTINGS ,
  EV_GET_V24_SETTINGS , EV_REBOOT
}
 Event type identifiers. More...
 
enum  event_queue_data_types_t {
  NET_IP_REMOTE , NET_IP_GATEWAY , NET_IP_LOCAL , NET_IP_MASK ,
  NET_PORT_LOCAL , NET_PORT_REMOTE , V24_BAUDRATE , V24_POLARITIES ,
  V24_CLOCK_MODE , SYS_REBOOT
}
 Typed payload selector for configuration-oriented events. More...
 

Functions

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.
 

Macro Definition Documentation

◆ EVENT_QUEUE_CAPACITY

#define EVENT_QUEUE_CAPACITY   16

Maximum number of event slots in queue storage.

Definition at line 29 of file event_queue.h.

Enumeration Type Documentation

◆ event_queue_data_types_t

Typed payload selector for configuration-oriented events.

Enumerator
NET_IP_REMOTE 
NET_IP_GATEWAY 
NET_IP_LOCAL 
NET_IP_MASK 
NET_PORT_LOCAL 
NET_PORT_REMOTE 
V24_BAUDRATE 
V24_POLARITIES 
V24_CLOCK_MODE 
SYS_REBOOT 

Definition at line 55 of file event_queue.h.

◆ event_type_t

Event type identifiers.

Enumerator
EV_NONE 
EV_CLI_LINE 
EV_UDP_RX 
EV_UDP_TX 
EV_HDLC_DECODE 
EV_SAVE_CONFIG 
EV_STATUS 
EV_MEM 
EV_WIPE_CONFIG 
EV_SET_NET_SETTINGS 
EV_GET_NET_SETTINGS 
EV_SET_V24_SETTINGS 
EV_GET_V24_SETTINGS 
EV_REBOOT 

Definition at line 34 of file event_queue.h.

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_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: