Add a new command line option '--no-restore-ai' ('-n') to rigctl

As Hamlib now restores the rig auto information state (AI) on exit
there is now a need to disable that functionality so that rigctl can
be used to set/reset AI mode on the rig explicitly.

A new  public API  function 'rig_no_restore_ai()'  is also  added that
allows any  client to  disable this auto  AI restore  functionality if
required. Most  clients should do nothing  as restoring AI state  is a
good thing.
This commit is contained in:
Bill Somerville 2015-12-04 00:04:51 +00:00
parent a924165786
commit aebe52a45e
8 changed files with 31 additions and 3 deletions

View File

@ -365,6 +365,12 @@ argument is not used. See @command{chk_vfo} below.
@*
@end ifhtml
@item -n
@itemx --no-restore-ai
On exit @command{rigctl} restores the state of auto information (AI)
on the controlled rig. If this is not desired, for example if you are
using @command{rigctl} to turn AI mode on or off, pass this option.
@item -i
@itemx --read-history
Read previously saved command and argument history from a file

View File

@ -1726,6 +1726,7 @@ extern HAMLIB_EXPORT(scan_t) rig_parse_scan(const char *s);
extern HAMLIB_EXPORT(rptr_shift_t) rig_parse_rptr_shift(const char *s);
extern HAMLIB_EXPORT(chan_type_t) rig_parse_mtype(const char *s);
HAMLIB_EXPORT(void) rig_no_restore_ai();
__END_DECLS

View File

@ -645,7 +645,7 @@ int kenwood_close(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig) return -RIG_EINVAL;
struct kenwood_priv_data *priv = rig->state.priv;
if (priv->trn_state >= 0)
if (!no_restore_ai && priv->trn_state >= 0)
{
/* restore AI state */
kenwood_set_trn (rig, priv->trn_state); /* ignore status in case

View File

@ -841,5 +841,11 @@ void HAMLIB_API rig_force_cache_timeout(struct timeval *tv)
tv->tv_usec = 0;
}
int no_restore_ai;
void HAMLIB_API rig_no_restore_ai()
{
no_restore_ai = -1;
}
/** @} */

View File

@ -61,6 +61,10 @@ extern HAMLIB_EXPORT(unsigned long long) from_bcd_be(const unsigned char bcd_dat
extern HAMLIB_EXPORT(int) sprintf_freq(char *str, freq_t);
/* flag that determines if AI mode should be restored on exit on
applicable rigs - See rig_no_restore_ai() */
extern int no_restore_ai;
/* check if it's any of CR or LF */
#define isreturn(c) ((c) == 10 || (c) == 13)

View File

@ -122,6 +122,11 @@ Dump capabilities for the radio defined with -m above and exit.
Set vfo mode, requiring an extra VFO argument in front of each appropriate
command. Otherwise, 'currVFO' is assumed when this option is not set.
.TP
.B \-n, --no-restore-ai
On exit 'rigctl' restores the state of auto information (AI) on the
controlled rig. If this is not desired, for example if you are
using 'rigctl' to turn AI mode on or off, pass this option.
.TP
.B \-i, --read-history
Read previously saved command and argument history from a file
(default '~/.rigctl_history') for the current session. Available when

View File

@ -87,7 +87,7 @@ void usage(void);
* NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file
*/
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:t:lC:LuovhV"
#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:t:lC:LuonvhV"
static struct option long_options[] =
{
{"model", 1, 0, 'm'},
@ -104,6 +104,7 @@ static struct option long_options[] =
{"show-conf", 0, 0, 'L'},
{"dump-caps", 0, 0, 'u'},
{"vfo", 0, 0, 'o'},
{"no-restore-ai", 0, 0, 'n'},
#ifdef HAVE_READLINE_HISTORY
{"read-history", 0, 0, 'i'},
{"save-history", 0, 0, 'I'},
@ -278,6 +279,9 @@ int main (int argc, char *argv[])
case 'o':
vfo_mode++;
break;
case 'n':
rig_no_restore_ai();
break;
#ifdef HAVE_READLINE_HISTORY
case 'i':
rd_hist++;
@ -461,6 +465,7 @@ void usage(void)
" -l, --list list all model numbers and exit\n"
" -u, --dump-caps dump capabilities and exit\n"
" -o, --vfo do not default to VFO_CURR, require extra vfo arg\n"
" -n, --no-restore-ai do not restore auto information mode on rig\n"
#ifdef HAVE_READLINE_HISTORY
" -i, --read-history read prior interactive session history\n"
" -I, --save-history save current interactive session history\n"

View File

@ -43,6 +43,7 @@
#include "hamlib/rig.h"
#include "iofunc.h"
#include "serial.h"
#include "misc.h"
#include "newcat.h"
/* global variables */
@ -343,7 +344,7 @@ int newcat_close(RIG *rig) {
if (!rig)
return -RIG_EINVAL;
struct newcat_priv_data * priv = rig->state.priv;
if (priv->trn_state >= 0)
if (!no_restore_ai && priv->trn_state >= 0)
{
/* restore AI state */
newcat_set_trn (rig, priv->trn_state); /* ignore status in