mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
[Console] Reduce boottime when using CDC as port for console
This commit is contained in:
@@ -46,6 +46,12 @@ public:
|
||||
|
||||
static Port_ESPEasySerial_base* ESPEasySerial_Port_factory(const ESPEasySerialConfig& config);
|
||||
|
||||
|
||||
// Ideal buffer size is a trade-off between bootspeed
|
||||
// and not missing data when the ESP is busy processing stuff.
|
||||
// Mainly HWCDC and USBCDC may appear blocking if the USB device is detected
|
||||
// by your OS but no serial port has been opened.
|
||||
// Flushing the buffers may then take buffSize * timeout to flush, which is blocking.
|
||||
ESPeasySerial(ESPEasySerialPort port,
|
||||
int receivePin,
|
||||
int transmitPin,
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include "../Commands/wd.h"
|
||||
#include "../Commands/WiFi.h"
|
||||
|
||||
#include "../DataStructs/TimingStats.h"
|
||||
|
||||
#include "../ESPEasyCore/ESPEasy_Log.h"
|
||||
|
||||
#include "../Helpers/Misc.h"
|
||||
@@ -213,7 +215,9 @@ bool do_command_case(command_case_data & data,
|
||||
if (do_command_case_check(data, cmd_test, nrArguments, group)) {
|
||||
// It has been handled, check if we need to execute it.
|
||||
// FIXME TD-er: Must change command function signature to use const String&
|
||||
START_TIMER;
|
||||
data.status = pFunc(data.event, data.line.c_str());
|
||||
STOP_TIMER(COMMAND_EXEC_INTERNAL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -229,7 +233,9 @@ bool do_command_case(command_case_data & data,
|
||||
if (do_command_case_check(data, cmd_test, nrArguments, group)) {
|
||||
// It has been handled, check if we need to execute it.
|
||||
// FIXME TD-er: Must change command function signature to use const String&
|
||||
START_TIMER;
|
||||
data.status = pFunc(data.event, data.line.c_str());
|
||||
STOP_TIMER(COMMAND_EXEC_INTERNAL);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -208,6 +208,7 @@ const __FlashStringHelper* getMiscStatsName_F(TimingStatsElements stat) {
|
||||
case TimingStatsElements::CPLUGIN_CALL_50PS: return F("CPlugin call 50 p/s");
|
||||
case TimingStatsElements::CPLUGIN_CALL_10PS: return F("CPlugin call 10 p/s");
|
||||
case TimingStatsElements::SENSOR_SEND_TASK: return F("SensorSendTask()");
|
||||
case TimingStatsElements::COMMAND_EXEC_INTERNAL: return F("Exec Internal Command");
|
||||
case TimingStatsElements::CONSOLE_LOOP: return F("Console loop()");
|
||||
case TimingStatsElements::CONSOLE_WRITE_SERIAL: return F("Console out");
|
||||
case TimingStatsElements::SEND_DATA_STATS: return F("sendData()");
|
||||
|
||||
@@ -61,8 +61,6 @@ enum class TimingStatsElements {
|
||||
CPLUGIN_CALL_10PS,
|
||||
CPLUGIN_CALL_50PS,
|
||||
SENSOR_SEND_TASK,
|
||||
CONSOLE_LOOP,
|
||||
CONSOLE_WRITE_SERIAL,
|
||||
SEND_DATA_STATS,
|
||||
COMPUTE_FORMULA_STATS,
|
||||
COMPUTE_STATS,
|
||||
@@ -74,6 +72,9 @@ enum class TimingStatsElements {
|
||||
RULES_PROCESSING,
|
||||
RULES_PROCESS_MATCHED,
|
||||
RULES_PARSE_LINE,
|
||||
COMMAND_EXEC_INTERNAL,
|
||||
CONSOLE_LOOP,
|
||||
CONSOLE_WRITE_SERIAL,
|
||||
|
||||
// Related to file access
|
||||
LOADFILE_STATS,
|
||||
|
||||
@@ -44,7 +44,12 @@ EspEasy_Console_t::EspEasy_Console_t()
|
||||
constexpr size_t buffSize = 256;
|
||||
# endif // ifdef ESP8266
|
||||
# ifdef ESP32
|
||||
constexpr size_t buffSize = 4096;
|
||||
// Ideal buffer size is a trade-off between bootspeed
|
||||
// and not missing data when the ESP is busy processing stuff.
|
||||
// Since we do have a separate buffer in the console,
|
||||
// it may just take less time in the background tasks to dump
|
||||
// any logs as larger chunks can be transferred at once.
|
||||
constexpr size_t buffSize = 512;
|
||||
# endif // ifdef ESP32
|
||||
|
||||
ESPEasySerialConfig config;
|
||||
@@ -363,16 +368,17 @@ void EspEasy_Console_t::setDebugOutput(bool enable)
|
||||
|
||||
String EspEasy_Console_t::getPortDescription() const
|
||||
{
|
||||
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
|
||||
|
||||
if (_serial != nullptr) {
|
||||
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
|
||||
return _serial->getPortDescription();
|
||||
#else
|
||||
String res = F("HW Serial0 @ ");
|
||||
res += _serial->baudRate();
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
return F("-");
|
||||
#else // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
|
||||
return F("HW Serial0");
|
||||
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
|
||||
}
|
||||
|
||||
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
|
||||
|
||||
Reference in New Issue
Block a user