Page 1 of 1
Switch Application Modes
Posted: Fri Jul 19, 2013 7:53 am
by eugenskt
Hello,
I know that the OSEK spec. does not support it and the EE_oo_start_os_flag flag protects to call Start0S twice. But the project I port app modes are switched during runtime :'(
Nevertheless, is there a possiblility to switch application modes during runtime? Maybe somehow hack the code? Write this protect flag constantly to 0?
What I should consider else?
Thanks!
Best regards, Eugen
Re: Switch Application Modes
Posted: Fri Jul 19, 2013 7:57 am
by paolo.gai
In that case, Application Modes are not what you are looking for! Don't get misleaded by the names
I suggest you just to implement an application internal state stored in RAM, with functions to access it, protected either by interrupt disabling or by Resources.
PJ
Re: Switch Application Modes
Posted: Fri Jul 19, 2013 8:36 am
by eugenskt
Unfortunately I really mean switching application modes during runtime.
My code looks like that:
First StartOS is called in the main operation and then in one of the tasks is this state machine implemented.
Code: Select all
switch(state)
{
case 0:
StartOS(Mode0);
break;
case 1:
StartOS(Mode1);
break;
...
...
}
Re: Switch Application Modes
Posted: Fri Jul 19, 2013 9:07 am
by paolo.gai
I do not suggest to write things in that way...
take a look at the "Resource" example available for many microcontrollers in the ERIKA templates. It implements a way to have different application modes at startup. (grep for ModeIncrement / ModeDecrement in the examples)
The main problem is that StartOS in the AUTOSAR specification does not return, so it must be the last thing called.
In the original ERIKA implementation we let the StartOS terminate (OSEK/VDX allows that), but the newer implementations by default do not return.
PJ
Re: Switch Application Modes
Posted: Fri Jul 19, 2013 1:00 pm
by eugenskt
I would never do it that way ;)
But I work on an existing project hence I have to find a way to make it work.
Back to this protect flag. When I remove this flag in StartOS and initialize some ram variables again it could work, or?
Eugen
Re: Switch Application Modes
Posted: Fri Jul 19, 2013 2:25 pm
by paolo.gai
well I did not understand...
he idea of the demo is that at the beginning of the application you discover somehow in which mode you are (it could be by reading buttons, gpios, or other means), and then initialize StartOS as the last thing... I do not understand what's wrong with that...
anyway, application runtime modes should not be handled using OSEK/VDX application modes... so a global variables and funcions accessing to that variable I guess should be the best choice...
PJ
Re: Switch Application Modes
Posted: Fri Jul 19, 2013 5:13 pm
by eugenskt
You are right!
BUT(sorry for that :) ) problem is the task and the code in the task already exists and I do not know why it is implemented in that way that app modes are switched during runtime. What I'm only doing is changing existing OS to Erika OS.
Unfortunately the resource example is not my use case.
Ok, thanks for your help and good inputs!
I will play a bit with my idea. But I think I at the end I have to remove the switched and just activate tasks and alarms directly.
Eugen
Re: Switch Application Modes
Posted: Fri Jul 19, 2013 5:19 pm
by paolo.gai
Ok...
but note that:
startos can't be called inside a task
changing the appmode is simple (just change the variable
maybe you'll need to hack the StartOS in a way to let it o again the startup initialization specified in autostart. But that should be simple enough...
PJ