Merge pull request #5586 from TD-er/bugfix/simplify_serial_fallback

[ESPEasy Console] Simplify init of ESPEasy console + update IDF/Arduino
This commit is contained in:
TD-er
2026-07-21 00:19:55 +02:00
committed by GitHub
18 changed files with 820 additions and 519 deletions
+1
View File
@@ -679,6 +679,7 @@ Datasheets
* `DS:ESP32 <https://documentation.espressif.com/esp32_datasheet_en.pdf>`_
* `DS:ESP32-S2 <https://documentation.espressif.com/esp32-s2_datasheet_en.pdf>`_
* `DS:ESP32-S3 <https://documentation.espressif.com/esp32-s3_datasheet_en.pdf>`_
* `DS:ESP32-S31 <https://documentation.espressif.com/esp32-s31_datasheet_en.pdf>`_
* `DS:ESP32-C2 <https://documentation.espressif.com/esp8684_datasheet_en.pdf>`_
* `DS:ESP32-C3 <https://documentation.espressif.com/esp32-c3_datasheet_en.pdf>`_
* `DS:ESP32-C5 <https://documentation.espressif.com/esp32-c5_datasheet_en.pdf>`_
+23
View File
@@ -2,6 +2,24 @@
#include "ESPEasySerialType.h"
bool ESPEasySerialConfig::operator==(const ESPEasySerialConfig& other) const
{
return port == other.port
&& baud == other.baud
&& receivePin == other.receivePin
&& transmitPin == other.transmitPin
&& inverse_logic == other.inverse_logic
&& rxBuffSize == other.rxBuffSize
&& txBuffSize == other.txBuffSize
&& forceSWserial == other.forceSWserial
&& timeout_ms == other.timeout_ms
&& config == other.config
#ifdef ESP8266
&& mode == other.mode
#endif
;
}
void ESPEasySerialConfig::validate()
{
port = ESPeasySerialType::getSerialType(port, receivePin, transmitPin);
@@ -18,6 +36,11 @@ void ESPEasySerialConfig::validate()
# endif // if USES_I2C_SC16IS752
}
#endif // if USES_SW_SERIAL
#if USES_HWCDC
if (port == ESPEasySerialPort::usb_hw_cdc) {
txBuffSize = 2048;
}
#endif
}
#ifdef ESP8266
+4
View File
@@ -24,6 +24,10 @@
struct ESPEasySerialConfig {
ESPEasySerialConfig() = default;
bool operator==(const ESPEasySerialConfig& other) const;
ESPEasySerialConfig& operator=(const ESPEasySerialConfig& other) = default;
void validate();
#ifdef ESP8266
@@ -48,6 +48,20 @@ static void hwcdcEventCallback(void *arg, esp_event_base_t event_base, int32_t e
}
}
bool Port_ESPEasySerial_USB_HWCDC_t::isConnected() const
{
static bool connected_cache{};
static uint32_t lastChecked{};
if (!connected_cache) {
const int32_t timePassedSince = (int32_t) (millis() - lastChecked);
if (timePassedSince < 1000) return false;
lastChecked = millis();
}
connected_cache = _hwcdc_serial != nullptr && _hwcdc_serial->isConnected();
return connected_cache;
}
Port_ESPEasySerial_USB_HWCDC_t::Port_ESPEasySerial_USB_HWCDC_t(const ESPEasySerialConfig& config)
# if ARDUINO_USB_CDC_ON_BOOT // Serial used for USB CDC
@@ -71,7 +85,7 @@ Port_ESPEasySerial_USB_HWCDC_t::Port_ESPEasySerial_USB_HWCDC_t(const ESPEasySeri
// _hwcdc_serial->begin();
// _hwcdc_serial->onEvent(hwcdcEventCallback);
// _hwcdc_serial->onEvent(hwcdcEventCallback);
}
}
@@ -106,7 +120,7 @@ void Port_ESPEasySerial_USB_HWCDC_t::end() {
int Port_ESPEasySerial_USB_HWCDC_t::available(void)
{
if (_hwcdc_serial != nullptr && _hwcdc_serial->isConnected()) {
if (isConnected()) {
return _hwcdc_serial->available();
}
return 0;
@@ -114,7 +128,7 @@ int Port_ESPEasySerial_USB_HWCDC_t::available(void)
int Port_ESPEasySerial_USB_HWCDC_t::availableForWrite(void)
{
if (_hwcdc_serial != nullptr && _hwcdc_serial->isConnected()) {
if (isConnected()) {
return _hwcdc_serial->availableForWrite();
}
return 0;
@@ -122,7 +136,7 @@ int Port_ESPEasySerial_USB_HWCDC_t::availableForWrite(void)
int Port_ESPEasySerial_USB_HWCDC_t::peek(void)
{
if (_hwcdc_serial != nullptr && _hwcdc_serial->isConnected()) {
if (isConnected()) {
return _hwcdc_serial->peek();
}
return 0;
@@ -130,7 +144,7 @@ int Port_ESPEasySerial_USB_HWCDC_t::peek(void)
int Port_ESPEasySerial_USB_HWCDC_t::read(void)
{
if (_hwcdc_serial != nullptr && _hwcdc_serial->isConnected()) {
if (isConnected()) {
return _hwcdc_serial->read();
}
return 0;
@@ -139,7 +153,7 @@ int Port_ESPEasySerial_USB_HWCDC_t::read(void)
size_t Port_ESPEasySerial_USB_HWCDC_t::read(uint8_t *buffer,
size_t size)
{
if (_hwcdc_serial != nullptr && _hwcdc_serial->isConnected()) {
if (isConnected()) {
return _hwcdc_serial->read(buffer, size);
}
return 0;
@@ -147,8 +161,8 @@ size_t Port_ESPEasySerial_USB_HWCDC_t::read(uint8_t *buffer,
void Port_ESPEasySerial_USB_HWCDC_t::flush(void)
{
if (_hwcdc_serial != nullptr && _hwcdc_serial->isConnected()) {
return _hwcdc_serial->flush();
if (isConnected()) {
_hwcdc_serial->flush();
}
}
@@ -176,16 +190,12 @@ size_t Port_ESPEasySerial_USB_HWCDC_t::write(const uint8_t *buffer,
Port_ESPEasySerial_USB_HWCDC_t::operator bool() const
{
if (_hwcdc_serial != nullptr && _hwcdc_serial->isConnected()) {
// return usbActive;
return true;
}
return false;
return _hwcdc_serial != nullptr && _hwcdc_serial->isPlugged();
}
void Port_ESPEasySerial_USB_HWCDC_t::setDebugOutput(bool enabled) {
if (_hwcdc_serial != nullptr) {
return _hwcdc_serial->setDebugOutput(enabled);
_hwcdc_serial->setDebugOutput(enabled);
}
}
@@ -212,4 +222,5 @@ bool Port_ESPEasySerial_USB_HWCDC_t::setRS485Mode(int8_t rtsPin, bool enableColl
return false;
}
#endif // if USES_HWCDC
@@ -43,6 +43,9 @@ public:
bool setRS485Mode(int8_t rtsPin, bool enableCollisionDetection = false);
private:
bool isConnected() const;
#if !ARDUINO_USB_CDC_ON_BOOT
HWCDC myUsbSerial;
#endif
+2 -1
View File
@@ -191,9 +191,10 @@ extra_scripts = ${esp82xx_common.extra_scripts}
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2904-2115-5.5/framework-arduinoespressif32-release_v5.5-f2a3fa2b.tar.xz
platform = https://github.com/Jason2866/platform-espressif32.git#Arduino/IDF55_gcc152
platform_packages =
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/1807-0842-5.5/framework-arduinoespressif32-release_v5.5-67336dba.tar.xz
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/2805-1324-5.5/framework-arduinoespressif32-release_v5.5-f3cdb9d0.tar.xz
custom_remove_include = true
custom_component_remove =
+1 -1
View File
@@ -88,6 +88,7 @@ boolean Plugin_040(uint8_t function, struct EventStruct *event, String& string)
{
if (Plugin_040_init)
{
success = true;
uint8_t val = 0;
uint8_t code[6];
uint8_t checksum = 0;
@@ -187,7 +188,6 @@ boolean Plugin_040(uint8_t function, struct EventStruct *event, String& string)
Scheduler.setPluginTaskTimer(500, event->TaskIndex, event->Par1);
}
}
success = true;
}
break;
}
+1 -1
View File
@@ -319,6 +319,7 @@ boolean Plugin_091(uint8_t function, struct EventStruct *event, String& string)
if (Plugin_091_init)
{
success = true;
while (ESPEASY_SERIAL_0.available() > 0) {
yield();
@@ -533,7 +534,6 @@ boolean Plugin_091(uint8_t function, struct EventStruct *event, String& string)
}
}
} // plugin initialized end
success = true;
break;
}
-442
View File
@@ -1,442 +0,0 @@
#include "../ESPEasyCore/ESPEasy_Console.h"
#include "../Commands/ExecuteCommand.h"
#include "../DataStructs/TimingStats.h"
#include "../DataTypes/ESPEasy_plugin_functions.h"
#include "../Globals/Cache.h"
#include "../Globals/Logging.h"
#include "../Globals/Plugins.h"
#include "../Globals/Settings.h"
#include "../Helpers/Memory.h"
#include <ESPEasySerialPort.h>
#ifdef ESP32
# include <esp32-hal-periman.h>
#endif
EspEasy_Console_t::EspEasy_Console_t() :
_mainSerial(LOG_TO_SERIAL)
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
# if USES_ESPEASY_CONSOLE_FALLBACK_PORT
, _fallbackSerial(LOG_TO_SERIAL_EXTRA)
# endif
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
{
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
const ESPEasySerialPort port = static_cast<ESPEasySerialPort>(_console_serial_port);
# if USES_USBCDC
/*
if (port == ESPEasySerialPort::usb_cdc_0 ||
port == ESPEasySerialPort::usb_cdc_1)
{
USB.manufacturerName(F("ESPEasy"));
USB.productName()
}
*/
# endif // if USES_USBCDC
# ifdef ESP8266
constexpr size_t buffSize = 256;
# endif // ifdef ESP8266
# ifdef ESP32
// 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;
config.port = port;
config.baud = DEFAULT_SERIAL_BAUD;
config.receivePin = _console_serial_rxpin;
config.transmitPin = _console_serial_txpin;
config.inverse_logic = false;
config.rxBuffSize = 256;
config.txBuffSize = buffSize;
{
# ifdef USE_SECOND_HEAP
HeapSelectDram ephemeral;
# endif // ifdef USE_SECOND_HEAP
_mainSerial._serial = new (std::nothrow) ESPeasySerial(config);
}
# if USES_ESPEASY_CONSOLE_FALLBACK_PORT
if (Settings.console_serial0_fallback && (port != ESPEasySerialPort::serial0)) {
config.port = ESPEasySerialPort::serial0;
config.receivePin = SOC_RX0;
config.transmitPin = SOC_TX0;
_fallbackSerial._serial = new (std::nothrow) ESPeasySerial(config);
}
# endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
}
void EspEasy_Console_t::reInit()
{
updateActiveTaskUseSerial0();
bool somethingChanged = false;
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
const ESPEasySerialPort port = static_cast<ESPEasySerialPort>(Settings.console_serial_port);
const bool consoleUseSerial0 = (
# ifdef ESP8266
(port == ESPEasySerialPort::serial0_swap) ||
# endif // ifdef ESP8266
port == ESPEasySerialPort::serial0);
const bool canUseSerial0 = !activeTaskUseSerial0() && !log_to_serial_disabled;
bool mustHaveSerial = Settings.UseSerial && (!consoleUseSerial0 || canUseSerial0);
# if USES_ESPEASY_CONSOLE_FALLBACK_PORT
bool mustHaveFallback = false;
if (Settings.UseSerial) {
if (consoleUseSerial0 && canUseSerial0 && (_fallbackSerial._serial != nullptr)) {
// Should not destruct an already running fallback serial port
mustHaveFallback = true;
mustHaveSerial = false;
} else {
if (Settings.console_serial0_fallback && !consoleUseSerial0 && canUseSerial0)
{
mustHaveFallback = true;
}
}
}
if (!mustHaveFallback) {
if (_fallbackSerial._serial != nullptr) {
delete _fallbackSerial._serial;
_fallbackSerial._serial = nullptr;
somethingChanged = true;
}
}
# endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
if ((_console_serial_port != Settings.console_serial_port) ||
(_console_serial_rxpin != Settings.console_serial_rxpin) ||
(_console_serial_txpin != Settings.console_serial_txpin) ||
!mustHaveSerial) {
if (_mainSerial._serial != nullptr) {
delete _mainSerial._serial;
_mainSerial._serial = nullptr;
somethingChanged = true;
}
_console_serial_port = Settings.console_serial_port;
_console_serial_rxpin = Settings.console_serial_rxpin;
_console_serial_txpin = Settings.console_serial_txpin;
}
if ((_mainSerial._serial == nullptr) && mustHaveSerial) {
# ifdef USE_SECOND_HEAP
HeapSelectDram ephemeral;
# endif // ifdef USE_SECOND_HEAP
unsigned int buffsize = 128;
const ESPEasySerialPort mainSerialPort = static_cast<ESPEasySerialPort>(_console_serial_port);
# if USES_HWCDC
if (mainSerialPort == ESPEasySerialPort::usb_hw_cdc) {
buffsize = 2048;
}
# endif // if USES_HWCDC
_mainSerial._serial = new (std::nothrow) ESPeasySerial(
mainSerialPort,
_console_serial_rxpin,
_console_serial_txpin,
false,
buffsize);
somethingChanged = true;
}
# if USES_ESPEASY_CONSOLE_FALLBACK_PORT
if ((_fallbackSerial._serial == nullptr) && mustHaveFallback) {
_fallbackSerial._serial = new (std::nothrow) ESPeasySerial(
ESPEasySerialPort::serial0,
SOC_RX0,
SOC_TX0);
somethingChanged = true;
}
# endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
# if USES_ESPEASY_CONSOLE_FALLBACK_PORT
if (_fallbackSerial._serial == nullptr) {
_fallbackSerial._serialWriteBuffer.clear();
}
# endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
if (_mainSerial._serial == nullptr) {
_mainSerial._serialWriteBuffer.clear();
}
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
if (somethingChanged) {
begin(Settings.BaudRate);
}
}
void EspEasy_Console_t::begin(uint32_t baudrate)
{
updateActiveTaskUseSerial0();
_baudrate = baudrate;
if (_mainSerial._serial != nullptr) {
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
_mainSerial._serial->begin(baudrate);
addLog(LOG_LEVEL_INFO, F("ESPEasy console using ESPEasySerial"));
#else // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
# ifdef ESP8266
_mainSerial._serial->begin(baudrate);
# ifndef BUILD_NO_DEBUG
addLog(LOG_LEVEL_INFO, F("ESPEasy console using HW Serial"));
# endif
# endif // ifdef ESP8266
# ifdef ESP32
// Allow to flush data from the serial buffers
// When not opening the USB serial port, the ESP may hang at boot.
delay(10);
_mainSerial._serial->end();
delay(10);
_mainSerial._serial->begin(baudrate);
_mainSerial._serial->flush();
# endif // ifdef ESP32
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
}
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
if (_fallbackSerial._serial != nullptr) {
_fallbackSerial._serial->begin(baudrate);
# ifdef ESP32
// Need to have this string as C-string, not F-string
perimanSetPinBusExtraType(SOC_RX0, "Console");
perimanSetPinBusExtraType(SOC_TX0, "Console");
# endif // ifdef ESP32
addLog(LOG_LEVEL_INFO, F("ESPEasy console fallback enabled"));
}
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
}
void EspEasy_Console_t::init() {
#if FEATURE_IMPROV
_mainSerial._improv.init();
# if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
# if USES_ESPEASY_CONSOLE_FALLBACK_PORT
_fallbackSerial._improv.init();
# endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
# endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
#endif // if FEATURE_IMPROV
updateActiveTaskUseSerial0();
if (!Settings.UseSerial) {
return;
}
#if !FEATURE_DEFINE_SERIAL_CONSOLE_PORT
if (activeTaskUseSerial0() || log_to_serial_disabled) {
return;
}
#endif // if !FEATURE_DEFINE_SERIAL_CONSOLE_PORT
begin(Settings.BaudRate);
}
void EspEasy_Console_t::loop()
{
if (!Settings.UseSerial) { return; }
START_TIMER;
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
const bool consoleUsesSerial0 =
(static_cast<ESPEasySerialPort>(_console_serial_port) == ESPEasySerialPort::serial0
# ifdef ESP8266
|| static_cast<ESPEasySerialPort>(_console_serial_port) == ESPEasySerialPort::serial0_swap
# endif // ifdef ESP8266
);
if (handledByPluginSerialIn())
{
// Any serial0 data is already dealt with
if (!consoleUsesSerial0 && (_mainSerial._serial != nullptr)) {
readInput(_mainSerial);
}
return;
}
#else // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
if (handledByPluginSerialIn()) {
return;
}
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
readInput(_mainSerial);
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
readInput(_fallbackSerial);
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
STOP_TIMER(CONSOLE_LOOP);
}
bool EspEasy_Console_t::process_serialWriteBuffer() {
START_TIMER;
bool res = false;
if (_mainSerial.process_serialWriteBuffer()) {
res = true;
}
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
if (_fallbackSerial.process_serialWriteBuffer()) {
res = true;
}
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
#if FEATURE_TIMING_STATS
if (res) { STOP_TIMER(CONSOLE_WRITE_SERIAL); }
#endif // if FEATURE_TIMING_STATS
return res;
}
void EspEasy_Console_t::setDebugOutput(bool enable)
{
auto port = getPort();
if (port != nullptr) {
port->setDebugOutput(enable);
}
}
String EspEasy_Console_t::getPortDescription() const
{
return _mainSerial.getPortDescription();
}
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
String EspEasy_Console_t::getFallbackPortDescription() const
{
return _fallbackSerial.getPortDescription();
}
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
bool EspEasy_Console_t::handledByPluginSerialIn()
{
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
if ((_fallbackSerial._serial != nullptr) &&
_fallbackSerial._serial->available())
{
String dummy;
return PluginCall(PLUGIN_SERIAL_IN, 0, dummy);
}
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
if ((_mainSerial._serial != nullptr) && _mainSerial._serial->available() &&
(static_cast<ESPEasySerialPort>(_console_serial_port) == ESPEasySerialPort::serial0
# ifdef ESP8266
|| static_cast<ESPEasySerialPort>(_console_serial_port) == ESPEasySerialPort::serial0_swap
# endif // ifdef ESP8266
))
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
{
String dummy;
return PluginCall(PLUGIN_SERIAL_IN, 0, dummy);
}
return false;
}
void EspEasy_Console_t::readInput(EspEasy_Console_Port& port)
{
size_t bytesToRead = port.available();
while (bytesToRead > 0)
{
--bytesToRead;
delay(0);
const int SerialInByte = port.read();
if (SerialInByte >= 0) {
if (port.process_consoleInput(SerialInByte)) {
// Processed a full line
return;
}
}
}
}
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
ESPeasySerial * EspEasy_Console_t::getPort()
{
if (_mainSerial._serial != nullptr) {
return _mainSerial._serial;
}
# if USES_ESPEASY_CONSOLE_FALLBACK_PORT
if (_fallbackSerial._serial != nullptr) {
return _fallbackSerial._serial;
}
# endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
return nullptr;
}
#else // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
HardwareSerial * EspEasy_Console_t::getPort()
{
if (_mainSerial._serial != nullptr) {
return _mainSerial._serial;
}
return nullptr;
}
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
void EspEasy_Console_t::endPort()
{
_mainSerial.endPort();
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
_fallbackSerial.endPort();
#endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
delay(10);
}
+28 -22
View File
@@ -5,26 +5,41 @@
#include "../ESPEasyCore/ESPEasy_Console_Port.h"
class EspEasy_Console_t {
#ifdef ESP8266
# define ESPEASY_CONSOLE_TX_BUFFSIZE 256
#endif // ifdef ESP8266
#ifdef ESP32
// 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.
# define ESPEASY_CONSOLE_TX_BUFFSIZE 1024
#endif // ifdef ESP32
class EspEasy_Console_t
{
public:
EspEasy_Console_t();
// Typically called after settings have been loaded.
void reInit();
void reInit();
void begin(uint32_t baudrate);
void begin(uint32_t baudrate);
void init();
void init();
// Process data from serial port
void loop();
void loop();
// Return true when something got written, or when the buffer was already empty
bool process_serialWriteBuffer();
bool process_serialWriteBuffer();
void setDebugOutput(bool enable);
void setDebugOutput(bool enable);
String getPortDescription() const;
@@ -32,35 +47,26 @@ public:
String getFallbackPortDescription() const;
#endif
private:
bool handledByPluginSerialIn();
void readInput(EspEasy_Console_Port& port);
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
ESPeasySerial * getPort();
ESPeasySerial* getPort();
#else // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
HardwareSerial* getPort();
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
void endPort();
uint32_t _baudrate = 115200u;
EspEasy_Console_Port _mainSerial;
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
# if USES_ESPEASY_CONSOLE_FALLBACK_PORT
EspEasy_Console_Port _fallbackSerial;
# endif
// Cache the used settings, so we can check whether to change the console serial
uint8_t _console_serial_port = DEFAULT_CONSOLE_PORT;
int8_t _console_serial_rxpin = DEFAULT_CONSOLE_PORT_RXPIN;
int8_t _console_serial_txpin = DEFAULT_CONSOLE_PORT_TXPIN;
#endif
};
// Serial port to be always used as HW Serial0
EspEasy_Console_Port _fallbackSerial;
# endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
}; // class EspEasy_Console_t
#endif // ifndef ESPEASYCORE_ESPEASY_CONSOLE_H
+236 -23
View File
@@ -13,9 +13,12 @@
#include "../Helpers/Memory.h"
#include "../Helpers/StringConverter.h"
#include <ESPEasySerialPort.h>
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
# include <ESPEasySerialPort.h>
# ifdef ESP32
# include <esp32-hal-periman.h>
# endif
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
#ifdef ESP32
# define CONSOLE_INPUT_BUFFER_SIZE 1280
@@ -23,6 +26,10 @@
# define CONSOLE_INPUT_BUFFER_SIZE 128
#endif // ifdef ESP32
// Set to max. of 64 bytes as this is the optimum 'chunk size' for most
// serial ports, like the CDC ports and I2C to UART.
// Also it is relatively fast to allocate.
#define CONSOLE_MAX_WRITE_CHUNKSIZE 64
/*
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
@@ -105,6 +112,47 @@ size_t EspEasy_Console_Port::available() const
return res;
}
void EspEasy_Console_Port::begin(uint32_t baudrate)
{
updateActiveTaskUseSerial0();
if (_serial != nullptr) {
#if FEATURE_IMPROV
_improv.init();
#endif
_serial->begin(baudrate);
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
_config.baud = baudrate;
#endif
_serial->flush();
#ifdef ESP32
// Allow to flush data from the serial buffers
// When not opening the USB serial port, the ESP may hang at boot.
/*
delay(10);
_serial->end();
delay(10);
_serial->begin(baudrate);
_serial->flush();
*/
# if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
if (useGPIOpins(_config.port)) {
// Need to have this string as C-string, not F-string
perimanSetPinBusExtraType(_config.receivePin, "Console");
perimanSetPinBusExtraType(_config.transmitPin, "Console");
}
# endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
#endif // ifdef ESP32
}
}
void EspEasy_Console_Port::endPort()
{
if (_serial != nullptr) {
@@ -112,38 +160,123 @@ void EspEasy_Console_Port::endPort()
}
}
void EspEasy_Console_Port::readInput()
{
if (_serial == nullptr) { return; }
size_t bytesToRead = available();
if (bytesToRead == 0) { return; }
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
if (getPortType() == ESPEasySerialPort::serial0
# ifdef ESP8266
|| getPortType() == ESPEasySerialPort::serial0_swap
# endif // ifdef ESP8266
)
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
{
String dummy;
if (PluginCall(PLUGIN_SERIAL_IN, 0, dummy)) {
// Any serial0 data is already dealt with
return;
}
}
while (bytesToRead > 0)
{
--bytesToRead;
delay(0);
const int SerialInByte = read();
if (SerialInByte >= 0) {
if (process_consoleInput(SerialInByte)) {
// Processed a full line
return;
}
}
}
}
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
ESPEasySerialPort EspEasy_Console_Port::getPortType() const
{
# if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
if (_serial == nullptr) { return ESPEasySerialPort::not_set; }
return _config.port;
# else // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
// TODO TD-er: Should I also try to see if we're using serial0_swapped?
return ESPEasySerialPort::serial0;
# endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
}
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
bool EspEasy_Console_Port::process_serialWriteBuffer()
{
if (_serial != nullptr) {
if (_serialWriteBuffer.getNrMessages() == 0) { return false; }
if (_serial == nullptr) { return false; }
#ifdef ESP32
if (!xPortCanYield()) { return false; }
if (!xPortCanYield()) { return false; }
#endif // ifdef ESP32
size_t availableForWrite = _serial->availableForWrite();
if (availableForWrite == 0) { return false; }
// Only check for nr. available bytes left once
// This can be a relatively "expensive" call
// and when using high baud rates this processing may take up
// too much time blocking everything else.
size_t availableForWrite = _serial->availableForWrite();
size_t nrLinesWritten = 0;
PrintToString str;
str.reserve(CONSOLE_MAX_WRITE_CHUNKSIZE);
size_t totalWritten = 0;
do
{
if (availableForWrite == 0) { return totalWritten > 0; }
if (availableForWrite == 1) {
// For only a single byte, just write it directly
return _serialWriteBuffer.process(_serial, availableForWrite);
if (_serialWriteBuffer.process(_serial, availableForWrite)) {
++totalWritten;
}
return totalWritten > 0;
}
if (availableForWrite > 64) {
// Set to max. of 64 bytes as this is the optimum 'chunk size' for most
// serial ports, like the CDC ports and I2C to UART.
// Also it is relatively fast to allocate.
availableForWrite = 64;
const size_t chunkSize = availableForWrite > CONSOLE_MAX_WRITE_CHUNKSIZE
? CONSOLE_MAX_WRITE_CHUNKSIZE
: availableForWrite;
availableForWrite -= chunkSize;
if (!_serialWriteBuffer.process(&str, chunkSize)) {
// Nothing left to write
return totalWritten > 0;
}
PrintToString str;
str.reserve(availableForWrite);
const size_t lastWritten = _serial->write(str.get().c_str(), str.length());
if (_serialWriteBuffer.process(&str, availableForWrite)) {
_serial->write(str.get().c_str(), str.length());
return true;
totalWritten += lastWritten;
if (lastWritten < chunkSize) {
// Try to end on a full log line to lower the chance of SDK debug logs
// interfering with console output.
++nrLinesWritten;
}
}
return false;
str.clear();
} while (availableForWrite > 0 && nrLinesWritten < 3);
return totalWritten > 0;
}
bool EspEasy_Console_Port::process_consoleInput(uint8_t SerialInByte)
@@ -188,14 +321,94 @@ bool EspEasy_Console_Port::process_consoleInput(uint8_t SerialInByte)
String EspEasy_Console_Port::getPortDescription() const
{
if (_serial != nullptr) {
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
return _serial->getPortDescription();
#else // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
#else // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
String res = F("HW Serial0 @ ");
res += _serial->baudRate();
return res;
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
}
return F("-");
}
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
bool EspEasy_Console_Port::updateSerialPort(
ESPEasySerialConfig& config)
{
updateActiveTaskUseSerial0();
bool somethingChanged = false;
config.validate();
const bool consoleUseSerial0 = (
# ifdef ESP8266
(config.port == ESPEasySerialPort::serial0_swap) ||
# endif // ifdef ESP8266
config.port == ESPEasySerialPort::serial0);
const bool canUseSerial0 = !activeTaskUseSerial0() && !log_to_serial_disabled;
bool mustHaveSerial = Settings.UseSerial && (!consoleUseSerial0 || canUseSerial0) && config.port != ESPEasySerialPort::not_set;
if (!(_config == config) ||
!mustHaveSerial) {
if (_serial != nullptr) {
delete _serial;
_serial = nullptr;
somethingChanged = true;
}
_config = config;
if (!mustHaveSerial) {
_config.port = ESPEasySerialPort::not_set;
}
}
if ((_serial == nullptr) && mustHaveSerial) {
{
# ifdef USE_SECOND_HEAP
HeapSelectDram ephemeral;
# endif // ifdef USE_SECOND_HEAP
_serial = new (std::nothrow) ESPeasySerial(_config);
# if USES_HWCDC
// Check to see if the port is plugged.
// If not, we can remove it again and save resources.
if ((_config.port == ESPEasySerialPort::usb_hw_cdc) && (_serial != nullptr)) {
bool isPlugged{};
for (uint32_t i = 0; !isPlugged && i < 5; i++) {
isPlugged = _serial->operator bool();
delay(50);
}
if (!isPlugged) {
delete _serial;
_serial = nullptr;
}
}
# endif // if USES_HWCDC
}
somethingChanged = true;
}
if (_serial == nullptr) {
_serialWriteBuffer.clear();
}
if (somethingChanged) {
begin(_config.baud);
}
return somethingChanged;
}
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
+30 -12
View File
@@ -13,7 +13,7 @@
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
#if FEATURE_IMPROV
#include "../Helpers/Improv_Helper.h"
# include "../Helpers/Improv_Helper.h"
#endif
@@ -24,23 +24,41 @@ struct EspEasy_Console_Port {
operator bool() const;
int read();
size_t available() const;
int read();
size_t available() const;
void endPort();
void begin(uint32_t baudrate);
bool process_serialWriteBuffer();
void endPort();
bool process_consoleInput(uint8_t SerialInByte);
void readInput();
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
ESPEasySerialPort getPortType() const;
#endif
bool process_serialWriteBuffer();
String getPortDescription() const;
bool process_consoleInput(uint8_t SerialInByte);
int SerialInByteCounter{};
char *InputBuffer_Serial{};
String getPortDescription() const;
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
bool updateSerialPort(ESPEasySerialConfig& config);
private:
// Cache the used settings, so we can check whether to change the console serial
ESPEasySerialConfig _config;
public:
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
int SerialInByteCounter{};
char *InputBuffer_Serial{};
SerialWriteBuffer_t _serialWriteBuffer;
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
ESPeasySerial *_serial = nullptr;
ESPeasySerial *_serial = nullptr;
#else // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
# if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) && ARDUINO_USB_CDC_ON_BOOT // Serial used for USB CDC
HardwareSerial *_serial = &Serial0;
@@ -52,9 +70,9 @@ struct EspEasy_Console_Port {
Improv_Helper_t _improv;
#endif
#endif // if FEATURE_IMPROV
};
#endif
#endif // ifndef ESPEASYCORE_ESPEASY_CONSOLE_PORT_H
@@ -0,0 +1,197 @@
#include "../ESPEasyCore/ESPEasy_Console.h"
#ifdef ESP32
// Only ESP32 does allow for multiple serial ports
# if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
# if USES_ESPEASY_CONSOLE_FALLBACK_PORT
# include "../Commands/ExecuteCommand.h"
# include "../DataStructs/TimingStats.h"
# include "../DataTypes/ESPEasy_plugin_functions.h"
# include "../Globals/Cache.h"
# include "../Globals/Logging.h"
# include "../Globals/Plugins.h"
# include "../Globals/Settings.h"
# include "../Helpers/Memory.h"
# include <ESPEasySerialPort.h>
EspEasy_Console_t::EspEasy_Console_t() :
_mainSerial(LOG_TO_SERIAL)
, _fallbackSerial(LOG_TO_SERIAL_EXTRA)
{
# if USES_USBCDC
/*
if (port == ESPEasySerialPort::usb_cdc_0 ||
port == ESPEasySerialPort::usb_cdc_1)
{
USB.manufacturerName(F("ESPEasy"));
USB.productName()
}
*/
# endif // if USES_USBCDC
ESPEasySerialConfig config;
config.port = static_cast<ESPEasySerialPort>(DEFAULT_CONSOLE_PORT);
config.baud = DEFAULT_SERIAL_BAUD;
config.receivePin = DEFAULT_CONSOLE_PORT_RXPIN;
config.transmitPin = DEFAULT_CONSOLE_PORT_TXPIN;
config.inverse_logic = false;
config.rxBuffSize = 256;
config.txBuffSize = ESPEASY_CONSOLE_TX_BUFFSIZE;
if (config.port != ESPEasySerialPort::serial0) {
// We only use the _mainSerial for ports other than HW Serial0
_mainSerial.updateSerialPort(config);
}
if (Settings.console_serial0_fallback ||
(config.port == ESPEasySerialPort::serial0))
{
config.port = ESPEasySerialPort::serial0;
config.receivePin = SOC_RX0;
config.transmitPin = SOC_TX0;
config.txBuffSize = ESPEASY_CONSOLE_TX_BUFFSIZE;
_fallbackSerial.updateSerialPort(config);
}
}
void EspEasy_Console_t::reInit()
{
ESPEasySerialConfig config;
config.port = static_cast<ESPEasySerialPort>(Settings.console_serial_port);
config.baud = Settings.BaudRate;
config.receivePin = Settings.console_serial_rxpin;
config.transmitPin = Settings.console_serial_txpin;
config.inverse_logic = false;
config.rxBuffSize = 256;
config.txBuffSize = ESPEASY_CONSOLE_TX_BUFFSIZE;
if (config.port != ESPEasySerialPort::serial0) {
// We only use the _mainSerial for ports other than HW Serial0
_mainSerial.updateSerialPort(config);
}
if (Settings.console_serial0_fallback ||
(config.port == ESPEasySerialPort::serial0))
{
config.port = ESPEasySerialPort::serial0;
config.receivePin = SOC_RX0;
config.transmitPin = SOC_TX0;
config.txBuffSize = ESPEASY_CONSOLE_TX_BUFFSIZE;
_fallbackSerial.updateSerialPort(config);
}
}
void EspEasy_Console_t::begin(uint32_t baudrate)
{
_mainSerial.begin(baudrate);
_fallbackSerial.begin(baudrate);
# ifndef BUILD_NO_DEBUG
if (_mainSerial._serial != nullptr) {
addLog(LOG_LEVEL_INFO, F("ESPEasy console enabled"));
}
if (_fallbackSerial._serial != nullptr) {
addLog(LOG_LEVEL_INFO,
(_mainSerial._serial != nullptr)
? F("ESPEasy console fallback enabled")
: F("ESPEasy console enabled"));
}
# endif // ifndef BUILD_NO_DEBUG
}
void EspEasy_Console_t::init() {
updateActiveTaskUseSerial0();
if (!Settings.UseSerial) {
return;
}
begin(Settings.BaudRate);
}
void EspEasy_Console_t::loop()
{
if (!Settings.UseSerial) { return; }
START_TIMER;
_mainSerial.readInput();
_fallbackSerial.readInput();
STOP_TIMER(CONSOLE_LOOP);
}
bool EspEasy_Console_t::process_serialWriteBuffer() {
START_TIMER;
bool res = false;
if (_mainSerial.process_serialWriteBuffer()) {
res = true;
}
if (_fallbackSerial.process_serialWriteBuffer()) {
res = true;
}
# if FEATURE_TIMING_STATS
if (res) { STOP_TIMER(CONSOLE_WRITE_SERIAL); }
# endif // if FEATURE_TIMING_STATS
return res;
}
void EspEasy_Console_t::setDebugOutput(bool enable)
{
if (_mainSerial._serial != nullptr) {
_mainSerial._serial->setDebugOutput(enable);
}
if (_fallbackSerial._serial != nullptr) {
_fallbackSerial._serial->setDebugOutput(enable);
}
}
String EspEasy_Console_t::getPortDescription() const
{
return _mainSerial.getPortDescription();
}
String EspEasy_Console_t::getFallbackPortDescription() const
{
return _fallbackSerial.getPortDescription();
}
ESPeasySerial * EspEasy_Console_t::getPort()
{
if (_mainSerial._serial != nullptr) {
return _mainSerial._serial;
}
if (_fallbackSerial._serial != nullptr) {
return _fallbackSerial._serial;
}
return nullptr;
}
void EspEasy_Console_t::endPort()
{
_mainSerial.endPort();
_fallbackSerial.endPort();
delay(10);
}
# endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
# endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
#endif // ifdef ESP32
@@ -0,0 +1,114 @@
#include "../ESPEasyCore/ESPEasy_Console.h"
#if !FEATURE_DEFINE_SERIAL_CONSOLE_PORT
# include "../Commands/ExecuteCommand.h"
# include "../DataStructs/TimingStats.h"
# include "../DataTypes/ESPEasy_plugin_functions.h"
# include "../Globals/Cache.h"
# include "../Globals/Logging.h"
# include "../Globals/Plugins.h"
# include "../Globals/Settings.h"
# include "../Helpers/Memory.h"
# include <ESPEasySerialPort.h>
# ifdef ESP32
# include <esp32-hal-periman.h>
# endif
EspEasy_Console_t::EspEasy_Console_t() :
_mainSerial(LOG_TO_SERIAL)
{}
void EspEasy_Console_t::reInit()
{
updateActiveTaskUseSerial0();
// TODO TD-er: Must check whether a task uses serial 0 and then stop serial console
// activeTaskUseSerial0()
bool somethingChanged = false;
if (somethingChanged) {
begin(Settings.BaudRate);
}
}
void EspEasy_Console_t::begin(uint32_t baudrate)
{
_mainSerial.begin(baudrate);
# ifndef BUILD_NO_DEBUG
addLog(LOG_LEVEL_INFO, F("ESPEasy console enabled"));
# endif
}
void EspEasy_Console_t::init() {
updateActiveTaskUseSerial0();
if (!Settings.UseSerial) {
return;
}
if (activeTaskUseSerial0() || log_to_serial_disabled) {
return;
}
begin(Settings.BaudRate);
}
void EspEasy_Console_t::loop()
{
if (!Settings.UseSerial) { return; }
START_TIMER;
_mainSerial.readInput();
STOP_TIMER(CONSOLE_LOOP);
}
bool EspEasy_Console_t::process_serialWriteBuffer() {
# if FEATURE_TIMING_STATS
START_TIMER;
if (_mainSerial.process_serialWriteBuffer()) {
STOP_TIMER(CONSOLE_WRITE_SERIAL);
return true;
}
return false;
# else // if FEATURE_TIMING_STATS
return _mainSerial.process_serialWriteBuffer();
# endif // if FEATURE_TIMING_STATS
}
void EspEasy_Console_t::setDebugOutput(bool enable)
{
auto port = getPort();
if (port != nullptr) {
port->setDebugOutput(enable);
}
}
String EspEasy_Console_t::getPortDescription() const
{
return _mainSerial.getPortDescription();
}
HardwareSerial * EspEasy_Console_t::getPort() { return _mainSerial._serial; }
void EspEasy_Console_t::endPort()
{
_mainSerial.endPort();
delay(10);
}
#endif // if !FEATURE_DEFINE_SERIAL_CONSOLE_PORT
@@ -0,0 +1,146 @@
#include "../ESPEasyCore/ESPEasy_Console.h"
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
# if !USES_ESPEASY_CONSOLE_FALLBACK_PORT
# include "../Commands/ExecuteCommand.h"
# include "../DataStructs/TimingStats.h"
# include "../DataTypes/ESPEasy_plugin_functions.h"
# include "../Globals/Cache.h"
# include "../Globals/Logging.h"
# include "../Globals/Plugins.h"
# include "../Globals/Settings.h"
# include "../Helpers/Memory.h"
# include <ESPEasySerialPort.h>
# ifdef ESP32
# include <esp32-hal-periman.h>
# endif
EspEasy_Console_t::EspEasy_Console_t() :
_mainSerial(LOG_TO_SERIAL)
{
# if USES_USBCDC
/*
if (port == ESPEasySerialPort::usb_cdc_0 ||
port == ESPEasySerialPort::usb_cdc_1)
{
USB.manufacturerName(F("ESPEasy"));
USB.productName()
}
*/
# endif // if USES_USBCDC
ESPEasySerialConfig config;
config.port = static_cast<ESPEasySerialPort>(DEFAULT_CONSOLE_PORT);
config.baud = DEFAULT_SERIAL_BAUD;
config.receivePin = DEFAULT_CONSOLE_PORT_RXPIN;
config.transmitPin = DEFAULT_CONSOLE_PORT_TXPIN;
config.inverse_logic = false;
config.rxBuffSize = 256;
config.txBuffSize = ESPEASY_CONSOLE_TX_BUFFSIZE;
_mainSerial.updateSerialPort(config);
}
void EspEasy_Console_t::reInit()
{
ESPEasySerialConfig config;
config.port = static_cast<ESPEasySerialPort>(Settings.console_serial_port);
config.baud = Settings.BaudRate;
config.receivePin = Settings.console_serial_rxpin;
config.transmitPin = Settings.console_serial_txpin;
config.inverse_logic = false;
config.rxBuffSize = 256;
config.txBuffSize = ESPEASY_CONSOLE_TX_BUFFSIZE;
_mainSerial.updateSerialPort(config);
}
void EspEasy_Console_t::begin(uint32_t baudrate) {
_mainSerial.begin(baudrate);
# ifndef BUILD_NO_DEBUG
if (_mainSerial._serial != nullptr) {
addLog(LOG_LEVEL_INFO, F("ESPEasy console enabled"));
}
# endif // ifndef BUILD_NO_DEBUG
}
void EspEasy_Console_t::init() {
updateActiveTaskUseSerial0();
if (!Settings.UseSerial) {
return;
}
begin(Settings.BaudRate);
}
void EspEasy_Console_t::loop()
{
if (!Settings.UseSerial) { return; }
START_TIMER;
_mainSerial.readInput();
STOP_TIMER(CONSOLE_LOOP);
}
bool EspEasy_Console_t::process_serialWriteBuffer() {
# if FEATURE_TIMING_STATS
START_TIMER;
if (_mainSerial.process_serialWriteBuffer()) {
STOP_TIMER(CONSOLE_WRITE_SERIAL);
return true;
}
return false;
# else // if FEATURE_TIMING_STATS
return _mainSerial.process_serialWriteBuffer();
# endif // if FEATURE_TIMING_STATS
}
void EspEasy_Console_t::setDebugOutput(bool enable)
{
auto port = getPort();
if (port != nullptr) {
port->setDebugOutput(enable);
}
}
String EspEasy_Console_t::getPortDescription() const
{
return _mainSerial.getPortDescription();
}
ESPeasySerial * EspEasy_Console_t::getPort()
{
if (_mainSerial._serial != nullptr) {
return _mainSerial._serial;
}
return nullptr;
}
void EspEasy_Console_t::endPort()
{
_mainSerial.endPort();
delay(10);
}
# endif // if !USES_ESPEASY_CONSOLE_FALLBACK_PORT
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
+5
View File
@@ -71,6 +71,11 @@ void Improv_Helper_t::init()
// FIXME TD-er: Implement callback to use ESPEasy functions to connect to WiFi
// _improv.setCustomTryConnectToWiFi(OnImprovESPEasyConnectWiFi);
update();
}
void Improv_Helper_t::update()
{
String firmwareName = get_binary_filename();
const String buildString = getSystemBuildString();
+2
View File
@@ -17,6 +17,8 @@ public:
void init();
void update();
bool handle(uint8_t b, Stream *serialForWrite);
bool getFromBuffer(uint8_t& b);
+2 -3
View File
@@ -294,9 +294,6 @@ void serialHelper_webformLoad(ESPEasySerialPort port,
true);
#endif // ifdef ESP32
#if !USES_SW_SERIAL
allowSoftwareSerial = false;
#endif
const int ids[] = {
static_cast<int>(ESPEasySerialPort::not_set)
@@ -369,9 +366,11 @@ void serialHelper_webformLoad(ESPEasySerialPort port,
if (!(allowedSerial & INCLUDE_HW_SERIAL) && isHWserial(serType)) {
attr[i] = F("disabled");
}
#if USES_SW_SERIAL
if (!(allowedSerial & INCLUDE_SW_SERIAL) && (serType == ESPEasySerialPort::software)) {
attr[i] = F("disabled");
}
#endif
#if USES_I2C_SC16IS752
if (!(allowedSerial & INCLUDE_I2C_SERIAL) && (serType == ESPEasySerialPort::sc16is752)) {
attr[i] = F("disabled");