|
ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "drivers/gpio_driver.h"#include "drivers/v24_config.h"#include "system/error.h"

Go to the source code of this file.
Data Structures | |
| struct | pin_info_t |
| Pin metadata entry used by CLI lookup and validation. More... | |
Functions | |
| size_t | get_num_pins (void) |
| Return number of entries in the CLI pin table. | |
| e2s_error_t | cli_parse (const char *line, char *cmd, size_t cmd_cap, char *args, size_t args_cap) |
| Split one CLI line into command and argument string. | |
| e2s_error_t | parse_get_args (const char *args, char *pin_name, const pin_info_t **pin) |
Parse get command arguments and resolve pin metadata. | |
| const pin_info_t * | find_pin (const char *name) |
| Lookup pin metadata by name. | |
| const pin_info_t * | get_pin_table (void) |
| Return pointer to static pin metadata table. | |
| e2s_error_t | parse_set_ip_args (const char *args, uint8_t ip_addr[4], uint8_t netmask[4]) |
| Parse ip_addr and optional netmask values. | |
| e2s_error_t | parse_set_gpio_args (const char *args, char *pin_name, int *value, const pin_info_t **pin) |
| Parse GPIO set command arguments. | |
| e2s_error_t | parse_set_net_ip_args (const char *args, uint8_t ip_addr[4], uint8_t netmask[4]) |
| Parse network local ip_addr/subnet arguments. | |
| e2s_error_t | parse_set_ip_remote_args (const char *args, uint8_t ip_addr[4]) |
| Parse remote ip_addr argument. | |
| e2s_error_t | parse_set_gateway_args (const char *args, uint8_t ip_addr[4]) |
| Parse gateway ip_addr argument. | |
| e2s_error_t | parse_set_udp_port_local_args (const char *args, uint16_t *port) |
| Parse local UDP port argument. | |
| e2s_error_t | parse_set_udp_port_remote_args (const char *args, uint16_t *port) |
| Parse remote UDP port argument. | |
| e2s_error_t | parse_set_v24_polarities (const char *args, V24_POLARITIES_T *polarities) |
| Parse V.24 polarities argument list. | |
| e2s_error_t | parse_set_v24_baudrate (const char *args, V24_BAUDRATE_T *baudrate) |
| Parse V.24 baudrate argument. | |
| e2s_error_t | parse_set_v24_clockmode (const char *args, bool *clockmode) |
| Parse V.24 tx clock mode argument. | |
| e2s_error_t cli_parse | ( | const char * | line, |
| char * | cmd, | ||
| size_t | cmd_cap, | ||
| char * | args, | ||
| size_t | args_cap | ||
| ) |
Split one CLI line into command and argument string.
| line | Input command line. |
| cmd | Output command token buffer. |
| cmd_cap | Command token buffer capacity. |
| args | Output argument string buffer. |
| args_cap | Args token buffer capacity. |
Definition at line 531 of file cli_parser.c.
References E2S_ERR_CLI_EMPTY_LINE, E2S_ERR_CLI_LINE_FORMAT, E2S_ERR_CLI_LINE_TRUNCATED, E2S_ERR_CLI_USAGE_SET, and E2S_OK.
Referenced by handle_cli_line().

| const pin_info_t * find_pin | ( | const char * | name | ) |
Lookup pin metadata by name.
| name | Pin name. |
NULL. Definition at line 503 of file cli_parser.c.
References NUM_PINS, and pin_table.
Referenced by cmd_pininfo(), parse_get_args(), parse_set_gpio_args(), and parse_set_v24_polarities().

| size_t get_num_pins | ( | void | ) |
Return number of entries in the CLI pin table.
Definition at line 44 of file cli_parser.c.
References NUM_PINS.
| const pin_info_t * get_pin_table | ( | void | ) |
Return pointer to static pin metadata table.
Definition at line 497 of file cli_parser.c.
References pin_table.
Referenced by cmd_help().

| e2s_error_t parse_get_args | ( | const char * | args, |
| char * | pin_name, | ||
| const pin_info_t ** | pin | ||
| ) |
Parse get command arguments and resolve pin metadata.
| args | Argument string. |
| pin_name | Output pin name. |
| pin | Resolved pin metadata entry. |
Definition at line 515 of file cli_parser.c.
References E2S_ERR_CLI_UNKNOWN_PIN, E2S_ERR_CLI_USAGE_GET, E2S_OK, and find_pin().
Referenced by cat_gpio_get().


| e2s_error_t parse_set_gateway_args | ( | const char * | args, |
| uint8_t | ip_addr[4] | ||
| ) |
Parse gateway ip_addr argument.
| args | Argument string. |
| ip_addr | Output ip_addrv4 address. |
Definition at line 297 of file cli_parser.c.
References parse_ipv4_with_optional_prefix().

