|
Hi,I'm trying to run 2 infinate loops at the same time. Is this possible?
this is an example of what I'm trying to do. thanks
#include <unistd.h>
#include <dmotor.h>
#include <dsensor.h>
#include <conio.h>
#include <time.h>
pid_t fun_a;
pid_t fun_c;
int go = 0;
int move = 0;
int input_a(int argc, char *argv[])
{
}
int pivot(int argc, char *argv[])
{
while(1<10)
{
while(ROTATION_1 != go)
{
if(ROTATION_1 < go)
{
motor_a_dir(fwd);
}
if(ROTATION_1 > go)
{
motor_a_dir(rev);
}
}
motor_a_dir(brake);
}
}
int rail(int argc, char *argv[])
{
while(1<10)
{
while(ROTATION_3 != move)
{
if(ROTATION_3 < move)
{
motor_c_dir(fwd);
}
if(ROTATION_3 > move)
{
motor_c_dir(rev);
}
}
motor_c_dir(brake);
}
}
int main(int argc, char *argv[])
{
ds_active(&SENSOR_3);
ds_rotation_on(&SENSOR_3);
ds_active(&SENSOR_1);
ds_rotation_on(&SENSOR_1);
ds_rotation_set(&SENSOR_3,0);
ds_rotation_set(&SENSOR_1,0);
msleep(100);
fun_a = execi(&pivot,0,0,9,
DEFAULT_STACK_SIZE);
fun_c = execi(&rail,0,0,10,
DEFAULT_STACK_SIZE);
go = 15;
msleep(400);
go = -15;
msleep(400);
go = 0;
msleep(400);
move = 2;
msleep(400);
move = -2;
msleep(400);
move = 0;
msleep(400);
kill(fun_c);
kill(fun_a);
return 0;
}
|
|
Message has 1 Reply: | | Re: code
|
| (...) [snip] (...) Can't see anything glaringly obvious, except you've used different priorities for your tasks. As they're infinite loops with no waiting, it's probably better to make their priorities equal. But the best way is probably to do all (...) (24 years ago, 19-Apr-01, to lugnet.robotics.rcx.legos)
|
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|