- 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);
- }
-}
-
-void usage(FILE *o, char *arg0){
- fprintf(o, "Usage: %s [opts]\n\nOptions\n"
- "-p PORT Custom port number, default: 8123\n" , arg0);
-}
-
-void setup()
-{
-#ifdef STM32F767xx
-#else
- int port = 8123, opti = 1;
- //Register signal handler
- if(signal(SIGINT, killHandler) == SIG_ERR){
- die("Couldn't register signal handler...\n");
- }
- if(signal(SIGTERM, killHandler) == SIG_ERR){
- die("Couldn't register signal handler...\n");
- }
- //Command line arguments
- while(opti < *argc){
- if(strcmp((*argv)+opti, "-h") == 0){
- usage(stdout, argv[0]);
- exit(EXIT_SUCCESS);
- } else if(strcmp(argv[opti], "-p") == 0 && opti+1<*argc){
- port = atoi(argv[++opti]);
- if(port < 1)
- die("Port numbers are > 1\n");
- } else {
- usage(stderr, argv[0]);
- exit(EXIT_FAILURE);
+ 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);