|
ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
|
#include "cli_commands.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <stdio.h>#include <string.h>#include "hardware/gpio.h"#include "hardware/structs/io_bank0.h"#include "hardware/watchdog.h"#include "wizchip_conf.h"#include "wizchip_qspi_pio.h"#include "drivers/v24_config.h"#include "platform/watchdog.h"#include "system/cli_parser.h"#include "system/common.h"#include "system/error.h"#include "system/event_queue.h"
Go to the source code of this file.
Data Structures | |
| struct | command_t |
| struct | category_t |
| struct | subcmd_t |
| struct | loglevel_entry_t |
Macros | |
| #define | MAX_CMD_BUFFER_LEN 16 |
| #define | MAX_PIN_NAME_LEN 16 |
| #define | MAX_ARG_BUFFER_LEN 64 |
| #define | INVERT_HELP "Invert pins (comma-separated, e.g. set v24 invert txd,rxd)" |
| #define | NUM_COMMANDS (sizeof(commands) / sizeof(commands[0])) |
| #define | NUM_CATEGORIES ARRAY_LEN(categories) |
| #define | NUM_NET_SUBCMDS ARRAY_LEN(net_subcmds) |
| #define | NUM_V24_SUBCMDS ARRAY_LEN(v24_subcmds) |
| #define | NUM_PINS get_num_pins() |
| #define | NUM_V24_BAUDRATES ARRAY_LEN(v24_baudrates) |
| #define | NUM_LOGLEVELS ARRAY_LEN(loglevels) |
Typedefs | |
| typedef void(* | cmd_handler_t) (const char *args) |
| typedef void(* | category_set_handler_t) (const char *args) |
| typedef void(* | category_get_handler_t) (const char *args) |
| typedef void(* | subcmd_set_handler_t) (const char *args) |
| typedef void(* | subcmd_get_handler_t) (const char *args) |
Functions | |
| static void | cmd_help (const char *args) |
| static void | cmd_status (const char *args) |
| static void | cmd_mem (const char *args) |
| static void | cmd_net (const char *args) |
| static void | cmd_set (const char *args) |
| static void | cmd_get (const char *args) |
| static void | cmd_pininfo (const char *args) |
| static void | cmd_save (const char *args) |
| static void | cmd_wipe (const char *args) |
| static void | cmd_reboot (const char *args) |
| static void | cat_gpio_set (const char *args) |
| static void | cat_gpio_get (const char *args) |
| static void | cat_net_set (const char *args) |
| static void | cat_net_get (const char *args) |
| static void | cat_v24_set (const char *args) |
| static void | cat_v24_get (const char *args) |
| static void | cat_loglevel_set (const char *args) |
| static void | cat_loglevel_get (const char *args) |
| static void | subcmd_set_ip_local (const char *args) |
| static void | subcmd_get_ip_local (const char *args) |
| static void | subcmd_set_ip_remote (const char *args) |
| static void | subcmd_get_ip_remote (const char *args) |
| static void | subcmd_set_ip_gateway (const char *args) |
| static void | subcmd_get_ip_gateway (const char *args) |
| static void | subcmd_set_udp_port_local (const char *args) |
| static void | subcmd_get_udp_port_local (const char *args) |
| static void | subcmd_set_udp_port_remote (const char *args) |
| static void | subcmd_get_udp_port_remote (const char *args) |
| static void | subcmd_set_v24_baudrate (const char *args) |
| static void | subcmd_get_v24_baudrate (const char *args) |
| static void | subcmd_set_v24_inverted (const char *args) |
| static void | subcmd_get_v24_inverted (const char *args) |
| static void | subcmd_set_v24_clockmode (const char *args) |
| static void | subcmd_get_v24_clockmode (const char *args) |
| static void | dispatch_v24_polarities (const V24_POLARITIES_T *polarities) |
| static void | dispatch_get_request (event_queue_data_types_t type, event_type_t event_type) |
| static void | dispatch_v24_baudrate (const V24_BAUDRATE_T *baudrate) |
| static void | dispatch_ip (const uint8_t *ip_addr, const event_queue_data_types_t type) |
| static void | dispatch_get_udp_port (const event_queue_data_types_t type) |
| static void | dispatch_set_udp_port (const event_queue_data_types_t type, uint16_t port) |
| const char * | get_command_name (int index) |
| Return command name by table index. | |
| void | handle_cli_line (const char *line) |
| Parse and execute one CLI input line. | |
Variables | |
| static const command_t | commands [] |
| static const category_t | categories [] |
| static const subcmd_t | net_subcmds [] |
| static const subcmd_t | v24_subcmds [] |
| static const V24_BAUDRATE_T | v24_baudrates [] |
| static const loglevel_entry_t | loglevels [] |
| #define INVERT_HELP "Invert pins (comma-separated, e.g. set v24 invert txd,rxd)" |
Definition at line 137 of file cli_commands.c.
| #define MAX_ARG_BUFFER_LEN 64 |
Definition at line 40 of file cli_commands.c.
| #define MAX_CMD_BUFFER_LEN 16 |
Definition at line 38 of file cli_commands.c.
| #define MAX_PIN_NAME_LEN 16 |
Definition at line 39 of file cli_commands.c.
| #define NUM_CATEGORIES ARRAY_LEN(categories) |
Definition at line 145 of file cli_commands.c.
Definition at line 144 of file cli_commands.c.
Definition at line 166 of file cli_commands.c.
| #define NUM_NET_SUBCMDS ARRAY_LEN(net_subcmds) |
Definition at line 146 of file cli_commands.c.
| #define NUM_PINS get_num_pins() |
Definition at line 148 of file cli_commands.c.
| #define NUM_V24_BAUDRATES ARRAY_LEN(v24_baudrates) |
Definition at line 154 of file cli_commands.c.
| #define NUM_V24_SUBCMDS ARRAY_LEN(v24_subcmds) |
Definition at line 147 of file cli_commands.c.
| typedef void(* category_get_handler_t) (const char *args) |
Definition at line 53 of file cli_commands.c.
| typedef void(* category_set_handler_t) (const char *args) |
Definition at line 52 of file cli_commands.c.
| typedef void(* cmd_handler_t) (const char *args) |
Definition at line 43 of file cli_commands.c.
| typedef void(* subcmd_get_handler_t) (const char *args) |
Definition at line 64 of file cli_commands.c.
| typedef void(* subcmd_set_handler_t) (const char *args) |
Definition at line 63 of file cli_commands.c.
|
static |
Definition at line 603 of file cli_commands.c.
References E2S_ERR_CLI_UNKNOWN_PIN, E2S_ERR_CLI_USAGE_GET, E2S_OK, pin_info_t::gpio_num, LOG_PLAIN, MAX_PIN_NAME_LEN, and parse_get_args().

