diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 5dbb5a7be..9762d21b4 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -337,9 +337,10 @@ enum agc_level_e { RIG_AGC_SUPERFAST, RIG_AGC_FAST, RIG_AGC_SLOW, - RIG_AGC_USER, /*!< user selectable */ + RIG_AGC_USER, /*!< user selectable -- RIG_LEVEL_AGC to set USER level */ RIG_AGC_MEDIUM, - RIG_AGC_AUTO + RIG_AGC_AUTO, + RIG_AGC_LONG, }; @@ -899,7 +900,7 @@ typedef unsigned int ant_t; //! @cond Doxygen_Suppress -#define RIG_AGC_LAST RIG_AGC_AUTO +#define RIG_AGC_LAST -1 //! @endcond #if 1 // deprecated diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c index 5cb0c3ad0..488e31f8d 100644 --- a/rigs/dummy/netrigctl.c +++ b/rigs/dummy/netrigctl.c @@ -810,6 +810,30 @@ static int netrigctl_open(RIG *rig) if (n < DCS_LIST_SIZE) { rig->caps->dcs_list[n] = 0; } } + else if (strcmp(setting, "agc_levels") == 0) + { + int i=1; + char *p = strtok(value," "); + rig->caps->agc_levels[0] = RIG_AGC_OFF; + while(p) + { + int agc_code; + char agc_string[32]; + int n = sscanf(p, "%d=%s\n", &agc_code, agc_string); + if (n == 2) + { + rig->caps->agc_levels[i++] = agc_code; + rig_debug(RIG_DEBUG_VERBOSE, "%s: rig has agc code=%d, level=%s\n", __func__, agc_code, agc_string); + } + else + { + rig_debug(RIG_DEBUG_ERR, "%s did not parse code=agc from '%s'\n", __func__, p); + } + rig_debug(RIG_DEBUG_VERBOSE, "%d=%s\n", agc_code, agc_string); + p = strtok(NULL, " "); + } + rig->caps->agc_level_count = i; + } else { // not an error -- just a warning for backward compatibility @@ -2689,7 +2713,7 @@ struct rig_caps netrigctl_caps = RIG_MODEL(RIG_MODEL_NETRIGCTL), .model_name = "NET rigctl", .mfg_name = "Hamlib", - .version = "20220722.0", + .version = "20221123.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_OTHER, diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 492ce6663..e17d1e984 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -3498,7 +3498,7 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) int found = 0; for (i = 0; - i <= RIG_AGC_LAST && priv_caps->agc_levels[i].level != RIG_AGC_LAST + i <= HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST && priv_caps->agc_levels[i].icom_level >= 0; i++) { if (priv_caps->agc_levels[i].level == val.i) @@ -4154,7 +4154,7 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) int found = 0; for (i = 0; - i <= RIG_AGC_LAST && priv_caps->agc_levels[i].level >= 0; i++) + i <= HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level >= 0; i++) { if (priv_caps->agc_levels[i].icom_level == icom_val) { diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 1ae700146..be4475cd6 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -230,7 +230,7 @@ struct icom_priv_caps int offs_len; /*!< Number of bytes in offset frequency field. 0 defaults to 3 */ int serial_USB_echo_check; /*!< Flag to test USB echo state */ int agc_levels_present; /*!< Flag to indicate that agc_levels array is populated */ - struct icom_agc_level agc_levels[RIG_AGC_LAST + 1]; /*!< Icom rig-specific AGC levels, the last entry should have level -1 */ + struct icom_agc_level agc_levels[HAMLIB_MAX_AGC_LEVELS + 1]; /*!< Icom rig-specific AGC levels, the last entry should have level -1 */ struct icom_spectrum_scope_caps spectrum_scope_caps; /*!< Icom spectrum scope capabilities, if supported by the rig. Main/Sub scopes in Icom rigs have the same caps. */ struct icom_spectrum_edge_frequency_range spectrum_edge_frequency_ranges[ICOM_MAX_SPECTRUM_FREQ_RANGES]; /*!< Icom spectrum scope edge frequencies, if supported by the rig. Last entry should have zeros in all fields. */ struct cmdparams *extcmds; /*!< Pointer to extended operations array */ diff --git a/rigs/kenwood/flex6xxx.c b/rigs/kenwood/flex6xxx.c index a47681ba6..28472398c 100644 --- a/rigs/kenwood/flex6xxx.c +++ b/rigs/kenwood/flex6xxx.c @@ -1234,7 +1234,7 @@ const struct rig_caps powersdr_caps = RIG_MODEL(RIG_MODEL_POWERSDR), .model_name = "PowerSDR/Thetis", .mfg_name = "FlexRadio/ANAN", - .version = "20221117.0", + .version = "20221123.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1276,6 +1276,8 @@ const struct rig_caps powersdr_caps = .vfo_ops = POWERSDR_VFO_OP, .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, .transceive = RIG_TRN_RIG, + .agc_level_count = 6, + .agc_levels = { RIG_AGC_OFF, RIG_AGC_LONG, RIG_AGC_SLOW, RIG_AGC_MEDIUM, RIG_AGC_FAST, RIG_AGC_USER }, .bank_qty = 0, .chan_desc_sz = 0, diff --git a/src/sprintflst.c b/src/sprintflst.c index e591d5587..5809c9a72 100644 --- a/src/sprintflst.c +++ b/src/sprintflst.c @@ -28,6 +28,8 @@ #include #include #include +#include "../rigs/icom/icom.h" + #include "sprintflst.h" #include "misc.h" @@ -896,3 +898,60 @@ int print_ext_param(const struct confparams *cfp, rig_ptr_t ptr) return 1; /* process them all */ } + +int rig_sprintf_agc_levels(RIG *rig, char *str, int lenstr) +{ + const struct icom_priv_caps *priv_caps = + (const struct icom_priv_caps *) rig->caps->priv; + + int len = 0; + int i; + char tmpbuf[256]; + + str[len] = 0; + + if (priv_caps && RIG_BACKEND_NUM(rig->caps->rig_model) == RIG_ICOM + && priv_caps->agc_levels_present) + { + for (i = 0; i <= HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level != RIG_AGC_LAST + && priv_caps->agc_levels[i].icom_level >= 0; i++) + { + if (strlen(str) > 0) { strcat(str, " "); } + + sprintf(tmpbuf, "%d=%s", priv_caps->agc_levels[i].level, + rig_stragclevel(priv_caps->agc_levels[i].level)); + + if (strlen(str) + strlen(tmpbuf) < lenstr - 1) + { + strncat(str, tmpbuf, lenstr - 1); + } + else + { + rig_debug(RIG_DEBUG_ERR, "%s: buffer overrun!! len=%ld > maxlen=%d\n", + __func__, strlen(str) + strlen(tmpbuf), lenstr - 1); + } + } + } + else + { + for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && i < rig->caps->agc_level_count; i++) + { + if (strlen(str)>0) { strcat(str, " "); } + + sprintf(tmpbuf, "%d=%s", rig->caps->agc_levels[i], + rig_stragclevel(rig->caps->agc_levels[i])); + + if (strlen(str) + strlen(tmpbuf) < lenstr - 1) + { + strncat(str, tmpbuf, lenstr - 1); + } + else + { + rig_debug(RIG_DEBUG_ERR, "%s: buffer overrun!! len=%ld > maxlen=%d\n", + __func__, strlen(str) + strlen(tmpbuf), lenstr - 1); + } + } + } + + return strlen(str); +} diff --git a/src/sprintflst.h b/src/sprintflst.h index 919ee896e..503f794f8 100644 --- a/src/sprintflst.h +++ b/src/sprintflst.h @@ -33,6 +33,7 @@ extern HAMLIB_EXPORT( int ) rig_sprintf_mode(char *str, int len, rmode_t mode); extern HAMLIB_EXPORT( int ) rig_sprintf_vfo(char *str, int len, vfo_t vfo); extern HAMLIB_EXPORT( int ) rig_sprintf_ant(char *str, int len, ant_t ant); extern HAMLIB_EXPORT( int ) rig_sprintf_func(char *str, int len, setting_t func); +extern HAMLIB_EXPORT( int ) rig_sprintf_agc_levels(RIG *rig, char *str, int len); extern HAMLIB_EXPORT( int ) rot_sprintf_func(char *str, int len, setting_t func); extern HAMLIB_EXPORT( int ) rig_sprintf_level(char *str, int len, setting_t level); extern HAMLIB_EXPORT( int ) rot_sprintf_level(char *str, int len, setting_t level); diff --git a/tests/dumpcaps.c b/tests/dumpcaps.c index 6bdf32014..ba64e113a 100644 --- a/tests/dumpcaps.c +++ b/tests/dumpcaps.c @@ -295,8 +295,9 @@ int dumpcaps(RIG *rig, FILE *fout) fprintf(fout, "\n"); - fprintf(fout, "AGC levels:"); +#if 0 + fprintf(fout, "AGC levels:"); const struct icom_priv_caps *priv_caps = (const struct icom_priv_caps *) rig->caps->priv; @@ -318,6 +319,13 @@ int dumpcaps(RIG *rig, FILE *fout) rig_stragclevel(caps->agc_levels[i])); } } +#else + //fprintf(fout, "\n"); + fprintf(fout, "AGC levels: "); + char buf[1024]; + rig_sprintf_agc_levels(rig, buf, (int)sizeof(buf)); + fprintf(fout,"%s", buf); +#endif if (i == 0) { diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 8ddbf0e51..fd567b00d 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -1749,7 +1749,8 @@ readline_repeat: rig_debug(RIG_DEBUG_WARN, "%s: command %s not allowed when rig is powered off\n", __func__, cmd_entry->name); - retcode = -RIG_EPOWER; +// retcode = -RIG_EPOWER; + retcode = RIG_OK; } else { @@ -4340,6 +4341,7 @@ declare_proto_rig(dump_state) { int i; struct rig_state *rs = &rig->state; + char buf[1024]; ENTERFUNC; @@ -4466,6 +4468,8 @@ declare_proto_rig(dump_state) fprintf(fout, "timeout=%d\n", rig->caps->timeout); fprintf(fout, "rig_model=%d\n", rig->caps->rig_model); fprintf(fout, "rigctld_version=%s\n", hamlib_version2); + rig_sprintf_agc_levels(rig, buf, sizeof(buf)); + fprintf(fout, "agc_levels=%s\n", buf); if (rig->caps->ctcss_list) {