ESP8266 Unexpected Crash or Reset
-
I had problems with the ESP8266 Gateway crashing and resetting every few minutes with an "Exception(28)".
After lots of searching, I found it was a problem in the 'core driver' in the MySensors library (1.51).
The Fix:
- Open the "MyMessage.cpp" file in your "...\Arduino\libraries\MySensors" folder.
- Search for the "MyMessage& MyMessage::set(const char* value)" function (WARNING: there are several similar names).
- Comment the existing code out and add replacement as illustrated below.
/* COMMENT OUT THE OLD FUNCTION MyMessage& MyMessage::set(const char* value) { uint8_t length = min(strlen(value), MAX_PAYLOAD); miSetLength(length); miSetPayloadType(P_STRING); strncpy(data, value, length); return *this; } */ /* INSERT THE FOLLOWING IN ITS PLACE */ MyMessage& MyMessage::set(const char* value) { uint8_t length = value == NULL ? 0 : min(strlen(value), MAX_PAYLOAD); miSetLength(length); miSetPayloadType(P_STRING); if (length) { strncpy(data, value, length); } // null terminate string data[length] = 0; return *this; }If you compile any MySensors ESP8266 project, the library will be rebuilt and with a bit of luck the crashes will vanish.
Paul
-
I had problems with the ESP8266 Gateway crashing and resetting every few minutes with an "Exception(28)".
After lots of searching, I found it was a problem in the 'core driver' in the MySensors library (1.51).
The Fix:
- Open the "MyMessage.cpp" file in your "...\Arduino\libraries\MySensors" folder.
- Search for the "MyMessage& MyMessage::set(const char* value)" function (WARNING: there are several similar names).
- Comment the existing code out and add replacement as illustrated below.
/* COMMENT OUT THE OLD FUNCTION MyMessage& MyMessage::set(const char* value) { uint8_t length = min(strlen(value), MAX_PAYLOAD); miSetLength(length); miSetPayloadType(P_STRING); strncpy(data, value, length); return *this; } */ /* INSERT THE FOLLOWING IN ITS PLACE */ MyMessage& MyMessage::set(const char* value) { uint8_t length = value == NULL ? 0 : min(strlen(value), MAX_PAYLOAD); miSetLength(length); miSetPayloadType(P_STRING); if (length) { strncpy(data, value, length); } // null terminate string data[length] = 0; return *this; }If you compile any MySensors ESP8266 project, the library will be rebuilt and with a bit of luck the crashes will vanish.
Paul
-
@AffordableTech So, concluding, the set-method will crash when called with a null-pointer.
Does your sketch call it with a null-pointer, or does the MySensors library pass it somewhere along the road?Yes, I believe it happens when a client connects with no message, it causes a memory fault (loss); after several such connections the stack is exhausted and the ESP8266 crashes (and reboots).
This cured my crashes, but I'm sure there are many other possibilities for an Exception(28).
-
Yes, as I gathered, but I have too many sensors on 1.5.1 and don't want to upgrade them to 2.0 while its not an official release.
I posted it because there are probably others on 1.5.1 with the problem, but can't find a fix.
Cheers...
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login