|
I was able to fix the previous problem regarding the light sensor
Thank u Joseph Woolley for your reply.
I have another one
In the legOS Howto their is a demo code demo.c which has some
task switching examples
I am having trouble with the following piece of code
int task_swapper()
{
wait_event(&button_press_wakeup,BUTTON_VIEW); /*wait for PROGRAM button*/
wait_event(&button_release_wakeup,BUTTON_VIEW);/*wait for release*/
pid2=execi(&motor_driver, 0, NULL, 2, DEFAULT_STACK_SIZE);/*start motor
example*/
wait_event(&button_press_wakeup,BUTTON_VIEW); /*wait for PROGRAM button*/
wait_event(&button_release_wakeup,BUTTON_VIEW); /*wait for release*/
kill(pid2); /*kill motor example*/
motor_a_speed(off);
motor_c_speed(off);
pid3=execi(&light_sensor, 0, NULL, 3, DEFAULT_STACK_SIZE);/*start light
example*/
wait_event(&button_press_wakeup,BUTTON_VIEW); /*wait for PROGRAM button*/
wait_event(&button_release_wakeup,BUTTON_VIEW);/*wait for release*/
kill(pid3); /*kill light example*/
ds_passive(&SENSOR_2); /* turn off light sensor LED (passive mode again) */
pid4=execi(&touch_sensor, 0, NULL, 4, DEFAULT_STACK_SIZE);/*start touch
example*/
wait_event(&button_press_wakeup,BUTTON_VIEW); /*wait for PROGRAM button*/
wait_event(&button_release_wakeup,BUTTON_VIEW);/*wait for release*/
kill(pid4); /*kill touch example*/
lcd_clear();
sleep(1);
cputs("reset");
sleep(3);
return 0;
}
after the program is started with the run button and the view button is pressed
the first task (motor example pid2) starts and it works .
but if I press the view button a second time the RCX hangs.
Display gets stuck to what is already on it , no buttons work any more
including on/off.
So I have to take out the batteries and when I put them back I have to re
install the firmaware as well.
I have tried changing the button to BUTTON_PROGRAM but get the same result
changing it to BUTTON_RUN does not work any way because if run pressed once the
program is started the program stops.
between task but the same behaviour happens.( I have tried it quite a lot of
times)
I did a search on the mailing list too there was a post which mentioned that
the the HOWTO is old and in the newer legOS "the buttons have been incorporated
in the OS and perhaps there isn't a way to decuple them from the OS".
Could this be the reason or does somone have an idea.
Many Thanks
Shehryar
|
|
1 Message in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|