uart vfs not working in 5.4
Posted: Tue Apr 22, 2025 7:25 am
I have recently installed 5.4.1 espidf version, previously on 5.3.1. I have noticed that the uart vfs is not working as intended.
The build was successfull, but i noticed that when reading the uart device file, there are missing bytes.
example:
if the message received "hello world\n"
vfs would contain "hel" (not consistent)
reverting this back to 5.3.1 eliminates this issue.
The build was successfull, but i noticed that when reading the uart device file, there are missing bytes.
example:
if the message received "hello world\n"
vfs would contain "hel" (not consistent)
reverting this back to 5.3.1 eliminates this issue.
Code: Select all
[/code
int uart_init(struct uart_config_t *uart)
{
int ret_val = 0;
esp_err_t ret = ESP_OK;
/* Configure parameters of an UART driver,
* communication pins and install the driver */
uart_config_t uart_config = {
.baud_rate = uart->baudrate,
.data_bits = UART_DATA_8_BITS,
.parity = uart->parity,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_APB,
};
ESP_LOGW(TAG, "REGISTER NORMAL UART PORT: %d", uart->uart_port);
/* Install UART driver without interrupt enabled */
if (!uart_is_driver_installed(uart->uart_port))
{
ret = uart_driver_install(uart->uart_port, BUFFER_SIZE * 2, 0, 0, NULL, 0);
}
if (ret != ESP_OK)
{
ret_val = -UART_DRIVER_INSTAL_FAIL;
ESP_LOGE(TAG, "UART DRIVER INSTALL FAILED %d", ret_val);
return ret_val;
}
uart_param_config(uart->uart_port, &uart_config);
if (ret != ESP_OK)
{
ret_val = -UART_PARAM_CONFIG_FAIL;
ESP_LOGE(TAG, "UART PARAMETER CONFIGURATION FAILED %d", ret_val);
return ret_val;
}
// Set UART pins (using UART0 default pins ie no changes.)
uart_set_pin(uart->uart_port, uart->tx_pin, uart->rx_pin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
/* Using Virtual File System */
uart_vfs_dev_use_driver(uart->uart_port);
uart_vfs_dev_port_set_rx_line_endings(uart->uart_port, ESP_LINE_ENDINGS_LF);
return ret_val;
}
void get_uart_vfs_buffer(struct uart_config_t *uart, char *buf, int len)
{
FILE *uart_file;
uart_file = fopen(uart->vfs_name, "r");
fgets(buf, len, uart_file);
fclose(uart_file);
}
void somethread(){
...
while(1){
get_uart_vfs_buffer(&uart_struct, buf, ESTIMATED_SIZE);
}
}
]