#include "interpret.h"
#include "mTaskSymbols.h"
#include "sds.h"
+#include "spec.h"
#include "task.h"
#include "interface.h"
#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)
//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:
//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;
// 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');
}
}
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;
}