wdt reset in espconn_regist_recvcb callback

muris
Posts: 35
Joined: Fri Oct 24, 2014 7:25 pm
Location: Bosnia-Herzegovina
Contact:

wdt reset in espconn_regist_recvcb callback

Postby muris » Fri Feb 13, 2015 3:51 am

Is it normal that "wdt reset" happens when I do long-lasting work in callback function defined with espconn_regist_recvcb()?
My chip resets if it receives more data and if it didn't exit the espconn_regist_recvcb callback function just yet.

For example:

Code: Select all

// somewhere I declare callback for receiving TCP data...
espconn_regist_recvcb(pespconn, ctrl_platform_recv_cb);


Code: Select all

// this is the function that uses received data
static void ICACHE_FLASH_ATTR ctrl_platform_recv_cb(void *arg, char *pdata, unsigned short len)
{
   struct espconn *pespconn = arg;

   // Here I do stuff with data I received...
   // The WDT RESET happens when chip receives more data before exiting this function :(
}

Is that normal? If not, how can I fix it?

If that is normal, how can I do some long-lasting work with the chip (such as forwarding data to GSM modem and waiting for a GSM modem reply) while ESP is receiving next data? Perhaps you have an example for me :D

Thanks!

muris
Posts: 35
Joined: Fri Oct 24, 2014 7:25 pm
Location: Bosnia-Herzegovina
Contact:

Re: wdt reset in espconn_regist_recvcb callback

Postby muris » Fri Feb 13, 2015 4:52 pm

Can I fix this using new API function: espconn_recv_hold() and espconn_recv_unhold() like this? (I am at work, can't test this until tonight) :(

Code: Select all

// this is the function that uses received data
static void ICACHE_FLASH_ATTR ctrl_platform_recv_cb(void *arg, char *pdata, unsigned short len)
{
   struct espconn *pespconn = arg;

   espconn_recv_hold(pespconn); // HOLD RECEIVING TCP DATA

   // Here I do stuff with data I received...
   // The WDT RESET happens when chip receives more data before exiting this function :(

   espconn_recv_unhold(pespconn); // RESUME RECEIVING TCP DATA
}

:?:

ESP_Sprite
Posts: 25
Joined: Fri Oct 24, 2014 7:58 pm

Re: wdt reset in espconn_regist_recvcb callback

Postby ESP_Sprite » Fri Feb 13, 2015 5:34 pm

muris wrote:Can I fix this using new API function: espconn_recv_hold() and espconn_recv_unhold() like this? (I am at work, can't test this until tonight) :(


No, you can't: the watchdog will reset the IC if you spend too much time in a routine, regardless of what you do inside the routine.
As I've mentioned on the other forum: a way to handle this is to push the data into a ring buffer (and you can use espconn_recv_hold there if the buffer gets too full) and use either the interrupt from the uart or a seperate thread to get the data from the ring buffer and send it out.

muris
Posts: 35
Joined: Fri Oct 24, 2014 7:25 pm
Location: Bosnia-Herzegovina
Contact:

Re: wdt reset in espconn_regist_recvcb callback

Postby muris » Fri Feb 13, 2015 6:28 pm

Thanks a lot, I will do as you recommended.

Who is online

Users browsing this forum: No registered users and 8 guests