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

commented Aug 29, 2019

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");

This comment has been minimized.

Copy link
@me-no-dev

me-no-dev Sep 5, 2019

Member

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

This comment has been minimized.

Copy link
@me-no-dev

me-no-dev Sep 5, 2019

Member

also unrelated change

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

This comment has been minimized.

Copy link
@me-no-dev

me-no-dev Sep 5, 2019

Member

so the issue is that readStringUntil timeouts

@paynterf

This comment has been minimized.

Copy link
Contributor Author

commented Sep 5, 2019

@stickbreaker

This comment has been minimized.

Copy link
Collaborator

commented Sep 5, 2019

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

This comment has been minimized.

Copy link
Contributor Author

commented Sep 6, 2019

@paynterf

This comment has been minimized.

Copy link
Contributor Author

commented Sep 6, 2019

Removed user-specific SSID/passphrase

@me-no-dev me-no-dev merged commit 4638628 into espressif:master Oct 2, 2019
21 checks passed
21 checks passed
Arduino 0 on ubuntu-latest
Details
Arduino 1 on ubuntu-latest
Details
Arduino 2 on ubuntu-latest
Details
Arduino 3 on ubuntu-latest
Details
Arduino 4 on ubuntu-latest
Details
Arduino 5 on ubuntu-latest
Details
Arduino 6 on ubuntu-latest
Details
Arduino 7 on ubuntu-latest
Details
Arduino 8 on ubuntu-latest
Details
Arduino 9 on ubuntu-latest
Details
Arduino 10 on ubuntu-latest
Details
Arduino 11 on ubuntu-latest
Details
Arduino 12 on ubuntu-latest
Details
Arduino 13 on ubuntu-latest
Details
Arduino 14 on ubuntu-latest
Details
Arduino on windows-latest
Details
Arduino on macOS-latest
Details
PlatformIO on ubuntu-latest
Details
PlatformIO on windows-latest
Details
PlatformIO on macOS-latest
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.