ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
Loading...
Searching...
No Matches
event_dispatch.c File Reference
#include "system/event_dispatch.h"
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "pico/time.h"
#include "wizchip_conf.h"
#include "wizchip_qspi_pio.h"
#include "drivers/pio_tx_rx_driver.h"
#include "drivers/tx_queue.h"
#include "drivers/v24_config.h"
#include "drivers/w5500_driver.h"
#include "platform/watchdog.h"
#include "protocol/hdlc_common.h"
#include "protocol/hdlc_decoder.h"
#include "protocol/hdlc_sync.h"
#include "system/app_context.h"
#include "system/cli_commands.h"
#include "system/cli_usb_cdc.h"
#include "system/common.h"
#include "system/error.h"
#include "system/event_queue.h"
#include "system/persistent_config.h"
Include dependency graph for event_dispatch.c:

Go to the source code of this file.

Data Structures

struct  apply_result_t
 
struct  ev_status_stats_t
 

Macros

#define ADD(name, flag)
 

Functions

static void print_v24_polarities (const V24_POLARITIES_T *polarities)
 
static const char * net_setting_id_name (event_queue_data_types_t event_id)
 
static const char * hdlc_sync_state_name (HDLC_SYNC_STATE_T state)
 
static void print_net_settings_event (const event_t *event)
 
static void request_save_config (void)
 
static bool ev_set_net_settings (const event_queue_data_t *payload, app_ctx_t *app)
 
static void ev_get_net_settings (const event_queue_data_t *payload, const app_ctx_t *app)
 
static apply_result_t ev_set_v24_settings (const event_queue_data_t *payload, app_ctx_t *app)
 
static void ev_get_v24_settings (const event_queue_data_t *payload, app_ctx_t *app)
 
static void ev_status (app_ctx_t *app, ev_status_stats_t *status_stats)
 
static void print_status_event (app_ctx_t *app, ev_status_stats_t *status_stats)
 
void event_dispatch (const event_t *event, app_ctx_t *app)
 Dispatch one event to the corresponding handler.
 

Macro Definition Documentation

◆ ADD

#define ADD (   name,
  flag 
)
Value:
do \
{ \
if (flag) \
{ \
LOG_PLAIN("%s%s", first ? "" : ",", name); \
first = false; \
} \
} while (0)

Function Documentation

◆ ev_get_net_settings()

static void ev_get_net_settings ( const event_queue_data_t payload,
const app_ctx_t app 
)
static

◆ ev_get_v24_settings()

static void ev_get_v24_settings ( const event_queue_data_t payload,
app_ctx_t app 
)
static

Definition at line 340 of file event_dispatch.c.

References V24_CONFIG_T::baudrate, V24_CONFIG_T::external_clock, event_queue_data_t::id, LOG_PLAIN, app_ctx_t::need_prompt, V24_CONFIG_T::polarities, print_v24_polarities(), V24_BAUDRATE, V24_CLOCK_MODE, app_ctx_t::v24_config, and V24_POLARITIES.

Referenced by event_dispatch().

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

◆ ev_set_net_settings()

◆ ev_set_v24_settings()

◆ ev_status()

◆ event_dispatch()

void event_dispatch ( const event_t event,
app_ctx_t app 
)

Dispatch one event to the corresponding handler.

Parameters
eventEvent to process.
appApplication context.

Definition at line 504 of file event_dispatch.c.

References app_ctx_t::accumulator, apply_result_t::changed, config_wipe(), config_write(), app_ctx_t::destination_config, dump_config(), EV_CLI_LINE, ev_get_net_settings(), EV_GET_NET_SETTINGS, ev_get_v24_settings(), EV_GET_V24_SETTINGS, EV_HDLC_DECODE, EV_MEM, EV_REBOOT, EV_SAVE_CONFIG, ev_set_net_settings(), EV_SET_NET_SETTINGS, ev_set_v24_settings(), EV_SET_V24_SETTINGS, ev_status(), EV_STATUS, EV_UDP_RX, EV_UDP_TX, EV_WIPE_CONFIG, event_get_payload_ptr(), event_queue_push(), get_loglevel(), handle_cli_line(), hdlc_decode(), HDLC_FLAG_BYTE, hdlc_sync_acc_init(), UDP_FRAME_T::length, HDLC_FRAME_T::length, app_ctx_t::local_config, config_t::local_config, LOG_DEBUG, config_t::log_level, LOG_LEVEL_DEBUG, LOG_PLAIN, app_ctx_t::need_prompt, app_ctx_t::net_config, config_t::net_config, NETWORK_CONFIG_T::net_info, UDP_FRAME_T::payload, HDLC_FRAME_T::payload, app_ctx_t::persistent_config, print_flash_usage(), PRINT_FRAME_HEX, print_memory_usage(), print_net_settings_event(), print_status_event(), reboot(), apply_result_t::reboot_required, config_t::remote_config, request_save_config(), app_ctx_t::rx_frame_buffer, TX_BUF_SIZE, app_ctx_t::tx_frame_buffer, app_ctx_t::tx_queue, tx_queue_enqueue_udp_frame(), event_t::type, app_ctx_t::v24_config, config_t::v24_config, and w5500_udp_tx().

Referenced by poll_and_dispatch_events().

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

