Chapter 2. API Reference
Non-socket VFS drivers
driver then you need to register the driver with functions start_select() and end_select() similarly to
the following example:
// In definition of esp_vfs_t:
.start_select
=
.end_select
=
&uart_end_select,
// ... other members initialized
start_select() is called for setting up the environment for detection of read/write/error conditions on file
descriptors belonging to the given VFS driver.
end_select() is called to stop/deinitialize/free the environment which was setup by start_select().
Note: end_select() might be called without a previous start_select() call in some rare circumstances.
end_select() should fail gracefully if this is the case.
Please refer to the reference implementation for the UART peripheral in
functions esp_vfs_dev_uart_register(), uart_start_select(), and uart_end_select()
for more information.
Please check the following examples that demonstrate the use of select() with VFS file descriptors:
•
peripherals/uart/uart_select
•
system/select
Socket VFS drivers
A socket VFS driver is using its own internal implementation of select() and non-socket
VFS drivers notify it upon read/write/error conditions.
A socket VFS driver needs to be registered with the following functions defined:
// In definition of esp_vfs_t:
.socket_select
=
.get_socket_select_semaphore
.stop_socket_select
.stop_socket_select_isr
// ... other members initialized
socket_select() is the internal implementation of select() for the socket driver. It works only with file
descriptors belonging to the socket VFS.
get_socket_select_semaphore() returns the signalization object (semaphore) which will be used in non-
socket drivers to stop the waiting in socket_select().
stop_socket_select() call is used to stop the waiting in socket_select() by passing the object returned
by get_socket_select_semaphore().
stop_socket_select_isr() has the same functionality as stop_socket_select() but it can be used
from ISR.
Please see
lwip/port/esp32/vfs_lwip.c
Note:
If you use select() for socket file descriptors only then you can enable the CON-
FIG_LWIP_USE_ONLY_LWIP_SELECT option to reduce the code size and improve performance.
Note: Don't change the socket driver during an active select() call or you might experience some undefined
behavior.
Espressif Systems
If you want to use select() with a file descriptor belonging to a non-socket VFS
&uart_start_select,
&lwip_select,
=
&lwip_get_socket_select_semaphore,
=
&lwip_stop_socket_select,
=
&lwip_stop_socket_select_isr,
for a reference socket driver implementation using LWIP.
Submit Document Feedback
vfs/vfs_uart.c
770
and most particularly to the
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?