6 #include <HardwareSerial.h>
15 struct task tasks
[MAXTASKS
];
19 memset(&tasks
, 0, sizeof(struct task
)*MAXTASKS
);
26 for(ct
= 0; ct
<MAXTASKS
; ct
++)
30 die("Trying to add too much tasks...\n");
32 memset(&tasks
[ct
], 0, sizeof(struct task
));
34 tasks
[ct
].interval
= read16();
36 tasks
[ct
].tlen
= read16();
38 if(tasks
[ct
].tlen
> MAXTASKSIZE
)
39 die("Task is too long: %d\n", tasks
[ct
].tlen
);
41 for(unsigned int i
= 0; i
<tasks
[ct
].tlen
; i
++){
42 tasks
[ct
].bc
[i
] = read_byte();
43 debug("t[][%i]: 0x%02x %d\n", 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\n", tasks
[ct
].tlen
);
48 tasks
[ct
].used
= true;
54 tasks
[read_byte()].used
= false;
57 struct task
*task_get(int num
)
59 return tasks
[num
].used
? &tasks
[num
] : NULL
;