Parses VT100 / ANSI escape sequences to interface with a terminal emulator.
#include <string.h>
#include "px_defs.h"
#include "px_board.h"
#include "px_uart.h"
#include "px_uart_stdio.h"
#include "px_pgm_P.h"
#include "px_cli.h"
static const char * px_cli_cmd_led_on_fn(uint8_t argc, char * argv[])
{
}
static const char * px_cli_cmd_led_off_fn(uint8_t argc, char * argv[])
{
}
static const char * px_cli_cmd_buzzer_fn(uint8_t argc, char * argv[])
{
uint16_t delay_ms;
{
}
else
{
return PX_PGM_STR("Error: <on time ms> must be from 0 to 1000 ms");
}
BUZZER_ON();
BUZZER_OFF();
}
PX_CLI_CMD_CREATE(px_cli_cmd_buzzer, "buzzer", 1, 1, "<on time ms>", "Switch buzzer on for specified number of milliseconds")
PX_CLI_CMD_CREATE(px_cli_cmd_help, "help", 0, 1, "[cmd(s) starts with...]", "Display list of commands with help. Optionally the list can be reduced.")
int main(void)
{
uint8_t data;
PX_UART_NR_0,
115200,
PX_UART_DATA_BITS_8,
PX_UART_PARITY_NONE,
PX_UART_STOP_BITS_1);
px_interrupts_enable();
px_cli_init(px_cli_cmd_list, PX_PGM_STR(
"CLI Example\n\n"));
while(true)
{
{
}
}
}
#define PX_LED_ON()
Enable LED (shared with SPI clock)
#define PX_LED_OFF()
Disable LED (shared with SPI clock)
void px_board_init(void)
Initialise the board hardware.
void px_board_delay_ms(uint16_t delay_ms)
Blocking delay for specified number of milliseconds.
void px_cli_init(const px_cli_cmd_list_item_t *cli_cmd_list, const char *startup_str)
Initialise command line module.
px_cli_argv_val_t px_cli_argv_val
Converted argument value using px_cli_util_argv_to_...() conversion function.
bool px_cli_util_argv_to_u16(uint8_t argv_index, uint16_t min, uint16_t max)
Utility function to convert an ARGV string to a number.
#define PX_CLI_CMD_LIST_END()
Macro to end a command list declaration.
#define PX_CLI_GROUP_CREATE(cli_group, name_str)
Macro to create a new CLI group.
#define PX_CLI_GROUP_END()
Macro to end a group list array.
#define PX_CLI_CMD_CREATE(cli_cmd, name_str, nr_arg_min, nr_arg_max, param_str, help_str)
Macro to create a new CLI command.
#define PX_CLI_CMD_ADD(cli_cmd, handler_fn)
Macro to add a created command to the list.
#define PX_CLI_CMD_LIST_CREATE(cli_cmd_list)
Macro to start a command list declaration.
void px_cli_on_rx_char(char data)
Function called to handle a received character.
#define PX_CLI_GROUP_ADD(cli_group)
Macro to add a created group to the list.
const char * px_cli_cmd_help_fn(uint8_t argc, char *argv[])
Handler function to call when "help" command is invoked.
#define NULL
NULL pointer.
void px_uart_stdio_init(px_uart_handle_t *handle)
Initialise stdio stream to use a UART driver.
bool px_uart_open2(px_uart_handle_t *handle, px_uart_nr_t uart_nr, uint32_t baud, px_uart_data_bits_t data_bits, px_uart_parity_t parity, px_uart_stop_bits_t stop_bits)
Open UART peripheral using specified parameters.
bool px_uart_rd_u8(px_uart_handle_t *handle, uint8_t *data)
See if a received byte is available and store it in the specified location.
void px_uart_init(void)
Initialise UART driver.
|
|
#define | PX_VT100_CURSOR_HOME "\x1B[H" |
| |
|
#define | PX_VT100_CURSOR_UP "\x1B[1A" |
| |
|
#define | PX_VT100_CURSOR_DOWN "\x1B[1B" |
| |
|
#define | PX_VT100_CURSOR_FORWARD "\x1B[1C" |
| |
|
#define | PX_VT100_CURSOR_BACKWARD "\x1B[1D" |
| |
|
#define | PX_VT100_SAVE_CURSOR "\x1B[s" |
| |
|
#define | PX_VT100_UNSAVE_CURSOR "\x1B[u" |
| |
|
#define | PX_VT100_SAVE_CURSOR_AND_ATTRS "\x1B7" |
| |
|
#define | PX_VT100_RESTORE_CURSOR_AND_ATTRS "\x1B8" |
| |
|
#define | PX_VT100_SCROLL_SCREEN "\x1B[r" |
| |
|
#define | PX_VT100_SCROLL_DOWN "\x1BD" |
| |
|
#define | PX_VT100_SCROLL_UP "\x1BM" |
| |
|
#define | PX_VT100_SET_TAB "\x1BH" |
| |
|
#define | PX_VT100_CLR_TAB "\x1B[g" |
| |
|
#define | PX_VT100_CLR_ALL_TABS "\x1B[3g" |
| |
|
#define | PX_VT100_ERASE_END_OF_LINE "\x1B[K" |
| |
|
#define | PX_VT100_ERASE_START_OF_LINE "\x1B[1K" |
| |
|
#define | PX_VT100_ERASE_LINE "\x1B[2K" |
| |
|
#define | PX_VT100_ERASE_DOWN "\x1B[J" |
| |
|
#define | PX_VT100_ERASE_UP "\x1B[1J" |
| |
|
#define | PX_VT100_ERASE_SCREEN "\x1B[2J" |
| |
|
#define | PX_VT100_ATTR_RST "\x1B[0m" |
| |
|
#define | PX_VT100_ATTR_BRIGHT "\x1B[1m" |
| |
|
#define | PX_VT100_ATTR_DIM "\x1B[2m" |
| |
|
#define | PX_VT100_ATTR_UNDERSCORE "\x1B[4m" |
| |
|
#define | PX_VT100_ATTR_BLINK "\x1B[5m" |
| |
|
#define | PX_VT100_ATTR_REVERSE "\x1B[7m" |
| |
|
#define | PX_VT100_ATTR_HIDDEN "\x1B[8m" |
| |
|
#define | PX_VT100_FG_BLACK "\x1B[30m" |
| |
|
#define | PX_VT100_FG_RED "\x1B[31m" |
| |
|
#define | PX_VT100_FG_GREEN "\x1B[32m" |
| |
|
#define | PX_VT100_FG_YELLOW "\x1B[33m" |
| |
|
#define | PX_VT100_FG_BLUE "\x1B[34m" |
| |
|
#define | PX_VT100_FG_MAGENTA "\x1B[35m" |
| |
|
#define | PX_VT100_FG_CYAN "\x1B[36m" |
| |
|
#define | PX_VT100_FG_WHITE "\x1B[37m" |
| |
|
#define | PX_VT100_BG_BLACK "\x1B[40m" |
| |
|
#define | PX_VT100_BG_RED "\x1B[41m" |
| |
|
#define | PX_VT100_BG_GREEN "\x1B[42m" |
| |
|
#define | PX_VT100_BG_YELLOW "\x1B[43m" |
| |
|
#define | PX_VT100_BG_BLUE "\x1B[44m" |
| |
|
#define | PX_VT100_BG_MAGENTA "\x1B[45m" |
| |
|
#define | PX_VT100_BG_CYAN "\x1B[46m" |
| |
|
#define | PX_VT100_BG_WHITE "\x1B[47m" |
| |