From 8f02ddc821bcfc9b3494bd3961539cc44c665711 Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Thu, 18 Sep 2014 19:47:48 +0200 Subject: [PATCH] imuboard: add commands to dump gps or imu --- imuboard/commands.c | 82 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/imuboard/commands.c b/imuboard/commands.c index 42d243f..ab4132e 100644 --- a/imuboard/commands.c +++ b/imuboard/commands.c @@ -41,6 +41,8 @@ #include "main.h" #include "cmdline.h" #include "eeprom_config.h" +#include "gps_venus.h" +#include "imu.h" /* commands_gen.c */ extern const parse_inst_t PROGMEM cmd_reset; @@ -253,6 +255,84 @@ const parse_inst_t PROGMEM cmd_eeprom_list = { }, }; +/* ************* */ + +struct cmd_gps_show_result { + fixed_string_t cmd; + fixed_string_t action; +}; + +static void cmd_gps_show_parsed(void *parsed_result, + void *data) +{ + (void)parsed_result; + (void)data; + + while (!cmdline_keypressed()) { + gps_log(1); + } +} + +const char PROGMEM str_gps_show_gps[] = "gps"; +const parse_token_string_t PROGMEM cmd_gps_show_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_gps_show_result, cmd, + str_gps_show_gps); +const char PROGMEM str_gps_show_show[] = "show"; +const parse_token_string_t PROGMEM cmd_gps_show_action = + TOKEN_STRING_INITIALIZER(struct cmd_gps_show_result, action, + str_gps_show_show); + +const char PROGMEM help_gps_show[] = "show gps position"; +const parse_inst_t PROGMEM cmd_gps_show = { + .f = cmd_gps_show_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = help_gps_show, + .tokens = { /* token show, NULL terminated */ + (PGM_P)&cmd_gps_show_cmd, + (PGM_P)&cmd_gps_show_action, + NULL, + }, +}; + +/* ************* */ + +struct cmd_imu_show_result { + fixed_string_t cmd; + fixed_string_t action; +}; + +static void cmd_imu_show_parsed(void *parsed_result, + void *data) +{ + (void)parsed_result; + (void)data; + + while (!cmdline_keypressed()) { + imu_log(1); + } +} + +const char PROGMEM str_imu_show_imu[] = "imu"; +const parse_token_string_t PROGMEM cmd_imu_show_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_imu_show_result, cmd, + str_imu_show_imu); +const char PROGMEM str_imu_show_show[] = "show"; +const parse_token_string_t PROGMEM cmd_imu_show_action = + TOKEN_STRING_INITIALIZER(struct cmd_imu_show_result, action, + str_imu_show_show); + +const char PROGMEM help_imu_show[] = "show imu position"; +const parse_inst_t PROGMEM cmd_imu_show = { + .f = cmd_imu_show_parsed, /* function to call */ + .data = NULL, /* 2nd arg of func */ + .help_str = help_imu_show, + .tokens = { /* token show, NULL terminated */ + (PGM_P)&cmd_imu_show_cmd, + (PGM_P)&cmd_imu_show_action, + NULL, + }, +}; + /* ************* */ @@ -272,5 +352,7 @@ const parse_ctx_t PROGMEM main_ctx[] = { &cmd_eeprom_add, &cmd_eeprom_add2, &cmd_eeprom_list, + &cmd_gps_show, + &cmd_imu_show, NULL, }; -- 2.20.1