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

  1. void send_deviceData(){
  2.     //static const char *buff="test";
  3.     char buff[100]={"0"};
  4.     sprintf(buff,"{'DeviceId':%s,'DeviceName':%s,'Mode':%d,'Power':%d,"
  5.     "'ProNum':%s}",deviceData.DeviceId,deviceData.DeviceName,
  6.     deviceData.Mode,deviceData.Power,deviceData.ProNum);
  7.  
  8.     while(1){
  9.         int err = send(sock, buff, strlen(buff), 0);
  10.         if (err < 0) {
  11.             ESP_LOGE(TAG, "Error occurred during sending: errno %d", errno);
  12.         }
  13.         /*
  14.         else{
  15.             //ESP_LOGE(TAG, "Send bytes success,content");
  16.         }
  17.         */
  18.     vTaskDelay(2000/portTICK_RATE_MS);
  19.     }
  20.     vTaskDelete(send_devdahandle);
  21.  
  22. }
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
  1.        
  2. else{
  3. //ESP_LOGE(TAG, "Send bytes success,content");
  4.  }
the problem disappeared.

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

chegewara
Posts: 2375
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: alifepretend, Bing [Bot] and 137 guests