[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 #ifdef USE_LOGGER_USB_SERIAL_JTAG
#include <driver/usb_serial_jtag.h> #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_dev.h>
#include <esp_vfs_usb_serial_jtag.h> #include <esp_vfs_usb_serial_jtag.h>
#else
#include <driver/usb_serial_jtag_vfs.h>
#endif
#endif #endif
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
@ -36,10 +40,17 @@ static const char *const TAG = "logger";
static void init_usb_serial_jtag_() { static void init_usb_serial_jtag_() {
setvbuf(stdin, NULL, _IONBF, 0); // Disable buffering on stdin 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 // 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); 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' // 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); 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 // Enable non-blocking mode on stdin and stdout
fcntl(fileno(stdout), F_SETFL, 0); fcntl(fileno(stdout), F_SETFL, 0);
@ -57,7 +68,11 @@ static void init_usb_serial_jtag_() {
} }
// Tell vfs to use usb-serial-jtag driver // 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(); esp_vfs_usb_serial_jtag_use_driver();
#else
usb_serial_jtag_vfs_use_driver();
#endif
} }
#endif #endif