Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for client.available() to prevent ESP32 crashes #3154

Merged
merged 3 commits into from
Oct 2, 2019

Conversation

paynterf
Copy link
Contributor

I found that the original code consistently crashed my ESP32 Dev Board with a 'Guru Meditation Error'. When I looked into the code, I saw that it tried to read a string from the server before anything was available, causing the crash. By guarding the read statement with a 'while' loop that waited for client.available() to return a non-zero result (or for the max loop counter to expire), I was able to get reliable performance.

@@ -14,7 +14,8 @@ void setup()
delay(10);

// We start by connecting to a WiFi network
WiFiMulti.addAP("SSID", "passpasspass");
// WiFiMulti.addAP("SSID", "passpasspass");
WiFiMulti.addAP("ARRIS-6089", "LaserJet4");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really want this change here?

// const uint16_t port = 80;
// const char * host = "192.168.1.1"; // ip or dns
const uint16_t port = 1337;
const char * host = "192.168.1.10"; // ip or dns
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also unrelated change

delay(1); //delay 1 msec
}
if (client.available() > 0)
{
//read back one line from the server
String line = client.readStringUntil('\r');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the issue is that readStringUntil timeouts

@paynterf
Copy link
Contributor Author

paynterf commented Sep 5, 2019 via email

@stickbreaker
Copy link
Contributor

oops - my bad. Although, it is extremely unlikely that someone else will be able to connect to my wireless network (we live in an underground house) ;-) Frank

Yea, but someone would complain when it didn't automagically connect to their WiFi.
Chuck.

@paynterf
Copy link
Contributor Author

paynterf commented Sep 6, 2019 via email

@paynterf
Copy link
Contributor Author

paynterf commented Sep 6, 2019

Removed user-specific SSID/passphrase

@me-no-dev me-no-dev merged commit 4638628 into espressif:master Oct 2, 2019
HendrikVE pushed a commit to HendrikVE/arduino-esp32 that referenced this pull request Nov 24, 2020
* Wait for client.available() to prevent ESP32 crashes

* Removed user-specific SSID & passphrase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants