Closed
Description
Hi,
I can fairly reproducibly crash the following code:
#include "Arduino.h"
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
#include <WiFiUdp.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#include <ArduinoOTA.h>
WiFiServer server(2001);
WiFiClient client;
// RX on GPIO14. GPIO12 is ignored for now.
SoftwareSerial swSer(14, 12, false, 128);
void setup()
{
Serial.begin(9600);
WiFi.persistent(false);
WiFi.begin("xx", "xx");
WiFi.mode(WIFI_STA);
ArduinoOTA.begin();
server.begin();
swSer.begin(9600);
}
unsigned int last_send = 0;
char buf[512];
int buflen = 0;
// this will run fine forever until you connect on the tcp socket and then
// it crashes fairly soon afterwards
void loop()
{
ArduinoOTA.handle();
if (server.hasClient())
client = server.available();
if (swSer.available())
{
char d = swSer.read();
buf[buflen++] = d;
Serial.print(d);
}
// if buffer is getting full, or its been 50ms since send, empty the buffer
if (buflen > 0 && (buflen > 500 || millis() - last_send > 50))
{
buf[buflen] = '\0';
if (client.connected())
client.print(buf);
Serial.print(buf);
buflen = 0;
last_send = millis();
}
}
SoftwareSerial is from https://github.com/plerup/espsoftwareserial
Connect the serial output of some other compatible device (I just use another ESP spitting out some debug information in a loop) to GPIO14 and wait :)
As per the comment in there, if you don't connect to the tcp socket at all then it doesn't crash. But once you connect, the crash comes reasonably quickly (can take a bit of time, depending on the serial datarate I think).
Any idea whats going on here? Some sort of interrupt clash?
There is no exception printed or anything, the ESP just hangs and then reboots. I don't even see a wdt message, oddly.
Metadata
Metadata
Assignees
Labels
No labels