Espeasy: Build in Arduino IDE fails in new module _Plugin_Helper_serial.ino

Created on 10 Jan 2019  路  7Comments  路  Source: letscontrolit/ESPEasy

Summarize of the problem/feature request

When trying to compile in the Arduino IDE starting with the mega-20190106 release or later, the build fails on the newly added module called _Plugin_Helper_serial.ino, The recent prior builds up to and including mega-20181231 compile as expected. It is complaining about ESPEasySerialType being undeclared, but it seems to be in ESPEasySerial.h so I'm missing what the issue is.

Related error messages:

_Plugin_Helper_serial:3:47: error: 'ESPeasySerialType' has not been declared
static String serialHelper_getSerialTypeLabel(ESPeasySerialType::serialtype serType) {
^

_Plugin_Helper_serial:30:1: error: 'ESPeasySerialType' does not name a type
ESPeasySerialType::serialtype serialHelper_getSerialType(struct EventStruct *event) {
^

M:\arduinoESPEasy_mega\arduino-1.8.8\portable\sketchbook\ESPEasy_Plugin_Helper_serial.ino: In function 'String serialHelper_getSerialTypeLabel(ESPeasySerialType::serialtype)':

_Plugin_Helper_serial:3:84: error: 'String serialHelper_getSerialTypeLabel(ESPeasySerialType::serialtype)' redeclared as different kind of symbol

static String serialHelper_getSerialTypeLabel(ESPeasySerialType::serialtype serType) {
^

_Plugin_Helper_serial:3:15: error: previous declaration of 'String serialHelper_getSerialTypeLabel'
static String serialHelper_getSerialTypeLabel(ESPeasySerialType::serialtype serType) {
^

M:\arduinoESPEasy_mega\arduino-1.8.8\portable\sketchbook\ESPEasy_Plugin_Helper_serial.ino: In function 'void serialHelper_webformLoad(EventStruct*)':

_Plugin_Helper_serial:49:55: error: no match for call to '(String) (ESPeasySerialType::serialtype&)'
option = serialHelper_getSerialTypeLabel(serType);

Build

Most helpful comment

@Barracuda09
These include guards should always be present in .h files, or else you will get undefined behavior when a .h file is included more than once.

I will look into the way the .h files for the ESPeasySerial are included.
Perhaps adding a list of these includes is also good to do at the start of the ESPEasy-Globals.h, since that one is included in ESPEasy.ino almost at the start.

Just have to make sure it is only included when needed, or hope the linker will not include it when not used.

All 7 comments

@ZericE had the same issue... as a workaround you can try to add #include <ESPeasySerial.h>to your Custom.h if you're using it, or alternatively to ESPEasy-Globals.h. The issue seems to be related to the order of the includes, not sure exactly why though...

I have seen that some include files do not have any 'include guards'. I don't know if this is intentional or it is part of the design.

But here are some file lacking these guards:
WebServer_Rules.h ESPEasyWiFiEvent.h and ESPEasyWiFiEvent.h

@Barracuda09
These include guards should always be present in .h files, or else you will get undefined behavior when a .h file is included more than once.

I will look into the way the .h files for the ESPeasySerial are included.
Perhaps adding a list of these includes is also good to do at the start of the ESPEasy-Globals.h, since that one is included in ESPEasy.ino almost at the start.

Just have to make sure it is only included when needed, or hope the linker will not include it when not used.

@clumsy-stefan

@ZericE had the same issue... as a workaround you can try to add #include <ESPeasySerial.h>to your Custom.h if you're using it, or alternatively to ESPEasy-Globals.h. The issue seems to be related to the order of the includes, not sure exactly why though...

Good suggestion, putting the #include in Custom.h did indeed work. It's certainly a satisfactory work around. Arduino IDE can be weird in how it handles some things so it's more an issue with that IDE.

I haven't used platform.io in quite a few months and figured it would need a lot of updating and tweaking to get it working again with ESP Easy. Arduino IDE seemed a good choice for a quick compile.

If you're on a Linux environment. or run Ubuntu on Windows (from the Microsoft store), you can also run the build script from the tools directory.
That's the one I often use for a build and I run it also on Ubuntu for Windows ;)

@ZericE had the same issue... as a workaround you can try to add #include <ESPeasySerial.h>to your Custom.h if you're using it, or alternatively to ESPEasy-Globals.h. The issue seems to be related to the order of the includes, not sure exactly why though...

I try this but now I have this error below
compile ESPeasySerial lib from Release mega-20190212

F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp: In member function 'void ESPeasySerial::end()': F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp:61:16: error: 'class SoftwareSerial' has no member named 'end' _swserial->end(); ^ F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp: In member function 'bool ESPeasySerial::hasOverrun()': F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp:224:23: error: 'class SoftwareSerial' has no member named 'overflow' return _swserial->overflow(); ^ F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp:226:21: error: 'class HardwareSerial' has no member named 'hasOverrun' return getHW()->hasOverrun(); ^ F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp: In member function 'void ESPeasySerial::startDetectBaudrate()': F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp:301:12: error: 'class HardwareSerial' has no member named 'startDetectBaudrate' getHW()->startDetectBaudrate(); ^ F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp: In member function 'long unsigned int ESPeasySerial::testBaudrate()': F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp:312:19: error: 'class HardwareSerial' has no member named 'testBaudrate' return getHW()->testBaudrate(); ^ F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp: In member function 'long unsigned int ESPeasySerial::detectBaudrate(time_t)': F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp:323:19: error: 'class HardwareSerial' has no member named 'detectBaudrate' return getHW()->detectBaudrate(timeoutMillis); ^ F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp: In member function 'bool ESPeasySerial::listen()': F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp:336:23: error: 'class SoftwareSerial' has no member named 'listen' return _swserial->listen(); ^ F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp: In member function 'bool ESPeasySerial::isListening()': F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp:345:23: error: 'class SoftwareSerial' has no member named 'isListening' return _swserial->isListening(); ^ F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp: In member function 'bool ESPeasySerial::stopListening()': F:\arduino-1.6.12P230\libraries\ESPEasySerial\ESPeasySerial.cpp:354:23: error: 'class SoftwareSerial' has no member named 'stopListening' return _swserial->stopListening(); ^

I have changed a lot yesterday in the code.
The problem you're now facing is related to a different version of the SoftwareSerial library.
One of the changes I made yesterday, was to re-introduce the old version of the SoftwareSerial library we used up-to 2018-12-31.
The newer one was causing issues with data corruption.

So I will now merge those changes so you can try again.
Also I will try to compile myself using the Arduino IDE and add some section to the documentation, since these are continuously returning questions regarding how to build, what versions to use, etc.
So better to properly document than explain it multiple times and also loose a lot of time from you, the users.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jroux1 picture jroux1  路  6Comments

Wandmalfarbe picture Wandmalfarbe  路  5Comments

jobst picture jobst  路  5Comments

TD-er picture TD-er  路  3Comments

ghtester picture ghtester  路  3Comments