void read_message()
{
//Find next task
- uint8_t c = read_byte();
- debug("Receiving input: %c\n", c);
- switch(c){
- case MSG_SDS_SPEC:
- debug("Receiving an sds\n");
- sds_register();
- break;
- case MSG_SDS_UPD:
- debug("Receiving an sds\n");
- //TODO do something with the return value
- sds_update();
- break;
- case MSG_DEL_TASK:
- debug("Receiving a delete task request\n");
- task_delete();
- break;
- case MSG_GET_TASK:
- debug("Receiving a task\n");
- c = task_register();
- break;
- case '\n':
- break;
- default:
- debug("Unknown message: %X\n", c);
+ if(input_available()){
+ uint8_t c = read_byte();
+ debug("Receiving input: %c\n", c);
+ switch(c){
+ case MSG_SDS_SPEC:
+ debug("Receiving an sds");
+ sds_register();
+ break;
+ case MSG_SDS_UPD:
+ debug("Receiving an sds");
+ //TODO do something with the return value
+ sds_update();
+ break;
+ case MSG_DEL_TASK:
+ debug("Receiving a delete task request");
+ task_delete();
+ break;
+ case MSG_GET_TASK:
+ debug("Receiving a task");
+ task_register();
+ break;
+ case '\0':
+ break;
+ case '\n':
+ break;
+ default:
+ debug("Unknown message: %X", c);
+ }
}
}
long cyclestart;
struct task *curtask;
- if(input_available())
- read_message();
+ read_message();
//Run tasks
cyclestart = millis();
// debug("Task %d not scheduled\n", ct);
continue;
}
- debug("Current task to run: %d\n", ct);
+ debug("Current task to run: %d", ct);
run_task(curtask);
curtask->lastrun = cyclestart;
write_byte('\n');
}
#ifdef STM32F767xx
-char s[128] = "";
int main1(void){
#else
int main(int argc, char *argv[]){
gargc = argc;
gargv = argv;
#endif
- debug("booting up\r\n");
//Initialize systems
setup();
sds_init();
task_init();
- write_byte('\n');
+ //debug("booting up");
+ int i = 0;
while(true){
//Check for new tasks
- debug("loop\r\n");
+// debug("loop\r\n");
loop();
delay(100);
+ i = (i + 1) % 3;
+ if(i == 0){
+ SET_LED_RED;
+ RESET_LED_BLUE;
+ RESET_LED_GREEN;
+ } else if(i == 1){
+ RESET_LED_RED;
+ SET_LED_BLUE;
+ RESET_LED_GREEN;
+ } else if(i == 2){
+ RESET_LED_RED;
+ RESET_LED_BLUE;
+ SET_LED_GREEN;
+ }
}
return 0;
}