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