Add -x/--uplink switch for GPredict. Will avoid reading freq from the uplink VFO 1=Sub, 2=Main

This will likely deprecate the twiddle option
https://github.com/Hamlib/Hamlib/issues/404

(cherry picked from commit 4e748df12b)
Hamlib-4.0
Michael Black W9MDB 2020-10-23 11:34:42 -05:00 zatwierdzone przez Nate Bargmann
rodzic 1b001dfdeb
commit c46d6cd728
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: F72625E2EDBED598
4 zmienionych plików z 86 dodań i 6 usunięć

Wyświetl plik

@ -2038,6 +2038,8 @@ struct rig_state {
freq_t lo_freq; /*!< Local oscillator frequency of any transverter */ freq_t lo_freq; /*!< Local oscillator frequency of any transverter */
time_t twiddle_time; /*!< time when vfo twiddling was detected */ time_t twiddle_time; /*!< time when vfo twiddling was detected */
int twiddle_timeout; /*!< timeout to resume from twiddling */ int twiddle_timeout; /*!< timeout to resume from twiddling */
// uplink allows gpredict to behave better by no reading the uplink VFO
int uplink; /*!< uplink=1 will not read Sub, uplink=2 will not read Main */
struct rig_cache cache; struct rig_cache cache;
int vfo_opt; /*!< Is -o switch turned on? */ int vfo_opt; /*!< Is -o switch turned on? */
int auto_power_on; /*!< Allow Hamlib to power rig int auto_power_on; /*!< Allow Hamlib to power rig
@ -2651,6 +2653,11 @@ extern HAMLIB_EXPORT(int)
rig_get_twiddle HAMLIB_PARAMS((RIG *rig, rig_get_twiddle HAMLIB_PARAMS((RIG *rig,
int *seconds)); int *seconds));
extern HAMLIB_EXPORT(int)
rig_set_uplink HAMLIB_PARAMS((RIG *rig,
int val));
extern HAMLIB_EXPORT(const char *) extern HAMLIB_EXPORT(const char *)
rig_get_info HAMLIB_PARAMS((RIG *rig)); rig_get_info HAMLIB_PARAMS((RIG *rig));

Wyświetl plik

@ -1160,11 +1160,11 @@ int HAMLIB_API rig_cleanup(RIG *rig)
* timeout seconds to stop rigctld when VFO is manually changed * timeout seconds to stop rigctld when VFO is manually changed
* turns on/off the radio. * turns on/off the radio.
* *
* \return RIG_OK if the operation has been successful, ortherwise * \return RIG_OK if the operation has been successful, otherwise
* a negative value if an error occurred (in which case, cause is * a negative value if an error occurred (in which case, cause is
* set appropriately). * set appropriately).
* *
* \sa rig_get_twiddle() * \sa rig_set_twiddle()
*/ */
int HAMLIB_API rig_set_twiddle(RIG *rig, int seconds) int HAMLIB_API rig_set_twiddle(RIG *rig, int seconds)
{ {
@ -1180,6 +1180,32 @@ int HAMLIB_API rig_set_twiddle(RIG *rig, int seconds)
return RIG_OK; return RIG_OK;
} }
/**
* \brief For GPredict to avoid reading frequency on uplink VFO
* \param rig The rig handle
* \param seconds 1=Ignore Sub, 2=Ignore Main
*
* \return RIG_OK if the operation has been successful, otherwise
* a negative value if an error occurred (in which case, cause is
* set appropriately).
*
* \sa rig_set_uplink()
*/
int HAMLIB_API rig_set_uplink(RIG *rig, int val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (CHECK_RIG_ARG(rig))
{
return -RIG_EINVAL;
}
rig->state.uplink = val;
return RIG_OK;
}
/** /**
* \brief get the twiddle timeout value (secs) * \brief get the twiddle timeout value (secs)
* \param rig The rig handle * \param rig The rig handle
@ -1309,6 +1335,7 @@ static int get_cache_freq(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms)
case RIG_VFO_CURR: case RIG_VFO_CURR:
*freq = rig->state.cache.freqCurr; *freq = rig->state.cache.freqCurr;
break; break;
case RIG_VFO_A: case RIG_VFO_A:
case RIG_VFO_MAIN: case RIG_VFO_MAIN:
case RIG_VFO_MAIN_A: case RIG_VFO_MAIN_A:
@ -1521,6 +1548,20 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
vfo = vfo_fixup(rig, vfo); vfo = vfo_fixup(rig, vfo);
// we ignore get_freq for the uplink VFO for gpredict to behave better
if ((rig->state.uplink == 1 && vfo == RIG_VFO_SUB)
|| (rig->state.uplink == 2 && vfo == RIG_VFO_MAIN))
{
rig_debug(RIG_DEBUG_TRACE, "%s: uplink=%d, ignoring get_freq\n", __func__,
rig->state.uplink);
rig_debug(RIG_DEBUG_TRACE, "%s: split=%d, satmode=%d, tx_vfo=%s\n", __func__,
rig->state.cache.split, rig->state.cache.satmode,
rig_strvfo(rig->state.tx_vfo));
// always return the cached freq for this clause
get_cache_freq(rig, vfo, freq, &cache_ms);
return RIG_OK;
}
// there are some rigs that can't get VFOA freq while VFOB is transmitting // there are some rigs that can't get VFOA freq while VFOB is transmitting
// so we'll return the cached VFOA freq for them // so we'll return the cached VFOA freq for them
// should we use the cached ptt maybe? No -- we have to be 100% sure we're in PTT to ignore this request // should we use the cached ptt maybe? No -- we have to be 100% sure we're in PTT to ignore this request
@ -5143,6 +5184,7 @@ static int wait_morse_ptt(RIG *rig, vfo_t vfo)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
hl_usleep(200 * 1000); // give little time for CW to start PTT hl_usleep(200 * 1000); // give little time for CW to start PTT
do do
{ {
rig_debug(RIG_DEBUG_TRACE, "%s: loop#%d until ptt=0, ptt=%d\n", __func__, loops, rig_debug(RIG_DEBUG_TRACE, "%s: loop#%d until ptt=0, ptt=%d\n", __func__, loops,
@ -5154,6 +5196,7 @@ static int wait_morse_ptt(RIG *rig, vfo_t vfo)
{ {
return retval; return retval;
} }
// every 25ms should be short enough // every 25ms should be short enough
hl_usleep(25 * 1000); hl_usleep(25 * 1000);
++loops; ++loops;

Wyświetl plik

@ -229,6 +229,7 @@ declare_proto_rig(chk_vfo);
declare_proto_rig(set_vfo_opt); declare_proto_rig(set_vfo_opt);
declare_proto_rig(set_twiddle); declare_proto_rig(set_twiddle);
declare_proto_rig(get_twiddle); declare_proto_rig(get_twiddle);
declare_proto_rig(set_uplink);
declare_proto_rig(set_cache); declare_proto_rig(set_cache);
declare_proto_rig(get_cache); declare_proto_rig(get_cache);
declare_proto_rig(halt); declare_proto_rig(halt);
@ -319,6 +320,7 @@ static struct test_table test_list[] =
{ 0x8b, "get_dcd", ACTION(get_dcd), ARG_OUT, "DCD" }, { 0x8b, "get_dcd", ACTION(get_dcd), ARG_OUT, "DCD" },
{ 0x8d, "set_twiddle", ACTION(set_twiddle), ARG_IN | ARG_NOVFO, "Timeout (secs)" }, { 0x8d, "set_twiddle", ACTION(set_twiddle), ARG_IN | ARG_NOVFO, "Timeout (secs)" },
{ 0x8e, "get_twiddle", ACTION(get_twiddle), ARG_OUT | ARG_NOVFO, "Timeout (secs)" }, { 0x8e, "get_twiddle", ACTION(get_twiddle), ARG_OUT | ARG_NOVFO, "Timeout (secs)" },
{ 0x97, "uplink", ACTION(set_uplink), ARG_IN | ARG_NOVFO, "1=Sub, 2=Main" },
{ 0x95, "set_cache", ACTION(set_cache), ARG_IN | ARG_NOVFO, "Timeout (msecs)" }, { 0x95, "set_cache", ACTION(set_cache), ARG_IN | ARG_NOVFO, "Timeout (msecs)" },
{ 0x96, "get_cache", ACTION(get_cache), ARG_OUT | ARG_NOVFO, "Timeout (msecs)" }, { 0x96, "get_cache", ACTION(get_cache), ARG_OUT | ARG_NOVFO, "Timeout (msecs)" },
{ '2', "power2mW", ACTION(power2mW), ARG_IN1 | ARG_IN2 | ARG_IN3 | ARG_OUT1 | ARG_NOVFO, "Power [0.0..1.0]", "Frequency", "Mode", "Power mW" }, { '2', "power2mW", ACTION(power2mW), ARG_IN1 | ARG_IN2 | ARG_IN3 | ARG_OUT1 | ARG_NOVFO, "Power [0.0..1.0]", "Frequency", "Mode", "Power mW" },
@ -4596,6 +4598,16 @@ declare_proto_rig(set_twiddle)
return rig_set_twiddle(rig, seconds); return rig_set_twiddle(rig, seconds);
} }
/* '0x97' */
declare_proto_rig(set_uplink)
{
int val;
CHKSCN1ARG(sscanf(arg1, "%d", &val));
return rig_set_uplink(rig, val);
}
/* '0x8e' */ /* '0x8e' */
declare_proto_rig(get_twiddle) declare_proto_rig(get_twiddle)

Wyświetl plik

@ -86,7 +86,7 @@
* NB: do NOT use -W since it's reserved by POSIX. * NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file * TODO: add an option to read from a file
*/ */
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:T:t:C:W:lLuovhVZ" #define SHORT_OPTIONS "m:r:p:d:P:D:s:c:T:t:C:W:x:z:lLuovhVZ"
static struct option long_options[] = static struct option long_options[] =
{ {
{"model", 1, 0, 'm'}, {"model", 1, 0, 'm'},
@ -108,6 +108,7 @@ static struct option long_options[] =
{"help", 0, 0, 'h'}, {"help", 0, 0, 'h'},
{"version", 0, 0, 'V'}, {"version", 0, 0, 'V'},
{"twiddle_timeout", 1, 0, 'W'}, {"twiddle_timeout", 1, 0, 'W'},
{"uplink", 1, 0, 'x'},
{"debug-time-stamps", 0, 0, 'Z'}, {"debug-time-stamps", 0, 0, 'Z'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
@ -248,6 +249,7 @@ int main(int argc, char *argv[])
int sock_listen; int sock_listen;
int reuseaddr = 1; int reuseaddr = 1;
int twiddle = 0; int twiddle = 0;
int uplink = 0;
char host[NI_MAXHOST]; char host[NI_MAXHOST];
char serv[NI_MAXSERV]; char serv[NI_MAXSERV];
#if HAVE_SIGACTION #if HAVE_SIGACTION
@ -277,6 +279,7 @@ int main(int argc, char *argv[])
{ {
break; break;
} }
switch (c) switch (c)
{ {
case 'h': case 'h':
@ -523,6 +526,17 @@ int main(int argc, char *argv[])
twiddle = atoi(optarg); twiddle = atoi(optarg);
break; break;
case 'x':
if (!optarg)
{
usage(); /* wrong arg count */
exit(1);
}
uplink = atoi(optarg);
break;
case 'Z': case 'Z':
rig_set_debug_time_stamp(1); rig_set_debug_time_stamp(1);
break; break;
@ -572,6 +586,9 @@ int main(int argc, char *argv[])
} }
my_rig->state.twiddle_timeout = twiddle; my_rig->state.twiddle_timeout = twiddle;
my_rig->state.uplink = uplink;
rig_debug(RIG_DEBUG_TRACE, "%s: twiddle=%d, uplink=%d\n", __func__,
my_rig->state.twiddle_timeout, my_rig->state.uplink);
/* /*
* ex: RIG_PTT_PARALLEL and /dev/parport0 * ex: RIG_PTT_PARALLEL and /dev/parport0
@ -1168,6 +1185,7 @@ void usage(void)
" -o, --vfo do not default to VFO_CURR, require extra vfo arg\n" " -o, --vfo do not default to VFO_CURR, require extra vfo arg\n"
" -v, --verbose set verbose mode, cumulative (-v to -vvvvv)\n" " -v, --verbose set verbose mode, cumulative (-v to -vvvvv)\n"
" -W, --twiddle_timeout timeout after detecting vfo manual change\n" " -W, --twiddle_timeout timeout after detecting vfo manual change\n"
" -x, --uplink set uplink get_freq ignore, 1=Sub, 2=Main\n"
" -Z, --debug-time-stamps enable time stamps for debug messages\n" " -Z, --debug-time-stamps enable time stamps for debug messages\n"
" -h, --help display this help and exit\n" " -h, --help display this help and exit\n"
" -V, --version output version information and exit\n\n", " -V, --version output version information and exit\n\n",