mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
feat(esp_stdio): Revert breaking change
- also revert the modification in the singature of uninstall function in all the concerned esp_driver* components and esp_stdio. - added proper documentation of the feature in the programming guide
This commit is contained in:
@@ -14,6 +14,18 @@ extern "C" {
|
||||
|
||||
#define ESP_VFS_DEV_CONSOLE "/dev/console"
|
||||
|
||||
/**
|
||||
* @brief Register the default console VFS backend(s) selected in Kconfig.
|
||||
*
|
||||
* Sets up the primary (and any Kconfig-selected secondary) console sink and
|
||||
* mounts them under /dev/console. This function is automatically called from
|
||||
* startup code to enable serial output; applications normally do not need to
|
||||
* call it themselves.
|
||||
*
|
||||
* @return ESP_OK on success, or an error code from the underlying VFS registration.
|
||||
*/
|
||||
esp_err_t esp_stdio_register(void);
|
||||
|
||||
#if CONFIG_VFS_SUPPORT_IO
|
||||
|
||||
#include "esp_vfs_common.h"
|
||||
@@ -134,7 +146,7 @@ esp_err_t esp_stdio_install_io_driver(void);
|
||||
* If a user has taken over the primary console with esp_stdio_push_primary(),
|
||||
* this function is a no-op.
|
||||
*/
|
||||
esp_err_t esp_stdio_uninstall_io_driver(void);
|
||||
void esp_stdio_uninstall_io_driver(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -21,10 +21,9 @@ static void disable_raw_mode(void)
|
||||
assert(tcsetattr(STDIN_FILENO, TCSAFLUSH, &s_orig_termios) == 0);
|
||||
}
|
||||
|
||||
esp_err_t linux_vfs_dev_port_deinit(linux_port_config_t *config)
|
||||
void linux_vfs_dev_port_deinit(linux_port_config_t *config)
|
||||
{
|
||||
(void)config;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t linux_vfs_dev_port_init(linux_port_config_t *config)
|
||||
|
||||
@@ -43,9 +43,8 @@ esp_err_t linux_vfs_dev_port_init(linux_port_config_t *config);
|
||||
* switching to another console interface.
|
||||
*
|
||||
* @param config Pointer to the Linux console port configuration.
|
||||
* @return ESP_OK if the driver was successfully uninstalled, or an error otherwise.
|
||||
*/
|
||||
esp_err_t linux_vfs_dev_port_deinit(linux_port_config_t *config);
|
||||
void linux_vfs_dev_port_deinit(linux_port_config_t *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -73,30 +73,28 @@ esp_err_t esp_stdio_install_io_driver(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_stdio_uninstall_io_driver(void)
|
||||
void esp_stdio_uninstall_io_driver(void)
|
||||
{
|
||||
#if CONFIG_VFS_SUPPORT_IO
|
||||
/* If a user primary is registered, deinit is the caller's responsibility. */
|
||||
if (esp_stdio_has_user_primary()) {
|
||||
return ESP_OK;
|
||||
return;
|
||||
}
|
||||
#endif // CONFIG_VFS_SUPPORT_IO
|
||||
|
||||
esp_err_t ret = ESP_FAIL;
|
||||
#if CONFIG_IDF_TARGET_LINUX
|
||||
linux_port_config_t config = ESP_CONSOLE_DEV_LINUX_CONFIG_DEFAULT();
|
||||
ret = linux_vfs_dev_port_deinit(&config);
|
||||
linux_vfs_dev_port_deinit(&config);
|
||||
#elif CONFIG_VFS_SUPPORT_IO
|
||||
#if CONFIG_ESP_CONSOLE_UART
|
||||
esp_console_dev_uart_config_t config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT();
|
||||
ret = uart_vfs_dev_port_deinit(&config);
|
||||
uart_vfs_dev_port_deinit(&config);
|
||||
#elif CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG
|
||||
esp_console_dev_usb_serial_jtag_config_t config = ESP_CONSOLE_DEV_USB_SERIAL_JTAG_CONFIG_DEFAULT();
|
||||
ret = usb_serial_jtag_vfs_dev_port_deinit(&config);
|
||||
usb_serial_jtag_vfs_dev_port_deinit(&config);
|
||||
#elif CONFIG_ESP_CONSOLE_USB_CDC
|
||||
esp_console_dev_usb_cdc_config_t config = ESP_CONSOLE_DEV_CDC_CONFIG_DEFAULT();
|
||||
ret = cdcacm_vfs_dev_port_deinit(&config);
|
||||
cdcacm_vfs_dev_port_deinit(&config);
|
||||
#endif
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ static const esp_vfs_fs_ops_t s_vfs_console = {
|
||||
#endif
|
||||
};
|
||||
|
||||
static esp_err_t esp_stdio_register(void)
|
||||
esp_err_t esp_stdio_register(void)
|
||||
{
|
||||
_lock_init(&s_lock);
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ TEST_CASE("install/uninstall are no-ops with user primary", "[esp_stdio]")
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_stdio_push_primary(h));
|
||||
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_stdio_install_io_driver());
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_stdio_uninstall_io_driver());
|
||||
esp_stdio_uninstall_io_driver();
|
||||
TEST_ASSERT_EQUAL(0, mock_a.open_count); /* driver not initialised by install */
|
||||
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_stdio_pop_primary(NULL));
|
||||
|
||||
Reference in New Issue
Block a user