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 / 2207
2206  |  2208
Subject: 
Re: threads
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Tue, 15 Jan 2002 19:08:07 GMT
Viewed: 
1824 times
  
Hi again, I'm now totally stuck with this problem. I've spent all day at it,
stepping through the
code line by line with key presses. I've marked the point that the code
appears to hang in
left_control_task (). Someone please help, please.
Thanks
Mike


int bumper_task • (int argc, char *argv[])
{
long int
random_delay;

while (1)
{
// • wait for bumper to be hit (and released to
debounce)
wait_event (&bumper_hit, • 0);
msleep (250);
wait_event
(&bumper_release, 0);
// hit an object so • kill all other threads and stop
kill
(left_thread);
kill • (right_thread);
kill (speed_thread);
stop_motors
();

// back • up
motor_a_speed (200);
motor_b_speed • (200);
motor_c_speed
(200);
motor_a_dir (rev);
motor_b_dir • (rev);
motor_c_dir (rev);
msleep
(500);

// turn a random • amount
motor_a_dir (fwd);
random_delay • =
random()/1000000;
msleep(random_delay);
stop_motors ();

// • restart
threads and motors

******** SEEMS TO BE THE NEXT 2 LINES THAT HANG • IT
********

left_thread = execi (&left_control_task, 0, 0, • 3,
DEFAULT_STACK_SIZE);
right_thread = execi (&right_control_task, 0, 0, • 3,
DEFAULT_STACK_SIZE);
speed_thread = execi (&speed_target_task, 0, 0, • 1,
DEFAULT_STACK_SIZE);
start_motors_full ();
}

return 0;
} // end • of
bumper_task ()

int left_control_task (int argc, char *argv[])
{
// dummy • code to keep
it simple till main structure correct
int count =
0;

********************* GETS THIS FAR STEPPING THROUGH ************

for (count = • 255; count > 100; count--
)
{
motor_a_speed (count);
lcd_int • (count);
msleep
(100);
}
stop_motors ();



return 0;
} // • end of left_control_task ()




Message has 2 Replies:
  Re: threads
 
some suggestions: 1) random_delay = random()/1000000; LegOS uses 16 bit integers, meaning the largest value an integer can have is something like 65535. The above statement is meaningless 2) (...) If you kill a thread, make sure it's still a valid (...) (23 years ago, 15-Jan-02, to lugnet.robotics.rcx.legos)
  Re: threads - bug in the firmware?
 
Hi again I have now totally stripped down my code to a minimum and I am still having problems with the code hanging up. I can see nowhere where there can be a fault. I am a long way from being an expert, but is it possible there is a bug in the (...) (23 years ago, 16-Jan-02, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  threads
 
Hi, I'm struggling to get threads working (in a simple motor speed matching program), the code just keeps hanging up. I've isolated the problem to when I restart the threads after killing them if a bumper is hit in the bumper_task() function. The (...) (23 years ago, 14-Jan-02, to lugnet.robotics.rcx.legos)

18 Messages in This Thread:





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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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