Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1642 → Rev 1641

/advdemos/trunk/elastic/elastic.c
40,6 → 40,9
extern unsigned int usleep(unsigned int usec); // include file for this??
 
 
PID pidvec[10];
 
 
TASK elastic_test(void *arg) {
 
int y = (int)arg;
72,7 → 75,7
cprintf("%c", c);
n--;
}
} else if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) {
} else if (c) {
cprintf("%c", c);
buf[n++] = c;
}
87,7 → 90,6
{
ELASTIC_TASK_MODEL e;
PID el_pid;
PID pidvec[MAX_TASKS];
int quit = 0;
char buf[80];
int y;
123,7 → 125,7
puts_xy(0,16,LIGHTGRAY," ");
place(0,16);
 
myinput("(q)uit, (c)reate, (k)ill, force (p)eriod, set (e)lasticity? ", buf, 10);
myinput("(q)uit, (c)reate, (f)orce period, (d)elete? ", buf, 10);
for (y = 17; y <=24; y++) {
puts_xy(0,y,LIGHTGRAY," ");
}
156,13 → 158,13
elastic_task_def_arg(e, (void *)i);
el_pid = task_create("Elastic",elastic_test,&e,NULL);
if (el_pid == NIL) {
cprintf("task_create failed!\n");
cprintf("Cannot create task!\n");
} else {
pidvec[i] = el_pid;
task_activate(el_pid);
}
break;
case 'p':
case 'f':
myinput("Force period\nTask nbr: ", buf, 10);
nbr = atoi(buf);
if (nbr < 0 || nbr >= MAX_TASKS) {
176,12 → 178,10
}
myinput("T (ms): ", buf, 10);
T = 1000*atoi(buf);
if (ELASTIC_set_period(el_pid, T) == -1) {
cprintf("ELASTIC_set_period failed!\n");
}
ELASTIC_set_period(el_pid, T);
break;
case 'k':
myinput("Kill task\nTask nbr: ", buf, 10);
case 'd':
myinput("Delete task\nTask nbr: ", buf, 10);
nbr = atoi(buf);
if (nbr < 0 || nbr >= MAX_TASKS) {
cprintf("Invalid task number!\n");
195,24 → 195,6
task_kill(el_pid);
pidvec[nbr] = NIL;
break;
case 'e':
myinput("Set elasticity\nTask nbr: ", buf, 10);
nbr = atoi(buf);
if (nbr < 0 || nbr >= MAX_TASKS) {
cprintf("Invalid task number!\n");
break;
}
el_pid = pidvec[nbr];
if (el_pid == NIL) {
cprintf("Task doesn't exist!\n");
break;
}
myinput("E: ", buf, 10);
E = atoi(buf);
if (ELASTIC_set_E(el_pid, E) == -1) {
cprintf("ELASTIC_set_E failed!\n");
}
break;
default:
cprintf("Unknown command\n");
break;