diff --git a/lib/default/TasmotaSerial-3.1.0/README.md b/lib/default/TasmotaSerial-3.2.0/README.md similarity index 87% rename from lib/default/TasmotaSerial-3.1.0/README.md rename to lib/default/TasmotaSerial-3.2.0/README.md index d2196ed4c..6dbd64823 100644 --- a/lib/default/TasmotaSerial-3.1.0/README.md +++ b/lib/default/TasmotaSerial-3.2.0/README.md @@ -2,6 +2,7 @@ Implementation of software serial with hardware serial fallback library for the ESP8266 Implementation of dual UART hardware serial for the ESP32 +Implementation of single UART hardware serial for the ESP32-S2 Allows for several instances to be active at the same time. diff --git a/lib/default/TasmotaSerial-3.1.0/examples/swsertest/swsertest.ino b/lib/default/TasmotaSerial-3.2.0/examples/swsertest/swsertest.ino similarity index 100% rename from lib/default/TasmotaSerial-3.1.0/examples/swsertest/swsertest.ino rename to lib/default/TasmotaSerial-3.2.0/examples/swsertest/swsertest.ino diff --git a/lib/default/TasmotaSerial-3.1.0/keywords.txt b/lib/default/TasmotaSerial-3.2.0/keywords.txt similarity index 100% rename from lib/default/TasmotaSerial-3.1.0/keywords.txt rename to lib/default/TasmotaSerial-3.2.0/keywords.txt diff --git a/lib/default/TasmotaSerial-3.1.0/library.json b/lib/default/TasmotaSerial-3.2.0/library.json similarity index 94% rename from lib/default/TasmotaSerial-3.1.0/library.json rename to lib/default/TasmotaSerial-3.2.0/library.json index 17764a8f2..caaa9f6f7 100644 --- a/lib/default/TasmotaSerial-3.1.0/library.json +++ b/lib/default/TasmotaSerial-3.2.0/library.json @@ -1,6 +1,6 @@ { "name": "TasmotaSerial", - "version": "3.1.0", + "version": "3.2.0", "keywords": [ "serial", "io", "TasmotaSerial" ], diff --git a/lib/default/TasmotaSerial-3.1.0/library.properties b/lib/default/TasmotaSerial-3.2.0/library.properties similarity index 94% rename from lib/default/TasmotaSerial-3.1.0/library.properties rename to lib/default/TasmotaSerial-3.2.0/library.properties index 8229443e9..30cc6138c 100644 --- a/lib/default/TasmotaSerial-3.1.0/library.properties +++ b/lib/default/TasmotaSerial-3.2.0/library.properties @@ -1,5 +1,5 @@ name=TasmotaSerial -version=3.1.0 +version=3.2.0 author=Theo Arends maintainer=Theo Arends sentence=Implementation of software serial with hardware serial fallback for ESP8266 and ESP32. diff --git a/lib/default/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp b/lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.cpp similarity index 92% rename from lib/default/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp rename to lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.cpp index 347457008..c3eff150a 100644 --- a/lib/default/TasmotaSerial-3.1.0/src/TasmotaSerial.cpp +++ b/lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.cpp @@ -91,7 +91,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal m_valid = true; } -TasmotaSerial::~TasmotaSerial() { +TasmotaSerial::~TasmotaSerial(void) { #ifdef ESP8266 if (!m_hardserial) { if (m_rx_pin > -1) { @@ -122,20 +122,23 @@ bool TasmotaSerial::begin(long speed, int stop_bits) { if (m_hardswap) { Serial.swap(); } + if (serial_buffer_size > 256) { + Serial.setRxBufferSize(serial_buffer_size); + } #endif // ESP8266 #ifdef ESP32 if (tasmota_serial_index > 0) { // We only support UART1 and UART2 and keep UART0 for debugging m_uart = tasmota_serial_index; tasmota_serial_index--; TSerial = new HardwareSerial(m_uart); - if (serial_buffer_size > 256) { - TSerial->setRxBufferSize(serial_buffer_size); - } if (2 == m_stop_bits) { TSerial->begin(speed, SERIAL_8N2, m_rx_pin, m_tx_pin); } else { TSerial->begin(speed, SERIAL_8N1, m_rx_pin, m_tx_pin); } + if (serial_buffer_size > 256) { + TSerial->setRxBufferSize(serial_buffer_size); + } } else { m_valid = false; } @@ -151,11 +154,11 @@ bool TasmotaSerial::begin(long speed, int stop_bits) { return m_valid; } -bool TasmotaSerial::begin() { +bool TasmotaSerial::begin(void) { return begin(TM_SERIAL_BAUDRATE); } -bool TasmotaSerial::hardwareSerial() { +bool TasmotaSerial::hardwareSerial(void) { #ifdef ESP8266 return m_hardserial; #endif // ESP8266 @@ -164,7 +167,7 @@ bool TasmotaSerial::hardwareSerial() { #endif // ESP32 } -void TasmotaSerial::flush() { +void TasmotaSerial::flush(void) { if (m_hardserial) { #ifdef ESP8266 Serial.flush(); @@ -177,7 +180,7 @@ void TasmotaSerial::flush() { } } -int TasmotaSerial::peek() { +int TasmotaSerial::peek(void) { if (m_hardserial) { #ifdef ESP8266 return Serial.peek(); @@ -191,7 +194,7 @@ int TasmotaSerial::peek() { } } -int TasmotaSerial::read() { +int TasmotaSerial::read(void) { if (m_hardserial) { #ifdef ESP8266 return Serial.read(); @@ -207,7 +210,26 @@ int TasmotaSerial::read() { } } -int TasmotaSerial::available() { +size_t TasmotaSerial::read(char* buffer, size_t size) { + if (m_hardserial) { +#ifdef ESP8266 + return Serial.read(buffer, size); +#endif // ESP8266 +#ifdef ESP32 + return TSerial->read(buffer, size); +#endif // ESP32 + } else { + if ((-1 == m_rx_pin) || (m_in_pos == m_out_pos)) { return 0; } + size_t count = 0; + for( ; size && (m_in_pos == m_out_pos) ; --size, ++count) { + *buffer++ = m_buffer[m_out_pos]; + m_out_pos = (m_out_pos +1) % serial_buffer_size; + } + return count; + } +} + +int TasmotaSerial::available(void) { if (m_hardserial) { #ifdef ESP8266 return Serial.available(); @@ -283,7 +305,7 @@ size_t TasmotaSerial::write(uint8_t b) { } } -void ICACHE_RAM_ATTR TasmotaSerial::rxRead() { +void ICACHE_RAM_ATTR TasmotaSerial::rxRead(void) { if (!m_nwmode) { int32_t loop_read = m_very_high_speed ? serial_buffer_size : 1; // Advance the starting point for the samples but compensate for the diff --git a/lib/default/TasmotaSerial-3.1.0/src/TasmotaSerial.h b/lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.h similarity index 90% rename from lib/default/TasmotaSerial-3.1.0/src/TasmotaSerial.h rename to lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.h index 2a97741e3..432344321 100644 --- a/lib/default/TasmotaSerial-3.1.0/src/TasmotaSerial.h +++ b/lib/default/TasmotaSerial-3.2.0/src/TasmotaSerial.h @@ -41,16 +41,17 @@ class TasmotaSerial : public Stream { virtual ~TasmotaSerial(); bool begin(long speed, int stop_bits = 1); - bool begin(); - bool hardwareSerial(); - int peek(); + bool begin(void); + bool hardwareSerial(void); + int peek(void); - virtual size_t write(uint8_t byte); - virtual int read(); - virtual int available(); - virtual void flush(); + size_t write(uint8_t byte) override; + int read(void) override; + size_t read(char* buffer, size_t size); + int available(void) override; + void flush(void) override; - void rxRead(); + void rxRead(void); uint32_t getLoopReadMetric(void) const { return m_bit_follow_metric; }