Implement K3 RIT/XIT clear via rig_set_ext_level()

Create new confparams token of 'ritclr' for clearing RIT/XIT offset
without turning off RIT/XIT function.  Thanks to Tor, N4OGW, for the
request.  May be replaced in the future by a dedicated RIT/XIT clear
function in the Hamlib API.
Hamlib-1.2.14
Nate Bargmann 2011-06-07 18:04:58 -05:00
rodzic 2808713233
commit 7fbcc9d9e1
4 zmienionych plików z 90 dodań i 18 usunięć

Wyświetl plik

@ -3,10 +3,10 @@ Elecraft K3 notes and Hamlib errata by Nate Bargmann, N0NB.
While the K3 uses a large set of commands compatible with the standard Kenwood
commands, a number are extended and others have side effects that are peculiar
to the K3. As such, a separate set of elecraft.[c|h] files have been written
to support the K2 and K3 in the best possible way using shared code when
to support the K2 and K3 in the best possible way using shared code when
possible. K3 specific code can be found in k3.c
As always, comments and bug reports should be submitted to
As always, comments and bug reports should be submitted to
hamlib-developer@lists.sourceforge.net
@ -16,18 +16,18 @@ elecraft_open()
The kenwood_open() function fails for the Elecraft radios as the function checks
the backend to be certain the ID from the radio matches the backend that called
the function. As the ID command of the Elecraft radios returns "017" which
corresponds to the TS-570, the backend test fails. Rather than muck up a
corresponds to the TS-570, the backend test fails. Rather than muck up a
working function, I chose to implement an independent elecraft_open which not
only checks for the existence of a connected radio that returns an ID of "017",
it also checks for K2 or K3 extensions and sets a pair of private variables
that may be used later for advanced functions. This way the backend should be
that may be used later for advanced functions. This way the backend should be
able to reliably test for either a K2 or K3 (needs more testing with the K2).
k3_set_vfo()
============
The K3's use of VFO A and VFO B differs from other rigs in that VFO A is
The K3's use of VFO A and VFO B differs from other rigs in that VFO A is
*always* the main or upper display and VFO B is *always* the sub or lower
display. The A/B panel button simply swaps the contents of the two displays.
The K3 manual states that VFO A is always the receive frequency and VFO B is
@ -51,7 +51,7 @@ k3_get_mode() k3_get_mode()
===========================
As an extension to the common Kenwood mode definitions, the K3 implements the
custom 'DT' command which can query and set its data sub-modes. These are as
custom 'DT' command which can query and set its data sub-modes. These are as
follows:
DT0 DATA A
@ -59,7 +59,7 @@ DT1 AFSK A
DT2 FSK D
DT3 PSK D
The main difference is that DT0 and DT1 are for soundcard audio modes from a
The main difference is that DT0 and DT1 are for soundcard audio modes from a
computer such as PSK31, MFSK, Olivia, etc. with DT1 being "optimized for RTTY".
Conversely, DT2 and DT3 utilize "direct FSK in" on the accessory jack as well
as enable the K3's internal encoding/decoding of RTTY and PSK31 modes (outside
@ -84,7 +84,7 @@ should map to AFSK A (DT1) or FSK D (DT2).
The K3 can set any bandwidth in any mode using its custom 'BW' command. Band-
width values are sent to the K3 in 10 Hz increments and the K3 will round down
to the nearest 100 Hz values from 10 to 40 Hz. It will round down to the
to the nearest 100 Hz values from 10 to 40 Hz. It will round down to the
nearest 50 Hz values from 50 to 90 Hz. As an example, sending 'BW0236' (2360 in
rigctl) will set the bandwidth to 2350 Hz (rounded down by the K3).
@ -92,13 +92,32 @@ The k3_get_mode function will query and return the actual bandwidth in use in
Hertz.
k3_set_ext_level()
==================
This function is used to set the K3 for some extra level functions (rigctl
command examples shown).
To clear the RIT and XIT offset, use the 'L' command with the token name
'ritclr' for 'Level' to set in rigctl[d]. The prompted value is not used
and can be safely set to 0. Use this level to clear the RIT and XIT offsets
when it is not desired to turn RIT|XIT off.
k3_get_ext_level()
==================
This function is used to query the K3 for the IF center frequency. Use the 'l'
command with the token name 'ifctr' for 'Level' to read in rigctl[d]. Value
returned is 8210000.0 + queried value from rig (see K3 Programmers Reference,
FI command). Returned type is a floating point value.
This function is used to query the K3 for some extra information (rigctl
command examples shown).
To query the IF center frequency, use the 'l' command with the token name
'ifctr' for 'Level' to read in rigctl[d]. Value returned is 8210000.0 +
queried value from rig (see K3 Programmers Reference, FI command). Returned
type is a floating point value.
To query the TX status, use the 'l' command with the token name 'txst' for
'Level' to read in rigctl[d]. Value returned is 1 for K3 in transmit mode
and 0 for receive mode. Returned type is an integer.
kenwood_get/set_ext_parms()

