Files
Guillaume Souchere 5fac0b7386 feat(console): Move IO initialization outside of the console component
- Move the linux repl chip and deprecate chip related functions
- Update location of driver specific default config
- Add missing comments on the newly added functions in the affected components.
2026-03-17 08:30:23 +01:00

68 lines
2.1 KiB
C

/*
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stddef.h>
#include <stdint.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp_console.h"
#define CONSOLE_PROMPT_MAX_LEN (32)
#if CONFIG_IDF_TARGET_LINUX
#define CONSOLE_PATH_MAX_LEN (128)
#else
#include "esp_vfs_dev.h"
#define CONSOLE_PATH_MAX_LEN (ESP_VFS_PATH_MAX)
#endif
typedef enum {
CONSOLE_REPL_STATE_DEINIT,
CONSOLE_REPL_STATE_INIT,
CONSOLE_REPL_STATE_START,
} repl_state_t;
typedef struct {
esp_console_repl_t repl_core; // base class
#if CONFIG_LIBC_PICOLIBC
FILE *_stdin;
FILE *_stdout;
#endif
char prompt[CONSOLE_PROMPT_MAX_LEN]; // Prompt to be printed before each line
repl_state_t state;
SemaphoreHandle_t state_mux;
const char *history_save_path;
TaskHandle_t task_hdl; // REPL task handle
size_t max_cmdline_length; // Maximum length of a command line. If 0, default value will be used.
} esp_console_repl_com_t;
typedef struct {
esp_console_repl_com_t repl_com; // base class
void *dev_config;
} esp_console_repl_universal_t;
_Static_assert(offsetof(esp_console_repl_com_t, repl_core) == 0,
"repl_core must be the first member of esp_console_repl_com_t");
_Static_assert(offsetof(esp_console_repl_universal_t, repl_com) == 0,
"repl_com must be the first member of esp_console_repl_universal_t");
void esp_console_repl_task(void *args);
esp_err_t esp_console_common_init(size_t max_cmdline_length, esp_console_repl_com_t *repl_com);
esp_err_t esp_console_common_deinit(esp_console_repl_com_t *repl_com);
esp_err_t esp_console_internal_set_event_fd(esp_console_repl_com_t *repl_com);
esp_err_t esp_console_setup_prompt(const char *prompt, esp_console_repl_com_t *repl_com);
esp_err_t esp_console_setup_history(const char *history_path,
uint32_t max_history_len,
esp_console_repl_com_t *repl_com);
void esp_console_setup_standard_stream(void *dev_config);