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"
74 struct cmd_event_result {
81 /* function called when cmd_event is parsed successfully */
82 static void cmd_event_parsed(void *parsed_result, void *data)
86 struct cmd_event_result * res = parsed_result;
88 if (!strcmp_P(res->arg1, PSTR("all"))) {
90 if (!strcmp_P(res->arg2, PSTR("on")))
91 mainboard.flags |= bit;
92 else if (!strcmp_P(res->arg2, PSTR("off")))
93 mainboard.flags &= bit;
95 printf_P(PSTR("encoders is %s\r\n"),
96 (DO_ENCODERS & mainboard.flags) ? "on":"off");
97 printf_P(PSTR("cs is %s\r\n"),
98 (DO_CS & mainboard.flags) ? "on":"off");
99 printf_P(PSTR("rs is %s\r\n"),
100 (DO_RS & mainboard.flags) ? "on":"off");
101 printf_P(PSTR("pos is %s\r\n"),
102 (DO_POS & mainboard.flags) ? "on":"off");
103 printf_P(PSTR("bd is %s\r\n"),
104 (DO_BD & mainboard.flags) ? "on":"off");
105 printf_P(PSTR("timer is %s\r\n"),
106 (DO_TIMER & mainboard.flags) ? "on":"off");
107 printf_P(PSTR("power is %s\r\n"),
108 (DO_POWER & mainboard.flags) ? "on":"off");
109 printf_P(PSTR("errblock is %s\r\n"),
110 (DO_ERRBLOCKING & mainboard.flags) ? "on":"off");
115 if (!strcmp_P(res->arg1, PSTR("encoders")))
117 else if (!strcmp_P(res->arg1, PSTR("cs"))) {
121 else if (!strcmp_P(res->arg1, PSTR("rs")))
123 else if (!strcmp_P(res->arg1, PSTR("pos")))
125 else if (!strcmp_P(res->arg1, PSTR("bd")))
127 else if (!strcmp_P(res->arg1, PSTR("timer"))) {
131 else if (!strcmp_P(res->arg1, PSTR("power")))
133 else if (!strcmp_P(res->arg1, PSTR("errblock")))
134 bit = DO_ERRBLOCKING;
136 if (!strcmp_P(res->arg2, PSTR("on")))
137 mainboard.flags |= bit;
138 else if (!strcmp_P(res->arg2, PSTR("off"))) {
139 if (!strcmp_P(res->arg1, PSTR("cs"))) {
141 robotsim_pwm(LEFT_PWM, 0);
142 robotsim_pwm(RIGHT_PWM, 0);
144 pwm_ng_set(LEFT_PWM, 0);
145 pwm_ng_set(RIGHT_PWM, 0);
148 mainboard.flags &= (~bit);
150 printf_P(PSTR("%s is %s\r\n"), res->arg1,
151 (bit & mainboard.flags) ? "on":"off");
154 prog_char str_event_arg0[] = "event";
155 parse_pgm_token_string_t cmd_event_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg0, str_event_arg0);
156 prog_char str_event_arg1[] = "all#encoders#cs#rs#pos#bd#timer#power#errblock";
157 parse_pgm_token_string_t cmd_event_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg1, str_event_arg1);
158 prog_char str_event_arg2[] = "on#off#show";
159 parse_pgm_token_string_t cmd_event_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_event_result, arg2, str_event_arg2);
161 prog_char help_event[] = "Enable/disable events";
162 parse_pgm_inst_t cmd_event = {
163 .f = cmd_event_parsed, /* function to call */
164 .data = NULL, /* 2nd arg of func */
165 .help_str = help_event,
166 .tokens = { /* token list, NULL terminated */
167 (prog_void *)&cmd_event_arg0,
168 (prog_void *)&cmd_event_arg1,
169 (prog_void *)&cmd_event_arg2,
175 /**********************************************************/
178 /* this structure is filled when cmd_spi_test is parsed successfully */
179 struct cmd_spi_test_result {
183 /* function called when cmd_spi_test is parsed successfully */
184 static void cmd_spi_test_parsed(void * parsed_result, void * data)
187 printf("not implemented\n");
189 uint16_t i = 0, ret = 0, ret2 = 0;
191 if (mainboard.flags & DO_ENCODERS) {
192 printf_P(PSTR("Disable encoder event first\r\n"));
198 ret = spi_send_and_receive_byte(i);
199 ret2 = spi_send_and_receive_byte(i);
200 spi_slave_deselect(0);
202 if ((i & 0x7ff) == 0)
203 printf_P(PSTR("Sent %.4x twice, received %x %x\r\n"),
207 } while(!cmdline_keypressed());
211 prog_char str_spi_test_arg0[] = "spi_test";
212 parse_pgm_token_string_t cmd_spi_test_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_spi_test_result, arg0, str_spi_test_arg0);
214 prog_char help_spi_test[] = "Test the SPI";
215 parse_pgm_inst_t cmd_spi_test = {
216 .f = cmd_spi_test_parsed, /* function to call */
217 .data = NULL, /* 2nd arg of func */
218 .help_str = help_spi_test,
219 .tokens = { /* token list, NULL terminated */
220 (prog_void *)&cmd_spi_test_arg0,
227 /**********************************************************/
230 /* this structure is filled when cmd_opponent is parsed successfully */
231 struct cmd_opponent_result {
238 /* function called when cmd_opponent is parsed successfully */
239 static void cmd_opponent_parsed(void *parsed_result, void *data)
243 if (get_opponent_xyda(&x, &y, &d, &a))
244 printf_P(PSTR("No opponent\r\n"));
246 printf_P(PSTR("x=%d y=%d, d=%d a=%d\r\n"), x, y, d, a);
249 prog_char str_opponent_arg0[] = "opponent";
250 parse_pgm_token_string_t cmd_opponent_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_opponent_result, arg0, str_opponent_arg0);
251 prog_char str_opponent_arg1[] = "show";
252 parse_pgm_token_string_t cmd_opponent_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_opponent_result, arg1, str_opponent_arg1);
254 prog_char help_opponent[] = "Show (x,y) opponent";
255 parse_pgm_inst_t cmd_opponent = {
256 .f = cmd_opponent_parsed, /* function to call */
257 .data = NULL, /* 2nd arg of func */
258 .help_str = help_opponent,
259 .tokens = { /* token list, NULL terminated */
260 (prog_void *)&cmd_opponent_arg0,
261 (prog_void *)&cmd_opponent_arg1,
267 prog_char str_opponent_arg1_set[] = "set";
268 parse_pgm_token_string_t cmd_opponent_arg1_set = TOKEN_STRING_INITIALIZER(struct cmd_opponent_result, arg1, str_opponent_arg1_set);
269 parse_pgm_token_num_t cmd_opponent_arg2 = TOKEN_NUM_INITIALIZER(struct cmd_opponent_result, arg2, INT32);
270 parse_pgm_token_num_t cmd_opponent_arg3 = TOKEN_NUM_INITIALIZER(struct cmd_opponent_result, arg3, INT32);
272 prog_char help_opponent_set[] = "Set (x,y) opponent";
273 parse_pgm_inst_t cmd_opponent_set = {
274 .f = cmd_opponent_parsed, /* function to call */
275 .data = NULL, /* 2nd arg of func */
276 .help_str = help_opponent_set,
277 .tokens = { /* token list, NULL terminated */
278 (prog_void *)&cmd_opponent_arg0,
279 (prog_void *)&cmd_opponent_arg1_set,
280 (prog_void *)&cmd_opponent_arg2,
281 (prog_void *)&cmd_opponent_arg3,
286 /**********************************************************/
289 /* this structure is filled when cmd_beacon_start is parsed successfully */
290 struct cmd_beacon_start_result {
295 /* function called when cmd_beacon_start is parsed successfully */
296 static void cmd_beacon_start_parsed(void *parsed_result, void *data)
298 struct cmd_beacon_start_result *res = parsed_result;
300 if (!strcmp_P(res->arg1, PSTR("start")))
301 i2c_ballboard_set_beacon(1);
303 i2c_ballboard_set_beacon(0);
306 prog_char str_beacon_start_arg0[] = "beacon";
307 parse_pgm_token_string_t cmd_beacon_start_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_beacon_start_result, arg0, str_beacon_start_arg0);
308 prog_char str_beacon_start_arg1[] = "start#stop";
309 parse_pgm_token_string_t cmd_beacon_start_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_beacon_start_result, arg1, str_beacon_start_arg1);
311 prog_char help_beacon_start[] = "Beacon enabled/disable";
312 parse_pgm_inst_t cmd_beacon_start = {
313 .f = cmd_beacon_start_parsed, /* function to call */
314 .data = NULL, /* 2nd arg of func */
315 .help_str = help_beacon_start,
316 .tokens = { /* token list, NULL terminated */
317 (prog_void *)&cmd_beacon_start_arg0,
318 (prog_void *)&cmd_beacon_start_arg1,
323 /**********************************************************/
326 /* this structure is filled when cmd_start is parsed successfully */
327 struct cmd_start_result {
329 fixed_string_t color;
330 fixed_string_t debug;
333 /* function called when cmd_start is parsed successfully */
334 static void cmd_start_parsed(void *parsed_result, void *data)
336 struct cmd_start_result *res = parsed_result;
337 uint8_t old_level = gen.log_level;
339 gen.logs[NB_LOGS] = E_USER_STRAT;
340 if (!strcmp_P(res->debug, PSTR("debug"))) {
341 strat_db.dump_enabled = 1;
345 strat_db.dump_enabled = 0;
349 if (!strcmp_P(res->color, PSTR("yellow"))) {
350 mainboard.our_color = I2C_COLOR_YELLOW;
351 i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_YELLOW);
352 i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_YELLOW);
354 else if (!strcmp_P(res->color, PSTR("blue"))) {
355 mainboard.our_color = I2C_COLOR_BLUE;
356 i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_BLUE);
357 i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_BLUE);
360 printf_P(PSTR("Press a key when beacon ready\r\n"));
361 i2c_ballboard_set_beacon(0);
362 while(!cmdline_keypressed());
363 i2c_ballboard_set_beacon(1);
367 gen.logs[NB_LOGS] = 0;
368 gen.log_level = old_level;
371 prog_char str_start_arg0[] = "start";
372 parse_pgm_token_string_t cmd_start_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_start_result, arg0, str_start_arg0);
373 prog_char str_start_color[] = "blue#yellow";
374 parse_pgm_token_string_t cmd_start_color = TOKEN_STRING_INITIALIZER(struct cmd_start_result, color, str_start_color);
375 prog_char str_start_debug[] = "debug#match";
376 parse_pgm_token_string_t cmd_start_debug = TOKEN_STRING_INITIALIZER(struct cmd_start_result, debug, str_start_debug);
378 prog_char help_start[] = "Start the robot";
379 parse_pgm_inst_t cmd_start = {
380 .f = cmd_start_parsed, /* function to call */
381 .data = NULL, /* 2nd arg of func */
382 .help_str = help_start,
383 .tokens = { /* token list, NULL terminated */
384 (prog_void *)&cmd_start_arg0,
385 (prog_void *)&cmd_start_color,
386 (prog_void *)&cmd_start_debug,
393 /**********************************************************/
396 /* this structure is filled when cmd_interact is parsed successfully */
397 struct cmd_interact_result {
401 static void print_cs(void)
403 printf_P(PSTR("cons_d=% .8"PRIi32" cons_a=% .8"PRIi32" fil_d=% .8"PRIi32" fil_a=% .8"PRIi32" "
404 "err_d=% .8"PRIi32" err_a=% .8"PRIi32" out_d=% .8"PRIi32" out_a=% .8"PRIi32"\r\n"),
405 cs_get_consign(&mainboard.distance.cs),
406 cs_get_consign(&mainboard.angle.cs),
407 cs_get_filtered_consign(&mainboard.distance.cs),
408 cs_get_filtered_consign(&mainboard.angle.cs),
409 cs_get_error(&mainboard.distance.cs),
410 cs_get_error(&mainboard.angle.cs),
411 cs_get_out(&mainboard.distance.cs),
412 cs_get_out(&mainboard.angle.cs));
415 static void print_pos(void)
417 printf_P(PSTR("x=% .8d y=% .8d a=% .8d\r\n"),
418 position_get_x_s16(&mainboard.pos),
419 position_get_y_s16(&mainboard.pos),
420 position_get_a_deg_s16(&mainboard.pos));
423 static void print_time(void)
425 printf_P(PSTR("time %d\r\n"),time_get_s());
429 static void print_sensors(void)
432 if (sensor_start_switch())
433 printf_P(PSTR("Start switch | "));
435 printf_P(PSTR(" | "));
437 if (IR_DISP_SENSOR())
438 printf_P(PSTR("IR disp | "));
440 printf_P(PSTR(" | "));
442 printf_P(PSTR("\r\n"));
446 static void print_pid(void)
448 printf_P(PSTR("P=% .8"PRIi32" I=% .8"PRIi32" D=% .8"PRIi32" out=% .8"PRIi32" | "
449 "P=% .8"PRIi32" I=% .8"PRIi32" D=% .8"PRIi32" out=% .8"PRIi32"\r\n"),
450 pid_get_value_in(&mainboard.distance.pid) * pid_get_gain_P(&mainboard.distance.pid),
451 pid_get_value_I(&mainboard.distance.pid) * pid_get_gain_I(&mainboard.distance.pid),
452 pid_get_value_D(&mainboard.distance.pid) * pid_get_gain_D(&mainboard.distance.pid),
453 pid_get_value_out(&mainboard.distance.pid),
454 pid_get_value_in(&mainboard.angle.pid) * pid_get_gain_P(&mainboard.angle.pid),
455 pid_get_value_I(&mainboard.angle.pid) * pid_get_gain_I(&mainboard.angle.pid),
456 pid_get_value_D(&mainboard.angle.pid) * pid_get_gain_D(&mainboard.angle.pid),
457 pid_get_value_out(&mainboard.angle.pid));
460 #define PRINT_POS (1<<0)
461 #define PRINT_PID (1<<1)
462 #define PRINT_CS (1<<2)
463 #define PRINT_SENSORS (1<<3)
464 #define PRINT_TIME (1<<4)
465 #define PRINT_BLOCKING (1<<5)
467 static void cmd_interact_parsed(void * parsed_result, void * data)
476 printf_P(PSTR("Display debugs:\r\n"
482 /* " 6:blocking\r\n" */
489 mainboard.flags &= (~DO_CS);
490 pwm_set_and_save(LEFT_PWM, 0);
491 pwm_set_and_save(RIGHT_PWM, 0);
494 if (print & PRINT_POS) {
498 if (print & PRINT_PID) {
502 if (print & PRINT_CS) {
506 if (print & PRINT_SENSORS) {
510 if (print & PRINT_TIME) {
513 /* if (print & PRINT_BLOCKING) { */
514 /* printf_P(PSTR("%s %s blocking=%d\r\n"), */
515 /* mainboard.blocking ? "BLOCK1":" ", */
516 /* rs_is_blocked(&mainboard.rs) ? "BLOCK2":" ", */
517 /* rs_get_blocking(&mainboard.rs)); */
520 c = cmdline_getchar();
525 cmd = vt100_parser(&vt100, c);
533 case '1': print ^= PRINT_POS; break;
534 case '2': print ^= PRINT_PID; break;
535 case '3': print ^= PRINT_CS; break;
536 case '4': print ^= PRINT_SENSORS; break;
537 case '5': print ^= PRINT_TIME; break;
538 case '6': print ^= PRINT_BLOCKING; break;
541 if (mainboard.flags & DO_CS)
543 pwm_set_and_save(LEFT_PWM, 0);
544 pwm_set_and_save(RIGHT_PWM, 0);
547 pwm_set_and_save(LEFT_PWM, 0);
548 pwm_set_and_save(RIGHT_PWM, 0);
556 #define PWM_INTERACT 1200
558 #define PWM_INTERACT 1200
562 pwm_set_and_save(LEFT_PWM, PWM_INTERACT);
563 pwm_set_and_save(RIGHT_PWM, PWM_INTERACT);
566 pwm_set_and_save(LEFT_PWM, -PWM_INTERACT);
567 pwm_set_and_save(RIGHT_PWM, PWM_INTERACT);
570 pwm_set_and_save(LEFT_PWM, -PWM_INTERACT);
571 pwm_set_and_save(RIGHT_PWM, -PWM_INTERACT);
574 pwm_set_and_save(LEFT_PWM, PWM_INTERACT);
575 pwm_set_and_save(RIGHT_PWM, -PWM_INTERACT);
583 prog_char str_interact_arg0[] = "interact";
584 parse_pgm_token_string_t cmd_interact_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_interact_result, arg0, str_interact_arg0);
586 prog_char help_interact[] = "Interactive mode";
587 parse_pgm_inst_t cmd_interact = {
588 .f = cmd_interact_parsed, /* function to call */
589 .data = NULL, /* 2nd arg of func */
590 .help_str = help_interact,
591 .tokens = { /* token list, NULL terminated */
592 (prog_void *)&cmd_interact_arg0,
598 /**********************************************************/
601 /* this structure is filled when cmd_color is parsed successfully */
602 struct cmd_color_result {
604 fixed_string_t color;
607 /* function called when cmd_color is parsed successfully */
608 static void cmd_color_parsed(void *parsed_result, void *data)
611 printf("not implemented\n");
613 struct cmd_color_result *res = (struct cmd_color_result *) parsed_result;
614 if (!strcmp_P(res->color, PSTR("yellow"))) {
615 mainboard.our_color = I2C_COLOR_YELLOW;
616 i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_YELLOW);
617 i2c_set_color(I2C_BALLBOARD_ADDR, I2C_COLOR_YELLOW);
619 else if (!strcmp_P(res->color, PSTR("blue"))) {
620 mainboard.our_color = I2C_COLOR_BLUE;
621 i2c_set_color(I2C_COBBOARD_ADDR, I2C_COLOR_BLUE);
622 i2c_set_color(I2C_BALLBOARD_ADDR, 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,