Esempio n. 1
0
static void shell_cmd_load(char *args, void *data)
{
    struct shell_argval argval[SHELL_CMD_LOAD_ARGS+1], *idx, *tab;
    unsigned char t, j;
    
    t = shell_arg_parser(args, argval, SHELL_CMD_LOAD_ARGS);
    
    idx = shell_get_argval(argval, 'i');
    tab = shell_get_argval(argval, 't');
    if ((t != 1) && ((idx == NULL) && (tab == NULL))) {
        shell_printf("load tab: [-i <tab index> | -t <tab number>]\n");
        shell_printf(" -i <tab index>   tab index (0 to %d)\n", tab_list[0]-1);
        shell_printf(" -t <tab id>      tab id\n");
    } else {
        if (idx != NULL) {
            j = atoi(idx->val);
            if (j < tab_list[0]) {
                shell_printf("Loading tab index %d of %d\n", j, tab_list[0]-1);
                load_tab(tab_list[j+1]);
            } else {
                shell_printf("Out of range [0 ... %d]\n", tab_list[0]-1);
            }
        } else {
            j = atoi(tab->val);
            shell_printf("Loading tab id %d\n", j);
            load_tab(j);
        }
    }
}
Esempio n. 2
0
static void shell_cmd_config(char *args, void *data)
{
    struct ch_switch *cfg = &config.tab_sw;
    struct shell_argval argval[SHELL_CMD_CONFIG_ARGS+1], *p;
    unsigned char t, i;
    unsigned int w;

    t = shell_arg_parser(args, argval, SHELL_CMD_CONFIG_ARGS);
    if (t < 1) {
        shell_printf("Tab switch config:\n");
        shell_printf(" Mode: %d (0:ch percent; 1:flight mode; 2:ch toggle)\n", cfg->mode);
        shell_printf(" Ch:   CH%d\n", cfg->ch + 1);
        shell_printf(" Min:  %d\n", cfg->ch_min);
        shell_printf(" Max:  %d\n", cfg->ch_max);
        shell_printf(" Time: %d00ms\n", cfg->time);
        shell_printf("\noptions: -m <mode> -c <ch> -l <min> -h <max> -t <time>\n");
    } else {
        p = shell_get_argval(argval, 'm');
        if (p != NULL) {
            i = atoi(p->val);
            if (i < SW_MODE_END)
                cfg->mode = i;
        }
        p = shell_get_argval(argval, 'c');
        if (p != NULL) {
            i = atoi(p->val);
            i = TRIM(i, 0, 17);
            cfg->ch = i;
        }
        p = shell_get_argval(argval, 'l');
        if (p != NULL) {
            w = atoi(p->val);
            w = TRIM(w, 900, 2100);
            cfg->ch_min = w;
        }
        p = shell_get_argval(argval, 'h');
        if (p != NULL) {
            w = atoi(p->val);
            w = TRIM(w, 900, 2100);
            cfg->ch_max = w;
        }
        p = shell_get_argval(argval, 't');
        if (p != NULL) {
            w = atoi(p->val);
            w = w / 100;
            cfg->time = w;
        }
    }
}
Esempio n. 3
0
void shell_cmd_rates(char *args, void *data)
{
    struct shell_argval argval[SHELL_CMD_MAVRATE_ARGS+1], *p;
    unsigned char t, i, val;
    unsigned char *v;
    
    t = shell_arg_parser(args, argval, SHELL_CMD_MAVRATE_ARGS);
    p = shell_get_argval(argval, 's');

    if ((t < 2) || (p == NULL)) {
        shell_printf("\nMavlink stream rates:\n");
        shell_printf("id - rate stream\n");
        for (i = 0; i < sizeof(mavlink_stream_map)-1; i++) {
            v = (unsigned char*) params_mavlink_rates[i].value;
            shell_printf(" %u - [%2u] %s\n", i+1, *v,
                        params_mavlink_rates[i].name);
        };
        
        shell_printf("\nset rate: [-s <stream_id> -r <rate>]\n");
        shell_printf(" -s <stream_id>  mavlink stream id (0=ALL)\n");
        shell_printf(" -r <rate>       stream rate: 0-10\n");
    } else {
        if (p != NULL) {
            i = atoi(p->val);
            if (i > sizeof(mavlink_stream_map)) {
                shell_printf("\nInvalid stream id\n");
            } else {
                p = shell_get_argval(argval, 'r');
                val = atoi(p->val);
                if (val > 10)
                    val = 0;
                shell_printf("\nSetting stream id %u to %uHz\n", i, val);
                mavlink_request_data_stream(i, val);
            }
        }
    }
}