mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
feat(storage/esp_vfs_console): move console to new vfs API
This commit is contained in:
@ -38,10 +38,10 @@ typedef struct {
|
|||||||
|
|
||||||
// Secondary register part.
|
// Secondary register part.
|
||||||
#if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG
|
#if CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG
|
||||||
const static esp_vfs_t *secondary_vfs = NULL;
|
const static esp_vfs_fs_ops_t *secondary_vfs = NULL;
|
||||||
#endif // Secondary part
|
#endif // Secondary part
|
||||||
|
|
||||||
const static esp_vfs_t *primary_vfs = NULL;
|
const static esp_vfs_fs_ops_t *primary_vfs = NULL;
|
||||||
|
|
||||||
static vfs_console_context_t vfs_console = {0};
|
static vfs_console_context_t vfs_console = {0};
|
||||||
|
|
||||||
@ -122,8 +122,8 @@ static esp_err_t console_start_select(int nfds, fd_set *readfds, fd_set *writefd
|
|||||||
esp_vfs_select_sem_t select_sem, void **end_select_args)
|
esp_vfs_select_sem_t select_sem, void **end_select_args)
|
||||||
{
|
{
|
||||||
// start_select is not guaranteed be implemented even though CONFIG_VFS_SUPPORT_SELECT is enabled in sdkconfig
|
// start_select is not guaranteed be implemented even though CONFIG_VFS_SUPPORT_SELECT is enabled in sdkconfig
|
||||||
if (primary_vfs->start_select) {
|
if (primary_vfs->select->start_select) {
|
||||||
return primary_vfs->start_select(nfds, readfds, writefds, exceptfds, select_sem, end_select_args);
|
return primary_vfs->select->start_select(nfds, readfds, writefds, exceptfds, select_sem, end_select_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ESP_ERR_NOT_SUPPORTED;
|
return ESP_ERR_NOT_SUPPORTED;
|
||||||
@ -132,8 +132,8 @@ static esp_err_t console_start_select(int nfds, fd_set *readfds, fd_set *writefd
|
|||||||
esp_err_t console_end_select(void *end_select_args)
|
esp_err_t console_end_select(void *end_select_args)
|
||||||
{
|
{
|
||||||
// end_select is not guaranteed be implemented even though CONFIG_VFS_SUPPORT_SELECT is enabled in sdkconfig
|
// end_select is not guaranteed be implemented even though CONFIG_VFS_SUPPORT_SELECT is enabled in sdkconfig
|
||||||
if (primary_vfs->end_select) {
|
if (primary_vfs->select->end_select) {
|
||||||
return primary_vfs->end_select(end_select_args);
|
return primary_vfs->select->end_select(end_select_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ESP_ERR_NOT_SUPPORTED;
|
return ESP_ERR_NOT_SUPPORTED;
|
||||||
@ -164,8 +164,29 @@ int console_tcflush(int fd, int select)
|
|||||||
}
|
}
|
||||||
#endif // CONFIG_VFS_SUPPORT_TERMIOS
|
#endif // CONFIG_VFS_SUPPORT_TERMIOS
|
||||||
|
|
||||||
static const esp_vfs_t vfs = {
|
#ifdef CONFIG_VFS_SUPPORT_DIR
|
||||||
.flags = ESP_VFS_FLAG_DEFAULT,
|
static const esp_vfs_dir_ops_t s_vfs_console_dir = {
|
||||||
|
.access = &console_access,
|
||||||
|
};
|
||||||
|
#endif // CONFIG_VFS_SUPPORT_DIR
|
||||||
|
|
||||||
|
#ifdef CONFIG_VFS_SUPPORT_SELECT
|
||||||
|
static const esp_vfs_select_ops_t s_vfs_console_select = {
|
||||||
|
.start_select = &console_start_select,
|
||||||
|
.end_select = &console_end_select,
|
||||||
|
};
|
||||||
|
#endif // CONFIG_VFS_SUPPORT_SELECT
|
||||||
|
|
||||||
|
#ifdef CONFIG_VFS_SUPPORT_TERMIOS
|
||||||
|
static const esp_vfs_termios_ops_t s_vfs_console_termios = {
|
||||||
|
.tcsetattr = &console_tcsetattr,
|
||||||
|
.tcgetattr = &console_tcgetattr,
|
||||||
|
.tcdrain = &console_tcdrain,
|
||||||
|
.tcflush = &console_tcflush,
|
||||||
|
};
|
||||||
|
#endif // CONFIG_VFS_SUPPORT_TERMIOS
|
||||||
|
|
||||||
|
static const esp_vfs_fs_ops_t s_vfs_console = {
|
||||||
.write = &console_write,
|
.write = &console_write,
|
||||||
.open = &console_open,
|
.open = &console_open,
|
||||||
.fstat = &console_fstat,
|
.fstat = &console_fstat,
|
||||||
@ -173,24 +194,23 @@ static const esp_vfs_t vfs = {
|
|||||||
.read = &console_read,
|
.read = &console_read,
|
||||||
.fcntl = &console_fcntl,
|
.fcntl = &console_fcntl,
|
||||||
.fsync = &console_fsync,
|
.fsync = &console_fsync,
|
||||||
|
|
||||||
#ifdef CONFIG_VFS_SUPPORT_DIR
|
#ifdef CONFIG_VFS_SUPPORT_DIR
|
||||||
.access = &console_access,
|
.dir = &s_vfs_console_dir,
|
||||||
#endif // CONFIG_VFS_SUPPORT_DIR
|
#endif // CONFIG_VFS_SUPPORT_DIR
|
||||||
|
|
||||||
#ifdef CONFIG_VFS_SUPPORT_SELECT
|
#ifdef CONFIG_VFS_SUPPORT_SELECT
|
||||||
.start_select = &console_start_select,
|
.select = &s_vfs_console_select,
|
||||||
.end_select = &console_end_select,
|
|
||||||
#endif // CONFIG_VFS_SUPPORT_SELECT
|
#endif // CONFIG_VFS_SUPPORT_SELECT
|
||||||
|
|
||||||
#ifdef CONFIG_VFS_SUPPORT_TERMIOS
|
#ifdef CONFIG_VFS_SUPPORT_TERMIOS
|
||||||
.tcsetattr = &console_tcsetattr,
|
.termios = &s_vfs_console_termios,
|
||||||
.tcgetattr = &console_tcgetattr,
|
|
||||||
.tcdrain = &console_tcdrain,
|
|
||||||
.tcflush = &console_tcflush,
|
|
||||||
#endif // CONFIG_VFS_SUPPORT_TERMIOS
|
#endif // CONFIG_VFS_SUPPORT_TERMIOS
|
||||||
};
|
};
|
||||||
|
|
||||||
static esp_err_t esp_vfs_dev_console_register(void)
|
static esp_err_t esp_vfs_dev_console_register(void)
|
||||||
{
|
{
|
||||||
return esp_vfs_register(ESP_VFS_DEV_CONSOLE, &vfs, NULL);
|
return esp_vfs_register_fs(ESP_VFS_DEV_CONSOLE, &s_vfs_console, ESP_VFS_FLAG_STATIC, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_vfs_console_register(void)
|
esp_err_t esp_vfs_console_register(void)
|
||||||
|
Reference in New Issue
Block a user