kopia lustrzana https://github.com/Hamlib/Hamlib
Implement combined split VFO frequency and mode setting.
CAT protocols that don't allow direct addressing of VFOs require that the "other" VFO be queried or set via a select then get/set then select back to original or swap then get/set then swap again. When both frequncy and mode need to be set the sequences can be optimized if a single funciton is avaiable. This enhancement adds those single functions rig_set_split_freq_mode() and rig_get_split_freq_mode() with a default impelementation that calls the individual rig_{get,set}_split_{freq,mode}() functions. Back ends can choose to implement an optimized version which is used instead of the default if present. Using these functions when an optimized implementation is available allows the TX VFO's frequency and mode to be set in a single operation with only one VFO exchange or selection either side of the operation. Many CAT protocols are very efficient when getting or setting both frequency and mode and some even combine the two in a single command. The letters 'K' and 'k' are used for the rigctl short command name for these functions.Hamlib-3.1
rodzic
2a849904af
commit
21c346453a
|
@ -311,6 +311,18 @@ rmode_t Rig::getSplitMode(pbwidth_t& width, vfo_t vfo) {
|
||||||
return mode;
|
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) {
|
void Rig::setSplitVFO(split_t split, vfo_t vfo, vfo_t tx_vfo) {
|
||||||
CHECK_RIG(rig_set_split_vfo(theRig, vfo, split, tx_vfo));
|
CHECK_RIG(rig_set_split_vfo(theRig, vfo, split, tx_vfo));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1241,6 +1241,10 @@ struct rig_caps {
|
||||||
pbwidth_t tx_width);
|
pbwidth_t tx_width);
|
||||||
int (*get_split_mode) (RIG * rig, vfo_t vfo, rmode_t * tx_mode,
|
int (*get_split_mode) (RIG * rig, vfo_t vfo, rmode_t * tx_mode,
|
||||||
pbwidth_t * tx_width);
|
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 (*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);
|
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_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_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_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_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));
|
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)
|
#define rig_set_split(r,v,s) rig_set_split_vfo((r),(v),(s),RIG_VFO_CURR)
|
||||||
|
|
|
@ -133,6 +133,8 @@ public:
|
||||||
freq_t getSplitFreq (vfo_t vfo = RIG_VFO_CURR);
|
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);
|
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);
|
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);
|
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);
|
split_t getSplitVFO(vfo_t &tx_vfo, vfo_t vfo = RIG_VFO_CURR);
|
||||||
|
|
||||||
|
|
91
src/rig.c
91
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
|
* \brief set the split mode
|
||||||
* \param rig The rig handle
|
* \param rig The rig handle
|
||||||
|
|
|
@ -182,6 +182,8 @@ declare_proto_rig(set_split_freq);
|
||||||
declare_proto_rig(get_split_freq);
|
declare_proto_rig(get_split_freq);
|
||||||
declare_proto_rig(set_split_mode);
|
declare_proto_rig(set_split_mode);
|
||||||
declare_proto_rig(get_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(set_split_vfo);
|
||||||
declare_proto_rig(get_split_vfo);
|
declare_proto_rig(get_split_vfo);
|
||||||
declare_proto_rig(set_ts);
|
declare_proto_rig(set_ts);
|
||||||
|
@ -228,7 +230,7 @@ declare_proto_rig(pause);
|
||||||
* NB: 'q' 'Q' '?' are reserved by interactive mode interface
|
* NB: 'q' 'Q' '?' are reserved by interactive mode interface
|
||||||
* do NOT use -W since it's reserved by POSIX.
|
* 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[] = {
|
static struct test_table test_list[] = {
|
||||||
{ 'F', "set_freq", ACTION(set_freq), ARG_IN, "Frequency" },
|
{ '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" },
|
{ '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', "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" },
|
{ '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', "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" },
|
{ 's', "get_split_vfo", ACTION(get_split_vfo), ARG_OUT, "Split", "TX VFO" },
|
||||||
{ 'N', "set_ts", ACTION(set_ts), ARG_IN, "Tuning Step" },
|
{ 'N', "set_ts", ACTION(set_ts), ARG_IN, "Tuning Step" },
|
||||||
|
@ -1739,6 +1743,52 @@ declare_proto_rig(get_split_mode)
|
||||||
return status;
|
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' */
|
/* 'S' */
|
||||||
declare_proto_rig(set_split_vfo)
|
declare_proto_rig(set_split_vfo)
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue