ESP_LOGE let the esp32 restat,when i use this fun(),want to know the reason?

User avatar
liankafohali
Posts: 4
Joined: Sat Mar 27, 2021 2:24 am

ESP_LOGE let the esp32 restat,when i use this fun(),want to know the reason?

Postby liankafohali » Sun May 23, 2021 3:13 pm

Code: Untitled.c Select all

void send_deviceData(){
//static const char *buff="test";
char buff[100]={"0"};
sprintf(buff,"{'DeviceId':%s,'DeviceName':%s,'Mode':%d,'Power':%d,"
"'ProNum':%s}",deviceData.DeviceId,deviceData.DeviceName,
deviceData.Mode,deviceData.Power,deviceData.ProNum);

while(1){
int err = send(sock, buff, strlen(buff), 0);
if (err < 0) {
ESP_LOGE(TAG, "Error occurred during sending: errno %d", errno);
}
/*
else{
//ESP_LOGE(TAG, "Send bytes success,content");
}
*/
vTaskDelay(2000/portTICK_RATE_MS);
}
vTaskDelete(send_devdahandle);

}
when i use xTaskCreate(send_deviceData, "send_deviceData", 1024, NULL,3, send_devdahandle) to create a new task,above is the task fun(),but when i remove this part of the code

Code: Untitled.c Select all

        
else{
//ESP_LOGE(TAG, "Send bytes success,content");
}
the problem disappeared.

Attachment is serial port printing information.
Attachments
snipaste_20210523_221802.png
snipaste_20210523_221802.png (144.88 KiB) Viewed 1900 times
snipaste_20210523_221754.png
snipaste_20210523_221754.png (287.2 KiB) Viewed 1900 times

chegewara
Posts: 2505
Joined: Wed Jun 14, 2017 9:00 pm

Re: ESP_LOGE let the esp32 restat,when i use this fun(),want to know the reason?

Postby chegewara » Sun May 23, 2021 3:59 pm

Its because task stack size is only 1024 bytes. If you are using any functions to print logs in task then it should be over 3 or 3.5kB (dont remember accurate value). Save is to set it to 4kB, as you may use task stack for other variables too.

Who is online

Users browsing this forum: Applebot, Google [Bot], Semrush [Bot] and 4 guests