kopia lustrzana https://github.com/Hamlib/Hamlib
Clean up rig power on/off sequencing for Kenwood/Elecraft rigs
Note that the K3/K3S cannot power on via CAT control https://github.com/Hamlib/Hamlib/issues/1225pull/1242/head
rodzic
9626894029
commit
52bed765ef
|
@ -97,11 +97,19 @@ int elecraft_open(RIG *rig)
|
|||
char buf[KENWOOD_MAX_BUF_LEN];
|
||||
struct kenwood_priv_data *priv = rig->state.priv;
|
||||
char *model = "Unknown";
|
||||
struct rig_state *rs = &rig->state;
|
||||
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called, rig version=%s\n", __func__,
|
||||
rig->caps->version);
|
||||
|
||||
if (rs->auto_power_on && priv->poweron == 0)
|
||||
{
|
||||
rig_set_powerstat(rig, 1);
|
||||
priv->poweron = 1;
|
||||
}
|
||||
|
||||
|
||||
/* Actual read extension levels from radio.
|
||||
*
|
||||
* The value stored in the k?_ext_lvl variables map to
|
||||
|
|
|
@ -342,6 +342,8 @@ transaction_write:
|
|||
skip |= strncmp(cmdstr, "RU", 2) == 0;
|
||||
skip |= strncmp(cmdstr, "RD", 2) == 0;
|
||||
skip |= strncmp(cmdstr, "KYW", 3) == 0;
|
||||
skip |= strncmp(cmdstr, "PS1", 3) == 0;
|
||||
skip |= strncmp(cmdstr, "PS0", 3) == 0;
|
||||
|
||||
if (skip)
|
||||
{
|
||||
|
@ -825,6 +827,14 @@ int kenwood_open(RIG *rig)
|
|||
|
||||
id[0] = 0;
|
||||
rig->state.rigport.retry = 0;
|
||||
|
||||
if (rig->state.auto_power_on)
|
||||
{
|
||||
// Ensure rig is on
|
||||
rig_set_powerstat(rig, 1);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
err = kenwood_get_id(rig, id);
|
||||
|
||||
if (err != RIG_OK)
|
||||
|
@ -857,14 +867,6 @@ int kenwood_open(RIG *rig)
|
|||
err = RIG_OK; // reset our err back to OK for later checks
|
||||
}
|
||||
|
||||
if (err == -RIG_ETIMEOUT && rig->state.auto_power_on)
|
||||
{
|
||||
// Ensure rig is on
|
||||
rig_set_powerstat(rig, 1);
|
||||
/* Try get id again */
|
||||
err = kenwood_get_id(rig, id);
|
||||
}
|
||||
|
||||
if (RIG_OK != err)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
|
@ -1069,6 +1071,8 @@ int kenwood_close(RIG *rig)
|
|||
|
||||
ENTERFUNC;
|
||||
|
||||
if (priv->poweron == 0) { RETURNFUNC(RIG_OK); } // nothing to do
|
||||
|
||||
if (!no_restore_ai && priv->trn_state >= 0)
|
||||
{
|
||||
/* restore AI state */
|
||||
|
@ -4825,9 +4829,16 @@ int kenwood_get_trn(RIG *rig, int *trn)
|
|||
*/
|
||||
int kenwood_set_powerstat(RIG *rig, powerstat_t status)
|
||||
{
|
||||
int retval = kenwood_transaction(rig,
|
||||
(status == RIG_POWER_ON) ? ";;;;PS1;" : "PS0",
|
||||
NULL, 0);
|
||||
int retval;
|
||||
struct kenwood_priv_data *priv = rig->state.priv;
|
||||
|
||||
if ((priv->is_k3 || priv->is_k3s) && status == RIG_POWER_ON)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR,
|
||||
"%s: K3/K3S must use aux I/O jack pulled low to power on\n", __func__);
|
||||
return -RIG_EPOWER;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
int retry_save = rig->state.rigport.retry;
|
||||
|
||||
|
@ -4835,6 +4846,10 @@ int kenwood_set_powerstat(RIG *rig, powerstat_t status)
|
|||
|
||||
rig->state.rigport.retry = 0;
|
||||
|
||||
retval = kenwood_transaction(rig,
|
||||
(status == RIG_POWER_ON) ? ";;;;PS1;" : "PS0",
|
||||
NULL, 0);
|
||||
|
||||
if (status == RIG_POWER_ON) // wait for wakeup only
|
||||
{
|
||||
for (i = 0; i < 8; ++i) // up to ~10 seconds including the timeouts
|
||||
|
|
13
src/rig.c
13
src/rig.c
|
@ -1267,6 +1267,19 @@ int HAMLIB_API rig_open(RIG *rig)
|
|||
|
||||
if (caps->rig_open != NULL)
|
||||
{
|
||||
if (caps->get_powerstat != NULL)
|
||||
{
|
||||
powerstat_t powerflag;
|
||||
status = rig_get_powerstat(rig, &powerflag);
|
||||
if (status == RIG_OK && powerflag == RIG_POWER_OFF) return (-RIG_EPOWER);
|
||||
// don't need auto_power_on if power is already on
|
||||
if (status == RIG_OK && powerflag == RIG_POWER_ON) rig->state.auto_power_on = 0;
|
||||
if (status == -RIG_ETIMEOUT) {
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Some rigs cannot get_powerstat while off\n", __func__);
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Known rigs: K3, K3S\n", __func__);
|
||||
return (-RIG_EPOWER);
|
||||
}
|
||||
}
|
||||
status = caps->rig_open(rig);
|
||||
|
||||
if (status != RIG_OK)
|
||||
|
|
|
@ -565,8 +565,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
fprintf(stderr, "rig_open: error = %s %s \n", rig_file,
|
||||
strerror(errno));
|
||||
// fprintf(stderr, "rig_open: error = %s %s \n", rig_file,
|
||||
// rigerror(retcode));
|
||||
|
||||
if (!ignore_rig_open_error) { exit(2); }
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue