code 2010
[aversive.git] / projects / microb2010 / cobboard / commands_cobboard.c
1 /*
2  *  Copyright Droids Corporation (2009)
3  * 
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.
8  *
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.
13  *
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
17  *
18  *  Revision : $Id: commands_cobboard.c,v 1.6 2009-11-08 17:25:00 zer0 Exp $
19  *
20  *  Olivier MATZ <zer0@droids-corp.org> 
21  */
22
23 #include <stdio.h>
24 #include <string.h>
25
26 #include <aversive/pgmspace.h>
27 #include <aversive/wait.h>
28 #include <aversive/error.h>
29
30 #include <ax12.h>
31 #include <uart.h>
32 #include <pwm_ng.h>
33 #include <clock_time.h>
34 #include <spi.h>
35
36 #include <pid.h>
37 #include <quadramp.h>
38 #include <control_system_manager.h>
39 #include <blocking_detection_manager.h>
40
41 #include <rdline.h>
42 #include <parse.h>
43 #include <parse_string.h>
44 #include <parse_num.h>
45
46 #include "../common/i2c_commands.h"
47 #include "main.h"
48 #include "sensor.h"
49 #include "cmdline.h"
50 #include "state.h"
51 #include "i2c_protocol.h"
52 #include "actuator.h"
53 #include "spickle.h"
54
55 extern uint16_t state_debug;
56
57 struct cmd_event_result {
58         fixed_string_t arg0;
59         fixed_string_t arg1;
60         fixed_string_t arg2;
61 };
62
63
64 /* function called when cmd_event is parsed successfully */
65 static void cmd_event_parsed(void *parsed_result, __attribute__((unused)) void *data)
66 {
67         u08 bit=0;
68
69         struct cmd_event_result * res = parsed_result;
70         
71         if (!strcmp_P(res->arg1, PSTR("all"))) {
72                 bit = DO_ENCODERS | DO_CS | DO_BD | DO_POWER;
73                 if (!strcmp_P(res->arg2, PSTR("on")))
74                         cobboard.flags |= bit;
75                 else if (!strcmp_P(res->arg2, PSTR("off")))
76                         cobboard.flags &= bit;
77                 else { /* show */
78                         printf_P(PSTR("encoders is %s\r\n"), 
79                                  (DO_ENCODERS & cobboard.flags) ? "on":"off");
80                         printf_P(PSTR("cs is %s\r\n"), 
81                                  (DO_CS & cobboard.flags) ? "on":"off");
82                         printf_P(PSTR("bd is %s\r\n"), 
83                                  (DO_BD & cobboard.flags) ? "on":"off");
84                         printf_P(PSTR("power is %s\r\n"), 
85                                  (DO_POWER & cobboard.flags) ? "on":"off");
86                 }
87                 return;
88         }
89
90         if (!strcmp_P(res->arg1, PSTR("encoders")))
91                 bit = DO_ENCODERS;
92         else if (!strcmp_P(res->arg1, PSTR("cs"))) {
93                 bit = DO_CS;
94         }
95         else if (!strcmp_P(res->arg1, PSTR("bd")))
96                 bit = DO_BD;
97         else if (!strcmp_P(res->arg1, PSTR("power")))
98                 bit = DO_POWER;
99
100
101         if (!strcmp_P(res->arg2, PSTR("on")))
102                 cobboard.flags |= bit;
103         else if (!strcmp_P(res->arg2, PSTR("off"))) {
104                 if (!strcmp_P(res->arg1, PSTR("cs"))) {
105                         pwm_ng_set(LEFT_SPICKLE_PWM, 0);
106                         pwm_ng_set(RIGHT_SPICKLE_PWM, 0);
107                         pwm_ng_set(SHOVEL_PWM, 0);
108                 }
109                 cobboard.flags &= (~bit);
110         }
111         printf_P(PSTR("%s is %s\r\n"), res->arg1, 
112                       (bit & cobboard.flags) ? "on":"off");
113 }
114
115 prog_char str_event_arg0[] = "event";
116 parse_pgm_token_string_t cmd_event_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg0, str_event_arg0);
117 prog_char str_event_arg1[] = "all#encoders#cs#bd#power";
118 parse_pgm_token_string_t cmd_event_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg1, str_event_arg1);
119 prog_char str_event_arg2[] = "on#off#show";
120 parse_pgm_token_string_t cmd_event_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg2, str_event_arg2);
121
122 prog_char help_event[] = "Enable/disable events";
123 parse_pgm_inst_t cmd_event = {
124         .f = cmd_event_parsed,  /* function to call */
125         .data = NULL,      /* 2nd arg of func */
126         .help_str = help_event,
127         .tokens = {        /* token list, NULL terminated */
128                 (prog_void *)&cmd_event_arg0, 
129                 (prog_void *)&cmd_event_arg1, 
130                 (prog_void *)&cmd_event_arg2, 
131                 NULL,
132         },
133 };
134
135 /**********************************************************/
136 /* Color */
137
138 /* this structure is filled when cmd_color is parsed successfully */
139 struct cmd_color_result {
140         fixed_string_t arg0;
141         fixed_string_t color;
142 };
143
144 /* function called when cmd_color is parsed successfully */
145 static void cmd_color_parsed(void *parsed_result, __attribute__((unused)) void *data)
146 {
147         struct cmd_color_result *res = (struct cmd_color_result *) parsed_result;
148         if (!strcmp_P(res->color, PSTR("red"))) {
149                 cobboard.our_color = I2C_COLOR_RED;
150         }
151         else if (!strcmp_P(res->color, PSTR("green"))) {
152                 cobboard.our_color = I2C_COLOR_GREEN;
153         }
154         printf_P(PSTR("Done\r\n"));
155 }
156
157 prog_char str_color_arg0[] = "color";
158 parse_pgm_token_string_t cmd_color_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_color_result, arg0, str_color_arg0);
159 prog_char str_color_color[] = "green#red";
160 parse_pgm_token_string_t cmd_color_color = TOKEN_STRING_INITIALIZER(struct cmd_color_result, color, str_color_color);
161
162 prog_char help_color[] = "Set our color";
163 parse_pgm_inst_t cmd_color = {
164         .f = cmd_color_parsed,  /* function to call */
165         .data = NULL,      /* 2nd arg of func */
166         .help_str = help_color,
167         .tokens = {        /* token list, NULL terminated */
168                 (prog_void *)&cmd_color_arg0, 
169                 (prog_void *)&cmd_color_color, 
170                 NULL,
171         },
172 };
173
174 /**********************************************************/
175 /* State1 */
176
177 /* this structure is filled when cmd_state1 is parsed successfully */
178 struct cmd_state1_result {
179         fixed_string_t arg0;
180         fixed_string_t arg1;
181 };
182
183 /* function called when cmd_state1 is parsed successfully */
184 static void cmd_state1_parsed(void *parsed_result,
185                               __attribute__((unused)) void *data)
186 {
187         struct cmd_state1_result *res = parsed_result;
188         struct i2c_cmd_cobboard_set_mode command;
189
190         if (!strcmp_P(res->arg1, PSTR("init"))) {
191                 state_init();
192                 return;
193         }
194
195         if (!strcmp_P(res->arg1, PSTR("manual")))
196                 command.mode = I2C_COBBOARD_MODE_MANUAL;
197         else if (!strcmp_P(res->arg1, PSTR("harvest")))
198                 command.mode = I2C_COBBOARD_MODE_HARVEST;
199         state_set_mode(&command);
200 }
201
202 prog_char str_state1_arg0[] = "cobboard";
203 parse_pgm_token_string_t cmd_state1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg0, str_state1_arg0);
204 prog_char str_state1_arg1[] = "init#manual";
205 parse_pgm_token_string_t cmd_state1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state1_result, arg1, str_state1_arg1);
206
207 prog_char help_state1[] = "set cobboard mode";
208 parse_pgm_inst_t cmd_state1 = {
209         .f = cmd_state1_parsed,  /* function to call */
210         .data = NULL,      /* 2nd arg of func */
211         .help_str = help_state1,
212         .tokens = {        /* token list, NULL terminated */
213                 (prog_void *)&cmd_state1_arg0, 
214                 (prog_void *)&cmd_state1_arg1, 
215                 NULL,
216         },
217 };
218
219 /**********************************************************/
220 /* State2 */
221
222 /* this structure is filled when cmd_state2 is parsed successfully */
223 struct cmd_state2_result {
224         fixed_string_t arg0;
225         fixed_string_t arg1;
226         fixed_string_t arg2;
227 };
228
229 /* function called when cmd_state2 is parsed successfully */
230 static void cmd_state2_parsed(void *parsed_result,
231                               __attribute__((unused)) void *data)
232 {
233         struct cmd_state2_result *res = parsed_result;
234         struct i2c_cmd_cobboard_set_mode command;
235         uint8_t side;
236
237         if (!strcmp_P(res->arg2, PSTR("left")))
238                 side = I2C_LEFT_SIDE;
239         else if (!strcmp_P(res->arg2, PSTR("right")))
240                 side = I2C_RIGHT_SIDE;
241
242         if (!strcmp_P(res->arg1, PSTR("yyy"))) {
243         }
244         else if (!strcmp_P(res->arg1, PSTR("xxx"))) {
245         }
246
247
248         state_set_mode(&command);
249 }
250
251 prog_char str_state2_arg0[] = "cobboard";
252 parse_pgm_token_string_t cmd_state2_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg0, str_state2_arg0);
253 prog_char str_state2_arg1[] = "xxx";
254 parse_pgm_token_string_t cmd_state2_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg1, str_state2_arg1);
255 prog_char str_state2_arg2[] = "left#right";
256 parse_pgm_token_string_t cmd_state2_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_state2_result, arg2, str_state2_arg2);
257
258 prog_char help_state2[] = "set cobboard mode";
259 parse_pgm_inst_t cmd_state2 = {
260         .f = cmd_state2_parsed,  /* function to call */
261         .data = NULL,      /* 2nd arg of func */
262         .help_str = help_state2,
263         .tokens = {        /* token list, NULL terminated */
264                 (prog_void *)&cmd_state2_arg0, 
265                 (prog_void *)&cmd_state2_arg1, 
266                 (prog_void *)&cmd_state2_arg2, 
267                 NULL,
268         },
269 };
270
271 /**********************************************************/
272 /* State3 */
273
274 /* this structure is filled when cmd_state3 is parsed successfully */
275 struct cmd_state3_result {
276         fixed_string_t arg0;
277         fixed_string_t arg1;
278         uint8_t arg2;
279 };
280
281 /* function called when cmd_state3 is parsed successfully */
282 static void cmd_state3_parsed(void *parsed_result, 
283                               __attribute__((unused)) void *data)
284 {
285         struct cmd_state3_result *res = parsed_result;
286         struct i2c_cmd_cobboard_set_mode command;
287
288         if (!strcmp_P(res->arg1, PSTR("xxx"))) {
289                 /* xxx = res->arg2 */
290         }
291         else if (!strcmp_P(res->arg1, PSTR("yyy"))) {
292         }
293         state_set_mode(&command);
294 }
295
296 prog_char str_state3_arg0[] = "cobboard";
297 parse_pgm_token_string_t cmd_state3_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state3_result, arg0, str_state3_arg0);
298 prog_char str_state3_arg1[] = "xxx";
299 parse_pgm_token_string_t cmd_state3_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_state3_result, arg1, str_state3_arg1);
300 parse_pgm_token_num_t cmd_state3_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_state3_result, arg2, UINT8);
301
302 prog_char help_state3[] = "set cobboard mode";
303 parse_pgm_inst_t cmd_state3 = {
304         .f = cmd_state3_parsed,  /* function to call */
305         .data = NULL,      /* 2nd arg of func */
306         .help_str = help_state3,
307         .tokens = {        /* token list, NULL terminated */
308                 (prog_void *)&cmd_state3_arg0, 
309                 (prog_void *)&cmd_state3_arg1, 
310                 (prog_void *)&cmd_state3_arg2, 
311                 NULL,
312         },
313 };
314
315 /**********************************************************/
316 /* State_Machine */
317
318 /* this structure is filled when cmd_state_machine is parsed successfully */
319 struct cmd_state_machine_result {
320         fixed_string_t arg0;
321 };
322
323 /* function called when cmd_state_machine is parsed successfully */
324 static void cmd_state_machine_parsed(__attribute__((unused)) void *parsed_result,
325                                      __attribute__((unused)) void *data)
326 {
327         state_machine();
328 }
329
330 prog_char str_state_machine_arg0[] = "state_machine";
331 parse_pgm_token_string_t cmd_state_machine_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_machine_result, arg0, str_state_machine_arg0);
332
333 prog_char help_state_machine[] = "launch state machine";
334 parse_pgm_inst_t cmd_state_machine = {
335         .f = cmd_state_machine_parsed,  /* function to call */
336         .data = NULL,      /* 2nd arg of func */
337         .help_str = help_state_machine,
338         .tokens = {        /* token list, NULL terminated */
339                 (prog_void *)&cmd_state_machine_arg0, 
340                 NULL,
341         },
342 };
343
344 /**********************************************************/
345 /* State_Debug */
346
347 /* this structure is filled when cmd_state_debug is parsed successfully */
348 struct cmd_state_debug_result {
349         fixed_string_t arg0;
350         uint8_t on;
351 };
352
353 /* function called when cmd_state_debug is parsed successfully */
354 static void cmd_state_debug_parsed(void *parsed_result,
355                                    __attribute__((unused)) void *data)
356 {
357         struct cmd_state_debug_result *res = parsed_result;
358         state_debug = res->on;
359 }
360
361 prog_char str_state_debug_arg0[] = "state_debug";
362 parse_pgm_token_string_t cmd_state_debug_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_state_debug_result, arg0, str_state_debug_arg0);
363 parse_pgm_token_num_t cmd_state_debug_on = TOKEN_NUM_INITIALIZER(struct cmd_state_debug_result, on, UINT8);
364
365 prog_char help_state_debug[] = "Set debug timer for state machine";
366 parse_pgm_inst_t cmd_state_debug = {
367         .f = cmd_state_debug_parsed,  /* function to call */
368         .data = NULL,      /* 2nd arg of func */
369         .help_str = help_state_debug,
370         .tokens = {        /* token list, NULL terminated */
371                 (prog_void *)&cmd_state_debug_arg0, 
372                 (prog_void *)&cmd_state_debug_on, 
373                 NULL,
374         },
375 };
376
377 /**********************************************************/
378 /* Servo_Door */
379
380 /* this structure is filled when cmd_servo_door is parsed successfully */
381 struct cmd_servo_door_result {
382         fixed_string_t arg0;
383         fixed_string_t arg1;
384 };
385
386 /* function called when cmd_servo_door is parsed successfully */
387 static void cmd_servo_door_parsed(void *parsed_result,
388                                     __attribute__((unused)) void *data)
389 {
390         struct cmd_servo_door_result *res = parsed_result;
391         if (!strcmp_P(res->arg1, PSTR("open")))
392                 servo_door_open();
393         else if (!strcmp_P(res->arg1, PSTR("closed")))
394                 servo_door_close();
395 }
396
397 prog_char str_servo_door_arg0[] = "door";
398 parse_pgm_token_string_t cmd_servo_door_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_servo_door_result, arg0, str_servo_door_arg0);
399 prog_char str_servo_door_arg1[] = "open#closed";
400 parse_pgm_token_string_t cmd_servo_door_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_servo_door_result, arg1, str_servo_door_arg1);
401
402 prog_char help_servo_door[] = "Servo door function";
403 parse_pgm_inst_t cmd_servo_door = {
404         .f = cmd_servo_door_parsed,  /* function to call */
405         .data = NULL,      /* 2nd arg of func */
406         .help_str = help_servo_door,
407         .tokens = {        /* token list, NULL terminated */
408                 (prog_void *)&cmd_servo_door_arg0, 
409                 (prog_void *)&cmd_servo_door_arg1, 
410                 NULL,
411         },
412 };
413
414 /**********************************************************/
415 /* Servo_Carry */
416
417 /* this structure is filled when cmd_servo_carry is parsed successfully */
418 struct cmd_servo_carry_result {
419         fixed_string_t arg0;
420         fixed_string_t arg1;
421 };
422
423 /* function called when cmd_servo_carry is parsed successfully */
424 static void cmd_servo_carry_parsed(void *parsed_result,
425                                     __attribute__((unused)) void *data)
426 {
427         struct cmd_servo_carry_result *res = parsed_result;
428         if (!strcmp_P(res->arg1, PSTR("open")))
429                 servo_carry_open();
430         else if (!strcmp_P(res->arg1, PSTR("closed")))
431                 servo_carry_close();
432 }
433
434 prog_char str_servo_carry_arg0[] = "carry";
435 parse_pgm_token_string_t cmd_servo_carry_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_servo_carry_result, arg0, str_servo_carry_arg0);
436 prog_char str_servo_carry_arg1[] = "open#closed";
437 parse_pgm_token_string_t cmd_servo_carry_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_servo_carry_result, arg1, str_servo_carry_arg1);
438
439 prog_char help_servo_carry[] = "Servo carry function";
440 parse_pgm_inst_t cmd_servo_carry = {
441         .f = cmd_servo_carry_parsed,  /* function to call */
442         .data = NULL,      /* 2nd arg of func */
443         .help_str = help_servo_carry,
444         .tokens = {        /* token list, NULL terminated */
445                 (prog_void *)&cmd_servo_carry_arg0, 
446                 (prog_void *)&cmd_servo_carry_arg1, 
447                 NULL,
448         },
449 };
450
451 /**********************************************************/
452 /* Spickles tests */
453
454 /* this structure is filled when cmd_spickle is parsed successfully */
455 struct cmd_spickle_result {
456         fixed_string_t arg0;
457         fixed_string_t arg1;
458 };
459
460 /* function called when cmd_spickle is parsed successfully */
461 static void cmd_spickle_parsed(void * parsed_result,
462                                __attribute__((unused)) void *data)
463 {
464         struct cmd_spickle_result * res = parsed_result;
465         
466         if (!strcmp_P(res->arg1, PSTR("up"))) {
467                 spickle_up();
468         }
469         else if (!strcmp_P(res->arg1, PSTR("down"))) {
470                 spickle_down();
471         }
472         else if (!strcmp_P(res->arg1, PSTR("stop"))) {
473                 spickle_stop();
474         }
475         else if (!strcmp_P(res->arg1, PSTR("auto"))) {
476                 spickle_auto();
477         }
478
479         printf_P(PSTR("done\r\n"));
480 }
481
482 prog_char str_spickle_arg0[] = "spickle";
483 parse_pgm_token_string_t cmd_spickle_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg0, str_spickle_arg0);
484 prog_char str_spickle_arg1[] = "auto#up#down#stop";
485 parse_pgm_token_string_t cmd_spickle_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_spickle_result, arg1, str_spickle_arg1);
486
487 prog_char help_spickle[] = "spickle auto mode: spickle auto delay_up delay_down";
488 parse_pgm_inst_t cmd_spickle = {
489         .f = cmd_spickle_parsed,  /* function to call */
490         .data = NULL,      /* 2nd arg of func */
491         .help_str = help_spickle,
492         .tokens = {        /* token list, NULL terminated */
493                 (prog_void *)&cmd_spickle_arg0, 
494                 (prog_void *)&cmd_spickle_arg1, 
495                 NULL,
496         },
497 };
498
499 /**********************************************************/
500 /* Set Spickle Params */
501
502 /* this structure is filled when cmd_spickle_params is parsed successfully */
503 struct cmd_spickle_params_result {
504         fixed_string_t arg0;
505         fixed_string_t arg1;
506         int32_t arg2;
507         int32_t arg3;
508 };
509
510 /* function called when cmd_spickle_params is parsed successfully */
511 static void cmd_spickle_params_parsed(void *parsed_result,
512                                       __attribute__((unused)) void *data)
513 {
514         struct cmd_spickle_params_result * res = parsed_result;
515         
516         
517         if (!strcmp_P(res->arg1, PSTR("delay"))) {
518                 spickle_set_delays(res->arg2, res->arg3);
519         }
520         else if (!strcmp_P(res->arg1, PSTR("coef"))) {
521                 spickle_set_coefs(res->arg2, res->arg3);
522         }
523         else if (!strcmp_P(res->arg1, PSTR("pos"))) {
524                 spickle_set_pos(res->arg2, res->arg3);
525         }
526
527         /* else show */
528         spickle_dump_params();
529 }
530
531 prog_char str_spickle_params_arg0[] = "spickle_params";
532 parse_pgm_token_string_t cmd_spickle_params_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg0, str_spickle_params_arg0);
533 prog_char str_spickle_params_arg1[] = "delay#pos#coef";
534 parse_pgm_token_string_t cmd_spickle_params_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg1, str_spickle_params_arg1);
535 parse_pgm_token_num_t cmd_spickle_params_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_spickle_params_result, arg2, INT32);
536 parse_pgm_token_num_t cmd_spickle_params_arg3 = TOKEN_NUM_INITIALIZER(struct cmd_spickle_params_result, arg3, INT32);
537
538 prog_char help_spickle_params[] = "Set spickle_params values";
539 parse_pgm_inst_t cmd_spickle_params = {
540         .f = cmd_spickle_params_parsed,  /* function to call */
541         .data = NULL,      /* 2nd arg of func */
542         .help_str = help_spickle_params,
543         .tokens = {        /* token list, NULL terminated */
544                 (prog_void *)&cmd_spickle_params_arg0, 
545                 (prog_void *)&cmd_spickle_params_arg1, 
546                 (prog_void *)&cmd_spickle_params_arg2, 
547                 (prog_void *)&cmd_spickle_params_arg3, 
548                 NULL,
549         },
550 };
551
552 prog_char str_spickle_params_arg1_show[] = "show";
553 parse_pgm_token_string_t cmd_spickle_params_arg1_show = TOKEN_STRING_INITIALIZER(struct cmd_spickle_params_result, arg1, str_spickle_params_arg1_show);
554
555 prog_char help_spickle_params_show[] = "show spickle params";
556 parse_pgm_inst_t cmd_spickle_params_show = {
557         .f = cmd_spickle_params_parsed,  /* function to call */
558         .data = NULL,      /* 2nd arg of func */
559         .help_str = help_spickle_params_show,
560         .tokens = {        /* token list, NULL terminated */
561                 (prog_void *)&cmd_spickle_params_arg0, 
562                 (prog_void *)&cmd_spickle_params_arg1_show, 
563                 NULL,
564         },
565 };
566
567 /**********************************************************/
568 /* Test */
569
570 /* this structure is filled when cmd_test is parsed successfully */
571 struct cmd_test_result {
572         fixed_string_t arg0;
573 };
574
575 /* function called when cmd_test is parsed successfully */
576 static void cmd_test_parsed(__attribute__((unused)) void *parsed_result,
577                             __attribute__((unused)) void *data)
578 {
579 }
580
581 prog_char str_test_arg0[] = "test";
582 parse_pgm_token_string_t cmd_test_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_test_result, arg0, str_test_arg0);
583
584 prog_char help_test[] = "Test function";
585 parse_pgm_inst_t cmd_test = {
586         .f = cmd_test_parsed,  /* function to call */
587         .data = NULL,      /* 2nd arg of func */
588         .help_str = help_test,
589         .tokens = {        /* token list, NULL terminated */
590                 (prog_void *)&cmd_test_arg0, 
591                 NULL,
592         },
593 };