◆ hdlc_sync_state_name()

static const char * hdlc_sync_state_name ( HDLC_SYNC_STATE_T  state)
static

Definition at line 103 of file event_dispatch.c.

References HDLC_SYNC_STATE_HUNTING, HDLC_SYNC_STATE_SYNCED, and HDLC_SYNC_STATE_SYNCING.

Referenced by print_status_event().

Here is the caller graph for this function:

◆ net_setting_id_name()

static const char * net_setting_id_name ( event_queue_data_types_t  event_id)
static

Definition at line 82 of file event_dispatch.c.

References NET_IP_GATEWAY, NET_IP_LOCAL, NET_IP_MASK, NET_IP_REMOTE, NET_PORT_LOCAL, and NET_PORT_REMOTE.

Referenced by print_net_settings_event().

Here is the caller graph for this function:

◆ print_net_settings_event()

static void print_net_settings_event ( const event_t event)
static

Definition at line 118 of file event_dispatch.c.

References event_get_payload_ptr(), event_queue_data_t::id, event_queue_data_t::ip, LOG_DEBUG, NET_IP_GATEWAY, NET_IP_LOCAL, NET_IP_MASK, NET_IP_REMOTE, NET_PORT_LOCAL, NET_PORT_REMOTE, net_setting_id_name(), event_queue_data_t::port, and event_queue_data_t::value.

Referenced by event_dispatch().

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

◆ print_status_event()

static void print_status_event ( app_ctx_t app,
ev_status_stats_t status_stats 
)
static

Definition at line 422 of file event_dispatch.c.

References app_ctx_t::accumulator, payload_statistics_t::accumulator_pos_max, baudrate_estimator_get_current_estimation(), HDLC_SYNC_ACCUMULATOR_T::bit_offset, HDLC_SYNC_ACCUMULATOR_T::candidate_end, HDLC_SYNC_ACCUMULATOR_T::candidate_valid, Ringbuffer::capacity, Ringbuffer::count, TX_QUEUE_T::current_entry, payload_statistics_t::decode_fail_crc_mismatch, payload_statistics_t::decode_fail_invalid_frame, payload_statistics_t::decode_fail_payload_too_long, ev_status_stats_t::decode_fail_rate, payload_statistics_t::decode_fail_too_short, payload_statistics_t::decode_fail_unstuff_error, payload_statistics_t::event_queue_drop_events, payload_statistics_t::event_queue_used_max, V24_CONFIG_T::external_clock, TX_QUEUE_ENTRY_T::frame, ev_status_stats_t::frame_gap, get_v24_runtime(), payload_statistics_t::hdlc_decode_fail, payload_statistics_t::hdlc_decode_ok, payload_statistics_t::hdlc_frame_ready, ev_status_stats_t::hdlc_rx_rate_fps, hdlc_sync_state_name(), payload_statistics_t::hdlc_tx_frames, payload_statistics_t::hunt_idle_drop_bytes, HDLC_FRAME_T::length, payload_statistics_t::log_drop_lines, LOG_PLAIN, payload_statistics_t::log_queue_used_max, TX_QUEUE_ENTRY_T::offset, HDLC_SYNC_ACCUMULATOR_T::position, PRIu32, PRIu64, HDLC_SYNC_ACCUMULATOR_T::processed, TX_QUEUE_T::queue_buffer, app_ctx_t::reconstructed_frame, payload_statistics_t::resync_hard_fail_count, payload_statistics_t::resync_idle_timeout_count, payload_statistics_t::resync_no_progress_count, payload_statistics_t::rx_fifo_stall_events, payload_statistics_t::serial_rx_bytes, payload_statistics_t::serial_rx_drop_acc_full, ev_status_stats_t::serial_rx_rate_bps, HDLC_SYNC_ACCUMULATOR_T::state, app_ctx_t::stats, payload_statistics_t::sync_candidate_consume, payload_statistics_t::sync_hardcap_drop_bytes, payload_statistics_t::sync_hardcap_drop_events, payload_statistics_t::sync_lookahead_wait_synced, payload_statistics_t::sync_lookahead_wait_syncing, ev_status_stats_t::tx_gap, v24_runtime_t::tx_pio, app_ctx_t::tx_queue, payload_statistics_t::tx_queue_drop_frames, payload_statistics_t::tx_queue_used_max, v24_runtime_t::tx_sm, TX_QUEUE_T::tx_wire_bytes, payload_statistics_t::udp_rx_buffer_full_counts, payload_statistics_t::udp_rx_frames, ev_status_stats_t::udp_rx_rate_fps, payload_statistics_t::udp_rx_throttle_enter, payload_statistics_t::udp_rx_throttle_skips, payload_statistics_t::udp_tx_buffer_full_counts, payload_statistics_t::udp_tx_frames, ev_status_stats_t::udp_tx_rate_fps, app_ctx_t::v24_config, v24_runtime, V24_RXC, and V24_TXC_DCE.

Referenced by event_dispatch().

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

◆ print_v24_polarities()

◆ request_save_config()

static void request_save_config ( void  )
static

Definition at line 156 of file event_dispatch.c.

References EV_SAVE_CONFIG, event_queue_push(), and event_t::type.

Referenced by event_dispatch().

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