X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=client%2Fmain.c;h=720fd1a29de98395e45a04ea753667a6c81cdc14;hb=c518754bec4758cce7d899463f9c68612c3bf4e4;hp=dc43de238e729df8e358d34fffd2d24c96813b26;hpb=58e526fc46f667943873621c9029d7e5dd7c158e;p=mTask.git diff --git a/client/main.c b/client/main.c index dc43de2..720fd1a 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" @@ -19,6 +20,7 @@ #define MSG_SDS_SPEC 's' #define MSG_SDS_DEL 'a' #define MSG_SDS_UPD 'u' +#define MSG_SPEC 'c' void read_message(void) { @@ -48,16 +50,18 @@ void read_message(void) debug("Receiving a task"); task_register(); break; + case MSG_SPEC: + debug("Receiving a spec request"); + spec_send(); + break; case '\0': + debug("Server closed connection"); break; case '\n': break; default: debug("Unknown message: %X", c); } - } else { - delay(1000); - printf("no input...\n"); } } @@ -77,21 +81,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 +111,11 @@ int main(int argc, char *argv[]){ setup(); sds_init(); task_init(); - debug("booting up"); + debug("sending device spec"); while(true){ //Check for newetasks - write_byte('\n'); loop(); - delay(50); + delay(100); } return 0; }