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_mainboard.c,v 1.9 2009-11-08 17:24:33 zer0 Exp $
20 * Olivier MATZ <zer0@droids-corp.org>
28 #include <aversive/pgmspace.h>
29 #include <aversive/wait.h>
30 #include <aversive/error.h>
31 #include <aversive/eeprom.h>
36 #include <clock_time.h>
42 #include <control_system_manager.h>
43 #include <trajectory_manager.h>
44 #include <trajectory_manager_core.h>
45 #include <trajectory_manager_utils.h>
46 #include <vect_base.h>
49 #include <obstacle_avoidance.h>
50 #include <blocking_detection_manager.h>
51 #include <robot_system.h>
52 #include <position_manager.h>
56 #include <parse_string.h>
57 #include <parse_num.h>
59 #include "../common/i2c_commands.h"
60 #include "../common/eeprom_mapping.h"
67 #include "strat_utils.h"
68 #include "strat_base.h"
70 #include "strat_corn.h"
71 #include "i2c_protocol.h"
75 struct cmd_event_result {
82 /* function called when cmd_event is parsed successfully */
83 static void cmd_event_parsed(void *parsed_result, void *data)
87 struct cmd_event_result * res = parsed_result;
89 if (!strcmp_P(res->arg1, PSTR("all"))) {
91 if (!strcmp_P(res->arg2, PSTR("on")))
92 mainboard.flags |= bit;
93 else if (!strcmp_P(res->arg2, PSTR("off")))
94 mainboard.flags &= bit;
96 printf_P(PSTR("encoders is %s\r\n"),
97 (DO_ENCODERS & mainboard.flags) ? "on":"off");
98 printf_P(PSTR("cs is %s\r\n"),
99 (DO_CS & mainboard.flags) ? "on":"off");
100 printf_P(PSTR("rs is %s\r\n"),
101 (DO_RS & mainboard.flags) ? "on":"off");
102 printf_P(PSTR("pos is %s\r\n"),
103 (DO_POS & mainboard.flags) ? "on":"off");
104 printf_P(PSTR("bd is %s\r\n"),
105 (DO_BD & mainboard.flags) ? "on":"off");
106 printf_P(PSTR("timer is %s\r\n"),
107 (DO_TIMER & mainboard.flags) ? "on":"off");
108 printf_P(PSTR("power is %s\r\n"),
109 (DO_POWER & mainboard.flags) ? "on":"off");
110 printf_P(PSTR("errblock is %s\r\n"),
111 (DO_ERRBLOCKING & mainboard.flags) ? "on":"off");
116 if (!strcmp_P(res->arg1, PSTR("encoders")))
118 else if (!strcmp_P(res->arg1, PSTR("cs"))) {
122 else if (!strcmp_P(res->arg1, PSTR("rs")))
124 else if (!strcmp_P(res->arg1, PSTR("pos")))
126 else if (!strcmp_P(res->arg1, PSTR("bd")))
128 else if (!strcmp_P(res->arg1, PSTR("timer"))) {
132 else if (!strcmp_P(res->arg1, PSTR("power")))
134 else if (!strcmp_P(res->arg1, PSTR("errblock")))
135 bit = DO_ERRBLOCKING;
137 if (!strcmp_P(res->arg2, PSTR("on")))
138 mainboard.flags |= bit;
139 else if (!strcmp_P(res->arg2, PSTR("off"))) {
140 if (!strcmp_P(res->arg1, PSTR("cs"))) {
142 robotsim_pwm(LEFT_PWM, 0);
143 robotsim_pwm(RIGHT_PWM, 0);
145 pwm_ng_set(LEFT_PWM, 0);
146 pwm_ng_set(RIGHT_PWM, 0);
149 mainboard.flags &= (~bit);
151 printf_P(PSTR("%s is %s\r\n"), res->arg1,
152 (bit & mainboard.flags) ? "on":"off");
155 prog_char str_event_arg0[] = "event";
156 parse_pgm_token_string_t cmd_event_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg0, str_event_arg0);
157 prog_char str_event_arg1[] = "all#encoders#cs#rs#pos#bd#timer#power#errblock";
158 parse_pgm_token_string_t cmd_event_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg1, str_event_arg1);
159 prog_char str_event_arg2[] = "on#off#show";
160 parse_pgm_token_string_t cmd_event_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg2, str_event_arg2);
162 prog_char help_event[] = "Enable/disable events";
163 parse_pgm_inst_t cmd_event = {
164 .f = cmd_event_parsed, /* function to call */
165 .data = NULL, /* 2nd arg of func */
166 .help_str = help_event,
167 .tokens = { /* token list, NULL terminated */
168 (prog_void *)&cmd_event_arg0,
169 (prog_void *)&cmd_event_arg1,
170 (prog_void *)&cmd_event_arg2,
176 /**********************************************************/
179 /* this structure is filled when cmd_spi_test is parsed successfully */
180 struct cmd_spi_test_result {
184 /* function called when cmd_spi_test is parsed successfully */
185 static void cmd_spi_test_parsed(void * parsed_result, void * data)
188 printf("not implemented\n");
190 uint16_t i = 0, ret = 0, ret2 = 0;
192 if (mainboard.flags & DO_ENCODERS) {
193 printf_P(PSTR("Disable encoder event first\r\n"));
199 ret = spi_send_and_receive_byte(i);
200 ret2 = spi_send_and_receive_byte(i);
201 spi_slave_deselect(0);
203 if ((i & 0x7ff) == 0)
204 printf_P(PSTR("Sent %.4x twice, received %x %x\r\n"),
208 } while(!cmdline_keypressed());
212 prog_char str_spi_test_arg0[] = "spi_test";
213 parse_pgm_token_string_t cmd_spi_test_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_spi_test_result, arg0, str_spi_test_arg0);
215 prog_char help_spi_test[] = "Test the SPI";
216 parse_pgm_inst_t cmd_spi_test = {
217 .f = cmd_spi_test_parsed, /* function to call */
218 .data = NULL, /* 2nd arg of func */
219 .help_str = help_spi_test,
220 .tokens = { /* token list, NULL terminated */
221 (prog_void *)&cmd_spi_test_arg0,
228 /**********************************************************/
231 /* this structure is filled when cmd_opponent is parsed successfully */
232 struct cmd_opponent_result {
239 /* function called when cmd_opponent is parsed successfully */
240 static void cmd_opponent_parsed(void *parsed_result, void *data)
244 if (get_opponent_xyda(&x, &y, &d, &a))
245 printf_P(PSTR("No opponent\r\n"));
247 printf_P(PSTR("x=%d y=%d, d=%d a=%d\r\n"), x, y, d, a);
250 prog_char str_opponent_arg0[] = "opponent";
251 parse_pgm_token_string_t cmd_opponent_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_opponent_result, arg0, str_opponent_arg0);
252 prog_char str_opponent_arg1[] = "show";
253 parse_pgm_token_string_t cmd_opponent_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_opponent_result, arg1, str_opponent_arg1);
255 prog_char help_opponent[] = "Show (x,y) opponent";
256 parse_pgm_inst_t cmd_opponent = {
257 .f = cmd_opponent_parsed, /* function to call */
258 .data = NULL, /* 2nd arg of func */
259 .help_str = help_opponent,
260 .tokens = { /* token list, NULL terminated */
261 (prog_void *)&cmd_opponent_arg0,
262 (prog_void *)&cmd_opponent_arg1,
268 prog_char str_opponent_arg1_set[] = "set";
269 parse_pgm_token_string_t cmd_opponent_arg1_set = TOKEN_STRING_INITIALIZER(struct cmd_opponent_result, arg1, str_opponent_arg1_set);
270 parse_pgm_token_num_t cmd_opponent_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_opponent_result, arg2, INT32);
271 parse_pgm_token_num_t cmd_opponent_arg3 = TOKEN_NUM_INITIALIZER(struct cmd_opponent_result, arg3, INT32);
273 prog_char help_opponent_set[] = "Set (x,y) opponent";
274 parse_pgm_inst_t cmd_opponent_set = {
275 .f = cmd_opponent_parsed, /* function to call */
276 .data = NULL, /* 2nd arg of func */
277 .help_str = help_opponent_set,
278 .tokens = { /* token list, NULL terminated */
279 (prog_void *)&cmd_opponent_arg0,
280 (prog_void *)&cmd_opponent_arg1_set,
281 (prog_void *)&cmd_opponent_arg2,
282 (prog_void *)&cmd_opponent_arg3,
287 /**********************************************************/
290 /* this structure is filled when cmd_beacon is parsed successfully */
291 struct cmd_beacon_result {
296 /* function called when cmd_beacon is parsed successfully */
297 static void cmd_beacon_parsed(void *parsed_result, void *data)
301 if (beacon_get_pos_double(&x, &y, &a) < 0)
302 printf_P(PSTR("No position from beacon\r\n"));
304 printf_P(PSTR("x=%2.2f y=%2.2f a=%2.2f\r\n"), x, y, DEG(a));
307 prog_char str_beacon_arg0[] = "beacon";
308 parse_pgm_token_string_t cmd_beacon_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_beacon_result, arg0, str_beacon_arg0);
309 prog_char str_beacon_arg1[] = "show";
310 parse_pgm_token_string_t cmd_beacon_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_beacon_result, arg1, str_beacon_arg1);
312 prog_char help_beacon[] = "Show (x,y) beacon";
313 parse_pgm_inst_t cmd_beacon = {
314 .f = cmd_beacon_parsed, /* function to call */
315 .data = NULL, /* 2nd arg of func */
316 .help_str = help_beacon,
317 .tokens = { /* token list, NULL terminated */
318 (prog_void *)&cmd_beacon_arg0,
319 (prog_void *)&cmd_beacon_arg1,
324 /**********************************************************/
327 /* this structure is filled when cmd_start is parsed successfully */
328 struct cmd_start_result {
330 fixed_string_t color;
331 fixed_string_t debug;
334 /* function called when cmd_start is parsed successfully */
335 static void cmd_start_parsed(void *parsed_result, void *data)
337 struct cmd_start_result *res = parsed_result;
338 uint8_t old_level = gen.log_level;
340 gen.logs[NB_LOGS] = E_USER_STRAT;
341 if (!strcmp_P(res->debug, PSTR("debug"))) {
342 strat_db.dump_enabled = 1;
346 strat_db.dump_enabled = 0;
350 if (!strcmp_P(res->color, PSTR("yellow"))) {
351 mainboard.our_color = I2C_COLOR_YELLOW;
352 i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_YELLOW);
353 i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_YELLOW);
354 beacon_set_color(I2C_COLOR_YELLOW);
356 else if (!strcmp_P(res->color, PSTR("blue"))) {
357 mainboard.our_color = I2C_COLOR_BLUE;
358 i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_BLUE);
359 i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_BLUE);
360 beacon_set_color(I2C_COLOR_BLUE);
365 gen.logs[NB_LOGS] = 0;
366 gen.log_level = old_level;
369 prog_char str_start_arg0[] = "start";
370 parse_pgm_token_string_t cmd_start_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_start_result, arg0, str_start_arg0);
371 prog_char str_start_color[] = "blue#yellow";
372 parse_pgm_token_string_t cmd_start_color = TOKEN_STRING_INITIALIZER(struct cmd_start_result, color, str_start_color);
373 prog_char str_start_debug[] = "debug#match";
374 parse_pgm_token_string_t cmd_start_debug = TOKEN_STRING_INITIALIZER(struct cmd_start_result, debug, str_start_debug);
376 prog_char help_start[] = "Start the robot";
377 parse_pgm_inst_t cmd_start = {
378 .f = cmd_start_parsed, /* function to call */
379 .data = NULL, /* 2nd arg of func */
380 .help_str = help_start,
381 .tokens = { /* token list, NULL terminated */
382 (prog_void *)&cmd_start_arg0,
383 (prog_void *)&cmd_start_color,
384 (prog_void *)&cmd_start_debug,
391 /**********************************************************/
394 /* this structure is filled when cmd_interact is parsed successfully */
395 struct cmd_interact_result {
399 static void print_cs(void)
401 printf_P(PSTR("cons_d=% .8"PRIi32" cons_a=% .8"PRIi32" fil_d=% .8"PRIi32" fil_a=% .8"PRIi32" "
402 "err_d=% .8"PRIi32" err_a=% .8"PRIi32" out_d=% .8"PRIi32" out_a=% .8"PRIi32"\r\n"),
403 cs_get_consign(&mainboard.distance.cs),
404 cs_get_consign(&mainboard.angle.cs),
405 cs_get_filtered_consign(&mainboard.distance.cs),
406 cs_get_filtered_consign(&mainboard.angle.cs),
407 cs_get_error(&mainboard.distance.cs),
408 cs_get_error(&mainboard.angle.cs),
409 cs_get_out(&mainboard.distance.cs),
410 cs_get_out(&mainboard.angle.cs));
413 static void print_pos(void)
415 printf_P(PSTR("x=% .8d y=% .8d a=% .8d\r\n"),
416 position_get_x_s16(&mainboard.pos),
417 position_get_y_s16(&mainboard.pos),
418 position_get_a_deg_s16(&mainboard.pos));
421 static void print_time(void)
423 printf_P(PSTR("time %d\r\n"),time_get_s());
427 static void print_sensors(void)
430 if (sensor_start_switch())
431 printf_P(PSTR("Start switch | "));
433 printf_P(PSTR(" | "));
435 if (IR_DISP_SENSOR())
436 printf_P(PSTR("IR disp | "));
438 printf_P(PSTR(" | "));
440 printf_P(PSTR("\r\n"));
444 static void print_pid(void)
446 printf_P(PSTR("P=% .8"PRIi32" I=% .8"PRIi32" D=% .8"PRIi32" out=% .8"PRIi32" | "
447 "P=% .8"PRIi32" I=% .8"PRIi32" D=% .8"PRIi32" out=% .8"PRIi32"\r\n"),
448 pid_get_value_in(&mainboard.distance.pid) * pid_get_gain_P(&mainboard.distance.pid),
449 pid_get_value_I(&mainboard.distance.pid) * pid_get_gain_I(&mainboard.distance.pid),
450 pid_get_value_D(&mainboard.distance.pid) * pid_get_gain_D(&mainboard.distance.pid),
451 pid_get_value_out(&mainboard.distance.pid),
452 pid_get_value_in(&mainboard.angle.pid) * pid_get_gain_P(&mainboard.angle.pid),
453 pid_get_value_I(&mainboard.angle.pid) * pid_get_gain_I(&mainboard.angle.pid),
454 pid_get_value_D(&mainboard.angle.pid) * pid_get_gain_D(&mainboard.angle.pid),
455 pid_get_value_out(&mainboard.angle.pid));
458 #define PRINT_POS (1<<0)
459 #define PRINT_PID (1<<1)
460 #define PRINT_CS (1<<2)
461 #define PRINT_SENSORS (1<<3)
462 #define PRINT_TIME (1<<4)
463 #define PRINT_BLOCKING (1<<5)
465 static void cmd_interact_parsed(void * parsed_result, void * data)
474 printf_P(PSTR("Display debugs:\r\n"
480 /* " 6:blocking\r\n" */
487 mainboard.flags &= (~DO_CS);
488 pwm_set_and_save(LEFT_PWM, 0);
489 pwm_set_and_save(RIGHT_PWM, 0);
492 if (print & PRINT_POS) {
496 if (print & PRINT_PID) {
500 if (print & PRINT_CS) {
504 if (print & PRINT_SENSORS) {
508 if (print & PRINT_TIME) {
511 /* if (print & PRINT_BLOCKING) { */
512 /* printf_P(PSTR("%s %s blocking=%d\r\n"), */
513 /* mainboard.blocking ? "BLOCK1":" ", */
514 /* rs_is_blocked(&mainboard.rs) ? "BLOCK2":" ", */
515 /* rs_get_blocking(&mainboard.rs)); */
518 c = cmdline_getchar();
523 cmd = vt100_parser(&vt100, c);
531 case '1': print ^= PRINT_POS; break;
532 case '2': print ^= PRINT_PID; break;
533 case '3': print ^= PRINT_CS; break;
534 case '4': print ^= PRINT_SENSORS; break;
535 case '5': print ^= PRINT_TIME; break;
536 case '6': print ^= PRINT_BLOCKING; break;
539 if (mainboard.flags & DO_CS)
541 pwm_set_and_save(LEFT_PWM, 0);
542 pwm_set_and_save(RIGHT_PWM, 0);
545 pwm_set_and_save(LEFT_PWM, 0);
546 pwm_set_and_save(RIGHT_PWM, 0);
554 #define PWM_INTERACT 1200
556 #define PWM_INTERACT 1200
560 pwm_set_and_save(LEFT_PWM, PWM_INTERACT);
561 pwm_set_and_save(RIGHT_PWM, PWM_INTERACT);
564 pwm_set_and_save(LEFT_PWM, -PWM_INTERACT);
565 pwm_set_and_save(RIGHT_PWM, PWM_INTERACT);
568 pwm_set_and_save(LEFT_PWM, -PWM_INTERACT);
569 pwm_set_and_save(RIGHT_PWM, -PWM_INTERACT);
572 pwm_set_and_save(LEFT_PWM, PWM_INTERACT);
573 pwm_set_and_save(RIGHT_PWM, -PWM_INTERACT);
581 prog_char str_interact_arg0[] = "interact";
582 parse_pgm_token_string_t cmd_interact_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_interact_result, arg0, str_interact_arg0);
584 prog_char help_interact[] = "Interactive mode";
585 parse_pgm_inst_t cmd_interact = {
586 .f = cmd_interact_parsed, /* function to call */
587 .data = NULL, /* 2nd arg of func */
588 .help_str = help_interact,
589 .tokens = { /* token list, NULL terminated */
590 (prog_void *)&cmd_interact_arg0,
596 /**********************************************************/
599 /* this structure is filled when cmd_color is parsed successfully */
600 struct cmd_color_result {
602 fixed_string_t color;
605 /* function called when cmd_color is parsed successfully */
606 static void cmd_color_parsed(void *parsed_result, void *data)
609 printf("not implemented\n");
611 struct cmd_color_result *res = (struct cmd_color_result *) parsed_result;
612 if (!strcmp_P(res->color, PSTR("yellow"))) {
613 mainboard.our_color = I2C_COLOR_YELLOW;
614 i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_YELLOW);
615 i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_YELLOW);
616 beacon_set_color(I2C_COLOR_YELLOW);
618 else if (!strcmp_P(res->color, PSTR("blue"))) {
619 mainboard.our_color = I2C_COLOR_BLUE;
620 i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_BLUE);
621 i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_BLUE);
622 beacon_set_color(I2C_COLOR_BLUE);
624 printf_P(PSTR("Done\r\n"));
628 prog_char str_color_arg0[] = "color";
629 parse_pgm_token_string_t cmd_color_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_color_result, arg0, str_color_arg0);
630 prog_char str_color_color[] = "blue#yellow";
631 parse_pgm_token_string_t cmd_color_color = TOKEN_STRING_INITIALIZER(struct cmd_color_result, color, str_color_color);
633 prog_char help_color[] = "Set our color";
634 parse_pgm_inst_t cmd_color = {
635 .f = cmd_color_parsed, /* function to call */
636 .data = NULL, /* 2nd arg of func */
637 .help_str = help_color,
638 .tokens = { /* token list, NULL terminated */
639 (prog_void *)&cmd_color_arg0,
640 (prog_void *)&cmd_color_color,
646 /**********************************************************/
649 /* this structure is filled when cmd_rs is parsed successfully */
650 struct cmd_rs_result {
655 /* function called when cmd_rs is parsed successfully */
656 static void cmd_rs_parsed(void *parsed_result, void *data)
658 // struct cmd_rs_result *res = parsed_result;
660 printf_P(PSTR("angle cons=% .6"PRIi32" in=% .6"PRIi32" out=% .6"PRIi32" / "),
661 cs_get_consign(&mainboard.angle.cs),
662 cs_get_filtered_feedback(&mainboard.angle.cs),
663 cs_get_out(&mainboard.angle.cs));
664 printf_P(PSTR("distance cons=% .6"PRIi32" in=% .6"PRIi32" out=% .6"PRIi32" / "),
665 cs_get_consign(&mainboard.distance.cs),
666 cs_get_filtered_feedback(&mainboard.distance.cs),
667 cs_get_out(&mainboard.distance.cs));
668 printf_P(PSTR("l=% .4"PRIi32" r=% .4"PRIi32"\r\n"), mainboard.pwm_l,
671 } while(!cmdline_keypressed());
674 prog_char str_rs_arg0[] = "rs";
675 parse_pgm_token_string_t cmd_rs_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_rs_result, arg0, str_rs_arg0);
676 prog_char str_rs_arg1[] = "show";
677 parse_pgm_token_string_t cmd_rs_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_rs_result, arg1, str_rs_arg1);
679 prog_char help_rs[] = "Show rs (robot system) values";
680 parse_pgm_inst_t cmd_rs = {
681 .f = cmd_rs_parsed, /* function to call */
682 .data = NULL, /* 2nd arg of func */
684 .tokens = { /* token list, NULL terminated */
685 (prog_void *)&cmd_rs_arg0,
686 (prog_void *)&cmd_rs_arg1,
691 /**********************************************************/
694 /* this structure is filled when cmd_i2cdebug is parsed successfully */
695 struct cmd_i2cdebug_result {
699 /* function called when cmd_i2cdebug is parsed successfully */
700 static void cmd_i2cdebug_parsed(void * parsed_result, void * data)
703 printf("not implemented\n");
706 i2c_protocol_debug();
710 prog_char str_i2cdebug_arg0[] = "i2cdebug";
711 parse_pgm_token_string_t cmd_i2cdebug_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_i2cdebug_result, arg0, str_i2cdebug_arg0);
713 prog_char help_i2cdebug[] = "I2c debug infos";
714 parse_pgm_inst_t cmd_i2cdebug = {
715 .f = cmd_i2cdebug_parsed, /* function to call */
716 .data = NULL, /* 2nd arg of func */
717 .help_str = help_i2cdebug,
718 .tokens = { /* token list, NULL terminated */
719 (prog_void *)&cmd_i2cdebug_arg0,
724 /**********************************************************/
727 /* this structure is filled when cmd_cobboard_show is parsed successfully */
728 struct cmd_cobboard_show_result {
733 /* function called when cmd_cobboard_show is parsed successfully */
734 static void cmd_cobboard_show_parsed(void * parsed_result, void * data)
737 printf("not implemented\n");
739 printf_P(PSTR("mode = %x\r\n"), cobboard.mode);
740 printf_P(PSTR("status = %x\r\n"), cobboard.status);
741 printf_P(PSTR("cob_count = %x\r\n"), cobboard.cob_count);
742 printf_P(PSTR("left_cobroller_speed = %d\r\n"), cobboard.left_cobroller_speed);
743 printf_P(PSTR("right_cobroller_speed = %d\r\n"), cobboard.right_cobroller_speed);
747 prog_char str_cobboard_show_arg0[] = "cobboard";
748 parse_pgm_token_string_t cmd_cobboard_show_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_show_result, arg0, str_cobboard_show_arg0);
749 prog_char str_cobboard_show_arg1[] = "show";
750 parse_pgm_token_string_t cmd_cobboard_show_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_show_result, arg1, str_cobboard_show_arg1);
752 prog_char help_cobboard_show[] = "show cobboard status";
753 parse_pgm_inst_t cmd_cobboard_show = {
754 .f = cmd_cobboard_show_parsed, /* function to call */
755 .data = NULL, /* 2nd arg of func */
756 .help_str = help_cobboard_show,
757 .tokens = { /* token list, NULL terminated */
758 (prog_void *)&cmd_cobboard_show_arg0,
759 (prog_void *)&cmd_cobboard_show_arg1,
764 /**********************************************************/
765 /* Cobboard_Setmode1 */
767 /* this structure is filled when cmd_cobboard_setmode1 is parsed successfully */
768 struct cmd_cobboard_setmode1_result {
773 /* function called when cmd_cobboard_setmode1 is parsed successfully */
774 static void cmd_cobboard_setmode1_parsed(void *parsed_result, void *data)
776 struct cmd_cobboard_setmode1_result *res = parsed_result;
778 if (!strcmp_P(res->arg1, PSTR("init")))
779 i2c_cobboard_set_mode(I2C_COBBOARD_MODE_INIT);
780 else if (!strcmp_P(res->arg1, PSTR("eject")))
781 i2c_cobboard_set_mode(I2C_COBBOARD_MODE_EJECT);
782 else if (!strcmp_P(res->arg1, PSTR("kickstand_up")))
783 i2c_cobboard_set_mode(I2C_COBBOARD_MODE_KICKSTAND_UP);
784 else if (!strcmp_P(res->arg1, PSTR("kickstand_down")))
785 i2c_cobboard_set_mode(I2C_COBBOARD_MODE_KICKSTAND_DOWN);
788 prog_char str_cobboard_setmode1_arg0[] = "cobboard";
789 parse_pgm_token_string_t cmd_cobboard_setmode1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode1_result, arg0, str_cobboard_setmode1_arg0);
790 prog_char str_cobboard_setmode1_arg1[] = "init#eject#kickstand_up#kickstand_down";
791 parse_pgm_token_string_t cmd_cobboard_setmode1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode1_result, arg1, str_cobboard_setmode1_arg1);
793 prog_char help_cobboard_setmode1[] = "set cobboard mode (mode)";
794 parse_pgm_inst_t cmd_cobboard_setmode1 = {
795 .f = cmd_cobboard_setmode1_parsed, /* function to call */
796 .data = NULL, /* 2nd arg of func */
797 .help_str = help_cobboard_setmode1,
798 .tokens = { /* token list, NULL terminated */
799 (prog_void *)&cmd_cobboard_setmode1_arg0,
800 (prog_void *)&cmd_cobboard_setmode1_arg1,
805 /**********************************************************/
806 /* Cobboard_Setmode2 */
808 /* this structure is filled when cmd_cobboard_setmode2 is parsed successfully */
809 struct cmd_cobboard_setmode2_result {
815 /* function called when cmd_cobboard_setmode2 is parsed successfully */
816 static void cmd_cobboard_setmode2_parsed(void *parsed_result, void *data)
818 struct cmd_cobboard_setmode2_result *res = parsed_result;
819 uint8_t side = I2C_LEFT_SIDE;
821 if (!strcmp_P(res->arg2, PSTR("left")))
822 side = I2C_LEFT_SIDE;
823 else if (!strcmp_P(res->arg2, PSTR("right")))
824 side = I2C_RIGHT_SIDE;
826 if (!strcmp_P(res->arg1, PSTR("deploy"))) {
827 i2c_cobboard_set_mode(I2C_COBBOARD_MODE_HARVEST);
828 i2c_cobboard_deploy(side);
830 else if (!strcmp_P(res->arg1, PSTR("harvest"))) {
831 i2c_cobboard_set_mode(I2C_COBBOARD_MODE_HARVEST);
832 i2c_cobboard_autoharvest(side);
834 else if (!strcmp_P(res->arg1, PSTR("pack"))) {
835 i2c_cobboard_set_mode(I2C_COBBOARD_MODE_HARVEST);
836 i2c_cobboard_pack(side);
838 else if (!strcmp_P(res->arg1, PSTR("weak_pack"))) {
839 i2c_cobboard_set_mode(I2C_COBBOARD_MODE_HARVEST);
840 i2c_cobboard_pack_weak(side);
842 else if (!strcmp_P(res->arg1, PSTR("deploy_nomove"))) {
843 i2c_cobboard_set_mode(I2C_COBBOARD_MODE_HARVEST);
844 i2c_cobboard_deploy_nomove(side);
846 else if (!strcmp_P(res->arg1, PSTR("harvest_nomove"))) {
847 i2c_cobboard_set_mode(I2C_COBBOARD_MODE_HARVEST);
848 i2c_cobboard_autoharvest_nomove(side);
852 prog_char str_cobboard_setmode2_arg0[] = "cobboard";
853 parse_pgm_token_string_t cmd_cobboard_setmode2_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode2_result, arg0, str_cobboard_setmode2_arg0);
854 prog_char str_cobboard_setmode2_arg1[] = "harvest#deploy#pack#weak_pack#harvest_nomove#deploy_nomove";
855 parse_pgm_token_string_t cmd_cobboard_setmode2_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode2_result, arg1, str_cobboard_setmode2_arg1);
856 prog_char str_cobboard_setmode2_arg2[] = "left#right";
857 parse_pgm_token_string_t cmd_cobboard_setmode2_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode2_result, arg2, str_cobboard_setmode2_arg2);
859 prog_char help_cobboard_setmode2[] = "set cobboard mode (mode, side)";
860 parse_pgm_inst_t cmd_cobboard_setmode2 = {
861 .f = cmd_cobboard_setmode2_parsed, /* function to call */
862 .data = NULL, /* 2nd arg of func */
863 .help_str = help_cobboard_setmode2,
864 .tokens = { /* token list, NULL terminated */
865 (prog_void *)&cmd_cobboard_setmode2_arg0,
866 (prog_void *)&cmd_cobboard_setmode2_arg1,
867 (prog_void *)&cmd_cobboard_setmode2_arg2,
872 /**********************************************************/
873 /* Cobboard_Setmode3 */
875 /* this structure is filled when cmd_cobboard_setmode3 is parsed successfully */
876 struct cmd_cobboard_setmode3_result {
882 /* function called when cmd_cobboard_setmode3 is parsed successfully */
883 static void cmd_cobboard_setmode3_parsed(void *parsed_result, void *data)
885 struct cmd_cobboard_setmode3_result *res = parsed_result;
886 if (!strcmp_P(res->arg1, PSTR("xxx")))
890 prog_char str_cobboard_setmode3_arg0[] = "cobboard";
891 parse_pgm_token_string_t cmd_cobboard_setmode3_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode3_result, arg0, str_cobboard_setmode3_arg0);
892 prog_char str_cobboard_setmode3_arg1[] = "xxx";
893 parse_pgm_token_string_t cmd_cobboard_setmode3_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_cobboard_setmode3_result, arg1, str_cobboard_setmode3_arg1);
894 parse_pgm_token_num_t cmd_cobboard_setmode3_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_cobboard_setmode3_result, level, UINT8);
896 prog_char help_cobboard_setmode3[] = "set cobboard mode (mode, level)";
897 parse_pgm_inst_t cmd_cobboard_setmode3 = {
898 .f = cmd_cobboard_setmode3_parsed, /* function to call */
899 .data = NULL, /* 2nd arg of func */
900 .help_str = help_cobboard_setmode3,
901 .tokens = { /* token list, NULL terminated */
902 (prog_void *)&cmd_cobboard_setmode3_arg0,
903 (prog_void *)&cmd_cobboard_setmode3_arg1,
904 (prog_void *)&cmd_cobboard_setmode3_arg2,
909 /**********************************************************/
912 /* this structure is filled when cmd_ballboard_show is parsed successfully */
913 struct cmd_ballboard_show_result {
918 /* function called when cmd_ballboard_show is parsed successfully */
919 static void cmd_ballboard_show_parsed(void * parsed_result, void * data)
922 printf("not implemented\n");
924 printf_P(PSTR("mode = %x\r\n"), ballboard.mode);
925 printf_P(PSTR("status = %x\r\n"), ballboard.status);
926 printf_P(PSTR("ball_count = %d\r\n"), ballboard.ball_count);
927 printf_P(PSTR("lcob = %d\r\n"), ballboard.lcob);
928 printf_P(PSTR("rcob = %d\r\n"), ballboard.rcob);
932 prog_char str_ballboard_show_arg0[] = "ballboard";
933 parse_pgm_token_string_t cmd_ballboard_show_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_ballboard_show_result, arg0, str_ballboard_show_arg0);
934 prog_char str_ballboard_show_arg1[] = "show";
935 parse_pgm_token_string_t cmd_ballboard_show_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_ballboard_show_result, arg1, str_ballboard_show_arg1);
937 prog_char help_ballboard_show[] = "show ballboard status";
938 parse_pgm_inst_t cmd_ballboard_show = {
939 .f = cmd_ballboard_show_parsed, /* function to call */
940 .data = NULL, /* 2nd arg of func */
941 .help_str = help_ballboard_show,
942 .tokens = { /* token list, NULL terminated */
943 (prog_void *)&cmd_ballboard_show_arg0,
944 (prog_void *)&cmd_ballboard_show_arg1,
949 /**********************************************************/
950 /* Ballboard_Setmode1 */
952 /* this structure is filled when cmd_ballboard_setmode1 is parsed successfully */
953 struct cmd_ballboard_setmode1_result {
958 /* function called when cmd_ballboard_setmode1 is parsed successfully */
959 static void cmd_ballboard_setmode1_parsed(void *parsed_result, void *data)
961 struct cmd_ballboard_setmode1_result *res = parsed_result;
963 if (!strcmp_P(res->arg1, PSTR("init")))
964 i2c_ballboard_set_mode(I2C_BALLBOARD_MODE_INIT);
965 else if (!strcmp_P(res->arg1, PSTR("off")))
966 i2c_ballboard_set_mode(I2C_BALLBOARD_MODE_OFF);
967 else if (!strcmp_P(res->arg1, PSTR("eject")))
968 i2c_ballboard_set_mode(I2C_BALLBOARD_MODE_EJECT);
969 else if (!strcmp_P(res->arg1, PSTR("harvest")))
970 i2c_ballboard_set_mode(I2C_BALLBOARD_MODE_HARVEST);
971 else if (!strcmp_P(res->arg1, PSTR("prepare")))
972 i2c_ballboard_set_mode(I2C_BALLBOARD_MODE_PREP_FORK);
973 else if (!strcmp_P(res->arg1, PSTR("take")))
974 i2c_ballboard_set_mode(I2C_BALLBOARD_MODE_TAKE_FORK);
979 prog_char str_ballboard_setmode1_arg0[] = "ballboard";
980 parse_pgm_token_string_t cmd_ballboard_setmode1_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_ballboard_setmode1_result, arg0, str_ballboard_setmode1_arg0);
981 prog_char str_ballboard_setmode1_arg1[] = "init#eject#harvest#off#take#prepare";
982 parse_pgm_token_string_t cmd_ballboard_setmode1_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_ballboard_setmode1_result, arg1, str_ballboard_setmode1_arg1);
984 prog_char help_ballboard_setmode1[] = "set ballboard mode (mode)";
985 parse_pgm_inst_t cmd_ballboard_setmode1 = {
986 .f = cmd_ballboard_setmode1_parsed, /* function to call */
987 .data = NULL, /* 2nd arg of func */
988 .help_str = help_ballboard_setmode1,
989 .tokens = { /* token list, NULL terminated */
990 (prog_void *)&cmd_ballboard_setmode1_arg0,
991 (prog_void *)&cmd_ballboard_setmode1_arg1,
996 /**********************************************************/
997 /* Ballboard_Setmode2 */
999 /* this structure is filled when cmd_ballboard_setmode2 is parsed successfully */
1000 struct cmd_ballboard_setmode2_result {
1001 fixed_string_t arg0;
1002 fixed_string_t arg1;
1003 fixed_string_t arg2;
1006 /* function called when cmd_ballboard_setmode2 is parsed successfully */
1007 static void cmd_ballboard_setmode2_parsed(void * parsed_result, void * data)
1011 prog_char str_ballboard_setmode2_arg0[] = "ballboard";
1012 parse_pgm_token_string_t cmd_ballboard_setmode2_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_ballboard_setmode2_result, arg0, str_ballboard_setmode2_arg0);
1013 prog_char str_ballboard_setmode2_arg1[] = "xxx";
1014 parse_pgm_token_string_t cmd_ballboard_setmode2_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_ballboard_setmode2_result, arg1, str_ballboard_setmode2_arg1);
1015 prog_char str_ballboard_setmode2_arg2[] = "left#right";
1016 parse_pgm_token_string_t cmd_ballboard_setmode2_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_ballboard_setmode2_result, arg2, str_ballboard_setmode2_arg2);
1018 prog_char help_ballboard_setmode2[] = "set ballboard mode (mode, side)";
1019 parse_pgm_inst_t cmd_ballboard_setmode2 = {
1020 .f = cmd_ballboard_setmode2_parsed, /* function to call */
1021 .data = NULL, /* 2nd arg of func */
1022 .help_str = help_ballboard_setmode2,
1023 .tokens = { /* token list, NULL terminated */
1024 (prog_void *)&cmd_ballboard_setmode2_arg0,
1025 (prog_void *)&cmd_ballboard_setmode2_arg1,
1026 (prog_void *)&cmd_ballboard_setmode2_arg2,
1031 /**********************************************************/
1032 /* Ballboard_Setmode3 */
1034 /* this structure is filled when cmd_ballboard_setmode3 is parsed successfully */
1035 struct cmd_ballboard_setmode3_result {
1036 fixed_string_t arg0;
1037 fixed_string_t arg1;
1041 /* function called when cmd_ballboard_setmode3 is parsed successfully */
1042 static void cmd_ballboard_setmode3_parsed(void *parsed_result, void *data)
1044 struct cmd_ballboard_setmode3_result *res = parsed_result;
1045 if (!strcmp_P(res->arg1, PSTR("xxx")))
1049 prog_char str_ballboard_setmode3_arg0[] = "ballboard";
1050 parse_pgm_token_string_t cmd_ballboard_setmode3_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_ballboard_setmode3_result, arg0, str_ballboard_setmode3_arg0);
1051 prog_char str_ballboard_setmode3_arg1[] = "xxx";
1052 parse_pgm_token_string_t cmd_ballboard_setmode3_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_ballboard_setmode3_result, arg1, str_ballboard_setmode3_arg1);
1053 parse_pgm_token_num_t cmd_ballboard_setmode3_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_ballboard_setmode3_result, level, UINT8);
1055 prog_char help_ballboard_setmode3[] = "set ballboard mode (mode, level)";
1056 parse_pgm_inst_t cmd_ballboard_setmode3 = {
1057 .f = cmd_ballboard_setmode3_parsed, /* function to call */
1058 .data = NULL, /* 2nd arg of func */
1059 .help_str = help_ballboard_setmode3,
1060 .tokens = { /* token list, NULL terminated */
1061 (prog_void *)&cmd_ballboard_setmode3_arg0,
1062 (prog_void *)&cmd_ballboard_setmode3_arg1,
1063 (prog_void *)&cmd_ballboard_setmode3_arg2,
1068 /**********************************************************/
1071 /* this structure is filled when cmd_servo_balls is parsed successfully */
1072 struct cmd_servo_balls_result {
1073 fixed_string_t arg0;
1074 fixed_string_t arg1;
1077 /* function called when cmd_servo_balls is parsed successfully */
1078 static void cmd_servo_balls_parsed(void *parsed_result,
1079 __attribute__((unused)) void *data)
1081 struct cmd_servo_balls_result *res = parsed_result;
1083 if (!strcmp_P(res->arg1, PSTR("deploy")))
1084 support_balls_deploy();
1085 else if (!strcmp_P(res->arg1, PSTR("pack")))
1086 support_balls_pack();
1089 prog_char str_servo_balls_arg0[] = "support_balls";
1090 parse_pgm_token_string_t cmd_servo_balls_arg0 =
1091 TOKEN_STRING_INITIALIZER(struct cmd_servo_balls_result, arg0, str_servo_balls_arg0);
1092 prog_char str_servo_balls_arg1[] = "deploy#pack";
1093 parse_pgm_token_string_t cmd_servo_balls_arg1 =
1094 TOKEN_STRING_INITIALIZER(struct cmd_servo_balls_result, arg1, str_servo_balls_arg1);
1096 prog_char help_servo_balls[] = "control support balls";
1097 parse_pgm_inst_t cmd_servo_balls = {
1098 .f = cmd_servo_balls_parsed, /* function to call */
1099 .data = NULL, /* 2nd arg of func */
1100 .help_str = help_servo_balls,
1101 .tokens = { /* token list, NULL terminated */
1102 (prog_void *)&cmd_servo_balls_arg0,
1103 (prog_void *)&cmd_servo_balls_arg1,
1108 /**********************************************************/
1111 /* this structure is filled when cmd_clitoid is parsed successfully */
1112 struct cmd_clitoid_result {
1113 fixed_string_t arg0;
1122 /* function called when cmd_test is parsed successfully */
1123 static void cmd_clitoid_parsed(void *parsed_result, void *data)
1125 struct cmd_clitoid_result *res = parsed_result;
1126 /* clitoid(res->alpha_deg, res->beta_deg, res->R_mm, */
1127 /* res->Vd, res->Amax, res->d_inter_mm); */
1128 double x = position_get_x_double(&mainboard.pos);
1129 double y = position_get_y_double(&mainboard.pos);
1130 double a = position_get_a_rad_double(&mainboard.pos);
1132 strat_set_speed(res->Vd, SPEED_ANGLE_FAST);
1133 trajectory_clitoid(&mainboard.traj, x, y, a, 150.,
1134 res->alpha_deg, res->beta_deg, res->R_mm,
1138 prog_char str_clitoid_arg0[] = "clitoid";
1139 parse_pgm_token_string_t cmd_clitoid_arg0 =
1140 TOKEN_STRING_INITIALIZER(struct cmd_clitoid_result,
1141 arg0, str_clitoid_arg0);
1142 parse_pgm_token_num_t cmd_clitoid_alpha_deg =
1143 TOKEN_NUM_INITIALIZER(struct cmd_clitoid_result,
1145 parse_pgm_token_num_t cmd_clitoid_beta_deg =
1146 TOKEN_NUM_INITIALIZER(struct cmd_clitoid_result,
1148 parse_pgm_token_num_t cmd_clitoid_R_mm =
1149 TOKEN_NUM_INITIALIZER(struct cmd_clitoid_result,
1151 parse_pgm_token_num_t cmd_clitoid_Vd =
1152 TOKEN_NUM_INITIALIZER(struct cmd_clitoid_result,
1154 parse_pgm_token_num_t cmd_clitoid_Amax =
1155 TOKEN_NUM_INITIALIZER(struct cmd_clitoid_result,
1157 parse_pgm_token_num_t cmd_clitoid_d_inter_mm =
1158 TOKEN_NUM_INITIALIZER(struct cmd_clitoid_result,
1161 prog_char help_clitoid[] = "do a clitoid (alpha, beta, R, Vd, Amax, d_inter)";
1162 parse_pgm_inst_t cmd_clitoid = {
1163 .f = cmd_clitoid_parsed, /* function to call */
1164 .data = NULL, /* 2nd arg of func */
1165 .help_str = help_clitoid,
1166 .tokens = { /* token list, NULL terminated */
1167 (prog_void *)&cmd_clitoid_arg0,
1168 (prog_void *)&cmd_clitoid_alpha_deg,
1169 (prog_void *)&cmd_clitoid_beta_deg,
1170 (prog_void *)&cmd_clitoid_R_mm,
1171 (prog_void *)&cmd_clitoid_Vd,
1172 (prog_void *)&cmd_clitoid_Amax,
1173 (prog_void *)&cmd_clitoid_d_inter_mm,
1178 /**********************************************************/
1181 /* this structure is filled when cmd_time_monitor is parsed successfully */
1182 struct cmd_time_monitor_result {
1183 fixed_string_t arg0;
1184 fixed_string_t arg1;
1187 /* function called when cmd_time_monitor is parsed successfully */
1188 static void cmd_time_monitor_parsed(void *parsed_result, void *data)
1190 #ifndef HOST_VERSION
1191 struct cmd_time_monitor_result *res = parsed_result;
1194 if (!strcmp_P(res->arg1, PSTR("reset"))) {
1195 eeprom_write_word(EEPROM_TIME_ADDRESS, 0);
1197 seconds = eeprom_read_word(EEPROM_TIME_ADDRESS);
1198 printf_P(PSTR("Running since %d mn %d\r\n"), seconds/60, seconds%60);
1202 prog_char str_time_monitor_arg0[] = "time_monitor";
1203 parse_pgm_token_string_t cmd_time_monitor_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_time_monitor_result, arg0, str_time_monitor_arg0);
1204 prog_char str_time_monitor_arg1[] = "show#reset";
1205 parse_pgm_token_string_t cmd_time_monitor_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_time_monitor_result, arg1, str_time_monitor_arg1);
1207 prog_char help_time_monitor[] = "Show since how long we are running";
1208 parse_pgm_inst_t cmd_time_monitor = {
1209 .f = cmd_time_monitor_parsed, /* function to call */
1210 .data = NULL, /* 2nd arg of func */
1211 .help_str = help_time_monitor,
1212 .tokens = { /* token list, NULL terminated */
1213 (prog_void *)&cmd_time_monitor_arg0,
1214 (prog_void *)&cmd_time_monitor_arg1,
1220 /**********************************************************/
1223 /* this structure is filled when cmd_strat_event is parsed successfully */
1224 struct cmd_strat_event_result {
1225 fixed_string_t arg0;
1226 fixed_string_t arg1;
1229 /* function called when cmd_strat_event is parsed successfully */
1230 static void cmd_strat_event_parsed(void *parsed_result, void *data)
1232 struct cmd_strat_event_result *res = parsed_result;
1234 if (!strcmp_P(res->arg1, PSTR("on")))
1235 strat_event_enable();
1237 strat_event_disable();
1240 prog_char str_strat_event_arg0[] = "strat_event";
1241 parse_pgm_token_string_t cmd_strat_event_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_strat_event_result, arg0, str_strat_event_arg0);
1242 prog_char str_strat_event_arg1[] = "on#off";
1243 parse_pgm_token_string_t cmd_strat_event_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_strat_event_result, arg1, str_strat_event_arg1);
1245 prog_char help_strat_event[] = "Enable/disable strat_event callback";
1246 parse_pgm_inst_t cmd_strat_event = {
1247 .f = cmd_strat_event_parsed, /* function to call */
1248 .data = NULL, /* 2nd arg of func */
1249 .help_str = help_strat_event,
1250 .tokens = { /* token list, NULL terminated */
1251 (prog_void *)&cmd_strat_event_arg0,
1252 (prog_void *)&cmd_strat_event_arg1,
1257 /**********************************************************/
1260 /* this structure is filled when cmd_sleep is parsed successfully */
1261 struct cmd_sleep_result {
1262 fixed_string_t arg0;
1266 /* function called when cmd_sleep is parsed successfully */
1267 static void cmd_sleep_parsed(void *parsed_result, void *data)
1269 struct cmd_sleep_result *res = parsed_result;
1270 time_wait_ms(res->ms);
1273 prog_char str_sleep_arg0[] = "sleep";
1274 parse_pgm_token_string_t cmd_sleep_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_sleep_result, arg0, str_sleep_arg0);
1275 parse_pgm_token_num_t cmd_sleep_ms = TOKEN_NUM_INITIALIZER(struct cmd_sleep_result, ms, UINT32);
1277 prog_char help_sleep[] = "Sleep during some miliseconds";
1278 parse_pgm_inst_t cmd_sleep = {
1279 .f = cmd_sleep_parsed, /* function to call */
1280 .data = NULL, /* 2nd arg of func */
1281 .help_str = help_sleep,
1282 .tokens = { /* token list, NULL terminated */
1283 (prog_void *)&cmd_sleep_arg0,
1284 (prog_void *)&cmd_sleep_ms,
1290 /**********************************************************/
1293 /* this structure is filled when cmd_test is parsed successfully */
1294 struct cmd_test_result {
1295 fixed_string_t arg0;
1300 /* function called when cmd_test is parsed successfully */
1301 static void cmd_test_parsed(void *parsed_result, void *data)
1303 strat_db.dump_enabled = 1;
1304 strat_db_dump(__FUNCTION__);
1306 corn_set_color(strat_db.corn_table[0], I2C_COB_BLACK);
1307 strat_db_dump(__FUNCTION__);
1309 corn_set_color(strat_db.corn_table[3], I2C_COB_WHITE);
1310 strat_db_dump(__FUNCTION__);
1311 corn_set_color(strat_db.corn_table[4], I2C_COB_WHITE);
1312 strat_db_dump(__FUNCTION__);
1313 corn_set_color(strat_db.corn_table[5], I2C_COB_WHITE);
1314 strat_db_dump(__FUNCTION__);
1317 prog_char str_test_arg0[] = "test";
1318 parse_pgm_token_string_t cmd_test_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_test_result, arg0, str_test_arg0);
1319 parse_pgm_token_num_t cmd_test_arg1 = TOKEN_NUM_INITIALIZER(struct cmd_test_result, radius, INT32);
1320 parse_pgm_token_num_t cmd_test_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_test_result, dist, INT32);
1322 prog_char help_test[] = "Test function";
1323 parse_pgm_inst_t cmd_test = {
1324 .f = cmd_test_parsed, /* function to call */
1325 .data = NULL, /* 2nd arg of func */
1326 .help_str = help_test,
1327 .tokens = { /* token list, NULL terminated */
1328 (prog_void *)&cmd_test_arg0,