Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By CheapB
#15410 I have been working on an UDP server sketch and it has been working so far. I tried to update my environment to get the UDP fixes in and now I am getting a reset every time i receive an UDP package.

Can someone try to compile this minimized example and send a package to the ESP to see if this is a general bug or just mine. obviously SSID and password needs to be set

Code: Select all
#include <ESP8266WiFi.h>
#include <WiFiUDP.h>

// WIFI
const char*   ssid        = "SSID";   
const char*   pass        = "PASSWORD";       
int           status      =  WL_IDLE_STATUS;

unsigned int  localPort  = 2390;     
byte          packetBuffer[512];
WiFiUDP       Udp;

char* recv;


void setup()
{
    Serial.begin(115200);
    while (!Serial)
    {
    }
 
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, pass);
    int tries=0;
     while (WiFi.status() != WL_CONNECTED)
    {
      delay(500);
      Serial.print(".");
      tries++;
    }
    Serial.println();
   
    IPAddress ip = WiFi.localIP();
    Udp.begin(localPort);
    Serial.print("Udp server started: ");
    Serial.println(ip);
    Serial.println(localPort);
       
}

void loop()
{
    int packetSize = Udp.parsePacket();
    if (packetSize)
    {
      int len = Udp.read(packetBuffer, 255);
      if (len > 0)
      {
        for (int i=1;i<=len;i++)
        {
          recv = recv + packetBuffer[i-1];
          Serial.print(recv);
        }
      }
    }
}


User avatar
By gerardwr
#15425 Compiled your sketch, and it resets after some received packets.

I would say the loop to print the received packet is not OK, due to the incorrect use of the recv variable. The variable recv is now declared as a pointer to a single char, I guess if you change recv to an array it could would.

If you replace your code to print the received packet with this it runs without problem:
Code: Select all       for (int i=1;i<=len;i++)
              Serial.print(packetBuffer[i-1]);
        }
User avatar
By CheapB
#15449
gerardwr wrote:Compiled your sketch, and it resets after some received packets.

I would say the loop to print the received packet is not OK, due to the incorrect use of the recv variable. The variable recv is now declared as a pointer to a single char, I guess if you change recv to an array it could would.

If you replace your code to print the received packet with this it runs without problem:
Code: Select all       for (int i=1;i<=len;i++)
              Serial.print(packetBuffer[i-1]);
        }


Yes, I was trying to provide the minimum code required to force the reset. I need the received UDP package in a string for further processing - hence the recv. How would you go about that?
User avatar
By gerardwr
#15468
CheapB wrote:Yes, I was trying to provide the minimum code required to force the reset. I need the received UDP package in a string for further processing - hence the recv. How would you go about that?


Have a look at my example here, maybe it helps:
http://www.esp8266.com/viewtopic.php?f=29&t=2451