Wyświetl plik

@ -52,6 +52,9 @@ const struct confparams elecraft_ext_levels[] = {
{ TOK_TX_STAT, "txst", "TX status", "TX status",
NULL, RIG_CONF_CHECKBUTTON, { { } },
},
{ TOK_RIT_CLR, "ritclr", "RIT clear", "RIT clear",
NULL, RIG_CONF_BUTTON, { { } },
},
{ RIG_CONF_END, NULL, }
};

Wyświetl plik

@ -55,9 +55,12 @@ enum k3_data_submodes_e {
/* Private tokens used for ext_lvl function in Elecraft backends.
* Extra levels which are rig specific should be coded in
* the individual rig files and token #s >= 101.
*
* See Private Elecraft extra levels definitions in elecraft.c
*/
#define TOK_IF_FREQ TOKEN_BACKEND(101) /* K3 FI command */
#define TOK_TX_STAT TOKEN_BACKEND(102) /* K3 TQ command */
#define TOK_RIT_CLR TOKEN_BACKEND(103) /* K3 RC command */
/* Token structure assigned to .cfgparams in rig_caps */
extern const struct confparams elecraft_ext_levels[];

Wyświetl plik

@ -63,6 +63,7 @@ static struct kenwood_priv_caps k3_priv_caps = {
int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
int k3_set_vfo(RIG *rig, vfo_t vfo);
int k3_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val);
int k3_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val);
int k3_set_rit(RIG * rig, vfo_t vfo, shortfreq_t rit);
int k3_set_xit(RIG * rig, vfo_t vfo, shortfreq_t rit);
@ -210,6 +211,7 @@ const struct rig_caps k3_caps = {
.get_ext_parm = kenwood_get_ext_parm,
.set_level = kenwood_set_level,
.get_level = kenwood_get_level,
.set_ext_level = k3_set_ext_level,
.get_ext_level = k3_get_ext_level,
.vfo_op = kenwood_vfo_op,
.set_trn = kenwood_set_trn,
@ -401,6 +403,50 @@ int k3_set_vfo(RIG *rig, vfo_t vfo)
}
/* Support the RC command for clearing RIT/XIT,
*
* token Defined in elecraft.h or this file
* val Type depends on token type from confparams structure:
* NUMERIC: val.f
* COMBO: val.i, starting from 0 Index to a string table.
* STRING: val.cs for set, val.s for get
* CHECKBUTTON: val.i 0/1
*
* See Private Elecraft extra levels definitions in elecraft.c and
* private token #define in elecraft.h
*/
int k3_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
return -RIG_EINVAL;
// char buf[KENWOOD_MAX_BUF_LEN];
int err;
// const struct confparams *cfp;
// cfp = rig_ext_lookup_tok(rig, token);
switch(token) {
case TOK_RIT_CLR:
/* Clear offset */
err = kenwood_simple_cmd(rig, "RC");
if (err != RIG_OK)
return err;
/* val is ignored for RC command */
break;
default:
rig_debug(RIG_DEBUG_WARN, "%s: Unsupported set_ext_level %d\n",
__func__, token);
return -RIG_EINVAL;
}
return RIG_OK;
}
/* Support the FI command for reading the IF center frequency,
* useful for panadapters and such that need to know the IF center.
* TQ command is a quick transmit status query--K2/K3 only.
@ -560,19 +606,20 @@ int set_rit_xit(RIG * rig, char *func, shortfreq_t rit)
return -RIG_EINVAL;
if (rit == 0) {
/* K3 RIT Off command */
/* Clear offset first */
err = kenwood_simple_cmd(rig, "RC");
if (err != RIG_OK)
return err;
/* K3 RIT|XIT Off command */
err = kenwood_simple_cmd(rig, func);
if (err != RIG_OK)
return err;
/* Clear offset */
err = kenwood_simple_cmd(rig, "RC");
if (err != RIG_OK)
return err;
return RIG_OK;
}
/* Set offset and turn on RIT */
/* Set offset and turn on RIT|XIT */
if (rit <= 9999 && rit >= -9999) {
offs = (rit < 0) ? '-' : '+';
snprintf(cmd, 8, "RO%c%04d", offs, abs((int)rit));