2 * Copyright Droids Corporation (2009)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: commands.c,v 1.7 2009-04-24 19:30:41 zer0 Exp $
20 * Olivier MATZ <zer0@droids-corp.org>
26 #include <aversive/pgmspace.h>
27 #include <aversive/wait.h>
28 #include <aversive/error.h>
34 #include <parse_string.h>
38 /**********************************************************/
41 /* this structure is filled when cmd_reset is parsed successfully */
42 struct cmd_reset_result {
46 /* function called when cmd_reset is parsed successfully */
47 static void cmd_reset_parsed(__attribute__((unused)) void *parsed_result,
48 __attribute__((unused)) void *data)
53 prog_char str_reset_arg0[] = "reset";
54 parse_pgm_token_string_t cmd_reset_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_reset_result, arg0, str_reset_arg0);
56 prog_char help_reset[] = "Reset the board";
57 parse_pgm_inst_t cmd_reset = {
58 .f = cmd_reset_parsed, /* function to call */
59 .data = NULL, /* 2nd arg of func */
60 .help_str = help_reset,
61 .tokens = { /* token list, NULL terminated */
62 (prog_void *)&cmd_reset_arg0,
67 /**********************************************************/
70 /* this structure is filled when cmd_debug_frame is parsed successfully */
71 struct cmd_debug_frame_result {
76 /* function called when cmd_debug_frame is parsed successfully */
77 static void cmd_debug_frame_parsed(void *parsed_result,
78 __attribute__((unused)) void *data)
80 struct cmd_debug_frame_result *res = parsed_result;
81 if (!strcmp_P(res->arg1, PSTR("on")))
82 beacon_tsop.debug_frame = 1;
84 beacon_tsop.debug_frame = 0;
87 prog_char str_debug_frame_arg0[] = "debug_frame";
88 parse_pgm_token_string_t cmd_debug_frame_arg0 =
89 TOKEN_STRING_INITIALIZER(struct cmd_debug_frame_result,
90 arg0, str_debug_frame_arg0);
91 prog_char str_debug_frame_arg1[] = "on#off";
92 parse_pgm_token_string_t cmd_debug_frame_arg1 =
93 TOKEN_STRING_INITIALIZER(struct cmd_debug_frame_result,
94 arg1, str_debug_frame_arg1);
96 prog_char help_debug_frame[] = "Enable frame debug [debug_frame on|off]";
97 parse_pgm_inst_t cmd_debug_frame = {
98 .f = cmd_debug_frame_parsed, /* function to call */
99 .data = NULL, /* 2nd arg of func */
100 .help_str = help_debug_frame,
101 .tokens = { /* token list, NULL terminated */
102 (prog_void *)&cmd_debug_frame_arg0,
103 (prog_void *)&cmd_debug_frame_arg1,
108 /**********************************************************/
111 /* this structure is filled when cmd_debug_speed is parsed successfully */
112 struct cmd_debug_speed_result {
117 /* function called when cmd_debug_speed is parsed successfully */
118 static void cmd_debug_speed_parsed(void *parsed_result,
119 __attribute__((unused)) void *data)
121 struct cmd_debug_speed_result *res = parsed_result;
122 if (!strcmp_P(res->arg1, PSTR("on")))
123 beacon_tsop.debug_speed = 1;
125 beacon_tsop.debug_speed = 0;
128 prog_char str_debug_speed_arg0[] = "debug_speed";
129 parse_pgm_token_string_t cmd_debug_speed_arg0 =
130 TOKEN_STRING_INITIALIZER(struct cmd_debug_speed_result,
131 arg0, str_debug_speed_arg0);
132 prog_char str_debug_speed_arg1[] = "on#off";
133 parse_pgm_token_string_t cmd_debug_speed_arg1 =
134 TOKEN_STRING_INITIALIZER(struct cmd_debug_speed_result,
135 arg1, str_debug_speed_arg1);
137 prog_char help_debug_speed[] = "Enable speed debug [debug_speed on|off]";
138 parse_pgm_inst_t cmd_debug_speed = {
139 .f = cmd_debug_speed_parsed, /* function to call */
140 .data = NULL, /* 2nd arg of func */
141 .help_str = help_debug_speed,
142 .tokens = { /* token list, NULL terminated */
143 (prog_void *)&cmd_debug_speed_arg0,
144 (prog_void *)&cmd_debug_speed_arg1,
149 /**********************************************************/
152 parse_pgm_ctx_t main_ctx[] = {
155 (parse_pgm_inst_t *)&cmd_reset,
156 (parse_pgm_inst_t *)&cmd_debug_frame,
157 (parse_pgm_inst_t *)&cmd_debug_speed,