X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=client%2Fmain.c;h=012e06269d9587e5c698300d4b3d96a86cfc8051;hb=be3f747f775c05facb8a34cf0baba523401b88fb;hp=90f6e5fe2c6a427e7346aae9bfa7dc46b907d4cc;hpb=55afb005ced3bba3813163596cdc7288a318a3c2;p=mTask.git diff --git a/client/main.c b/client/main.c index 90f6e5f..012e062 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" @@ -49,6 +50,7 @@ void read_message(void) task_register(); break; case '\0': + die("Server closed connection"); break; case '\n': break; @@ -74,21 +76,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'); } } @@ -104,12 +106,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 -// debug("loop"); loop(); - delay(50); + delay(100); } return 0; }