X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;ds=sidebyside;f=client%2Fmain.c;h=9de18bc54c3b03997797b8d4d9ce57dad5296123;hb=1827e72942a355fc90dcb4e0b93f68c98dc6eea5;hp=dc43de238e729df8e358d34fffd2d24c96813b26;hpb=58e526fc46f667943873621c9029d7e5dd7c158e;p=mTask.git diff --git a/client/main.c b/client/main.c index dc43de2..9de18bc 100644 --- a/client/main.c +++ b/client/main.c @@ -11,6 +11,7 @@ #include "interpret.h" #include "mTaskSymbols.h" #include "sds.h" +#include "spec.h" #include "task.h" #include "interface.h" @@ -55,9 +56,6 @@ void read_message(void) default: debug("Unknown message: %X", c); } - } else { - delay(1000); - printf("no input...\n"); } } @@ -77,21 +75,21 @@ void loop(void) // 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; - } - debug("Current task to run: %d", ct); - run_task(curtask); - curtask->lastrun = cyclestart; - if(curtask->interval == 0){ - curtask->used = false; - write_byte('m'); - write_byte('d'); - write_byte('\n'); + //interrupt task + if(is_interrupt_task(curtask) && had_interrupt(curtask)){ + debug("Interrupt task %d not implemented", ct); + run_task(curtask); + //Interval task, and interval passed + } else if(cyclestart-curtask->lastrun > curtask->interval){ + debug("Running interval task: %d", ct); + run_task(curtask); + + //Oneshot task, thus disable + if(curtask->interval == 0){ + curtask->used = false; + } + curtask->lastrun = cyclestart; } - write_byte('\n'); } } @@ -107,12 +105,12 @@ int main(int argc, char *argv[]){ setup(); sds_init(); task_init(); - debug("booting up"); + debug("sending device spec"); + spec_send(); while(true){ //Check for newetasks - write_byte('\n'); loop(); - delay(50); + delay(100); } return 0; }