printf -> logs in xbee_user
[protos/xbee-avr.git] / commands.c
index ffcd918..3448ded 100644 (file)
@@ -753,18 +753,18 @@ static void cmd_range_parsed(void *parsed_result, void *data)
                        return;
                }
                range_cur_count = range_count;
-               callout_init(&range_event, range_cb, NULL, 0);
-               callout_schedule(&xbeeboard.mainloop_cm,
-                       &range_event, 0); /* immediate */
+               callout_init(&range_event, range_cb, NULL, LOW_PRIO);
                range_running = 1;
+               callout_schedule(&xbeeboard.intr_cm,
+                       &range_event, 0); /* immediate */
        }
        else if (!strcmp(res->action, "end")) {
                if (range_running == 0) {
                        printf_P(PSTR("not running\r\n"));
                        return;
                }
+               callout_stop(&xbeeboard.intr_cm, &range_event);
                range_running = 0;
-               callout_stop(&xbeeboard.mainloop_cm, &range_event);
        }
 }
 
@@ -1003,11 +1003,11 @@ static void cmd_monitor_parsed(void *parsed_result, void *data)
                        printf_P(PSTR("no regs to be monitored\r\n"));
                        return;
                }
-               callout_init(&monitor_event, monitor_cb, NULL, 0);
-               callout_schedule(&xbeeboard.mainloop_cm,
-                       &monitor_event, 0); /* immediate */
+               callout_init(&monitor_event, monitor_cb, NULL, 1);
                monitor_running = 1;
                monitor_current = LIST_FIRST(&xbee_monitor_list);
+               callout_schedule(&xbeeboard.intr_cm,
+                       &monitor_event, 0); /* immediate */
                printf_P(PSTR("monitor cb: %S %s\r\n"),
                         monitor_current->desc,
                         monitor_current->atcmd);
@@ -1018,8 +1018,8 @@ static void cmd_monitor_parsed(void *parsed_result, void *data)
                        printf_P(PSTR("not running\r\n"));
                        return;
                }
+               callout_stop(&xbeeboard.intr_cm, &monitor_event);
                monitor_running = 0;
-               callout_stop(&xbeeboard.mainloop_cm, &monitor_event);
        }
 }
 
@@ -1182,7 +1182,7 @@ static void cmd_monitor_del_parsed(void *parsed_result, void *data)
        monitor_count --;
        if (monitor_count == 0) {
                printf_P(PSTR("Disable monitoring, no more event\r\n"));
-               callout_stop(&xbeeboard.mainloop_cm, &monitor_event);
+               callout_stop(&xbeeboard.intr_cm, &monitor_event);
                monitor_running = 0;
                return;
        }
@@ -1288,94 +1288,6 @@ const parse_inst_t PROGMEM cmd_raw = {
        },
 };
 
-/* ************* */
-
-/* this structure is filled when cmd_dump is parsed successfully */
-struct cmd_dump_result {
-       fixed_string_t dump;
-       fixed_string_t onoff;
-};
-
-/* function called when cmd_dump is parsed successfully */
-static void cmd_dump_parsed(void *parsed_result, void *data)
-{
-       struct cmd_dump_result *res = parsed_result;
-
-       (void)data;
-       if (!strcmp(res->onoff, "on"))
-               xbee_hexdump = 1;
-       else
-               xbee_hexdump = 0;
-}
-
-const char PROGMEM str_dump[] = "dump";
-const char PROGMEM str_dump_onoff[] = "on#off";
-
-const parse_token_string_t PROGMEM cmd_dump_dump =
-       TOKEN_STRING_INITIALIZER(struct cmd_dump_result, dump,
-                                str_dump);
-
-const parse_token_string_t PROGMEM cmd_dump_onoff =
-       TOKEN_STRING_INITIALIZER(struct cmd_dump_result, onoff,
-                                str_dump_onoff);
-
-const char PROGMEM help_dump[] = "enable/disable hexdump of received packets";
-
-const parse_inst_t PROGMEM cmd_dump = {
-       .f = cmd_dump_parsed,  /* function to call */
-       .data = NULL,      /* 2nd arg of func */
-       .help_str = help_dump,
-       .tokens = {        /* token list, NULL terminated */
-               (PGM_P)&cmd_dump_dump,
-               (PGM_P)&cmd_dump_onoff,
-               NULL,
-       },
-};
-
-/* ************* */
-
-/* this structure is filled when cmd_debug is parsed successfully */
-struct cmd_debug_result {
-       fixed_string_t debug;
-       fixed_string_t onoff;
-};
-
-/* function called when cmd_debug is parsed successfully */
-static void cmd_debug_parsed(void *parsed_result, void *data)
-{
-       struct cmd_debug_result *res = parsed_result;
-
-       (void)data;
-       if (!strcmp(res->onoff, "on"))
-               xbee_debug = 1;
-       else
-               xbee_debug = 0;
-}
-
-const char PROGMEM str_debug[] = "debug";
-const char PROGMEM str_debug_onoff[] = "on#off";
-
-const parse_token_string_t PROGMEM cmd_debug_debug =
-       TOKEN_STRING_INITIALIZER(struct cmd_debug_result, debug,
-                                str_debug);
-
-const parse_token_string_t PROGMEM cmd_debug_onoff =
-       TOKEN_STRING_INITIALIZER(struct cmd_debug_result, onoff,
-                                str_debug_onoff);
-
-const char PROGMEM help_debug[] = "enable/disable additionnal debug";
-
-const parse_inst_t PROGMEM cmd_debug = {
-       .f = cmd_debug_parsed,  /* function to call */
-       .data = NULL,      /* 2nd arg of func */
-       .help_str = help_debug,
-       .tokens = {        /* token list, NULL terminated */
-               (PGM_P)&cmd_debug_debug,
-               (PGM_P)&cmd_debug_onoff,
-               NULL,
-       },
-};
-
 /**********************************************************/
 
 /* this structure is filled when cmd_baudrate is parsed successfully */
@@ -1937,8 +1849,6 @@ const parse_ctx_t PROGMEM main_ctx[] = {
        &cmd_monitor_del,
        &cmd_ping,
        &cmd_raw,
-       &cmd_dump,
-       &cmd_debug,
        &cmd_baudrate,
        &cmd_beep,
        &cmd_servo_set,