vTaskSuspendAll() and vTaskEndScheduler()

egoncalves
Posts: 22
Joined: Thu Jan 23, 2020 9:31 am

vTaskSuspendAll() and vTaskEndScheduler()

Postby egoncalves » Mon Mar 30, 2020 11:08 am

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() ?

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: vTaskSuspendAll() and vTaskEndScheduler()

Postby ESP_Dazz » Mon Mar 30, 2020 11:23 am

Don't call blocking functions (e.g. xQueueReceive()) whilst the scheduler is suspended.

egoncalves
Posts: 22
Joined: Thu Jan 23, 2020 9:31 am

Re: vTaskSuspendAll() and vTaskEndScheduler()

Postby egoncalves » Tue Mar 31, 2020 12:58 pm

Hi

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

ESP_Sprite
Posts: 8999
Joined: Thu Nov 26, 2015 4:08 am

Re: vTaskSuspendAll() and vTaskEndScheduler()

Postby ESP_Sprite » Tue Mar 31, 2020 7:00 pm

Can we see your code?

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: vTaskSuspendAll() and vTaskEndScheduler()

Postby ESP_Dazz » Wed Apr 01, 2020 8:25 am

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.

egoncalves
Posts: 22
Joined: Thu Jan 23, 2020 9:31 am

Re: vTaskSuspendAll() and vTaskEndScheduler()

Postby egoncalves » Wed Apr 01, 2020 1:08 pm

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();
}

egoncalves
Posts: 22
Joined: Thu Jan 23, 2020 9:31 am

Re: vTaskSuspendAll() and vTaskEndScheduler()

Postby egoncalves » Wed Apr 01, 2020 1:14 pm

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.

ESP_Sprite
Posts: 8999
Joined: Thu Nov 26, 2015 4:08 am

Re: vTaskSuspendAll() and vTaskEndScheduler()

Postby ESP_Sprite » Thu Apr 02, 2020 8:05 am

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.

egoncalves
Posts: 22
Joined: Thu Jan 23, 2020 9:31 am

Re: vTaskSuspendAll() and vTaskEndScheduler()

Postby egoncalves » Thu Apr 02, 2020 11:21 am

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

Who is online

Users browsing this forum: Bing [Bot] and 111 guests