| e2s_error_t parse_set_gpio_args | ( | const char * | args, |
| char * | pin_name, | ||
| int * | value, | ||
| const pin_info_t ** | pin | ||
| ) |
Parse GPIO set command arguments.
| args | Argument string. |
| pin_name | Output pin name. |
| value | Output pin value. |
| pin | Resolved pin metadata entry. |
Definition at line 231 of file cli_parser.c.
References E2S_ERR_CLI_PIN_INPUT_ONLY, E2S_ERR_CLI_UNKNOWN_PIN, E2S_ERR_CLI_USAGE_SET, E2S_OK, find_pin(), and parse_i32_strict().
Referenced by cat_gpio_set().


| e2s_error_t parse_set_ip_args | ( | const char * | args, |
| uint8_t | ip_addr[4], | ||
| uint8_t | netmask[4] | ||
| ) |
Parse ip_addr and optional netmask values.
| args | Argument string. |
| ip_addr | Output ip_addrv4 address. |
| netmask | Output subnet netmas. |
Definition at line 187 of file cli_parser.c.
References E2S_ERR_CLI_USAGE_SET, E2S_OK, parse_ipv4_strict(), parse_u32_strict(), and prefix_to_mask().
Referenced by parse_set_net_ip_args(), and subcmd_set_ip_local().


| e2s_error_t parse_set_ip_remote_args | ( | const char * | args, |
| uint8_t | ip_addr[4] | ||
| ) |
Parse remote ip_addr argument.
| args | Argument string. |
| ip_addr | Output ip_addrv4 address. |
Definition at line 292 of file cli_parser.c.
References parse_ipv4_with_optional_prefix().
Referenced by subcmd_set_ip_gateway(), and subcmd_set_ip_remote().


| e2s_error_t parse_set_net_ip_args | ( | const char * | args, |
| uint8_t | ip_addr[4], | ||
| uint8_t | netmask[4] | ||
| ) |
Parse network local ip_addr/subnet arguments.
| args | Argument string. |
| ip_addr | Output ip_addrv4 address. |
| netmask | Output subnet netmask. |
Definition at line 283 of file cli_parser.c.
References E2S_ERR_CLI_USAGE_SET, and parse_set_ip_args().

| e2s_error_t parse_set_udp_port_local_args | ( | const char * | args, |
| uint16_t * | port | ||
| ) |
Parse local UDP port argument.
| args | Argument string. |
| port | Output UDP port. |
Definition at line 302 of file cli_parser.c.
References parse_u16_with_optional_prefix().
Referenced by subcmd_set_udp_port_local().


| e2s_error_t parse_set_udp_port_remote_args | ( | const char * | args, |
| uint16_t * | port | ||
| ) |
Parse remote UDP port argument.
| args | Argument string. |
| port | Output UDP port. |
Definition at line 307 of file cli_parser.c.
References parse_u16_with_optional_prefix().
Referenced by subcmd_set_udp_port_remote().


| e2s_error_t parse_set_v24_baudrate | ( | const char * | args, |
| V24_BAUDRATE_T * | baudrate | ||
| ) |
Parse V.24 baudrate argument.
| args | Argument string. |
| baudrate | Output baudrate value. |
Definition at line 417 of file cli_parser.c.
References E2S_ERR_CLI_USAGE_SET, E2S_OK, parse_u32_strict(), V24_BAUD_115200, V24_BAUD_1200, V24_BAUD_16000, V24_BAUD_19200, V24_BAUD_2400, V24_BAUD_38400, V24_BAUD_4800, V24_BAUD_57600, and V24_BAUD_9600.
Referenced by subcmd_set_v24_baudrate().


| e2s_error_t parse_set_v24_clockmode | ( | const char * | args, |
| bool * | clockmode | ||
| ) |
Parse V.24 tx clock mode argument.
| args | Argument string. |
| clockmode | Output clock mode (0 internal, 1 external). |
Definition at line 462 of file cli_parser.c.
References E2S_ERR_CLI_USAGE_SET, E2S_OK, and parse_u32_strict().
Referenced by subcmd_set_v24_clockmode().


| e2s_error_t parse_set_v24_polarities | ( | const char * | args, |
| V24_POLARITIES_T * | polarities | ||
| ) |
Parse V.24 polarities argument list.
| args | Argument string. |
| polarities | Output polarity configuration. |
Definition at line 312 of file cli_parser.c.
References V24_TX_POLARITIES_T::cts_inverted, V24_RX_POLARITIES_T::dcd_inverted, V24_TX_POLARITIES_T::dtr_inverted, E2S_ERR_CLI_USAGE_SET, E2S_OK, find_pin(), V24_TX_POLARITIES_T::rts_inverted, V24_POLARITIES_T::rx_polarities, V24_RX_POLARITIES_T::rxc_inverted, V24_RX_POLARITIES_T::rxd_inverted, V24_POLARITIES_T::tx_polarities, V24_TX_POLARITIES_T::txc_inverted, and V24_TX_POLARITIES_T::txd_inverted.
Referenced by subcmd_set_v24_inverted().

