3d9a64444259b15a17064ac9560fa12ea8cdd7b7
10 #include "interface.h"
12 struct task tasks
[MAXTASKS
];
16 memset(&tasks
, 0, sizeof(struct task
)*MAXTASKS
);
19 int task_register(void)
24 for(ct
= 0; ct
<MAXTASKS
; ct
++)
28 die("Trying to add too much tasks...");
30 memset(&tasks
[ct
], 0, sizeof(struct task
));
32 tasks
[ct
].interval
= read16();
34 tasks
[ct
].tlen
= read16();
35 debug("task interval: %d, length: %d\n",
36 tasks
[ct
].interval
, tasks
[ct
].tlen
);
38 if(tasks
[ct
].tlen
> MAXTASKSIZE
)
39 die("Task is too long: %d", tasks
[ct
].tlen
);
41 for(i
= 0; i
<tasks
[ct
].tlen
; i
++){
42 tasks
[ct
].bc
[i
] = read_byte();
43 // debug("t[][%i]: 0x%02x %d", i,
44 // tasks[ct].bc[i], tasks[ct].bc[i]);
46 //Return the task number for later removal
47 debug("Received a task of length %d", tasks
[ct
].tlen
);
48 tasks
[ct
].used
= true;
49 tasks
[ct
].lastrun
= 0L;
54 void task_delete(void)
56 tasks
[read_byte()].used
= false;
59 struct task
*task_get(int num
)
61 return tasks
[num
].used
? &tasks
[num
] : NULL
;