Improve watchdog monitoring and CLI
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include "usb_cdc_log.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "esp_check.h"
|
||||
@@ -13,28 +12,6 @@ static const char *TAG = "usb_log";
|
||||
static bool s_initialized;
|
||||
static bool s_host_ready;
|
||||
|
||||
static int usb_cdc_vprintf(const char *fmt, va_list args)
|
||||
{
|
||||
if (s_host_ready) {
|
||||
char buffer[256];
|
||||
va_list args_copy;
|
||||
va_copy(args_copy, args);
|
||||
int len = vsnprintf(buffer, sizeof(buffer), fmt, args_copy);
|
||||
va_end(args_copy);
|
||||
if (len > 0) {
|
||||
if (len >= (int)sizeof(buffer)) {
|
||||
len = sizeof(buffer) - 1;
|
||||
}
|
||||
if (tinyusb_cdcacm_write_queue(TINYUSB_CDC_ACM_0, (const uint8_t *)buffer, len) == ESP_OK) {
|
||||
tinyusb_cdcacm_write_flush(TINYUSB_CDC_ACM_0, 0);
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void usb_cdc_line_state_changed_callback(int itf, cdcacm_event_t *event)
|
||||
{
|
||||
(void)itf;
|
||||
@@ -83,8 +60,7 @@ esp_err_t usb_cdc_log_init(void)
|
||||
};
|
||||
ESP_RETURN_ON_ERROR(tusb_cdc_acm_init(&acm_cfg), TAG, "CDC init failed");
|
||||
|
||||
esp_log_set_vprintf(usb_cdc_vprintf);
|
||||
s_initialized = true;
|
||||
ESP_LOGI(TAG, "ESP_LOG перенаправлено в USB CDC");
|
||||
ESP_LOGI(TAG, "USB CDC лог ініціалізовано (перенаправлення ESP_LOG вимкнено)");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user