diff --git a/c++/rigclass.cc b/c++/rigclass.cc index 216b65d67..5e9fe692d 100644 --- a/c++/rigclass.cc +++ b/c++/rigclass.cc @@ -311,6 +311,18 @@ rmode_t Rig::getSplitMode(pbwidth_t& width, vfo_t vfo) { return mode; } +void Rig::setSplitFreqMode(freq_t tx_freq, rmode_t mode, pbwidth_t width, vfo_t vfo) { + CHECK_RIG (rig_set_split_freq_mode (theRig, vfo, tx_freq, mode, width)); +} + +freq_t Rig::getSplitFreqMode(rmode_t& mode, pbwidth_t& width, vfo_t vfo) { + freq_t freq; + + CHECK_RIG (rig_get_split_freq_mode (theRig, vfo, &freq, &mode, &width)); + + return freq; +} + void Rig::setSplitVFO(split_t split, vfo_t vfo, vfo_t tx_vfo) { CHECK_RIG(rig_set_split_vfo(theRig, vfo, split, tx_vfo)); } diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index a4e18004e..610fcebc3 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -1241,6 +1241,10 @@ struct rig_caps { pbwidth_t tx_width); int (*get_split_mode) (RIG * rig, vfo_t vfo, rmode_t * tx_mode, pbwidth_t * tx_width); + int (*set_split_freq_mode) (RIG * rig, vfo_t vfo, freq_t tx_freq, + rmode_t tx_mode, pbwidth_t tx_width); + int (*get_split_freq_mode) (RIG * rig, vfo_t vfo, freq_t * tx_freq, + rmode_t * tx_mode, pbwidth_t * tx_width); int (*set_split_vfo) (RIG * rig, vfo_t vfo, split_t split, vfo_t tx_vfo); int (*get_split_vfo) (RIG * rig, vfo_t vfo, split_t * split, vfo_t *tx_vfo); @@ -1559,6 +1563,8 @@ extern HAMLIB_EXPORT(int) rig_set_split_freq HAMLIB_PARAMS((RIG *rig, vfo_t vfo, extern HAMLIB_EXPORT(int) rig_get_split_freq HAMLIB_PARAMS((RIG *rig, vfo_t vfo, freq_t *tx_freq)); extern HAMLIB_EXPORT(int) rig_set_split_mode HAMLIB_PARAMS((RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)); extern HAMLIB_EXPORT(int) rig_get_split_mode HAMLIB_PARAMS((RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_width)); +extern HAMLIB_EXPORT(int) rig_set_split_freq_mode HAMLIB_PARAMS((RIG *rig, vfo_t vfo, freq_t tx_freq, rmode_t tx_mode, pbwidth_t tx_width)); +extern HAMLIB_EXPORT(int) rig_get_split_freq_mode HAMLIB_PARAMS((RIG *rig, vfo_t vfo, freq_t * tx_freq, rmode_t *tx_mode, pbwidth_t *tx_width)); extern HAMLIB_EXPORT(int) rig_set_split_vfo HAMLIB_PARAMS((RIG*, vfo_t rx_vfo, split_t split, vfo_t tx_vfo)); extern HAMLIB_EXPORT(int) rig_get_split_vfo HAMLIB_PARAMS((RIG*, vfo_t rx_vfo, split_t *split, vfo_t *tx_vfo)); #define rig_set_split(r,v,s) rig_set_split_vfo((r),(v),(s),RIG_VFO_CURR) diff --git a/include/hamlib/rigclass.h b/include/hamlib/rigclass.h index d34811507..0dbd78870 100644 --- a/include/hamlib/rigclass.h +++ b/include/hamlib/rigclass.h @@ -133,6 +133,8 @@ public: freq_t getSplitFreq (vfo_t vfo = RIG_VFO_CURR); void setSplitMode(rmode_t, pbwidth_t width = RIG_PASSBAND_NORMAL, vfo_t vfo = RIG_VFO_CURR); rmode_t getSplitMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR); + void setSplitFreqMode(freq_t, rmode_t, pbwidth_t width = RIG_PASSBAND_NORMAL, vfo_t vfo = RIG_VFO_CURR); + freq_t getSplitFreqMode(rmode_t&, pbwidth_t&, vfo_t vfo = RIG_VFO_CURR); void setSplitVFO(split_t split, vfo_t vfo = RIG_VFO_CURR, vfo_t tx_vfo = RIG_VFO_CURR); split_t getSplitVFO(vfo_t &tx_vfo, vfo_t vfo = RIG_VFO_CURR); diff --git a/src/rig.c b/src/rig.c index 2fc22b0ba..221a80a66 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1992,6 +1992,97 @@ int HAMLIB_API rig_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth } +/** + * \brief set the split frequency and mode + * \param rig The rig handle + * \param vfo The target VFO + * \param tx_freq The transmit frequency to set to + * \param tx_mode The transmit split mode to set to + * \param tx_width The transmit split width to set to + * + * Sets the split(TX) frequency and mode. + * + * This function maybe optimized on some rig back ends, where the TX + * VFO cannot be directly addressed, to reduce the number of times + * the rig VFOs have to be exchanged or swapped to complete this + * combined function. + * + * \return RIG_OK if the operation has been sucessful, otherwise + * a negative value if an error occured (in which case, cause is + * set appropriately). + * + * \sa rig_set_split_freq(), rig_set_split_mode(), rig_get_split_freq_mode() + */ + +int HAMLIB_API rig_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, rmode_t tx_mode, pbwidth_t tx_width) +{ + const struct rig_caps *caps; + int retcode; + + if (CHECK_RIG_ARG(rig)) + return -RIG_EINVAL; + + caps = rig->caps; + + if (caps->set_split_freq_mode) { + return caps->set_split_freq_mode (rig, vfo, tx_freq, tx_mode, tx_width); + } + + retcode = rig_set_split_freq (rig, vfo, tx_freq); + if (RIG_OK == retcode) { + retcode = rig_set_split_mode (rig, vfo, tx_mode, tx_width); + } + + return retcode; +} + +/** + * \brief get the current split frequency and mode + * \param rig The rig handle + * \param vfo The target VFO + * \param tx_freq The location where to store the current transmit frequency + * \param tx_mode The location where to store the current transmit split mode + * \param tx_width The location where to store the current transmit split width + * + * Retrieves the current split(TX) frequency, mode and passband. + * If the backend is unable to determine the width, the \a tx_width + * will be set to RIG_PASSBAND_NORMAL as a default. + * The value stored at \a tx_mode location equals RIG_MODE_NONE + * when the current mode of the VFO is not defined (e.g. blank memory). + * + * This function maybe optimized on some rig back ends, where the TX + * VFO cannot be directly addressed, to reduce the number of times + * the rig VFOs have to be exchanged or swapped to complete this + * combined function. + * + * \return RIG_OK if the operation has been sucessful, otherwise + * a negative value if an error occured (in which case, cause is + * set appropriately). + * + * \sa rig_get_split_freq(), rig_get_split_mode(), rig_set_split_freq_mode() + */ +int HAMLIB_API rig_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, rmode_t *tx_mode, pbwidth_t *tx_width) +{ + const struct rig_caps *caps; + int retcode; + + if (CHECK_RIG_ARG(rig) || !tx_freq || !tx_mode || !tx_width) + return -RIG_EINVAL; + + caps = rig->caps; + + if (caps->get_split_freq_mode) { + return caps->get_split_freq_mode (rig, vfo, tx_freq, tx_mode, tx_width); + } + + retcode = rig_get_split_freq (rig, vfo, tx_freq); + if (RIG_OK == retcode) { + retcode = rig_get_split_mode (rig, vfo, tx_mode, tx_width); + } + + return retcode; +} + /** * \brief set the split mode * \param rig The rig handle diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 8e3a5a9ea..71ee6e0da 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -182,6 +182,8 @@ declare_proto_rig(set_split_freq); declare_proto_rig(get_split_freq); declare_proto_rig(set_split_mode); declare_proto_rig(get_split_mode); +declare_proto_rig(set_split_freq_mode); +declare_proto_rig(get_split_freq_mode); declare_proto_rig(set_split_vfo); declare_proto_rig(get_split_vfo); declare_proto_rig(set_ts); @@ -228,7 +230,7 @@ declare_proto_rig(pause); * NB: 'q' 'Q' '?' are reserved by interactive mode interface * do NOT use -W since it's reserved by POSIX. * - * Available alphabetic letters: -.--------K-----*-----W-Y- + * Available alphabetic letters: -.--------------*-----W-Y- */ static struct test_table test_list[] = { { 'F', "set_freq", ACTION(set_freq), ARG_IN, "Frequency" }, @@ -239,6 +241,8 @@ static struct test_table test_list[] = { { 'i', "get_split_freq", ACTION(get_split_freq), ARG_OUT, "TX Frequency" }, { 'X', "set_split_mode", ACTION(set_split_mode), ARG_IN, "TX Mode", "TX Passband" }, { 'x', "get_split_mode", ACTION(get_split_mode), ARG_OUT, "TX Mode", "TX Passband" }, + { 'K', "set_split_freq_mode", ACTION(set_split_freq_mode), ARG_IN, "TX Frequency", "TX Mode", "TX Passband" }, + { 'k', "get_split_freq_mode", ACTION(get_split_freq_mode), ARG_OUT, "TX Frequency", "TX Mode", "TX Passband" }, { 'S', "set_split_vfo", ACTION(set_split_vfo), ARG_IN, "Split", "TX VFO" }, { 's', "get_split_vfo", ACTION(get_split_vfo), ARG_OUT, "Split", "TX VFO" }, { 'N', "set_ts", ACTION(set_ts), ARG_IN, "Tuning Step" }, @@ -1739,6 +1743,52 @@ declare_proto_rig(get_split_mode) return status; } +/* 'K' */ +declare_proto_rig(set_split_freq_mode) +{ + freq_t freq; + rmode_t mode; + int width; + vfo_t txvfo = RIG_VFO_TX; + + if (!strcmp(arg1, "?")) { + char s[SPRINTF_MAX_SIZE]; + sprintf_mode(s, rig->state.mode_list); + fprintf(fout, "%s\n", s); + return RIG_OK; + } + + CHKSCN1ARG(sscanf(arg1, "%"SCNfreq, &freq)); + mode = rig_parse_mode(arg2); + CHKSCN1ARG(sscanf(arg3, "%d", &width)); + return rig_set_split_freq_mode(rig, txvfo, freq, mode, (pbwidth_t) width); +} + +/* 'k' */ +declare_proto_rig(get_split_freq_mode) +{ + int status; + freq_t freq; + rmode_t mode; + pbwidth_t width; + vfo_t txvfo = RIG_VFO_TX; + + status = rig_get_split_freq_mode(rig, txvfo, &freq, &mode, &width); + if (status != RIG_OK) + return status; + if ((interactive && prompt) || (interactive && !prompt && ext_resp)) + fprintf(fout, "%s: ", cmd->arg1); + fprintf(fout, "%"PRIll"%c", (int64_t)freq, resp_sep); + if ((interactive && prompt) || (interactive && !prompt && ext_resp)) + fprintf(fout, "%s: ", cmd->arg2); + fprintf(fout, "%s%c", rig_strrmode(mode), resp_sep); + if ((interactive && prompt) || (interactive && !prompt && ext_resp)) + fprintf(fout, "%s: ", cmd->arg3); + fprintf(fout, "%ld%c", width, resp_sep); + + return status; +} + /* 'S' */ declare_proto_rig(set_split_vfo) {