From 325277f269615eef8fdfb1fc1104203557dc99b1 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 24 Oct 2023 23:07:33 -0500 Subject: [PATCH] Add USB_AF and USB_AF_INPUT for FTDX101D/MP --- rigs/yaesu/ftdx101.c | 1 + rigs/yaesu/ftdx101.h | 2 +- rigs/yaesu/ftdx101mp.c | 1 + rigs/yaesu/newcat.c | 109 +++++++++++++++++++++++++++++++++++++++ rigs/yaesu/newcat.h | 2 +- simulators/simftdx101.c | 16 +++++- simulators/simftdx1200.c | 2 +- simulators/simftdx3000.c | 2 +- simulators/simftdx5000.c | 2 +- simulators/simyaesu.c | 2 +- 10 files changed, 132 insertions(+), 7 deletions(-) diff --git a/rigs/yaesu/ftdx101.c b/rigs/yaesu/ftdx101.c index c5e6b0659..57cdc80c1 100644 --- a/rigs/yaesu/ftdx101.c +++ b/rigs/yaesu/ftdx101.c @@ -203,6 +203,7 @@ const struct rig_caps ftdx101d_caps = [LVL_SQL] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, [LVL_MONITOR_GAIN] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, [LVL_RFPOWER] = { .min = { .f = .05 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, + [LVL_USB_AF] = { .min = { .f = .0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, }, .parm_gran = { [PARM_BANDSELECT] = {.min = {.f = 0.0f}, .max = {.f = 1.0f}, .step = {.s = "BAND160M,BAND80M,BAND60M,BAND40M,BAND30M,BAND20M,BAND17M,BAND15M,BAND12M,BAND10M,BAND6M,BANDGEN,BANDMW,BANDUNUSED,BANDUNUSED,BANDUNUSED,BANDUNUSED,BAND4M"}} diff --git a/rigs/yaesu/ftdx101.h b/rigs/yaesu/ftdx101.h index e721f2155..fd830f1c5 100644 --- a/rigs/yaesu/ftdx101.h +++ b/rigs/yaesu/ftdx101.h @@ -60,7 +60,7 @@ RIG_LEVEL_ANTIVOX|RIG_LEVEL_NR|RIG_LEVEL_NB|RIG_LEVEL_NOTCHF|\ RIG_LEVEL_MONITOR_GAIN|RIG_LEVEL_RFPOWER_METER|RIG_LEVEL_RFPOWER_METER_WATTS|\ RIG_LEVEL_COMP_METER|RIG_LEVEL_VD_METER|RIG_LEVEL_ID_METER|RIG_LEVEL_TEMP_METER|\ - RIG_LEVEL_BAND_SELECT) + RIG_LEVEL_BAND_SELECT|RIG_LEVEL_USB_AF) #define FTDX101_FUNCS (RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_LOCK|\ RIG_FUNC_MON|RIG_FUNC_NB|RIG_FUNC_NR|RIG_FUNC_VOX|\ diff --git a/rigs/yaesu/ftdx101mp.c b/rigs/yaesu/ftdx101mp.c index fe5ecb450..801fa3dbe 100644 --- a/rigs/yaesu/ftdx101mp.c +++ b/rigs/yaesu/ftdx101mp.c @@ -105,6 +105,7 @@ const struct rig_caps ftdx101mp_caps = [LVL_SQL] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, [LVL_MONITOR_GAIN] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, [LVL_RFPOWER] = { .min = { .f = .05 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, + [LVL_USB_AF] = { .min = { .f = .0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, }, .parm_gran = { [PARM_BANDSELECT] = {.min = {.f = 0.0f}, .max = {.f = 1.0f}, .step = {.s = "BAND160M,BAND80M,BANDUNUSED,BAND40M,BAND30M,BAND20M,BAND17M,BAND15M,BAND12M,BAND10M,BAND6M,BANDGEN,BANDMW,BANDUNUSED,BANDUNUSED,BANDUNUSED,BANDUNUSED,BAND4M"}} diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 14dd26df0..e51040e17 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -4850,6 +4850,36 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) break; + case RIG_LEVEL_USB_AF: + if (is_ftdx101d || is_ftdx101mp) + { + rmode_t curmode = rig->state.current_vfo == RIG_VFO_A? rig->state.cache.modeMainA : rig->state.cache.modeMainB; + switch(curmode) + { + case RIG_MODE_USB: + case RIG_MODE_LSB: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010113%03.0f%c", val.f*100, cat_term); + break; + case RIG_MODE_AM: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010214%03.0f%c", val.f*100, cat_term); + break; + case RIG_MODE_FM: + case RIG_MODE_FMN: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010313%03.0f%c", val.f*100, cat_term); + break; + case RIG_MODE_PKTFM: // is this the right place for this? + case RIG_MODE_PKTFMN: // is this the right place for this? + case RIG_MODE_PKTUSB: + case RIG_MODE_PKTLSB: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010415%03.0f%c", val.f*100, cat_term); + break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown how to set USB_AF for mode=%s\n", __func__, rig_strrmode(curmode)); + RETURNFUNC(-RIG_EINVAL); + } + } + break; + default: RETURNFUNC(-RIG_EINVAL); } @@ -5396,7 +5426,79 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) break; + case RIG_LEVEL_USB_AF_INPUT: + if (is_ftdx101d || is_ftdx101mp) + { + rmode_t curmode = rig->state.current_vfo == RIG_VFO_A? rig->state.cache.modeMainA : rig->state.cache.modeMainB; + switch(curmode) + { + case RIG_MODE_LSB: + case RIG_MODE_USB: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010113%c", cat_term); + break; + case RIG_MODE_AM: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010214%c", cat_term); + break; + case RIG_MODE_FM: + case RIG_MODE_FMN: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010313%c", cat_term); + break; + case RIG_MODE_PKTFM: + case RIG_MODE_PKTFMN: + case RIG_MODE_PKTUSB: + case RIG_MODE_PKTLSB: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010415%c", cat_term); + break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown how to get USB_AF_INPUT for mode=%s\n", __func__, rig_strrmode(curmode)); + RETURNFUNC(-RIG_EINVAL); + } + } + else + { + RETURNFUNC(-RIG_ENIMPL); + } + break; + + case RIG_LEVEL_USB_AF: + if (is_ftdx101d || is_ftdx101mp) + { + rmode_t curmode = rig->state.current_vfo == RIG_VFO_A? rig->state.cache.modeMainA : rig->state.cache.modeMainB; + switch(curmode) + { + case RIG_MODE_LSB: + case RIG_MODE_USB: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010109%c", cat_term); + break; + case RIG_MODE_AM: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010209%c", cat_term); + break; + case RIG_MODE_FM: + case RIG_MODE_FMN: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010309%c", cat_term); + break; + case RIG_MODE_PKTFM: + case RIG_MODE_PKTFMN: + case RIG_MODE_PKTUSB: + case RIG_MODE_PKTLSB: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010411%c", cat_term); + break; + case RIG_MODE_RTTY: + SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "EX010511%c", cat_term); + break; + // we have PSK level too but no means to have this mode yet + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown how to get USB_AF for mode=%s\n", __func__, rig_strrmode(curmode)); + RETURNFUNC(-RIG_EINVAL); + } + } + else + { + RETURNFUNC(-RIG_ENIMPL); + } + break; default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown level=%08lx\n", __func__, level); RETURNFUNC(-RIG_EINVAL); } @@ -5844,6 +5946,13 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) i, val->f); break; + case RIG_LEVEL_USB_AF: + case RIG_LEVEL_USB_AF_INPUT: + i = 0; + sscanf(retlvl, "%3d", &i); + val->f = i / 100.0; + break; + default: RETURNFUNC(-RIG_EINVAL); } diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index c5b41f702..d7c451587 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20231012" +#define NEWCAT_VER "20231024" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 diff --git a/simulators/simftdx101.c b/simulators/simftdx101.c index 79615b792..f12cbdaac 100644 --- a/simulators/simftdx101.c +++ b/simulators/simftdx101.c @@ -33,6 +33,10 @@ int ex039 = 0; int keyspd = 20; int split = 0; int power=50; +int rport_gain_ssb=50; +int rport_gain_am=50; +int rport_gain_fm=50; +int rport_gain_psk=50; // ID 0310 == 310, Must drop leading zero typedef enum nc_rigid_e @@ -298,7 +302,7 @@ int main(int argc, char *argv[]) SNPRINTF(buf, sizeof(buf), "EX039%d;", ex039); n = write(fd, buf, strlen(buf)); } - else if (strncmp(buf, "EX039", 3) == 0) + else if (strncmp(buf, "EX039", 5) == 0) { sscanf(buf, "EX039%d", &ex039); } @@ -325,6 +329,16 @@ int main(int argc, char *argv[]) { sscanf(buf, "ST%d", &split); } + else if (strcmp(buf, "EX010415;") == 0) + { + sprintf(buf,"EX010415%03d;", rport_gain); + n = write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "EX010415", 8) == 0) + { + printf("Here#1"); + sscanf(buf,"EX010415%d", &rport_gain); + } else if (strlen(buf) > 0) { diff --git a/simulators/simftdx1200.c b/simulators/simftdx1200.c index 7a8c7fef6..2aa814b70 100644 --- a/simulators/simftdx1200.c +++ b/simulators/simftdx1200.c @@ -273,7 +273,7 @@ int main(int argc, char *argv[]) SNPRINTF(buf, sizeof(buf), "EX039%d;", ex039); n = write(fd, buf, strlen(buf)); } - else if (strncmp(buf, "EX039", 3) == 0) + else if (strncmp(buf, "EX039", 5) == 0) { sscanf(buf, "EX039%d", &ex039); } diff --git a/simulators/simftdx3000.c b/simulators/simftdx3000.c index d48476de6..23a1ae999 100644 --- a/simulators/simftdx3000.c +++ b/simulators/simftdx3000.c @@ -275,7 +275,7 @@ int main(int argc, char *argv[]) SNPRINTF(buf, sizeof(buf), "EX039%d;", ex039); n = write(fd, buf, strlen(buf)); } - else if (strncmp(buf, "EX039", 3) == 0) + else if (strncmp(buf, "EX039", 5) == 0) { sscanf(buf, "EX039%d", &ex039); } diff --git a/simulators/simftdx5000.c b/simulators/simftdx5000.c index c28ad049e..25450001d 100644 --- a/simulators/simftdx5000.c +++ b/simulators/simftdx5000.c @@ -280,7 +280,7 @@ int main(int argc, char *argv[]) SNPRINTF(buf, sizeof(buf), "EX039%d;", ex039); n = write(fd, buf, strlen(buf)); } - else if (strncmp(buf, "EX039", 3) == 0) + else if (strncmp(buf, "EX039", 5) == 0) { sscanf(buf, "EX039%d", &ex039); } diff --git a/simulators/simyaesu.c b/simulators/simyaesu.c index 3eb170537..550108f89 100644 --- a/simulators/simyaesu.c +++ b/simulators/simyaesu.c @@ -417,7 +417,7 @@ int main(int argc, char *argv[]) SNPRINTF(buf, sizeof(buf), "EX039%d;", ex039); n = write(fd, buf, strlen(buf)); } - else if (strncmp(buf, "EX039", 3) == 0) + else if (strncmp(buf, "EX039", 5) == 0) { sscanf(buf, "EX039%d", &ex039); }