Page 1 of 1

vTaskSuspendAll() and vTaskEndScheduler()

Posted: Mon Mar 30, 2020 11:08 am
by egoncalves
Hi

I have tried to use vTaskSuspendAll() and I get this :
-------------------------------------------------------------
I (11943) ctMain_Routine(): (((((((((((((((( LEDs GREEN ))))))))))))))))
C:/esp/esp-idf/components/freertos/queue.c:1452 (xQueueGenericReceive)- assert failed!
abort() was called at PC 0x400925c3 on core 0

ELF file SHA256: 2e68ae5fd3a5aed4595dc6ad5739557e2fc7c56b3c7ae1f704dad2fa68cc5c9f

Backtrace: 0x4008f279:0x3ffbb4b0 0x4008f5f1:0x3ffbb4d0 0x400925c3:0x3ffbb4f0 0x400822b9:0x3ffbb530 0x400d595c:0x3ffbb580 0x400d2994:0x3ffbb5b0 0x40091b19:0x3ffbb5d0

Rebooting...
I (321) cpu_start: Pro cpu up.
I (322) cpu_start: Application information:

I have tried to use vTaskEndScheduler() and I get this
(although this FreeRTOS function may only be available for the x86 Real Mode PC port) :
-------------------------------------------------------------
abort() was called at PC 0x40082caa on core 0
ELF file SHA256: 87ca977fac4ad4a259cf0f9e421ce27c8660546b18d425828a88105ff737546e
Backtrace: 0x4008f279:0x3ffbb160 0x4008f5f1:0x3ffbb180 0x40082caa:0x3ffbb1a0 0x40082dcd:0x3ffbb1d0 0x4014d60e:0x3ffbb1f0 0x4015063d:0x3ffbb500 0x400823c9:0x3ffbb530 0x400d595c:0x3ffbb580 0x400d2994:0x3ffbb5b0 0x40091b19:0x3ffbb5d0
Rebooting...
I (321) cpu_start: Pro cpu up.
I (322) cpu_start: Application information:


Would there be any explication for this behaviour, specially regarding vTaskSuspendAll() ?

Re: vTaskSuspendAll() and vTaskEndScheduler()

Posted: Mon Mar 30, 2020 11:23 am
by ESP_Dazz
Don't call blocking functions (e.g. xQueueReceive()) whilst the scheduler is suspended.

Re: vTaskSuspendAll() and vTaskEndScheduler()

Posted: Tue Mar 31, 2020 12:58 pm
by egoncalves
Hi

thanks for the reply.
I have tried that ( I was calling vTaskDelay() ) and it still resets... :(

Re: vTaskSuspendAll() and vTaskEndScheduler()

Posted: Tue Mar 31, 2020 7:00 pm
by ESP_Sprite
Can we see your code?

Re: vTaskSuspendAll() and vTaskEndScheduler()

Posted: Wed Apr 01, 2020 8:25 am
by ESP_Dazz
egoncalves wrote: Hi

thanks for the reply.
I have tried that ( I was calling vTaskDelay() ) and it still resets... :(
vTaskDelay() is also a blocking function.

Re: vTaskSuspendAll() and vTaskEndScheduler()

Posted: Wed Apr 01, 2020 1:08 pm
by egoncalves
This is the code:

The Delay_ms() is just a for loop. Can ESP_LOGI be called after vTaskSuspendAll() ?

Code: Select all

void Error ( const char *file, const char *function, uint32_t line, uint32_t error_number )
{
	/* Fatal Error, so initialise the minimum, inform the user, go to sleep */

	vTaskSuspendAll();

	for ( uint32_t i=0 ; i<2*30 ; i++ )
	{
		if (i%2==0)
			ESP_LOGI ( "", "\n--------------- ERROR -----\n  version:%s\n  file:%s\n  function:%s\n  line:%d\n  error:%d\n\n",
													VERSION, file,function,line,error_number );

		ct_Tasks_UpdateLEDs ( /*power LED*/ (i%2==0) ? CT_RGB_RED : CT_RGB_OFF,
					           /*state LED*/ (i%2==0) ? CT_RGB_OFF : CT_RGB_RED );

		ctVibro_Vibrate_Start ( VIBRO_UNHAPPY );
		Delay_ms ( 250 );
		ctVibro_Vibrate_Finish ();
		Delay_ms ( 250  );
	}

	PowerOff();
}

Re: vTaskSuspendAll() and vTaskEndScheduler()

Posted: Wed Apr 01, 2020 1:14 pm
by egoncalves
In fact would I would like to have is a FreeRTOS function that stops all the other tasks with the exception of the task calling that function.
Can the stop scheduler do this?
Of course I can keep all the handles of the tasks that I have created and suspend one by one, by this is much more work and a problem to maintain. If somebody in the future creates another task and is not aware of this then a bug is born.

Re: vTaskSuspendAll() and vTaskEndScheduler()

Posted: Thu Apr 02, 2020 8:05 am
by ESP_Sprite
Sorry, there is no such thing. If any, you can't shut down the idle tasks, so killing all tasks except the one running is no option. Killing the scheduler would stop you from doing anything that uses blocking functions, and your Error function seems to be full of them.

Re: vTaskSuspendAll() and vTaskEndScheduler()

Posted: Thu Apr 02, 2020 11:21 am
by egoncalves
In fact what I want is to suspend all the tasks with the exception of the one running (the one calling the function to suspend all the other tasks). The running task should continue to run.
I cannot find such call so I assume that I need to suspend all the tasks with the exception the one that is running... :D