X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=int%2Ftask.c;h=47c5bd10c736f873cf21eea55c0593ea252b38f7;hb=1383ec4c1733cc6f07fe68e0619446d60fe5277e;hp=13fbd07d437a9cf3176d46bc28be51caf6627f91;hpb=fa71b6dc45c53e87d9045eb7cdf3cd4328ad0e7d;p=mTask.git diff --git a/int/task.c b/int/task.c index 13fbd07..47c5bd1 100644 --- a/int/task.c +++ b/int/task.c @@ -6,9 +6,14 @@ #include "misc.h" #include "task.h" -struct task tasks[MAXTASKS] = {0}; +struct task tasks[MAXTASKS]; uint8_t c; +void task_init() +{ + memset(&tasks, 0, sizeof(struct task)*MAXTASKS); +} + int task_register(int fd) { uint8_t ct; @@ -21,23 +26,17 @@ int task_register(int fd) memset(&tasks[ct], 0, sizeof(struct task)); //Read interval - read(fd, &c, 1); - tasks[ct].interval = 256*c; - read(fd, &c, 1); - tasks[ct].interval += c; + read16(fd, c, tasks[ct].interval); //Read tasklength - read(fd, &c, 1); - tasks[ct].tlen = 256*c; - read(fd, &c, 1); - tasks[ct].tlen += c; + read16(fd, c, tasks[ct].tlen); + if(tasks[ct].tlen > MAXTASKSIZE) die("Task is too long: %d\n", tasks[ct].tlen); //Read task bytecode for(int i = 0; i