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 / 2690
2689  |  2691
Subject: 
Re: HOWTO Demo.c
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 9 Jul 2002 13:28:10 GMT
Viewed: 
2227 times
  
I'm no expert, but I can try to help you figure it out.

Let's start with something simple.  What version of LegOS are you using?

How are you starting the 'task_swapper' task?

What is in the 'motor_driver' task?

At one time, when I was working with tasks, I seemed to have a problem where one task would take control, and not stop.  I think it may have been the priorities of the tasks.

Steve

----- Original Message -----
From: "Shehryar Shaheen" <shehryar.shaheen@ul.ie>
Date: Tue, 9 Jul 2002 13:21:04 GMT
To: lugnet.robotics.rcx.legos@lugnet.com
Subject: HOWTO Demo.c

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

--
_______________________________________________
Talk More, Pay Less with Net2Phone Direct(R), up to 1500 minutes free!
http://www.net2phone.com/cgi-bin/link.cgi?143



Message has 1 Reply:
  Re: HOWTO Demo.c
 
The code I have taken out of HOWTO.ps (URL) given at the end of the document under the name Demo.c I have fixed some compile time errors (like mismatching process ids in the kill call, the function for getting button state is dbutton() and not (...) (22 years ago, 9-Jul-02, to lugnet.robotics.rcx.legos)

2 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