I need to detect whether my ESP32-S3 is connected to a host computer running a terminal program before I start a console on the ESP32. When the ESP32 resets, it may not be connected to anything, it may be connected to a USB cable for charging or there may be a host computer that wants to talk to it. If I just start the console it blocks until a terminal is connected (no good!). I saw on github that @chipweinberger was looking to do something similar, but I don't see that it was resolved.
Does anyone have an idea of a simple way to check if a host computer is connected?
Thanks so much for any help!
Detect if USB serial/JTAG port is connected to host computer
Re: Detect if USB serial/JTAG port is connected to host computer
For posterity: While I didn't figure out how to detect if the USB serial/JTAG was hooked to a computer running a terminal program such as Tera Term, I found a work around. Basically, I just started the console initialization in a task, so it didn't matter if it blocked. Everything else runs just fine, and if a terminal is connected, it initializes the console and terminates the task. Instead of calling consoleInit() I call consoleRunInit().
Code: Select all
static wl_handle_t wl_handle;
// runs when USB plugged in (charger or terminal)
void consoleInitTask(void *pvParameter)
{
consoleInit();
vTaskDelete(xHandle);
}
void consoleRunInit(void)
{
xTaskCreate(&consoleInitTask, "console_init_task", 4096, NULL, 4, &xHandle);
}
void consoleInit(void)
{
esp_console_repl_t *Repl = NULL;
esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
...
}
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Detect if USB serial/JTAG port is connected to host computer
Trying to solve a similiar problem, I found
in driver/usb_serial_jtag
Code: Select all
bool usb_serial_jtag_is_connected(void);
Who is online
Users browsing this forum: No registered users and 156 guests