Skip to content

Commit

Permalink
Improve powerstat on/off behavior for Icom rigs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdblack98 committed Jan 19, 2023
1 parent 177d58b commit 84d86aa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 24 additions & 2 deletions rigs/icom/icom.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ int icom_init(RIG *rig)
|| rig->caps->rig_model == RIG_MODEL_IC821H
|| rig->caps->rig_model == RIG_MODEL_IC910
|| rig->caps->rig_model == RIG_MODEL_IC2730
|| rig->caps->rig_model == RIG_MODEL_ID5100
)
{
priv->x25cmdfails = 1;
Expand Down Expand Up @@ -991,6 +992,18 @@ icom_rig_open(RIG *rig)

rig_debug(RIG_DEBUG_VERBOSE, "%s: %s v%s\n", __func__, rig->caps->model_name,
rig->caps->version);

if (rs->auto_power_on && priv->poweron == 0)
{
rig_debug(RIG_DEBUG_VERBOSE,
"%s asking for power on *****************************************\n", __func__);
rig_set_powerstat(rig, 1);
rig_debug(RIG_DEBUG_VERBOSE,
"%s asking for power on #2 =======================================\n",
__func__);
priv->poweron = 1;
}

retry_open:
retval_echo = icom_get_usb_echo_off(rig);

Expand Down Expand Up @@ -1127,7 +1140,8 @@ icom_rig_close(RIG *rig)

ENTERFUNC;

if (priv->poweron != 0 && rs->auto_power_off)
if (priv->poweron == 0) RETURNFUNC(RIG_OK); // nothing to do
if (priv->poweron == 1 && rs->auto_power_off)
{
// maybe we need power off?
rig_debug(RIG_DEBUG_VERBOSE, "%s trying power off\n", __func__);
Expand Down Expand Up @@ -7971,7 +7985,6 @@ int icom_set_powerstat(RIG *rig, powerstat_t status)
{
case RIG_POWER_ON:

sleep(1); // let serial bus idle for a while
// ic7300 manual says ~150 for 115,200
// we'll just send a few more to be sure for all speeds
memset(fe_buf, 0xfe, fe_max);
Expand All @@ -7990,13 +8003,22 @@ int icom_set_powerstat(RIG *rig, powerstat_t status)
retval =
icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len);

// poweron == 0 means never powered -- == 2 means CAT turned off
if (priv->poweron == 0 || priv->poweron == 2)
{
sleep(1); // give it a while to power up
icom_get_usb_echo_off(rig);
return RIG_OK;
}

break;

default:
pwr_sc = S_PWR_OFF;
fe_buf[0] = 0;
retval =
icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len);
priv->poweron = 2;
}

i = 0;
Expand Down
4 changes: 4 additions & 0 deletions rigs/icom/icom.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ struct icom_priv_caps
struct icom_spectrum_scope_caps spectrum_scope_caps; /*!< Icom spectrum scope capabilities, if supported by the rig. Main/Sub scopes in Icom rigs have the same caps. */
struct icom_spectrum_edge_frequency_range spectrum_edge_frequency_ranges[ICOM_MAX_SPECTRUM_FREQ_RANGES]; /*!< Icom spectrum scope edge frequencies, if supported by the rig. Last entry should have zeros in all fields. */
struct cmdparams *extcmds; /*!< Pointer to extended operations array */
<<<<<<< HEAD
=======
int dualwatch_split; /*!< Rig supports dual watch for split ops -- e.g. ID-5100 */
>>>>>>> 9d096c4a (Improve powerstat on/off behavior for Icom rigs)
};

struct icom_priv_data
Expand Down

0 comments on commit 84d86aa

Please sign in to comment.