jeelabs / esp-link

esp8266 wifi-serial bridge, outbound TCP, and arduino/AVR/LPC/NXP programmer
Other
2.84k stars 723 forks source link

UART framing error when making more than 3 rest.get requests in the setup #400

Closed stramike closed 6 years ago

stramike commented 6 years ago

Hey there! As long as I make 3 or less rest.get requests into the setup(), esp-link works very good! When I add the 4th rest.get request this is what I'm getting on the debug log:

25605> UART framing error (bad baud rate?) 27032> UART framing error (bad baud rate?) 27487> HTTP GET /mqtt: 200, 5ms, h=15424 28449> UART framing error (bad baud rate?) 28511> HTTP GET /console/text: 200, 3ms, h=15432 29534> HTTP GET /mqtt: 200, 3ms, h=15424 29867> UART framing error (bad baud rate?) 30282> Wifi check: mode=STA status=5 31286> UART framing error (bad baud rate?) 31581> HTTP GET /mqtt: 200, 2ms, h=15424 32368> HTTP GET /console/text: 200, 5ms, h=15432 32710> UART framing error (bad baud rate?) 33386> HTTP GET /console/text: 200, 8ms, h=15056 33393> HTTP GET /mqtt: 200, 7ms, h=15432 34134> UART framing error (bad baud rate?) 34368> HTTP GET /console/text: 200, 6ms, h=15432 35368> HTTP GET /console/text: 200, 3ms, h=15432 35377> HTTP GET /mqtt: 200, 2ms, h=15424 35556> UART framing error (bad baud rate?) 36982> UART framing error (bad baud rate?)

This is what I'm getting on the µC Console:

-ELCEL-eEL-EL-ELeeEL-EL-EL-EL-EL-EL-ELqeEL-EL-EL-EL-EL-EL

I'm making the rest.get requests as following:

       rest.get("/api/getVal/204");

char response204[BUFLEN]; memset(response204, 0, BUFLEN); uint16_t code204 = rest.waitResponse(response204, BUFLEN); if(code204 == HTTP_STATUS_OK){ Serial.println("ARDUINO: GET successful:"); Serial.println(response204);

      //CHECKING THE RESPONSE AND DO STUFF HERE
    } else {
      Serial.print("ARDUINO: GET failed: ");
      Serial.println(code204);
}
//SECOND REQUEST
    rest.get("/api/getVal/227");

    char response227[BUFLEN];
    memset(response227, 0, BUFLEN);
    uint16_t code227 = rest.waitResponse(response227, BUFLEN);
    if(code227 == HTTP_STATUS_OK){
      Serial.println("ARDUINO: GET successful:");
      Serial.println(response227);

        //CHECKING THE RESPONSE AND DO STUFF HERE
    } else {
      Serial.print("ARDUINO: GET failed: ");
      Serial.println(code227);
}
      //THIRD REQUEST
    rest.get("/api/getVal/252");

    char response252[BUFLEN];
    memset(response252, 0, BUFLEN);
    uint16_t code252 = rest.waitResponse(response252, BUFLEN);
    if(code252 == HTTP_STATUS_OK){
      Serial.println("ARDUINO: GET successful:");
      Serial.println(response252);

      //CHECKING THE RESPONSE AND DO STUFF HERE

    } else {
      Serial.print("ARDUINO: GET failed: ");
      Serial.println(code252);
}

//FOURTH REQUEST ...

Adding the fourth request results in this error. Removing the fourth request results in no error. What am I doing wrong?

Thanks for any help

stramike commented 6 years ago

After a weekend of testing and debugging turns out I was declaring too many global variables and printing too many stuff on the serial port and this causes the SRAM to crash or having very strange behaviours. This was hard to debug because compiling was ok and no warnings of any type was showed. After cleaning up some global variables and reducing the prints on the Serial port now everything is working just fine!