i allocate memory for an array of structs, this is my code:
Code: Select all
size_t taskAmount;
object *tasks = parseJSON(subbuff,sizeof(subbuff),&taskAmount);
os_free(tasks);
without that code my application works fine, but if i use it, after a certain time my application crashes and i get this text written on the serial terminal:
Fatal exception 9(LoadStoreAlignmentCause):
epc1=0x4024035f, epc2=0x00000000, epc3=0x00000000, excvaddr=0x4010045b, depc=0x00000000
I think that this error might have to do with too less available memory? This is how i allocate the memory in the parseJSON function:
Code: Select all
object *retObj = (object*)os_zalloc(sizeof(object) * 10);
How can i fix this error?
Edit: If i remove this line of code:
Code: Select all
code os_free(tasks)
my code works for ~30 minutes.
But then the esp8266 won't connect to the network again, for example, this is my user_dns_found function (which is called by user_dns_check callback):
Code: Select all
LOCAL void ICACHE_FLASH_ATTR
user_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
{
struct espconn *pespconn = (struct espconn *)arg;
if (ipaddr == NULL)
{
os_printf("user_dns_found NULL \r\n");
return;
}
//dns got ip
os_printf("user_dns_found %d.%d.%d.%d \r\n",
*((uint8 *)&ipaddr->addr), *((uint8 *)&ipaddr->addr + 1),
*((uint8 *)&ipaddr->addr + 2), *((uint8 *)&ipaddr->addr + 3));
if (tcp_server_ip.addr == 0 && ipaddr->addr != 0)
{
// dns succeed, create tcp connection
tcp_server_ip.addr = ipaddr->addr;
os_memcpy(pespconn->proto.tcp->remote_ip, &ipaddr->addr, 4); // remote ip of tcp server which get by dns
pespconn->proto.tcp->remote_port = 80; // remote port of tcp server
pespconn->proto.tcp->local_port = espconn_port(); //local port of ESP8266
espconn_regist_connectcb(pespconn, user_tcp_connect_cb); // register connect callback
espconn_regist_reconcb(pespconn, user_tcp_recon_cb); // register reconnect callback as error handler
espconn_connect(pespconn); // tcp connect
}
}
Normally the esp8266 would connect and call a function but instead it just prints
E:M 1584
user_dns_found 1.2.3.4
What does E:M 1584 mean and why does the esp8266 stop to connect to the server?