[fix] deprecated functions warnings for logger component with ESP IDF version 5.3.0+ (#7600)

This commit is contained in:
Ramil Valitov 2024-10-16 06:25:47 +03:00 committed by GitHub
parent 3ef31e55ca
commit b274d6901a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,8 +10,12 @@
#ifdef USE_LOGGER_USB_SERIAL_JTAG
#include <driver/usb_serial_jtag.h>
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
#include <esp_vfs_dev.h>
#include <esp_vfs_usb_serial_jtag.h>
#else
#include <driver/usb_serial_jtag_vfs.h>
#endif
#endif
#include "freertos/FreeRTOS.h"
@ -36,10 +40,17 @@ static const char *const TAG = "logger";
static void init_usb_serial_jtag_() {
setvbuf(stdin, NULL, _IONBF, 0); // Disable buffering on stdin
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
// Minicom, screen, idf_monitor send CR when ENTER key is pressed
esp_vfs_dev_usb_serial_jtag_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
// Move the caret to the beginning of the next line on '\n'
esp_vfs_dev_usb_serial_jtag_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
#else
// Minicom, screen, idf_monitor send CR when ENTER key is pressed
usb_serial_jtag_vfs_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
// Move the caret to the beginning of the next line on '\n'
usb_serial_jtag_vfs_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
#endif
// Enable non-blocking mode on stdin and stdout
fcntl(fileno(stdout), F_SETFL, 0);
@ -57,7 +68,11 @@ static void init_usb_serial_jtag_() {
}
// Tell vfs to use usb-serial-jtag driver
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
esp_vfs_usb_serial_jtag_use_driver();
#else
usb_serial_jtag_vfs_use_driver();
#endif
}
#endif