Page 1 of 1

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

Posted: Sun May 23, 2021 3:13 pm
by liankafohali

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.

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

Posted: Sun May 23, 2021 3:59 pm
by chegewara
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.