To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 2689
2688  |  2690
Subject: 
HOWTO Demo.c
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 9 Jul 2002 13:21:04 GMT
Viewed: 
2094 times
  
Need Help, if someone has faced such a problem or knows the fix
please do reply.

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.

I have also tried using a touch sensor instead of buttons for wake up
functions to switch
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



Message has 1 Reply:
  Re: HOWTO Demo.c
 
To solve your problems with demo.c, you sent me your source. There are some problems with it, but I think they are intresting enough to say something about them. The big problem you get with your program is caused by your main function: ---...--- (...) (22 years ago, 10-Jul-02, to lugnet.robotics.rcx.legos)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR