kopia lustrzana https://github.com/Hamlib/Hamlib
Added EPOWER error return when rig is powered off
Only set_powerstat will be accepted and rig will be polled for powerstat https://github.com/Hamlib/Hamlib/issues/1085pull/1091/head
rodzic
668db3a0e2
commit
d0c615ae43
|
@ -157,7 +157,8 @@ enum rig_errcode_e {
|
||||||
RIG_EVFO, /*!< 16 Invalid VFO */
|
RIG_EVFO, /*!< 16 Invalid VFO */
|
||||||
RIG_EDOM, /*!< 17 Argument out of domain of func */
|
RIG_EDOM, /*!< 17 Argument out of domain of func */
|
||||||
RIG_EDEPRECATED,/*!< 18 Function deprecated */
|
RIG_EDEPRECATED,/*!< 18 Function deprecated */
|
||||||
RIG_ESECURITY /*!< 19 Security error */
|
RIG_ESECURITY, /*!< 19 Security error */
|
||||||
|
RIG_EPOWER /*!< 20 Rig not powered on */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2575,6 +2576,7 @@ struct rig_state {
|
||||||
int use_cached_ptt; /*<! flag instructing rig_get_ptt to use cached values when asyncio is in use */
|
int use_cached_ptt; /*<! flag instructing rig_get_ptt to use cached values when asyncio is in use */
|
||||||
int depth; /*<! a depth counter to use for debug indentation and such */
|
int depth; /*<! a depth counter to use for debug indentation and such */
|
||||||
int lock_mode; /*<! flag that prevents mode changes if ~= 0 -- see set/get_lock_mode */
|
int lock_mode; /*<! flag that prevents mode changes if ~= 0 -- see set/get_lock_mode */
|
||||||
|
powerstat_t powerstat; /*<! power status */
|
||||||
};
|
};
|
||||||
|
|
||||||
//! @cond Doxygen_Suppress
|
//! @cond Doxygen_Suppress
|
||||||
|
|
|
@ -238,6 +238,7 @@ static int dummy_init(RIG *rig)
|
||||||
|
|
||||||
priv->ptt = RIG_PTT_OFF;
|
priv->ptt = RIG_PTT_OFF;
|
||||||
priv->powerstat = RIG_POWER_ON;
|
priv->powerstat = RIG_POWER_ON;
|
||||||
|
rig->state.powerstat = priv->powerstat;
|
||||||
priv->bank = 0;
|
priv->bank = 0;
|
||||||
memset(priv->parms, 0, RIG_SETTING_MAX * sizeof(value_t));
|
memset(priv->parms, 0, RIG_SETTING_MAX * sizeof(value_t));
|
||||||
|
|
||||||
|
@ -2260,7 +2261,7 @@ struct rig_caps dummy_caps =
|
||||||
RIG_MODEL(RIG_MODEL_DUMMY),
|
RIG_MODEL(RIG_MODEL_DUMMY),
|
||||||
.model_name = "Dummy",
|
.model_name = "Dummy",
|
||||||
.mfg_name = "Hamlib",
|
.mfg_name = "Hamlib",
|
||||||
.version = "20220510.0",
|
.version = "20220715.0",
|
||||||
.copyright = "LGPL",
|
.copyright = "LGPL",
|
||||||
.status = RIG_STATUS_STABLE,
|
.status = RIG_STATUS_STABLE,
|
||||||
.rig_type = RIG_TYPE_OTHER,
|
.rig_type = RIG_TYPE_OTHER,
|
||||||
|
|
|
@ -2091,6 +2091,10 @@ int HAMLIB_API rig_flush(hamlib_port_t *port)
|
||||||
rig_debug(RIG_DEBUG_TRACE, "%s: called for %s device\n", __func__,
|
rig_debug(RIG_DEBUG_TRACE, "%s: called for %s device\n", __func__,
|
||||||
port->type.rig == RIG_PORT_SERIAL ? "serial" : "network");
|
port->type.rig == RIG_PORT_SERIAL ? "serial" : "network");
|
||||||
|
|
||||||
|
if (port->type.rig == RIG_PORT_NONE)
|
||||||
|
{
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
if (port->type.rig == RIG_PORT_NETWORK
|
if (port->type.rig == RIG_PORT_NETWORK
|
||||||
|| port->type.rig == RIG_PORT_UDP_NETWORK)
|
|| port->type.rig == RIG_PORT_UDP_NETWORK)
|
||||||
{
|
{
|
||||||
|
|
|
@ -207,7 +207,8 @@ static const char *const rigerror_table[] =
|
||||||
"Invalid VFO",
|
"Invalid VFO",
|
||||||
"Argument out of domain of func",
|
"Argument out of domain of func",
|
||||||
"Function deprecated",
|
"Function deprecated",
|
||||||
"Security error password not provided or crypto failure"
|
"Security error password not provided or crypto failure",
|
||||||
|
"Rig is not powered on"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1723,7 +1723,21 @@ readline_repeat:
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if ((my_rig->state.powerstat == RIG_POWER_OFF || my_rig->state.powerstat == RIG_POWER_STANDBY))
|
||||||
|
{
|
||||||
|
// Update power status
|
||||||
|
powerstat_t stat;
|
||||||
|
rig_get_powerstat(my_rig, &stat);
|
||||||
|
}
|
||||||
|
// only command allows when powered off is 135=set_powerstat
|
||||||
|
if ((my_rig->state.powerstat == RIG_POWER_OFF || my_rig->state.powerstat == RIG_POWER_STANDBY) && cmd_entry->cmd != 135)
|
||||||
|
{
|
||||||
|
//rig_debug(RIG_DEBUG_WARN, "%s: %s - only \\set_powerstat can be run \n", __func__, rigerror(-RIG_EPOWER));
|
||||||
|
rig_debug(RIG_DEBUG_WARN, "%s: only \\set_powerstat can be run when rig powered off\n", __func__);
|
||||||
|
retcode = -RIG_EPOWER;
|
||||||
|
}
|
||||||
|
else {
|
||||||
retcode = (*cmd_entry->rig_routine)(my_rig,
|
retcode = (*cmd_entry->rig_routine)(my_rig,
|
||||||
fout,
|
fout,
|
||||||
fin,
|
fin,
|
||||||
|
@ -1738,6 +1752,7 @@ readline_repeat:
|
||||||
p1,
|
p1,
|
||||||
p2 ? p2 : "",
|
p2 ? p2 : "",
|
||||||
p3 ? p3 : "");
|
p3 ? p3 : "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4659,6 +4674,7 @@ 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;
|
||||||
fflush(fin);
|
fflush(fin);
|
||||||
RETURNFUNC(retval);
|
RETURNFUNC(retval);
|
||||||
}
|
}
|
||||||
|
@ -4685,6 +4701,7 @@ declare_proto_rig(get_powerstat)
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(fout, "%d\n", stat);
|
fprintf(fout, "%d\n", stat);
|
||||||
|
rig->state.powerstat = stat;
|
||||||
|
|
||||||
RETURNFUNC(status);
|
RETURNFUNC(status);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1150,6 +1150,7 @@ void *handle_socket(void *arg)
|
||||||
char serv[NI_MAXSERV];
|
char serv[NI_MAXSERV];
|
||||||
char send_cmd_term = '\r'; /* send_cmd termination char */
|
char send_cmd_term = '\r'; /* send_cmd termination char */
|
||||||
int ext_resp = 0;
|
int ext_resp = 0;
|
||||||
|
powerstat_t powerstat = RIG_POWER_ON; // defaults to power on
|
||||||
|
|
||||||
fsockin = get_fsockin(handle_data_arg);
|
fsockin = get_fsockin(handle_data_arg);
|
||||||
|
|
||||||
|
@ -1205,6 +1206,9 @@ void *handle_socket(void *arg)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
rig_get_powerstat(my_rig, &powerstat);
|
||||||
|
my_rig->state.powerstat = powerstat;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
mutex_rigctld(1);
|
mutex_rigctld(1);
|
||||||
|
|
Ładowanie…
Reference in New Issue