- //Check for new tasks
- if(input_available(fd))
- read_message(fd, fd);
- //Run tasks
- cyclestart = millis();
- for(ct = 0; ct<MAXTASKS; ct++){
- //See whether the task is even in use
- if((curtask = task_get(ct)) == NULL){
-// debug("Task %d not implemented\n", ct);
- continue;
- }
- //See whether the task interval has passed
- if(cyclestart-curtask->lastrun < curtask->interval){
-// debug("Task %d not scheduled\n", ct);
- continue;
- }
-#ifdef DEBUG
- printf("Current task to run: %d\n", ct);
- getchar();
-#endif
- run_task(curtask, fd);
- }
- debug("Waiting for 500ms\n");
- usleep(500000);
- debug("done waiting\n");
- write(fd, "\n", 1);