kopia lustrzana https://github.com/Hamlib/Hamlib
Merge pull request #1302 from mikaelnousiainen/power-status-bug-fixes
Power status bug fixespull/1330/head
commit
f01a165ec7
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
#define IC746_FUNC_ALL (RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN|RIG_FUNC_NR|RIG_FUNC_MON|RIG_FUNC_MN|RIG_FUNC_RF|RIG_FUNC_ANF|RIG_FUNC_APF|RIG_FUNC_RESUME|RIG_FUNC_ARO)
|
#define IC746_FUNC_ALL (RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_TONE|RIG_FUNC_TSQL|RIG_FUNC_SBKIN|RIG_FUNC_FBKIN|RIG_FUNC_NR|RIG_FUNC_MON|RIG_FUNC_MN|RIG_FUNC_RF|RIG_FUNC_ANF|RIG_FUNC_APF|RIG_FUNC_RESUME|RIG_FUNC_ARO)
|
||||||
|
|
||||||
#define IC746_LEVEL_ALL (RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_PREAMP|RIG_LEVEL_ATT|RIG_LEVEL_AGC|RIG_LEVEL_COMP|RIG_LEVEL_BKINDL|RIG_LEVEL_NR|RIG_LEVEL_PBT_IN|RIG_LEVEL_PBT_OUT|RIG_LEVEL_CWPITCH|RIG_LEVEL_RFPOWER|RIG_LEVEL_MICGAIN|RIG_LEVEL_KEYSPD|RIG_LEVEL_NOTCHF_RAW|RIG_LEVEL_SQL|RIG_LEVEL_RAWSTR|RIG_LEVEL_APF)
|
#define IC746_LEVEL_ALL (RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_PREAMP|RIG_LEVEL_ATT|RIG_LEVEL_AGC|RIG_LEVEL_COMP|RIG_LEVEL_BKINDL|RIG_LEVEL_NR|RIG_LEVEL_PBT_IN|RIG_LEVEL_PBT_OUT|RIG_LEVEL_CWPITCH|RIG_LEVEL_RFPOWER|RIG_LEVEL_MICGAIN|RIG_LEVEL_KEYSPD|RIG_LEVEL_NOTCHF_RAW|RIG_LEVEL_SQL|RIG_LEVEL_RAWSTR|RIG_LEVEL_APF|RIG_LEVEL_AGC_TIME)
|
||||||
|
|
||||||
#define IC746_GET_PARM (RIG_PARM_BACKLIGHT|RIG_PARM_BEEP)
|
#define IC746_GET_PARM (RIG_PARM_BACKLIGHT|RIG_PARM_BEEP)
|
||||||
#define IC746_SET_PARM (RIG_PARM_BACKLIGHT|RIG_PARM_BEEP|RIG_PARM_ANN)
|
#define IC746_SET_PARM (RIG_PARM_BACKLIGHT|RIG_PARM_BEEP|RIG_PARM_ANN)
|
||||||
|
|
|
@ -537,7 +537,7 @@ static int ic756pro2_get_ext_parm(RIG *rig, token_t token, value_t *val);
|
||||||
#define IC756PROII_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM)
|
#define IC756PROII_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM)
|
||||||
#define IC756PROII_AM_TX_MODES (RIG_MODE_AM)
|
#define IC756PROII_AM_TX_MODES (RIG_MODE_AM)
|
||||||
|
|
||||||
#define IC756PROII_LEVEL_ALL (IC756PRO_LEVEL_ALL|RIG_LEVEL_VOXDELAY)
|
#define IC756PROII_LEVEL_ALL (IC756PRO_LEVEL_ALL|RIG_LEVEL_VOXDELAY|RIG_LEVEL_AGC_TIME)
|
||||||
|
|
||||||
#define IC756PROII_PARMS (RIG_PARM_ANN|RIG_PARM_BEEP|RIG_PARM_BACKLIGHT|RIG_PARM_TIME)
|
#define IC756PROII_PARMS (RIG_PARM_ANN|RIG_PARM_BEEP|RIG_PARM_BACKLIGHT|RIG_PARM_TIME)
|
||||||
|
|
||||||
|
|
|
@ -328,15 +328,6 @@ transaction_write:
|
||||||
/* flush anything in the read buffer before command is sent */
|
/* flush anything in the read buffer before command is sent */
|
||||||
rig_flush(&rs->rigport);
|
rig_flush(&rs->rigport);
|
||||||
|
|
||||||
// PS command may need to wake up serial port
|
|
||||||
if (priv->ps_cmd_wakeup_data)
|
|
||||||
{
|
|
||||||
if (strncmp(cmd, "PS", 2) == 0)
|
|
||||||
{
|
|
||||||
write_block(&rs->rigport, (unsigned char *) ";;;;", 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmd, len);
|
retval = write_block(&rs->rigport, (unsigned char *) cmd, len);
|
||||||
|
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
@ -553,19 +544,8 @@ transaction_read:
|
||||||
*/
|
*/
|
||||||
if (datasize)
|
if (datasize)
|
||||||
{
|
{
|
||||||
char *ps_cmd;
|
|
||||||
|
|
||||||
if (priv->ps_cmd_wakeup_data)
|
|
||||||
{
|
|
||||||
ps_cmd = ";;;;PS";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ps_cmd = "PS";
|
|
||||||
}
|
|
||||||
|
|
||||||
// we ignore the special PS command
|
// we ignore the special PS command
|
||||||
if (cmdstr && strcmp(cmdstr, ps_cmd) != 0 && (buffer[0] != cmdstr[0]
|
if (cmdstr && strcmp(cmdstr, "PS") != 0 && (buffer[0] != cmdstr[0]
|
||||||
|| (cmdstr[1] && buffer[1] != cmdstr[1])))
|
|| (cmdstr[1] && buffer[1] != cmdstr[1])))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -5060,6 +5040,7 @@ int kenwood_get_trn(RIG *rig, int *trn)
|
||||||
int kenwood_set_powerstat(RIG *rig, powerstat_t status)
|
int kenwood_set_powerstat(RIG *rig, powerstat_t status)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
struct rig_state *state = &rig->state;
|
||||||
struct kenwood_priv_data *priv = rig->state.priv;
|
struct kenwood_priv_data *priv = rig->state.priv;
|
||||||
|
|
||||||
if ((priv->is_k3 || priv->is_k3s) && status == RIG_POWER_ON)
|
if ((priv->is_k3 || priv->is_k3s) && status == RIG_POWER_ON)
|
||||||
|
@ -5074,6 +5055,14 @@ int kenwood_set_powerstat(RIG *rig, powerstat_t status)
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called status=%d\n", __func__, status);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s called status=%d\n", __func__, status);
|
||||||
|
|
||||||
|
if (status == RIG_POWER_ON)
|
||||||
|
{
|
||||||
|
// When powering on a Kenwood rig needs dummy bytes to wake it up,
|
||||||
|
// then wait at least 200ms and within 2 seconds issue the power-on command again
|
||||||
|
write_block(&state->rigport, (unsigned char *) "PS1;", 4);
|
||||||
|
hl_usleep(500000);
|
||||||
|
}
|
||||||
|
|
||||||
rig->state.rigport.retry = 0;
|
rig->state.rigport.retry = 0;
|
||||||
|
|
||||||
retval = kenwood_transaction(rig,
|
retval = kenwood_transaction(rig,
|
||||||
|
@ -5117,7 +5106,8 @@ int kenwood_set_powerstat(RIG *rig, powerstat_t status)
|
||||||
int kenwood_get_powerstat(RIG *rig, powerstat_t *status)
|
int kenwood_get_powerstat(RIG *rig, powerstat_t *status)
|
||||||
{
|
{
|
||||||
char pwrbuf[6];
|
char pwrbuf[6];
|
||||||
int retval;
|
int result;
|
||||||
|
struct rig_state *state = &rig->state;
|
||||||
struct kenwood_priv_data *priv = rig->state.priv;
|
struct kenwood_priv_data *priv = rig->state.priv;
|
||||||
|
|
||||||
ENTERFUNC;
|
ENTERFUNC;
|
||||||
|
@ -5133,22 +5123,61 @@ int kenwood_get_powerstat(RIG *rig, powerstat_t *status)
|
||||||
RETURNFUNC(-RIG_EINVAL);
|
RETURNFUNC(-RIG_EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ps_cmd;
|
// The first PS command has two purposes:
|
||||||
|
// 1. to detect that the rig is turned on/off when it responds with PS1/PS0 immediately
|
||||||
|
// 2. to act as dummy wake-up data for a rig that is turned off
|
||||||
|
|
||||||
if (priv->ps_cmd_wakeup_data)
|
// Timeout needs to be set temporarily to a low value,
|
||||||
|
// so that the second command can be sent in 2 seconds, which is what Kenwood rigs expect.
|
||||||
|
short retry_save;
|
||||||
|
short timeout_retry_save;
|
||||||
|
int timeout_save;
|
||||||
|
|
||||||
|
retry_save = state->rigport.retry;
|
||||||
|
timeout_retry_save = state->rigport.timeout_retry;
|
||||||
|
timeout_save = state->rigport.timeout;
|
||||||
|
|
||||||
|
state->rigport.retry = 0;
|
||||||
|
state->rigport.timeout_retry = 0;
|
||||||
|
state->rigport.timeout = 500;
|
||||||
|
|
||||||
|
result = kenwood_safe_transaction(rig, "PS", pwrbuf, 6, 3);
|
||||||
|
|
||||||
|
state->rigport.retry = retry_save;
|
||||||
|
state->rigport.timeout_retry = timeout_retry_save;
|
||||||
|
state->rigport.timeout = timeout_save;
|
||||||
|
|
||||||
|
// Rig may respond here already
|
||||||
|
if (result == RIG_OK)
|
||||||
{
|
{
|
||||||
ps_cmd = ";;;;PS";
|
char ps = pwrbuf[2];
|
||||||
}
|
|
||||||
else
|
switch (ps)
|
||||||
{
|
{
|
||||||
ps_cmd = "PS";
|
case '1':
|
||||||
|
*status = RIG_POWER_ON;
|
||||||
|
RETURNFUNC(RIG_OK);
|
||||||
|
|
||||||
|
case '0':
|
||||||
|
*status = RIG_POWER_OFF;
|
||||||
|
RETURNFUNC(RIG_OK);
|
||||||
|
|
||||||
|
default:
|
||||||
|
// fall through to retry command
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = kenwood_safe_transaction(rig, ps_cmd, pwrbuf, 6, 3);
|
// Kenwood rigs in powered-off state require the PS command to be sent
|
||||||
|
// after waiting for at least 200ms and within 2 seconds after dummy data
|
||||||
|
hl_usleep(500000);
|
||||||
|
// Discard any unsolicited data
|
||||||
|
rig_flush(&rig->state.rigport);
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
result = kenwood_safe_transaction(rig, "PS", pwrbuf, 6, 3);
|
||||||
|
if (result != RIG_OK)
|
||||||
{
|
{
|
||||||
RETURNFUNC(retval);
|
RETURNFUNC(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
*status = pwrbuf[2] == '0' ? RIG_POWER_OFF : RIG_POWER_ON;
|
*status = pwrbuf[2] == '0' ? RIG_POWER_OFF : RIG_POWER_ON;
|
||||||
|
|
|
@ -175,7 +175,6 @@ struct kenwood_priv_data
|
||||||
rmode_t modeB;
|
rmode_t modeB;
|
||||||
int datamodeA; // datamode status from get_mode or set_mode
|
int datamodeA; // datamode status from get_mode or set_mode
|
||||||
int datamodeB; // datamode status from get_mode or set_mode
|
int datamodeB; // datamode status from get_mode or set_mode
|
||||||
int ps_cmd_wakeup_data; // PS command requires wakeup characters (;)
|
|
||||||
int question_mark_response_means_rejected; /* the question mark response has multiple meanings */
|
int question_mark_response_means_rejected; /* the question mark response has multiple meanings */
|
||||||
int save_k2_ext_lvl; // so we can restore to original
|
int save_k2_ext_lvl; // so we can restore to original
|
||||||
int save_k3_ext_lvl; // so we can restore to original -- for future use if needed
|
int save_k3_ext_lvl; // so we can restore to original -- for future use if needed
|
||||||
|
|
|
@ -1211,7 +1211,6 @@ int ts480_init(RIG *rig)
|
||||||
priv->ag_format = 2;
|
priv->ag_format = 2;
|
||||||
priv->micgain_min = 0;
|
priv->micgain_min = 0;
|
||||||
priv->micgain_max = 100;
|
priv->micgain_max = 100;
|
||||||
priv->ps_cmd_wakeup_data = 1;
|
|
||||||
|
|
||||||
RETURNFUNC(RIG_OK);
|
RETURNFUNC(RIG_OK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3536,7 +3536,6 @@ int newcat_set_powerstat(RIG *rig, powerstat_t status)
|
||||||
int retval;
|
int retval;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int retry_save;
|
int retry_save;
|
||||||
char ps;
|
|
||||||
|
|
||||||
ENTERFUNC;
|
ENTERFUNC;
|
||||||
|
|
||||||
|
@ -3552,9 +3551,8 @@ int newcat_set_powerstat(RIG *rig, powerstat_t status)
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case RIG_POWER_ON:
|
case RIG_POWER_ON:
|
||||||
ps = '1';
|
// When powering on a Yaesu rig needs dummy bytes to wake it up,
|
||||||
// when powering on need a dummy byte to wake it up
|
// then wait from 1 to 2 seconds and issue the power-on command again
|
||||||
// then sleep from 1 to 2 seconds so we'll do 1.5 secs
|
|
||||||
write_block(&state->rigport, (unsigned char *) "PS1;", 4);
|
write_block(&state->rigport, (unsigned char *) "PS1;", 4);
|
||||||
hl_usleep(1200000);
|
hl_usleep(1200000);
|
||||||
break;
|
break;
|
||||||
|
@ -3565,10 +3563,11 @@ int newcat_set_powerstat(RIG *rig, powerstat_t status)
|
||||||
RETURNFUNC(retval);
|
RETURNFUNC(retval);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
RETURNFUNC(-RIG_ENAVAIL);
|
RETURNFUNC(-RIG_EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "PS%c%c", ps, cat_term);
|
// Power on may require a second command
|
||||||
|
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "PS1%c", cat_term);
|
||||||
|
|
||||||
retval = write_block(&state->rigport, (unsigned char *) priv->cmd_str,
|
retval = write_block(&state->rigport, (unsigned char *) priv->cmd_str,
|
||||||
strlen(priv->cmd_str));
|
strlen(priv->cmd_str));
|
||||||
|
@ -3618,9 +3617,9 @@ int newcat_set_powerstat(RIG *rig, powerstat_t status)
|
||||||
*/
|
*/
|
||||||
int newcat_get_powerstat(RIG *rig, powerstat_t *status)
|
int newcat_get_powerstat(RIG *rig, powerstat_t *status)
|
||||||
{
|
{
|
||||||
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
|
struct rig_state *state = (struct rig_state *) &rig->state;
|
||||||
//struct rig_state *state = &rig->state;
|
struct newcat_priv_data *priv = (struct newcat_priv_data *) rig->state.priv;
|
||||||
int err;
|
int result;
|
||||||
char ps;
|
char ps;
|
||||||
char command[] = "PS";
|
char command[] = "PS";
|
||||||
|
|
||||||
|
@ -3633,30 +3632,61 @@ int newcat_get_powerstat(RIG *rig, powerstat_t *status)
|
||||||
RETURNFUNC(-RIG_ENAVAIL);
|
RETURNFUNC(-RIG_ENAVAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// when not powered on need a dummy byte to wake it up
|
// The first PS command has two purposes:
|
||||||
// then sleep from 1 to 2 seconds so we'll do 1.5 secs
|
// 1. to detect that the rig is turned on when it responds with PS1 immediately
|
||||||
// write_block(&state->rigport, (unsigned char *) "PS;", 3);
|
// 2. to act as dummy wake-up data for a rig that is turned off
|
||||||
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", command, cat_term);
|
SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", command, cat_term);
|
||||||
newcat_get_cmd(rig); // don't care about the return
|
|
||||||
if (priv->ret_data[2] == '1')
|
|
||||||
{
|
|
||||||
*status = 1;
|
|
||||||
RETURNFUNC(RIG_OK);
|
|
||||||
}
|
|
||||||
if (rig->state.auto_power_on == 0)
|
|
||||||
{
|
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s(%d): auto_power_on not selected so skipping power on\n", __func__, __LINE__);
|
|
||||||
rig->state.powerstat = RIG_POWER_OFF;
|
|
||||||
return -RIG_ETIMEOUT;
|
|
||||||
}
|
|
||||||
hl_usleep(1200000); // then we must be waking up
|
|
||||||
rig_flush(&rig->state.rigport); /* discard any unsolicited data */
|
|
||||||
|
|
||||||
|
// Timeout needs to be set temporarily to a low value,
|
||||||
|
// so that the second command can be sent in 2 seconds, which is what Yaesu rigs expect.
|
||||||
|
short retry_save;
|
||||||
|
short timeout_retry_save;
|
||||||
|
int timeout_save;
|
||||||
|
|
||||||
/* Get Power status */
|
retry_save = state->rigport.retry;
|
||||||
if (RIG_OK != (err = newcat_get_cmd(rig)))
|
timeout_retry_save = state->rigport.timeout_retry;
|
||||||
|
timeout_save = state->rigport.timeout;
|
||||||
|
|
||||||
|
state->rigport.retry = 0;
|
||||||
|
state->rigport.timeout_retry = 0;
|
||||||
|
state->rigport.timeout = 500;
|
||||||
|
|
||||||
|
result = newcat_get_cmd(rig);
|
||||||
|
|
||||||
|
state->rigport.retry = retry_save;
|
||||||
|
state->rigport.timeout_retry = timeout_retry_save;
|
||||||
|
state->rigport.timeout = timeout_save;
|
||||||
|
|
||||||
|
// Rig may respond here already
|
||||||
|
if (result == RIG_OK)
|
||||||
{
|
{
|
||||||
RETURNFUNC(err);
|
ps = priv->ret_data[2];
|
||||||
|
|
||||||
|
switch (ps)
|
||||||
|
{
|
||||||
|
case '1':
|
||||||
|
*status = RIG_POWER_ON;
|
||||||
|
RETURNFUNC(RIG_OK);
|
||||||
|
|
||||||
|
case '0':
|
||||||
|
*status = RIG_POWER_OFF;
|
||||||
|
RETURNFUNC(RIG_OK);
|
||||||
|
|
||||||
|
default:
|
||||||
|
// fall through to retry command
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Yeasu rigs in powered-off state require the PS command to be sent between 1 and 2 seconds after dummy data
|
||||||
|
hl_usleep(1100000);
|
||||||
|
// Discard any unsolicited data
|
||||||
|
rig_flush(&rig->state.rigport);
|
||||||
|
|
||||||
|
result = newcat_get_cmd(rig);
|
||||||
|
if (result != RIG_OK)
|
||||||
|
{
|
||||||
|
RETURNFUNC(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
ps = priv->ret_data[2];
|
ps = priv->ret_data[2];
|
||||||
|
@ -3672,7 +3702,7 @@ int newcat_get_powerstat(RIG *rig, powerstat_t *status)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
RETURNFUNC(-RIG_ENAVAIL);
|
RETURNFUNC(-RIG_EPROTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURNFUNC(RIG_OK);
|
RETURNFUNC(RIG_OK);
|
||||||
|
@ -10504,10 +10534,11 @@ int newcat_get_cmd(RIG *rig)
|
||||||
int retry_count = 0;
|
int retry_count = 0;
|
||||||
int rc = -RIG_EPROTO;
|
int rc = -RIG_EPROTO;
|
||||||
int is_read_cmd = 0;
|
int is_read_cmd = 0;
|
||||||
|
int is_power_status_cmd = strncmp(priv->cmd_str, "PS", 2) == 0;
|
||||||
|
|
||||||
ENTERFUNC;
|
ENTERFUNC;
|
||||||
|
|
||||||
if (state->powerstat == 0)
|
if (state->powerstat == 0 && !is_power_status_cmd)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: Cannot get from rig when power is off\n", __func__);
|
rig_debug(RIG_DEBUG_WARN, "%s: Cannot get from rig when power is off\n", __func__);
|
||||||
return RIG_OK; // to prevent repeats
|
return RIG_OK; // to prevent repeats
|
||||||
|
@ -10584,14 +10615,13 @@ int newcat_get_cmd(RIG *rig)
|
||||||
|| strcmp(priv->cmd_str, "VT0;") == 0
|
|| strcmp(priv->cmd_str, "VT0;") == 0
|
||||||
|| strcmp(priv->cmd_str, "VT1;") == 0;
|
|| strcmp(priv->cmd_str, "VT1;") == 0;
|
||||||
|
|
||||||
if (priv->cmd_str[2] !=
|
if (priv->cmd_str[2] != ';' && !is_read_cmd)
|
||||||
';' && !is_read_cmd) // then we must be setting something so we'll invalidate the cache
|
|
||||||
{
|
{
|
||||||
|
// then we must be setting something so we'll invalidate the cache
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: cache invalidated\n", __func__);
|
rig_debug(RIG_DEBUG_TRACE, "%s: cache invalidated\n", __func__);
|
||||||
priv->cache_start.tv_sec = 0;
|
priv->cache_start.tv_sec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while (rc != RIG_OK && retry_count++ <= state->rigport.retry)
|
while (rc != RIG_OK && retry_count++ <= state->rigport.retry)
|
||||||
{
|
{
|
||||||
rig_flush(&state->rigport); /* discard any unsolicited data */
|
rig_flush(&state->rigport); /* discard any unsolicited data */
|
||||||
|
@ -10600,11 +10630,8 @@ int newcat_get_cmd(RIG *rig)
|
||||||
/* send the command */
|
/* send the command */
|
||||||
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
|
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
|
||||||
|
|
||||||
|
rc = write_block(&state->rigport, (unsigned char *) priv->cmd_str, strlen(priv->cmd_str));
|
||||||
if (strncmp(priv->cmd_str,"PS",2)==0) state->rigport.timeout_retry = 0;
|
if (rc != RIG_OK)
|
||||||
if (RIG_OK != (rc = write_block(&state->rigport,
|
|
||||||
(unsigned char *) priv->cmd_str,
|
|
||||||
strlen(priv->cmd_str))))
|
|
||||||
{
|
{
|
||||||
RETURNFUNC(rc);
|
RETURNFUNC(rc);
|
||||||
}
|
}
|
||||||
|
@ -10616,9 +10643,10 @@ int newcat_get_cmd(RIG *rig)
|
||||||
&cat_term, sizeof(cat_term), 0, 1)) <= 0)
|
&cat_term, sizeof(cat_term), 0, 1)) <= 0)
|
||||||
{
|
{
|
||||||
// if we get a timeout from PS probably means power is off
|
// if we get a timeout from PS probably means power is off
|
||||||
if (strncmp(priv->cmd_str,"PS",2)==0) {
|
if (rc == -RIG_ETIMEOUT && is_power_status_cmd)
|
||||||
|
{
|
||||||
rig_debug(RIG_DEBUG_WARN, "%s: rig power is off?\n", __func__);
|
rig_debug(RIG_DEBUG_WARN, "%s: rig power is off?\n", __func__);
|
||||||
return -RIG_ETIMEOUT;
|
RETURNFUNC(rc);
|
||||||
}
|
}
|
||||||
continue; /* usually a timeout - retry */
|
continue; /* usually a timeout - retry */
|
||||||
}
|
}
|
||||||
|
|
42
src/rig.c
42
src/rig.c
|
@ -100,7 +100,7 @@ const char *hamlib_version2 = "Hamlib " PACKAGE_VERSION " " HAMLIBDATETIME " "
|
||||||
ARCHBITS;
|
ARCHBITS;
|
||||||
HAMLIB_EXPORT_VAR(int) cookie_use;
|
HAMLIB_EXPORT_VAR(int) cookie_use;
|
||||||
HAMLIB_EXPORT_VAR(int) lock_mode; // for use by rigctld
|
HAMLIB_EXPORT_VAR(int) lock_mode; // for use by rigctld
|
||||||
HAMLIB_EXPORT_VAR(powerstat_t) rig_powerstat; // for use by rigctld
|
HAMLIB_EXPORT_VAR(powerstat_t) rig_powerstat; // for use by both rigctld and rigctl
|
||||||
//! @endcond
|
//! @endcond
|
||||||
|
|
||||||
struct rig_caps caps_test;
|
struct rig_caps caps_test;
|
||||||
|
@ -1290,14 +1290,13 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||||
powerstat_t powerflag;
|
powerstat_t powerflag;
|
||||||
status = rig_get_powerstat(rig, &powerflag);
|
status = rig_get_powerstat(rig, &powerflag);
|
||||||
|
|
||||||
if (status == RIG_OK && powerflag == RIG_POWER_OFF
|
if (status == RIG_OK && (powerflag == RIG_POWER_OFF || powerflag == RIG_POWER_STANDBY)
|
||||||
&& rig->state.auto_power_on == 0)
|
&& rig->state.auto_power_on == 0)
|
||||||
{
|
{
|
||||||
|
// rig_open() should succeed even if the rig is powered off, so simply log power status
|
||||||
rig_debug(RIG_DEBUG_ERR,
|
rig_debug(RIG_DEBUG_ERR,
|
||||||
"%s: rig power is off, use --set-conf=auto_power_on=1 if power on is wanted\n",
|
"%s: rig power is off, use --set-conf=auto_power_on=1 if power on is wanted\n",
|
||||||
__func__);
|
__func__);
|
||||||
|
|
||||||
RETURNFUNC2(-RIG_EPOWER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't need auto_power_on if power is already on
|
// don't need auto_power_on if power is already on
|
||||||
|
@ -1305,14 +1304,10 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||||
|
|
||||||
if (status == -RIG_ETIMEOUT)
|
if (status == -RIG_ETIMEOUT)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: Some rigs cannot get_powerstat while off\n",
|
// rig_open() should succeed even if get_powerstat() fails,
|
||||||
__func__);
|
// as many rigs cannot get power status while powered off
|
||||||
|
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__);
|
rig_debug(RIG_DEBUG_ERR, "%s: Known rigs: K3, K3S\n", __func__);
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: Rigs that should but don't work: TS480\n",
|
|
||||||
__func__);
|
|
||||||
// A TS-480 user was showing ;;;;PS; not working so we'll just show the error message for now
|
|
||||||
// https://github.com/Hamlib/Hamlib/issues/1226
|
|
||||||
//RETURNFUNC2 (-RIG_EPOWER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6172,8 +6167,14 @@ int HAMLIB_API rig_set_powerstat(RIG *rig, powerstat_t status)
|
||||||
|
|
||||||
HAMLIB_TRACE;
|
HAMLIB_TRACE;
|
||||||
retcode = rig->caps->set_powerstat(rig, status);
|
retcode = rig->caps->set_powerstat(rig, status);
|
||||||
rig_flush(&rig->state.rigport); // if anything is queued up flush it
|
|
||||||
rig->state.auto_power_on = 1; // ensure we auto power on in the future
|
if (retcode == RIG_OK)
|
||||||
|
{
|
||||||
|
rig->state.powerstat = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if anything is queued up flush it
|
||||||
|
rig_flush_force(&rig->state.rigport, 1);
|
||||||
RETURNFUNC(retcode);
|
RETURNFUNC(retcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6219,16 +6220,15 @@ int HAMLIB_API rig_get_powerstat(RIG *rig, powerstat_t *status)
|
||||||
HAMLIB_TRACE;
|
HAMLIB_TRACE;
|
||||||
retcode = rig->caps->get_powerstat(rig, status);
|
retcode = rig->caps->get_powerstat(rig, status);
|
||||||
|
|
||||||
if (retcode == RIG_EIO)
|
if (retcode == RIG_OK)
|
||||||
{
|
{
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: hard error, reopening rig\n", __func__);
|
rig->state.powerstat = *status;
|
||||||
rig_close(rig);
|
}
|
||||||
rig_open(rig);
|
else
|
||||||
|
{
|
||||||
|
// if failed, assume power is on
|
||||||
|
*status = RIG_POWER_ON;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retcode != RIG_OK) { *status = RIG_POWER_ON; } // if failed assume power is on
|
|
||||||
|
|
||||||
if (*status == RIG_POWER_OFF && rig->state.auto_power_on) { rig->caps->set_powerstat(rig, RIG_POWER_ON); }
|
|
||||||
|
|
||||||
RETURNFUNC(retcode);
|
RETURNFUNC(retcode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ static struct option long_options[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char rig_resp_sep;
|
extern char rig_resp_sep;
|
||||||
|
extern powerstat_t rig_powerstat;
|
||||||
|
|
||||||
#define MAXCONFLEN 1024
|
#define MAXCONFLEN 1024
|
||||||
|
|
||||||
|
@ -149,6 +150,7 @@ int main(int argc, char *argv[])
|
||||||
int i;
|
int i;
|
||||||
char rigstartup[1024];
|
char rigstartup[1024];
|
||||||
char vbuf[1024];
|
char vbuf[1024];
|
||||||
|
rig_powerstat = RIG_POWER_ON; // defaults to power on
|
||||||
|
|
||||||
int err = setvbuf(stderr, vbuf, _IOFBF, sizeof(vbuf));
|
int err = setvbuf(stderr, vbuf, _IOFBF, sizeof(vbuf));
|
||||||
|
|
||||||
|
@ -575,6 +577,12 @@ int main(int argc, char *argv[])
|
||||||
my_rig->caps->model_name);
|
my_rig->caps->model_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (my_rig->caps->get_powerstat)
|
||||||
|
{
|
||||||
|
rig_get_powerstat(my_rig, &rig_powerstat);
|
||||||
|
my_rig->state.powerstat = rig_powerstat;
|
||||||
|
}
|
||||||
|
|
||||||
if (my_rig->caps->rig_model == RIG_MODEL_NETRIGCTL)
|
if (my_rig->caps->rig_model == RIG_MODEL_NETRIGCTL)
|
||||||
{
|
{
|
||||||
/* We automatically detect if we need to be in vfo mode or not */
|
/* We automatically detect if we need to be in vfo mode or not */
|
||||||
|
@ -650,6 +658,21 @@ int main(int argc, char *argv[])
|
||||||
interactive, prompt, &vfo_opt, send_cmd_term,
|
interactive, prompt, &vfo_opt, send_cmd_term,
|
||||||
&ext_resp, &rig_resp_sep, 0);
|
&ext_resp, &rig_resp_sep, 0);
|
||||||
|
|
||||||
|
// If we get a timeout, the rig might be powered off
|
||||||
|
// Update our power status in case power gets turned off
|
||||||
|
if (retcode == -RIG_ETIMEOUT && my_rig->caps->get_powerstat)
|
||||||
|
{
|
||||||
|
powerstat_t powerstat;
|
||||||
|
|
||||||
|
rig_get_powerstat(my_rig, &powerstat);
|
||||||
|
rig_powerstat = powerstat;
|
||||||
|
|
||||||
|
if (powerstat == RIG_POWER_OFF || powerstat == RIG_POWER_STANDBY)
|
||||||
|
{
|
||||||
|
retcode = -RIG_EPOWER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if we get a hard error we try to reopen the rig again
|
// if we get a hard error we try to reopen the rig again
|
||||||
// this should cover short dropouts that can occur
|
// this should cover short dropouts that can occur
|
||||||
if (retcode < 0 && !RIG_IS_SOFT_ERRCODE(-retcode))
|
if (retcode < 0 && !RIG_IS_SOFT_ERRCODE(-retcode))
|
||||||
|
|
|
@ -104,7 +104,7 @@ char rigctld_password[64];
|
||||||
int is_passwordOK;
|
int is_passwordOK;
|
||||||
int is_rigctld;
|
int is_rigctld;
|
||||||
extern int lock_mode; // used by rigctld
|
extern int lock_mode; // used by rigctld
|
||||||
extern int rig_powerstat;
|
extern powerstat_t rig_powerstat;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1732,8 +1732,7 @@ readline_repeat:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Allow only certain commands when the rig is powered off
|
// Allow only certain commands when the rig is powered off
|
||||||
if (retcode == RIG_OK && (rig_powerstat == RIG_POWER_OFF
|
if ((rig_powerstat == RIG_POWER_OFF || rig_powerstat == RIG_POWER_STANDBY)
|
||||||
|| rig_powerstat == RIG_POWER_STANDBY)
|
|
||||||
&& cmd_entry->cmd != '1' // dump_caps
|
&& cmd_entry->cmd != '1' // dump_caps
|
||||||
&& cmd_entry->cmd != '3' // dump_conf
|
&& cmd_entry->cmd != '3' // dump_conf
|
||||||
&& cmd_entry->cmd != 0x8f // dump_state
|
&& cmd_entry->cmd != 0x8f // dump_state
|
||||||
|
@ -4722,8 +4721,10 @@ declare_proto_rig(set_powerstat)
|
||||||
CHKSCN1ARG(sscanf(arg1, "%d", &stat));
|
CHKSCN1ARG(sscanf(arg1, "%d", &stat));
|
||||||
|
|
||||||
retval = rig_set_powerstat(rig, (powerstat_t) stat);
|
retval = rig_set_powerstat(rig, (powerstat_t) stat);
|
||||||
rig->state.powerstat = stat;
|
if (retval == RIG_OK)
|
||||||
rig_powerstat = stat; // update our global so others can see powerstat
|
{
|
||||||
|
rig_powerstat = stat; // update our global so others can see powerstat
|
||||||
|
}
|
||||||
fflush(fin);
|
fflush(fin);
|
||||||
RETURNFUNC2(retval);
|
RETURNFUNC2(retval);
|
||||||
}
|
}
|
||||||
|
@ -4750,7 +4751,7 @@ declare_proto_rig(get_powerstat)
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "%d\n", stat);
|
fprintf(fout, "%d\n", stat);
|
||||||
rig->state.powerstat = stat;
|
rig_powerstat = stat; // update our global so others can see powerstat
|
||||||
|
|
||||||
RETURNFUNC2(status);
|
RETURNFUNC2(status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1278,14 +1278,17 @@ void *handle_socket(void *arg)
|
||||||
|
|
||||||
if (retcode != 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: rigctl_parse retcode=%d\n", __func__, retcode); }
|
if (retcode != 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: rigctl_parse retcode=%d\n", __func__, retcode); }
|
||||||
|
|
||||||
// update our power stat in case power gets turned off
|
// If we get a timeout, the rig might be powered off
|
||||||
if (retcode == -RIG_ETIMEOUT
|
// Update our power status in case power gets turned off
|
||||||
&& my_rig->caps->get_powerstat) // if we get a timeout we might be powered off
|
if (retcode == -RIG_ETIMEOUT && my_rig->caps->get_powerstat)
|
||||||
{
|
{
|
||||||
rig_get_powerstat(my_rig, &powerstat);
|
rig_get_powerstat(my_rig, &powerstat);
|
||||||
rig_powerstat = powerstat;
|
rig_powerstat = powerstat;
|
||||||
|
|
||||||
if (powerstat == RIG_POWER_OFF) { retcode = -RIG_EPOWER; }
|
if (powerstat == RIG_POWER_OFF || powerstat == RIG_POWER_STANDBY)
|
||||||
|
{
|
||||||
|
retcode = -RIG_EPOWER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Ładowanie…
Reference in New Issue