Merge pull request #775 from wutje/get_ant_cleanup

Simplify get_ant by setting ant to 'unknown' by default.
pull/776/head
Michael Black 2021-08-25 16:49:51 -05:00 zatwierdzone przez GitHub
commit fe48129598
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
11 zmienionych plików z 16 dodań i 31 usunięć

Wyświetl plik

@ -512,8 +512,6 @@ int drake_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
char mdbuf[BUFSZ]; char mdbuf[BUFSZ];
char cant; char cant;
*ant_tx = *ant_rx = RIG_ANT_UNKNOWN;
retval = drake_transaction(rig, "RM" EOM, 3, mdbuf, &mdbuf_len); retval = drake_transaction(rig, "RM" EOM, 3, mdbuf, &mdbuf_len);
if (retval != RIG_OK) if (retval != RIG_OK)
@ -542,7 +540,6 @@ int drake_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
rig_debug(RIG_DEBUG_ERR, rig_debug(RIG_DEBUG_ERR,
"drake_get_ant: unsupported antenna %c\n", "drake_get_ant: unsupported antenna %c\n",
cant); cant);
*ant_curr = RIG_ANT_UNKNOWN;
return -RIG_EINVAL; return -RIG_EINVAL;
} }

Wyświetl plik

@ -1671,8 +1671,6 @@ static int dummy_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x\n", __func__, ant); rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x\n", __func__, ant);
*ant_tx = *ant_rx = RIG_ANT_UNKNOWN;
switch (ant) switch (ant)
{ {
case RIG_ANT_CURR: case RIG_ANT_CURR:

Wyświetl plik

@ -2111,8 +2111,6 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
*ant_tx = *ant_rx = RIG_ANT_UNKNOWN;
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo); ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; } if (ret != RIG_OK) { return ret; }

Wyświetl plik

@ -7663,8 +7663,6 @@ int icom_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x\n", __func__, ant); rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x\n", __func__, ant);
*ant_tx = *ant_rx = RIG_ANT_UNKNOWN;
if (ant != RIG_ANT_CURR) if (ant != RIG_ANT_CURR)
{ {
ant = rig_setting2idx(ant); ant = rig_setting2idx(ant);

Wyświetl plik

@ -505,7 +505,6 @@ int ic10_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
char infobuf[50]; char infobuf[50];
int info_len, retval; int info_len, retval;
*ant_tx = *ant_rx = RIG_ANT_UNKNOWN;
info_len = 4; info_len = 4;
retval = ic10_transaction(rig, "AN;", 3, infobuf, &info_len); retval = ic10_transaction(rig, "AN;", 3, infobuf, &info_len);

Wyświetl plik

@ -4188,8 +4188,6 @@ int kenwood_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
*ant_tx = *ant_rx = RIG_ANT_UNKNOWN;
if (!ant_curr) if (!ant_curr)
{ {
RETURNFUNC(-RIG_EINVAL); RETURNFUNC(-RIG_EINVAL);

Wyświetl plik

@ -2532,8 +2532,6 @@ int th_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__); rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
*ant_tx = *ant_rx = RIG_ANT_UNKNOWN;
retval = kenwood_safe_transaction(rig, "ANT", buf, sizeof(buf), 5); retval = kenwood_safe_transaction(rig, "ANT", buf, sizeof(buf), 5);
if (retval != RIG_OK) if (retval != RIG_OK)

Wyświetl plik

@ -760,8 +760,6 @@ int ra37xx_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
char buf[BUFSZ]; char buf[BUFSZ];
int retval, buflen, ra_ant; int retval, buflen, ra_ant;
*ant_tx = *ant_rx = RIG_ANT_UNKNOWN;
retval = ra37xx_transaction(rig, "QANT", buf, &buflen); retval = ra37xx_transaction(rig, "QANT", buf, &buflen);
if (retval != RIG_OK) if (retval != RIG_OK)

Wyświetl plik

@ -2125,8 +2125,6 @@ int tt565_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
char respbuf[TT565_BUFSIZE]; char respbuf[TT565_BUFSIZE];
int resp_len, retval; int resp_len, retval;
*ant_tx = *ant_rx = RIG_ANT_UNKNOWN;
resp_len = sizeof(respbuf); resp_len = sizeof(respbuf);
retval = tt565_transaction(rig, "?KA" EOM, 4, respbuf, &resp_len); retval = tt565_transaction(rig, "?KA" EOM, 4, respbuf, &resp_len);

Wyświetl plik

@ -3383,8 +3383,6 @@ int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
ENTERFUNC; ENTERFUNC;
option->i = 0; // default to no options
if (!newcat_valid_command(rig, command)) if (!newcat_valid_command(rig, command))
{ {
RETURNFUNC(-RIG_ENAVAIL); RETURNFUNC(-RIG_ENAVAIL);
@ -3437,7 +3435,6 @@ int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option,
break; break;
default: default:
*ant_curr = RIG_ANT_UNKNOWN;
RETURNFUNC(-RIG_EPROTO); RETURNFUNC(-RIG_EPROTO);
} }

Wyświetl plik

@ -5188,15 +5188,18 @@ int HAMLIB_API rig_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option)
* \brief get the current antenna * \brief get the current antenna
* \param rig The rig handle * \param rig The rig handle
* \param vfo The target VFO * \param vfo The target VFO
* \param ant The location where to store the current antenna * \param ant The antenna to query option for
* \param option The option value for the antenna * \param option The option value for the antenna, rig specific.
* \param ant_curr The currently selected antenna * \param ant_curr The currently selected antenna
* \param ant_tx The currently selected TX antenna * \param ant_tx The currently selected TX antenna
* \param ant_rx The currently selected RX antenna * \param ant_rx The currently selected RX antenna
* *
* Retrieves the current antenna. * Retrieves the current antenna.
* *
* \RETURNFUNC(RIG_OK) if the operation has been successful, otherwise * If \a ant_tx and/or \a ant_rx are unused by the rig they will be set to
* RIG_ANT_UNKNOWN and only \a ant_curr will be set.
*
* \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).
* *
@ -5224,8 +5227,6 @@ int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
RETURNFUNC(-RIG_EINVAL); RETURNFUNC(-RIG_EINVAL);
} }
*ant_tx = *ant_rx = RIG_ANT_UNKNOWN;
caps = rig->caps; caps = rig->caps;
if (caps->get_ant == NULL) if (caps->get_ant == NULL)
@ -5233,6 +5234,11 @@ int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option,
RETURNFUNC(-RIG_ENAVAIL); RETURNFUNC(-RIG_ENAVAIL);
} }
/* Set antenna default to unknown and clear option.
* So we have sane defaults for all backends */
*ant_tx = *ant_rx = *ant_curr = RIG_ANT_UNKNOWN;
option->i = 0;
if ((caps->targetable_vfo & RIG_TARGETABLE_ANT) if ((caps->targetable_vfo & RIG_TARGETABLE_ANT)
|| vfo == RIG_VFO_CURR || vfo == RIG_VFO_CURR
|| vfo == rig->state.current_vfo) || vfo == rig->state.current_vfo)