|
static |
Definition at line 540 of file cli_commands.c.
References E2S_ERR_CLI_PIN_INPUT_ONLY, E2S_ERR_CLI_UNKNOWN_PIN, E2S_ERR_CLI_USAGE_SET, E2S_OK, pin_info_t::gpio_num, LOG_PLAIN, MAX_PIN_NAME_LEN, and parse_set_gpio_args().

|
static |
Definition at line 347 of file cli_commands.c.
References get_loglevel(), log_level_tag(), and LOG_PLAIN.

|
static |
Definition at line 318 of file cli_commands.c.
References get_loglevel(), log_level_tag(), LOG_PLAIN, loglevels, NUM_LOGLEVELS, and set_loglevel().

|
static |
Definition at line 514 of file cli_commands.c.
References subcmd_t::get_handler, LOG_DEBUG, LOG_PLAIN, net_subcmds, and NUM_NET_SUBCMDS.
|
static |
Definition at line 578 of file cli_commands.c.
References LOG_PLAIN, net_subcmds, NUM_NET_SUBCMDS, and subcmd_t::set_handler.
|
static |
Definition at line 292 of file cli_commands.c.
References subcmd_t::get_handler, LOG_DEBUG, LOG_PLAIN, NUM_V24_SUBCMDS, and v24_subcmds.
|
static |
Definition at line 266 of file cli_commands.c.
References LOG_DEBUG, LOG_PLAIN, NUM_V24_SUBCMDS, subcmd_t::set_handler, and v24_subcmds.
|
static |
Definition at line 673 of file cli_commands.c.
References categories, category_t::get_handler, LOG_PLAIN, and NUM_CATEGORIES.
|
static |
Definition at line 715 of file cli_commands.c.
References categories, commands, get_pin_table(), LOG_PLAIN, net_subcmds, NUM_CATEGORIES, NUM_COMMANDS, NUM_NET_SUBCMDS, NUM_PINS, NUM_V24_BAUDRATES, NUM_V24_SUBCMDS, pin_table, v24_baudrates, and v24_subcmds.

