X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=client%2Fmain.c;h=f86beff79013463844d7bf19323c6c676559f389;hb=acd239b3f29e215ade0b63d5b26b6cf8e8ae0d63;hp=3388f2102e74e6ceb44b0ce0ee3d68283fb6ecc1;hpb=6c8939998c64aafb8cdfa40e52a227bf72767648;p=mTask.git diff --git a/client/main.c b/client/main.c index 3388f21..f86beff 100644 --- a/client/main.c +++ b/client/main.c @@ -17,6 +17,7 @@ #define MSG_GET_TASK 't' #define MSG_DEL_TASK 'd' #define MSG_SDS_SPEC 's' +#define MSG_SDS_DEL 'a' #define MSG_SDS_UPD 'u' void read_message(void) @@ -24,7 +25,6 @@ void read_message(void) //Find next task if(input_available()){ uint8_t c = read_byte(); - uint8_t ct; debug("Receiving input: %c %02x\n", c, c); switch(c){ case MSG_SDS_SPEC: @@ -36,16 +36,17 @@ void read_message(void) //TODO do something with the return value sds_update(); break; + case MSG_SDS_DEL: + debug("Receiving a delete SDS request"); + sds_delete(); + break; case MSG_DEL_TASK: debug("Receiving a delete task request"); task_delete(); break; case MSG_GET_TASK: debug("Receiving a task"); - ct = task_register(); - write_byte('t'); - write16(ct); - write_byte('\n'); + task_register(); break; case '\0': break; @@ -73,21 +74,19 @@ 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; + //Onshot task if(curtask->interval == 0){ + run_task(curtask); curtask->used = false; - write_byte('m'); - write_byte('d'); - write_byte('\n'); + //Interrupt task + } else if(curtask->interval & 32768){ + debug("Interrupt task %d not implemented", ct); + //Interval task, check if interval is passed + } else if(cyclestart-curtask->lastrun > curtask->interval){ + debug("Running interval task: %d", ct); + run_task(curtask); + curtask->lastrun = cyclestart; } - write_byte('\n'); } } @@ -103,10 +102,9 @@ int main(int argc, char *argv[]){ setup(); sds_init(); task_init(); - //debug("booting up"); + debug("booting up"); while(true){ //Check for newetasks -// debug("loop"); loop(); delay(50); }