3280b1e2382fd3746adc9e5991b1a5c3c001b86a
10 #include "interface.h"
12 struct task tasks
[MAXTASKS
];
16 memset(&tasks
, 0, sizeof(struct task
)*MAXTASKS
);
19 int task_register(void)
23 for(ct
= 0; ct
<MAXTASKS
; ct
++)
27 die("Trying to add too much tasks...");
29 memset(&tasks
[ct
], 0, sizeof(struct task
));
31 tasks
[ct
].interval
= read16();
33 tasks
[ct
].tlen
= read16();
34 debug("task interval: %d, length: %d\n",
35 tasks
[ct
].interval
, tasks
[ct
].tlen
);
37 if(tasks
[ct
].tlen
> MAXTASKSIZE
)
38 die("Task is too long: %d", tasks
[ct
].tlen
);
40 for(unsigned int i
= 0; i
<tasks
[ct
].tlen
; i
++){
41 tasks
[ct
].bc
[i
] = read_byte();
42 // debug("t[][%i]: 0x%02x %d", i,
43 // tasks[ct].bc[i], tasks[ct].bc[i]);
45 //Return the task number for later removal
46 debug("Received a task of length %d", tasks
[ct
].tlen
);
47 tasks
[ct
].used
= true;
48 tasks
[ct
].lastrun
= 0L;
57 void task_delete(void)
59 tasks
[read_byte()].used
= false;
62 struct task
*task_get(int num
)
64 return tasks
[num
].used
? &tasks
[num
] : NULL
;