|
static |
Definition at line 783 of file cli_commands.c.
References EV_MEM, event_queue_push(), LOG_PLAIN, and event_t::type.

|
static |
Definition at line 794 of file cli_commands.c.
References LOG_PLAIN.
|
static |
Definition at line 807 of file cli_commands.c.
References find_pin(), pin_info_t::gpio_num, LOG_PLAIN, and MAX_PIN_NAME_LEN.

|
static |
Definition at line 357 of file cli_commands.c.
References EV_REBOOT, event_queue_push(), and event_t::type.

|
static |
Definition at line 706 of file cli_commands.c.
References EV_SAVE_CONFIG, event_queue_push(), and event_t::type.

|
static |
Definition at line 649 of file cli_commands.c.
References categories, LOG_PLAIN, NUM_CATEGORIES, and category_t::set_handler.
|
static |
Definition at line 776 of file cli_commands.c.
References EV_STATUS, event_queue_push(), and event_t::type.

|
static |
Definition at line 698 of file cli_commands.c.
References EV_WIPE_CONFIG, event_queue_push(), and event_t::type.

|
static |
Definition at line 182 of file cli_commands.c.
References event_queue_push(), event_queue_data_t::id, and event_t::type.
Referenced by subcmd_get_ip_gateway(), subcmd_get_ip_local(), subcmd_get_ip_remote(), subcmd_get_v24_baudrate(), subcmd_get_v24_clockmode(), and subcmd_get_v24_inverted().


|
static |
Definition at line 445 of file cli_commands.c.
References EV_GET_NET_SETTINGS, event_queue_push(), event_queue_data_t::id, and event_t::type.
Referenced by subcmd_get_udp_port_local(), and subcmd_get_udp_port_remote().


|
static |
Definition at line 366 of file cli_commands.c.
References event_t::bytes, event_t::data, EV_SET_NET_SETTINGS, event_queue_push(), event_queue_data_t::id, event_queue_data_t::ip, event_t::type, and event_queue_data_t::value.
Referenced by subcmd_set_ip_gateway(), subcmd_set_ip_local(), and subcmd_set_ip_remote().


|
static |
Definition at line 458 of file cli_commands.c.
References EV_SET_NET_SETTINGS, event_queue_push(), event_queue_data_t::id, and event_t::type.
Referenced by subcmd_set_udp_port_local(), and subcmd_set_udp_port_remote().


|
static |
Definition at line 211 of file cli_commands.c.
References event_queue_data_t::baudrate, EV_SET_V24_SETTINGS, event_queue_push(), event_queue_data_t::id, event_t::type, V24_BAUDRATE, and event_queue_data_t::value.
Referenced by subcmd_set_v24_baudrate().


|
static |
Definition at line 168 of file cli_commands.c.
References EV_SET_V24_SETTINGS, event_queue_push(), event_queue_data_t::id, event_queue_data_t::polarities, event_t::type, V24_POLARITIES, and event_queue_data_t::value.
Referenced by subcmd_set_v24_inverted().


| const char * get_command_name | ( | int | index | ) |
Return command name by table index.
| index | Command table index. |
NULL when out of range. Definition at line 834 of file cli_commands.c.
References commands, and command_t::name.
| void handle_cli_line | ( | const char * | line | ) |
Parse and execute one CLI input line.
Process one CLI line.
| line | Null-terminated command line. |
Definition at line 839 of file cli_commands.c.
References cli_parse(), commands, E2S_ERR_CLI_EMPTY_LINE, E2S_ERR_CLI_LINE_TRUNCATED, E2S_OK, command_t::handler, LOG_PLAIN, MAX_ARG_BUFFER_LEN, MAX_CMD_BUFFER_LEN, and NUM_COMMANDS.
Referenced by event_dispatch().


