882baa4d3d234ace19b1f465ffa8694212428f6f
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();
35 if(tasks
[ct
].tlen
> MAXTASKSIZE
)
36 die("Task is too long: %d", tasks
[ct
].tlen
);
38 for(unsigned int i
= 0; i
<tasks
[ct
].tlen
; i
++){
39 tasks
[ct
].bc
[i
] = read_byte();
40 debug("t[][%i]: 0x%02x %d", i
,
41 tasks
[ct
].bc
[i
], tasks
[ct
].bc
[i
]);
43 //Return the task number for later removal
44 debug("Received a task of length %d", tasks
[ct
].tlen
);
45 tasks
[ct
].used
= true;
46 tasks
[ct
].lastrun
= 0L;
51 void task_delete(void)
53 tasks
[read_byte()].used
= false;
56 struct task
*task_get(int num
)
58 return tasks
[num
].used
? &tasks
[num
] : NULL
;