SoftwareSerial not compiling

Hi there

I’m a Newbe in vscPlatformIO and try to build my first project.
I try to use 2 SerialPorts at a ESP nodeMCU. The normal Port is working. No Problem. OTA programing is working.
Then I installed the espSoftwareSerial.
And from there I have a Error in SoftwareSerial.h :

… 'bool overflow();
int available() override;
#if defined(ESP8266)
int availableForWrite() override { //////here is the Problem
#else
int availableForWrite() {
#endif
if (!m_txValid) return 0;
return 1;
}…

the Errorcode is: Eine mit “override” deklarierte Memberfunktion überschreibt keinen Basisklassenmember

Do anyone have a Idea what I could do?

This is question for the library author. And he already received and answered this question before: SoftwareSerial::availableForWrite()' marked override, but does not override · Issue #200 · plerup/espsoftwareserial · GitHub

same as

same as

And the author seems to get more and more frustrated with people. You can read how the frustration grows within him as more people ask it.

To make things simple:

Uninstall this library by removing it from the lib_deps expression of the platformio.ini. The Arduino ESP8266 Arduino core already features the library in the correct version.

If you do a platformio.ini like

[env:esp12e]
platform = espressif8266
board = esp12e
framework = arduino

and a src\main.cpp like

#include "Arduino.h"
#include <SoftwareSerial.h>

#define SER_RX_PIN 3
#define SER_TX_PIN 2
SoftwareSerial softSer(SER_RX_PIN, SER_TX_PIN);

void setup()
{
  softSer.println("Test");
}

void loop()
{
}

It will compile by using the library in the core. You can see that in the Advanced → Verbose Build output

Processing esp12e (platform: espressif8266; board: esp12e; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp12e.html
PLATFORM: Espressif 8266 (2.6.3) > Espressif ESP8266 ESP-12E
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
 - framework-arduinoespressif8266 3.20704.0 (2.7.4)
 - tool-esptool 1.413.0 (4.13)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa 2.40802.200502 (4.8.2)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 40 compatible libraries
More details about "Library Compatibility Mode": https://docs.platformio.org/page/librarymanager/ldf.html#ldf-compat-mode
Scanning dependencies...
Dependency Graph
|-- <EspSoftwareSerial> 6.8.5 (C:\Users\Max\.platformio\packages\framework-arduinoespressif8266\libraries\SoftwareSerial)
Building in release mode
..
Checking size .pio\build\esp12e\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  33.2% (used 27228 bytes from 81920 bytes)
Flash: [===       ]  25.2% (used 262988 bytes from 1044464 bytes)
=========================== [SUCCESS] Took 1.86 seconds ===========================

The reason you’re getting the error is because you’re installing the latest espsoftwareserial libary version which targets a bleeding-edge version of the Arduino-ESP8266 core. PlatformIO uses stable releases (latest is 2.7.4) but the latest espsoftwareserial library relies on code made in commits after that stable release.

Of course, per documentation you can also update to this bleeding edge Arduino-esp8266 version. Which is however not recommended due to it being bleeding-edge and thus not-stable.

Anyways, if I keep the C++ code above and write my platformio.ini as

[env:esp12e]
platform = espressif8266
board = esp12e
framework = arduino
lib_deps =
  plerup/EspSoftwareSerial @ ^6.11.6

(Notice how that version is 6.11.6 instead if the previously used 6.8.5 version)

I’m greeted with

In file included from .pio\libdeps\esp12e\EspSoftwareSerial\src\SoftwareSerial.cpp:23:0:
.pio\libdeps\esp12e\EspSoftwareSerial\src\SoftwareSerial.h:132:9: error: 'int SoftwareSerial::availableForWrite()' marked override, but does not override
     int availableForWrite() override {
         ^
In file included from src\main.cpp:2:0:
.pio\libdeps\esp12e\EspSoftwareSerial\src/SoftwareSerial.h:132:9: error: 'int SoftwareSerial::availableForWrite()' marked override, but does not override
     int availableForWrite() override {
         ^
*** [.pio\build\esp12e\src\main.cpp.o] Error 1
*** [.pio\build\esp12e\libf19\EspSoftwareSerial\SoftwareSerial.cpp.o] Error 1

and thus if I add

platform_packages = 
  framework-arduinoespressif8266@https://github.com/esp8266/Arduino.git
  mcspr/toolchain-xtensa@^5.100200.0

to the platformio.ini to use the latest core version from git, and a new compiler version that is needed, and I recompile, I get…

Processing esp12e (platform: espressif8266; board: esp12e; framework: arduino)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/esp12e.html
PLATFORM: Espressif 8266 (2.6.3) > Espressif ESP8266 ESP-12E
HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
PACKAGES:
 - framework-arduinoespressif8266 3.0.0-dev+sha.20413f8
 - tool-esptool 1.413.0 (4.13)
 - tool-esptoolpy 1.30000.201119 (3.0.0)
 - toolchain-xtensa 5.100200.201223 (10.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 46 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <EspSoftwareSerial> 6.11.6
Building in release mode
Generating .pio\build\esp12e\core\core_version.h
..
Linking .pio\build\esp12e\firmware.elf
Building .pio\build\esp12e\firmware.bin
Retrieving maximum program size .pio\build\esp12e\firmware.elf
Checking size .pio\build\esp12e\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [===       ]  34.6% (used 28352 bytes from 81920 bytes)
Flash: [===       ]  25.5% (used 266268 bytes from 1044464 bytes)
Creating BIN file ".pio\build\esp12e\firmware.bin" using "C:\Users\Max\.platformio\packages\framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910\bootloaders\eboot\eboot.elf" and ".pio\build\esp12e\firmware.elf"
===================================================================================================== [SUCCESS] Took 10.17 seconds =====================================================================================================

and thus the library is compilable again.

But as discussed, you should really use the standard release version of stuff and the ESPSoftwareSerial library contained within the Arduino-ESP8266 core (currently v6.8.5), which is usable without any special lib_deps or platform_packages directives – in fact to be sure, you should delete the .pio folder of the project to remove the newer version of the library for sure, after deleting it from lib_deps.

2 Likes

This was the most helpful thing I’ve come across in a week of searching - Thank you so much for your thoughtful, informative and in-depth explanation. Take out the extra dependency = everything compiles and works.

1 Like