|
static |
Definition at line 424 of file cli_commands.c.
References dispatch_get_request(), EV_GET_NET_SETTINGS, LOG_PLAIN, and NET_IP_GATEWAY.

|
static |
Definition at line 380 of file cli_commands.c.
References dispatch_get_request(), EV_GET_NET_SETTINGS, LOG_PLAIN, and NET_IP_LOCAL.

|
static |
Definition at line 403 of file cli_commands.c.
References dispatch_get_request(), EV_GET_NET_SETTINGS, LOG_PLAIN, and NET_IP_REMOTE.

|
static |
Definition at line 471 of file cli_commands.c.
References dispatch_get_udp_port(), LOG_PLAIN, and NET_PORT_LOCAL.

|
static |
Definition at line 492 of file cli_commands.c.
References dispatch_get_udp_port(), LOG_PLAIN, and NET_PORT_REMOTE.

|
static |
Definition at line 260 of file cli_commands.c.
References dispatch_get_request(), EV_GET_V24_SETTINGS, and V24_BAUDRATE.

|
static |
Definition at line 254 of file cli_commands.c.
References dispatch_get_request(), EV_GET_V24_SETTINGS, and V24_CLOCK_MODE.

|
static |
Definition at line 205 of file cli_commands.c.
References dispatch_get_request(), EV_GET_V24_SETTINGS, and V24_POLARITIES.

|
static |
Definition at line 434 of file cli_commands.c.
References dispatch_ip(), E2S_OK, LOG_PLAIN, NET_IP_GATEWAY, and parse_set_ip_remote_args().

|
static |
Definition at line 390 of file cli_commands.c.
References dispatch_ip(), E2S_OK, LOG_PLAIN, NET_IP_LOCAL, NET_IP_MASK, and parse_set_ip_args().

|
static |
Definition at line 413 of file cli_commands.c.
References dispatch_ip(), E2S_OK, LOG_PLAIN, NET_IP_REMOTE, and parse_set_ip_remote_args().

|
static |
Definition at line 481 of file cli_commands.c.
References dispatch_set_udp_port(), E2S_OK, LOG_PLAIN, NET_PORT_LOCAL, and parse_set_udp_port_local_args().

|
static |
Definition at line 503 of file cli_commands.c.
References dispatch_set_udp_port(), E2S_OK, LOG_PLAIN, NET_PORT_REMOTE, and parse_set_udp_port_remote_args().

|
static |
Definition at line 244 of file cli_commands.c.
References dispatch_v24_baudrate(), E2S_OK, LOG_PLAIN, and parse_set_v24_baudrate().

|
static |
Definition at line 224 of file cli_commands.c.
References E2S_OK, EV_SET_V24_SETTINGS, event_queue_push(), event_queue_data_t::id, LOG_PLAIN, parse_set_v24_clockmode(), event_t::type, V24_CLOCK_MODE, event_queue_data_t::v24_clock_mode, and event_queue_data_t::value.

|
static |
Definition at line 194 of file cli_commands.c.
References dispatch_v24_polarities(), E2S_OK, LOG_PLAIN, and parse_set_v24_polarities().

|
static |
Definition at line 124 of file cli_commands.c.
Referenced by cmd_get(), cmd_help(), and cmd_set().
|
static |
Definition at line 111 of file cli_commands.c.
Referenced by cmd_help(), get_command_name(), and handle_cli_line().
|
static |
Definition at line 162 of file cli_commands.c.
Referenced by cat_loglevel_set().
|
static |
Definition at line 130 of file cli_commands.c.
Referenced by cat_net_get(), cat_net_set(), and cmd_help().
|
static |
|
static |
Definition at line 138 of file cli_commands.c.
Referenced by cat_v24_get(), cat_v24_set(), and cmd_help().