diff --git a/rigs/yaesu/YaesuTargetableVFO.xlsx b/rigs/yaesu/YaesuTargetableVFO.xlsx new file mode 100755 index 000000000..4c33caabc Binary files /dev/null and b/rigs/yaesu/YaesuTargetableVFO.xlsx differ diff --git a/rigs/yaesu/ft1200.c b/rigs/yaesu/ft1200.c index cac526271..68faac7e5 100644 --- a/rigs/yaesu/ft1200.c +++ b/rigs/yaesu/ft1200.c @@ -87,7 +87,7 @@ const struct rig_caps ft1200_caps = .max_xit = Hz(9999), .max_ifshift = Hz(1000), .vfo_ops = FT1200_VFO_OPS, - .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, + .targetable_vfo = RIG_TARGETABLE_FREQ, .transceive = RIG_TRN_OFF, /* May enable later as the 1200 has an Auto Info command */ .bank_qty = 0, .chan_desc_sz = 0, diff --git a/rigs/yaesu/ft5000.c b/rigs/yaesu/ft5000.c index 0e43e8ea0..7545a5d73 100644 --- a/rigs/yaesu/ft5000.c +++ b/rigs/yaesu/ft5000.c @@ -421,7 +421,7 @@ const struct rig_caps ftdx101d_caps = .max_xit = Hz(9999), .max_ifshift = Hz(1000), .vfo_ops = FTDX5000_VFO_OPS, - .targetable_vfo = RIG_TARGETABLE_FREQ, /* one of the few diffs from the 5000 */ + .targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE, .transceive = RIG_TRN_OFF, /* May enable later as the 5000 has an Auto Info command */ .bank_qty = 0, .chan_desc_sz = 0, diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index e87cc8279..6f0a0bd8a 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -11,10 +11,6 @@ * via serial interface to any newer Yaesu radio using the * "new" text CAT interface. * - * Models this code aims to support are FTDX-9000*, FT-2000, FT-DX5000, - * FT-950, FT-450 and FT-1200. Much testing remains. -N0NB - * - * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -97,6 +93,18 @@ typedef struct _yaesu_newcat_commands ncboolean ft101; } yaesu_newcat_commands_t; +// Easy reference to rig model -- it is set in newcat_valid_command +static ncboolean is_ft450; +static ncboolean is_ft891; +static ncboolean is_ft950; +static ncboolean is_ft991; +static ncboolean is_ft2000; +static ncboolean is_ft9000; +static ncboolean is_ft5000; +static ncboolean is_ft1200; +static ncboolean is_ft3000; +static ncboolean is_ft101; + /* * Even thought this table does make a handy reference, it could be depreciated as it is not really needed. * All of the CAT commands used in the newcat interface are available on the FT-950, FT-2000, FT-5000, and FT-9000. @@ -115,7 +123,7 @@ typedef struct _yaesu_newcat_commands */ static const yaesu_newcat_commands_t valid_commands[] = { - /* Command FT-450 FT-950 FT-891 FT-991 FT-2000 FT-9000 FT-5000 FT-1200 FT-3000 FTDX101D */ + /* Command FT-450 FT-950 FT-891 FT-991 FT-2000 FT-9000 FT-5000 FT-1200 FT-3000 FTDX101D */ {"AB", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, {"AC", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, {"AG", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, @@ -176,7 +184,7 @@ static const yaesu_newcat_commands_t valid_commands[] = {"MT", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE }, {"MW", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, {"MX", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, - {"NA", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, + {"NA", TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE }, {"NB", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, {"NL", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, {"NR", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE }, @@ -742,9 +750,7 @@ int newcat_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) /* FT9000 RIG_TARGETABLE_MODE (mode and width) */ /* FT2000 mode only */ - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { priv->cmd_str[2] = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -802,9 +808,7 @@ int newcat_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = RIG_VFO_B == vfo ? '1' : '0'; } @@ -1159,9 +1163,7 @@ int newcat_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = RIG_VFO_B == vfo ? '1' : '0'; } @@ -1214,9 +1216,7 @@ int newcat_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -1882,9 +1882,7 @@ int newcat_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -1943,9 +1941,7 @@ int newcat_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -2340,7 +2336,7 @@ int newcat_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = RIG_VFO_B == vfo ? '1' : '0'; } @@ -2432,7 +2428,7 @@ int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -2499,10 +2495,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) return err; } - /* Start with both but mostly FT9000 */ - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -2585,7 +2578,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "IS0%+.4d%c", val.i, cat_term); /* problem with %+04d */ - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE && !is_ft2000) { priv->cmd_str[2] = main_sub_vfo; } @@ -2692,7 +2685,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "PA00%c", cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE && !is_ft2000) { priv->cmd_str[2] = main_sub_vfo; } @@ -2711,7 +2704,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) if (strlen(priv->cmd_str) != 0) { - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { priv->cmd_str[2] = main_sub_vfo; } @@ -2731,7 +2724,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RA00%c", cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE && !is_ft2000) { priv->cmd_str[2] = main_sub_vfo; } @@ -2750,7 +2743,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) if (strlen(priv->cmd_str) != 0) { - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { priv->cmd_str[2] = main_sub_vfo; } @@ -2809,7 +2802,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RL0%02d%c", fpf, cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE && !is_ft2000) { priv->cmd_str[2] = main_sub_vfo; } @@ -2859,9 +2852,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) val.i = 3000; } } - else if (newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + else if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { if (val.i < 1) { @@ -2910,9 +2901,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) val.i = 3000; } } - else if (newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + else if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { if (val.i < 0) { @@ -2988,10 +2977,14 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "BP01%03d%c", val.i, cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) /* The old CAT Man. shows VFO */ + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE && !is_ft9000) { priv->cmd_str[2] = main_sub_vfo; } + else if (is_ft9000) // different BP command format + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "BP%03d%c", val.i, cat_term); + } break; @@ -3023,9 +3016,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -3049,7 +3040,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "PA0%c", cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { priv->cmd_str[2] = main_sub_vfo; } @@ -3084,7 +3075,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "IS0%c", cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { priv->cmd_str[2] = main_sub_vfo; } @@ -3135,7 +3126,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RA0%c", cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { priv->cmd_str[2] = main_sub_vfo; } @@ -3169,7 +3160,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RL0%c", cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { priv->cmd_str[2] = main_sub_vfo; } @@ -3236,7 +3227,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return -RIG_ENAVAIL; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM09%c", cat_term); } @@ -3253,7 +3244,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return -RIG_ENAVAIL; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM07%c", cat_term); } @@ -3288,7 +3279,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "BP01%c", cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { priv->cmd_str[2] = main_sub_vfo; } @@ -3503,9 +3494,7 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -3521,7 +3510,7 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "BC0%d%c", status ? 1 : 0, cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE && !is_ft2000) { priv->cmd_str[2] = main_sub_vfo; } @@ -3537,7 +3526,7 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "BP00%03d%c", status ? 1 : 0, cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE && !is_ft2000) { priv->cmd_str[2] = main_sub_vfo; } @@ -3676,7 +3665,7 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "BC0%c", cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { priv->cmd_str[2] = main_sub_vfo; } @@ -3691,7 +3680,7 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) snprintf(priv->cmd_str, sizeof(priv->cmd_str), "BP00%c", cat_term); - if (newcat_is_rig(rig, RIG_MODEL_FT9000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { priv->cmd_str[2] = main_sub_vfo; } @@ -4076,9 +4065,7 @@ int newcat_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -4592,16 +4579,6 @@ const char *newcat_get_info(RIG *rig) ncboolean newcat_valid_command(RIG *rig, char const *const command) { const struct rig_caps *caps; - ncboolean is_ft450; - ncboolean is_ft891; - ncboolean is_ft950; - ncboolean is_ft991; - ncboolean is_ft2000; - ncboolean is_ft9000; - ncboolean is_ft5000; - ncboolean is_ft1200; - ncboolean is_ft3000; - ncboolean is_ft101; int search_high; int search_low; @@ -4962,10 +4939,7 @@ int newcat_set_narrow(RIG *rig, vfo_t vfo, ncboolean narrow) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000) || - newcat_is_rig(rig, RIG_MODEL_FTDX3000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -5010,10 +4984,7 @@ int newcat_get_narrow(RIG *rig, vfo_t vfo, ncboolean *narrow) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FT2000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000) || - newcat_is_rig(rig, RIG_MODEL_FTDX3000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -5066,9 +5037,7 @@ int newcat_set_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000) || - newcat_is_rig(rig, RIG_MODEL_FTDX3000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE && !is_ft2000) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } @@ -5731,9 +5700,7 @@ int newcat_get_rx_bandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *width) return err; } - if (newcat_is_rig(rig, RIG_MODEL_FT9000) || - newcat_is_rig(rig, RIG_MODEL_FTDX5000) || - newcat_is_rig(rig, RIG_MODEL_FTDX3000)) + if (rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) { main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; } diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 9695a1055..7a034067b 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20200511" +#define NEWCAT_VER "20200526" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 diff --git a/tests/rigctl.c b/tests/rigctl.c index fedb0405b..fc0b543b0 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) char conf_parms[MAXCONFLEN] = ""; int interactive; /* if no cmd on command line, switch to interactive */ int prompt = 1; /* Print prompt in rigctl */ - int vfo_mode = 0; /* vfo_mode = 0 means target VFO is 'currVFO' */ + int vfo_opt = 0; /* vfo_opt = 0 means target VFO is 'currVFO' */ char send_cmd_term = '\r'; /* send_cmd termination char */ int ext_resp = 0; char resp_sep = '\n'; @@ -380,7 +380,7 @@ int main(int argc, char *argv[]) break; case 'o': - vfo_mode++; + vfo_opt = 1; break; case 'n': @@ -448,6 +448,7 @@ int main(int argc, char *argv[]) } my_rig = rig_init(my_model); + my_rig->state.vfo_opt = 1; if (!my_rig) { @@ -555,21 +556,21 @@ int main(int argc, char *argv[]) if (my_rig->caps->rig_model == RIG_MODEL_NETRIGCTL) { /* We automatically detect if we need to be in vfo mode or not */ - int rigctld_vfo_mode = netrigctl_get_vfo_mode(my_rig); + int rigctld_vfo_opt = netrigctl_get_vfo_mode(my_rig); - if (rigctld_vfo_mode && !vfo_mode) + if (rigctld_vfo_opt && !vfo_opt) { fprintf(stderr, "Looks like rigctld is using vfo mode so we're switching to vfo mode\n"); - vfo_mode = rigctld_vfo_mode; + vfo_opt = rigctld_vfo_opt; } - else if (!rigctld_vfo_mode && vfo_mode) + else if (!rigctld_vfo_opt && vfo_opt) { fprintf(stderr, "Looks like rigctld is not using vfo mode so we're switching vfo mode off\n"); - vfo_mode = rigctld_vfo_mode; + vfo_opt = rigctld_vfo_opt; } - else if (vfo_mode && my_rig->caps->rig_model != RIG_MODEL_NETRIGCTL) + else if (vfo_opt && my_rig->caps->rig_model != RIG_MODEL_NETRIGCTL) { fprintf(stderr, "vfo mode doesn't make sense for any rig other than rig#2\n"); fprintf(stderr, "But we'll let you run this way if you want\n"); @@ -632,7 +633,7 @@ int main(int argc, char *argv[]) do { retcode = rigctl_parse(my_rig, stdin, stdout, argv, argc, NULL, - interactive, prompt, &vfo_mode, send_cmd_term, + interactive, prompt, &vfo_opt, send_cmd_term, &ext_resp, &resp_sep); if (retcode == 2) diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 8f0195b00..ab892e27d 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -144,7 +144,7 @@ struct test_table FILE *fin, \ int interactive, \ int prompt, \ - int vfo_mode, \ + int vfo_opt, \ char send_cmd_term, \ int ext_resp, \ char resp_sep, \ @@ -613,7 +613,7 @@ static int next_word(char *buffer, int argc, char *argv[], int newline) int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, sync_cb_t sync_cb, - int interactive, int prompt, int *vfo_mode, char send_cmd_term, + int interactive, int prompt, int *vfo_opt, char send_cmd_term, int *ext_resp_ptr, char *resp_sep_ptr) { int retcode; /* generic return code from functions */ @@ -651,8 +651,10 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, return -1; } + if (cmd != 0xa) { rig_debug(RIG_DEBUG_TRACE, "%s: cmd=%c(%02x)\n", __func__, isprint(cmd) ? cmd : ' ', cmd); + } /* Extended response protocol requested with leading '+' on command * string--rigctld only! @@ -764,9 +766,11 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, return 0; } - if (cmd == '(') {rig_debug(RIG_DEBUG_ERR, "%s: vfo_mode on\n", __func__); *vfo_mode = 1; return 0;} + if (cmd == '(') {rig_debug(RIG_DEBUG_ERR, "%s: vfo_opt on\n", __func__); *vfo_opt = 1; return 0;} - if (cmd == ')') {rig_debug(RIG_DEBUG_ERR, "%s: vfo_mode off\n", __func__); *vfo_mode = 0; return 0;} + if (cmd == ')') {rig_debug(RIG_DEBUG_ERR, "%s: vfo_opt off\n", __func__); *vfo_opt = 0; return 0;} + + my_rig->state.vfo_opt = *vfo_opt; if (cmd == 'Q' || cmd == 'q') { @@ -820,7 +824,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, return 0; } - if (!(cmd_entry->flags & ARG_NOVFO) && *vfo_mode) + if (!(cmd_entry->flags & ARG_NOVFO) && *vfo_opt) { if (interactive) { @@ -1222,10 +1226,10 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, return 0; } - /* If vfo_mode is enabled (-o|--vfo) check if already given + /* If vfo_opt is enabled (-o|--vfo) check if already given * or prompt for it. */ - if (!(cmd_entry->flags & ARG_NOVFO) && *vfo_mode) + if (!(cmd_entry->flags & ARG_NOVFO) && *vfo_opt) { /* Check if VFO was given with command. */ result = strtok(NULL, " "); @@ -1321,7 +1325,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, */ result = strtok(NULL, "\0"); - if (*vfo_mode && result) + if (*vfo_opt && result) { x = 2; parsed_input[x] = result; @@ -1384,7 +1388,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, { result = strtok(NULL, " "); - if (*vfo_mode && result) + if (*vfo_opt && result) { x = 2; parsed_input[x] = result; @@ -1450,7 +1454,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, result = strtok(NULL, " "); - if (*vfo_mode && result) + if (*vfo_opt && result) { x = 3; parsed_input[x] = result; @@ -1516,7 +1520,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, result = strtok(NULL, " "); - if (*vfo_mode && result) + if (*vfo_opt && result) { x = 4; parsed_input[x] = result; @@ -1612,7 +1616,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, char a3[MAXARGSZ + 2]; char vfo_str[MAXARGSZ + 2]; - *vfo_mode == 0 ? vfo_str[0] = '\0' : snprintf(vfo_str, + *vfo_opt == 0 ? vfo_str[0] = '\0' : snprintf(vfo_str, sizeof(vfo_str), " %s", rig_strvfo(vfo)); @@ -1631,13 +1635,13 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, *resp_sep_ptr); } - rig_debug(RIG_DEBUG_TRACE, "%s: vfo_mode=%d\n", __func__, *vfo_mode); + rig_debug(RIG_DEBUG_TRACE, "%s: vfo_opt=%d\n", __func__, *vfo_opt); retcode = (*cmd_entry->rig_routine)(my_rig, fout, fin, interactive, prompt, - *vfo_mode, + *vfo_opt, send_cmd_term, *ext_resp_ptr, *resp_sep_ptr, @@ -4507,7 +4511,7 @@ declare_proto_rig(chk_vfo) fprintf(fout, "%s: ", cmd->arg1); /* i.e. "Frequency" */ } - fprintf(fout, "%d\n", vfo_mode); + fprintf(fout, "%d\n", rig->state.vfo_opt); return RIG_OK; }