Page 1 of 1

Restarting a task inside another task...

PostPosted: Sun Feb 04, 2007 9:18 am
by tja105
Hello,

I'm trying to do the following:

The idea is that I have a task that changes a pointer, SRAMprogram to point to a new part of a datastructure. I want to kill the task that is reading the datastructure, and restart it, so that its internal variables etc are re-initialised.

What I have is this:

for(;
{
OS_WaitBinSem(BINSEM_PWMFIN, OSNO_TIMEOUT, TASKWAVEFORM1);
if(change_program) {
routine_counter++;
if (SRAMroutine[routine_counter].program == END)
routine_counter=0;
OSDestroyTask(TASK_PWM_P);
SRAMprogram = SRAMroutine[routine_counter].program;
OSCreateTask(TaskPWM, TASK_PWM_P, PRIO_PWM);
change_program = 0;
}
else
SRAMroutine[routine_counter].tally++; // Increment the current program tally counter.

However when I try to compile it, I get:

../CDL_RTOS.c: In function `TaskWaveform':
../CDL_RTOS.c:129: error: `TaskPWM' undeclared (first use in this function)
../CDL_RTOS.c:129: error: (Each undeclared identifier is reported only once
../CDL_RTOS.c:129: error: for each function it appears in.)

the same OSCreateTask line works in main...

So, any ideas what I'm doing wrong, and / or is there a better approach to this problem?

Thank you in advance,

Tom.


Re: Restarting a task inside another task...

PostPosted: Mon Feb 05, 2007 1:09 am
by aek
You need to define a header file with your own function prototypes (including TaskPWM) and #include it in each source file that references said functions.

------------------


Re: Restarting a task inside another task...

PostPosted: Thu Feb 15, 2007 1:37 am
by tja105
Ahh yes, thank you for that. All the functions were in the same file, but it turned out that I'd put this task in the source file above the task that it referenced...

Thanks,

Tom.