pull/978/head
Mike Black W9MDB 2022-03-01 11:40:14 -06:00
rodzic 499198bf50
commit 0333cdfca5
13 zmienionych plików z 412 dodań i 333 usunięć

Wyświetl plik

@ -81,7 +81,7 @@ static void dra818_subaudio(RIG *rig, char *subaudio, int subaudio_len,
{
if (code)
{
SNPRINTF(subaudio, subaudio_len, "%03uI", code%10000);
SNPRINTF(subaudio, subaudio_len, "%03uI", code % 10000);
return;
}
else if (tone)
@ -92,7 +92,7 @@ static void dra818_subaudio(RIG *rig, char *subaudio, int subaudio_len,
{
if (rig->caps->ctcss_list[i] == tone)
{
SNPRINTF(subaudio, subaudio_len, "%04d", (i + 1)%10000);
SNPRINTF(subaudio, subaudio_len, "%04d", (i + 1) % 10000);
return;
}
}

Wyświetl plik

@ -2630,7 +2630,8 @@ static int netrigctl_power2mW(RIG *rig, unsigned int *mwpower, float power,
RETURNFUNC(RIG_OK);
}
int netrigctl_password(RIG *rig, const unsigned char *key1, const unsigned char *key2)
int netrigctl_password(RIG *rig, const unsigned char *key1,
const unsigned char *key2)
{
char cmdbuf[256];
char buf[BUF_MAX];

Wyświetl plik

@ -107,7 +107,8 @@ static int gomx_transaction(RIG *rig, char *message, char *response);
/* GS100 transceiver control init */
static int gs100_init(RIG *rig)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
ENTERFUNC;
@ -117,6 +118,7 @@ static int gs100_init(RIG *rig)
}
priv = (struct gs100_priv_data *)malloc(sizeof(struct gs100_priv_data));
if (!priv)
{
RETURNFUNC(-RIG_ENOMEM);
@ -139,7 +141,8 @@ static int gs100_init(RIG *rig)
/* GS100 transceiver control deinit */
static int gs100_cleanup(RIG *rig)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
ENTERFUNC;
@ -185,7 +188,8 @@ static int gs100_close(RIG *rig)
/* GS100 transceiver set configuration */
static int gs100_set_conf(RIG *rig, token_t token, const char *val)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
ENTERFUNC;
@ -210,7 +214,8 @@ static int gs100_set_conf(RIG *rig, token_t token, const char *val)
/* GS100 transceiver get configuration */
static int gs100_get_conf(RIG *rig, token_t token, char *val)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
ENTERFUNC;
@ -232,7 +237,8 @@ static int gs100_get_conf(RIG *rig, token_t token, char *val)
/* GS100 transceiver set receiver frequency */
static int gs100_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
char fstr[20], value[20];
int retval;
@ -247,12 +253,14 @@ static int gs100_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
#endif
// range check - GS100 don't do it!
if (freq < rig->caps->rx_range_list1->startf || freq > rig->caps->rx_range_list1->endf) RETURNFUNC(-RIG_EDOM);
if (freq < rig->caps->rx_range_list1->startf
|| freq > rig->caps->rx_range_list1->endf) { RETURNFUNC(-RIG_EDOM); }
// perform set command
sprintf(value, "%1.0lf", freq);
retval = gomx_set(rig, GOM_CONFIG_TAB_RX, "freq", value);
if (retval != RIG_OK) RETURNFUNC(retval);
if (retval != RIG_OK) { RETURNFUNC(retval); }
RETURNFUNC(retval);
}
@ -261,7 +269,8 @@ static int gs100_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
/* GS100 transceiver get receiver frequency */
static int gs100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
char resp[20];
int retval;
freq_t f;
@ -270,7 +279,8 @@ static int gs100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
// perform the get command
retval = gomx_get(rig, GOM_CONFIG_TAB_RX, "freq", resp);
if (retval != RIG_OK) RETURNFUNC(retval);
if (retval != RIG_OK) { RETURNFUNC(retval); }
#ifdef _LOCAL_SIMULATION_
*freq = priv->freq_rx;
@ -279,8 +289,11 @@ static int gs100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
#endif
// relevance check
if (retval != 1) RETURNFUNC(-RIG_EPROTO);
if (f < rig->caps->rx_range_list1->startf || f > rig->caps->rx_range_list1->endf) RETURNFUNC(-RIG_EDOM);
if (retval != 1) { RETURNFUNC(-RIG_EPROTO); }
if (f < rig->caps->rx_range_list1->startf
|| f > rig->caps->rx_range_list1->endf) { RETURNFUNC(-RIG_EDOM); }
*freq = f;
RETURNFUNC(RIG_OK);
@ -290,7 +303,8 @@ static int gs100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
/* GS100 transceiver set transmitter frequency */
static int gs100_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
char fstr[20], value[20];
int retval;
@ -305,12 +319,14 @@ static int gs100_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq)
#endif
// range check - GS100 don't do it!
if (freq < rig->caps->tx_range_list1->startf || freq > rig->caps->tx_range_list1->endf) RETURNFUNC(-RIG_EDOM);
if (freq < rig->caps->tx_range_list1->startf
|| freq > rig->caps->tx_range_list1->endf) { RETURNFUNC(-RIG_EDOM); }
// perform set command
sprintf(value, "%1.0lf", freq);
retval = gomx_set(rig, GOM_CONFIG_TAB_TX, "freq", value);
if (retval != RIG_OK) RETURNFUNC(retval);
if (retval != RIG_OK) { RETURNFUNC(retval); }
RETURNFUNC(RIG_OK);
}
@ -319,7 +335,8 @@ static int gs100_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq)
/* GS100 transceiver get transmitter frequency */
static int gs100_get_tx_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
char resp[20];
int retval;
freq_t f;
@ -328,7 +345,8 @@ static int gs100_get_tx_freq(RIG *rig, vfo_t vfo, freq_t *freq)
// perform the get command
retval = gomx_get(rig, GOM_CONFIG_TAB_TX, "freq", resp);
if (retval != RIG_OK) RETURNFUNC(retval);
if (retval != RIG_OK) { RETURNFUNC(retval); }
#ifdef _LOCAL_SIMULATION_
*freq = priv->freq_tx;
@ -337,8 +355,11 @@ static int gs100_get_tx_freq(RIG *rig, vfo_t vfo, freq_t *freq)
#endif
// relevance check
if (retval != 1) RETURNFUNC(-RIG_EPROTO);
if (f < rig->caps->tx_range_list1->startf || f > rig->caps->tx_range_list1->endf) RETURNFUNC(-RIG_EDOM);
if (retval != 1) { RETURNFUNC(-RIG_EPROTO); }
if (f < rig->caps->tx_range_list1->startf
|| f > rig->caps->tx_range_list1->endf) { RETURNFUNC(-RIG_EDOM); }
*freq = f;
RETURNFUNC(RIG_OK);
@ -348,7 +369,7 @@ static int gs100_get_tx_freq(RIG *rig, vfo_t vfo, freq_t *freq)
/* GS100 transceiver get info */
static const char *gs100_get_info(RIG *rig)
{
return("Gomspace Ground Station Transceiver GS100");
return ("Gomspace Ground Station Transceiver GS100");
}
/* The HAMLIB RIG Capabilities Structure Definition --------------------------*/
@ -394,12 +415,14 @@ struct rig_caps GS100_caps =
.startf = MHz(430), .endf = MHz(440), .modes = GS100_MODES,
.low_power = -1, .high_power = -1, GS100_VFOS,
.label = "GS100#1"
}, RIG_FRNG_END, },
}, RIG_FRNG_END,
},
.tx_range_list1 = { {
.startf = MHz(430), .endf = MHz(440), .modes = GS100_MODES,
.low_power = -1, .high_power = -1, GS100_VFOS,
.label = "GS100#1"
}, RIG_FRNG_END, },
}, RIG_FRNG_END,
},
.tuning_steps = { {GS100_MODES, Hz(10)}, RIG_TS_END, },
.priv = NULL,
.rig_init = gs100_init,
@ -420,7 +443,8 @@ struct rig_caps GS100_caps =
/* Set variable in the GS100 configuration table */
static int gomx_set(RIG *rig, int table, char *varname, char *varvalue)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
int retval;
char msg[BUFSZ], resp[BUFSZ];
@ -428,7 +452,8 @@ static int gomx_set(RIG *rig, int table, char *varname, char *varvalue)
assert(varname != NULL);
assert(varvalue != NULL);
rig_debug(RIG_DEBUG_TRACE, "%s: table=%d, '%s' = '%s'\n", __func__, table, varname, varvalue);
rig_debug(RIG_DEBUG_TRACE, "%s: table=%d, '%s' = '%s'\n", __func__, table,
varname, varvalue);
if (!PARAM_MEM_MINIMAL || table != priv->param_mem)
{
@ -436,24 +461,28 @@ static int gomx_set(RIG *rig, int table, char *varname, char *varvalue)
priv->param_mem = table;
sprintf(msg, "param mem %d\n", table);
retval = gomx_transaction(rig, msg, resp);
if (retval != RIG_OK) return(retval);
if (retval != RIG_OK) { return (retval); }
}
// set the variable
sprintf(msg, "param set %s %s\n", varname, varvalue);
retval = gomx_transaction(rig, msg, resp);
if (retval != RIG_OK) return(retval);
if (retval != RIG_OK) { return (retval); }
// check response
if (strlen(resp) > 0) return(-RIG_EPROTO);
return(RIG_OK);
if (strlen(resp) > 0) { return (-RIG_EPROTO); }
return (RIG_OK);
}
/* Get variable from the GS100 configuration table */
static int gomx_get(RIG *rig, int table, char *varname, char *varvalue)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
int retval;
char msg[BUFSZ], resp[BUFSZ], *c;
@ -469,25 +498,30 @@ static int gomx_get(RIG *rig, int table, char *varname, char *varvalue)
priv->param_mem = table;
sprintf(msg, "param mem %d\n", table);
retval = gomx_transaction(rig, msg, resp);
if (retval != RIG_OK) return(retval);
if (retval != RIG_OK) { return (retval); }
}
// get the variable
sprintf(msg, "param get %s\n", varname);
retval = gomx_transaction(rig, msg, resp);
if (retval != RIG_OK) return(retval);
if (retval != RIG_OK) { return (retval); }
// check response and extract the value
if ((c = strchr(resp, '=')) == NULL) return(-RIG_EPROTO);
if (sscanf(c + 1, "%s", varvalue) != 1) return(-RIG_EPROTO);
return(RIG_OK);
if ((c = strchr(resp, '=')) == NULL) { return (-RIG_EPROTO); }
if (sscanf(c + 1, "%s", varvalue) != 1) { return (-RIG_EPROTO); }
return (RIG_OK);
}
/* Sends a message to the GS100 and parses response lines */
static int gomx_transaction(RIG *rig, char *message, char *response)
{
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data *)rig->state.priv;
__attribute__((unused)) struct gs100_priv_data *priv = (struct gs100_priv_data
*)rig->state.priv;
struct rig_state *rs;
int retval, n = 0;
char buf[BUFSZ];
@ -496,7 +530,8 @@ static int gomx_transaction(RIG *rig, char *message, char *response)
assert(message != NULL);
assert(response != NULL);
rig_debug(RIG_DEBUG_TRACE, "%s: msg='%s'\n", __func__, message == NULL ? "NULL" : message);
rig_debug(RIG_DEBUG_TRACE, "%s: msg='%s'\n", __func__,
message == NULL ? "NULL" : message);
// access to private variables
rs = &rig->state;
@ -504,27 +539,36 @@ static int gomx_transaction(RIG *rig, char *message, char *response)
// send message to the transceiver
rig_flush(&rs->rigport);
retval = write_block(&rs->rigport, (uint8_t*)message, strlen(message));
if (retval != RIG_OK) return(retval);
retval = write_block(&rs->rigport, (uint8_t *)message, strlen(message));
if (retval != RIG_OK) { return (retval); }
while (1)
{
// read the response line
retval = read_string(&rs->rigport, (unsigned char*)buf, BUFSZ, (const char*)GOM_STOPSET, 0, strlen(GOM_STOPSET), 0);
if (retval < 0) return(retval);
if (retval == 0) return(-RIG_ETIMEOUT);
retval = read_string(&rs->rigport, (unsigned char *)buf, BUFSZ,
(const char *)GOM_STOPSET, 0, strlen(GOM_STOPSET), 0);
if (retval < 0) { return (retval); }
if (retval == 0) { return (-RIG_ETIMEOUT); }
n++;
// prompt is always the last line
if (strcmp(buf, GOM_PROMPT) == 0) break;
if (strcmp(buf, GOM_PROMPT) == 0) { break; }
// before last line would be the response
if (n > 1) strcpy(response, buf);
else *response = '\0'; // don't return command echo
if (n > GOM_MAXLINES) return(-RIG_EPROTO);
if (n > 1) { strcpy(response, buf); }
else { *response = '\0'; } // don't return command echo
if (n > GOM_MAXLINES) { return (-RIG_EPROTO); }
}
// report the response
rig_debug(RIG_DEBUG_VERBOSE, "%s: returning response='%s'\n", __func__, response == NULL ? "NULL" : response);
return(RIG_OK);
rig_debug(RIG_DEBUG_VERBOSE, "%s: returning response='%s'\n", __func__,
response == NULL ? "NULL" : response);
return (RIG_OK);
}
/* System Integration Functions ----------------------------------------------*/
@ -534,14 +578,14 @@ DECLARE_INITRIG_BACKEND(gomspace)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: _init called\n", __func__);
rig_register(&GS100_caps);
return(RIG_OK);
return (RIG_OK);
}
/* Probe RIG backend function */
DECLARE_PROBERIG_BACKEND(gomspace)
{
return(RIG_MODEL_GS100);
return (RIG_MODEL_GS100);
}
/*----------------------------------------------------------------------------*/

Wyświetl plik

@ -832,7 +832,8 @@ int kenwood_open(RIG *rig)
if (RIG_OK != err)
{
rig_debug(RIG_DEBUG_ERR, "%s: cannot get f/w version, defaulting to 1.0\n", __func__);
rig_debug(RIG_DEBUG_ERR, "%s: cannot get f/w version, defaulting to 1.0\n",
__func__);
rig->state.rigport.retry = retry_save;
priv->fw_rev_uint = 100;
}
@ -857,7 +858,7 @@ int kenwood_open(RIG *rig)
}
rig_debug(RIG_DEBUG_TRACE, "%s: found f/w version %.1f\n", __func__,
priv->fw_rev_uint/100.0);
priv->fw_rev_uint / 100.0);
}
if (!RIG_IS_XG3 && -RIG_ETIMEOUT == err)
@ -1049,7 +1050,7 @@ int kenwood_get_if(RIG *rig)
ENTERFUNC;
RETURNFUNC (kenwood_safe_transaction(rig, "IF", priv->info,
RETURNFUNC(kenwood_safe_transaction(rig, "IF", priv->info,
KENWOOD_MAX_BUF_LEN, caps->if_len));
}
@ -1106,6 +1107,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo)
break;
#if 0 // VFO_RX really should NOT be VFO_CURR as VFO_CURR could be either VFO
case RIG_VFO_RX:
vfo_function = rig->state.rx_vfo == RIG_VFO_B ? '1' : '0';
break;
@ -2259,7 +2261,8 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
c = 'A' + kmode - 10;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s: kmode=%d, cmode=%c, datamode=%c\n", __func__, kmode, c, data_mode);
rig_debug(RIG_DEBUG_VERBOSE, "%s: kmode=%d, cmode=%c, datamode=%c\n", __func__,
kmode, c, data_mode);
if (RIG_IS_TS990S)
{
@ -2300,17 +2303,21 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (err != RIG_OK) { RETURNFUNC2(err); }
if (data_mode == '1' && (RIG_IS_TS590S || RIG_IS_TS590SG || RIG_IS_TS950S || RIG_IS_TS950SDX))
if (data_mode == '1' && (RIG_IS_TS590S || RIG_IS_TS590SG || RIG_IS_TS950S
|| RIG_IS_TS950SDX))
{
if (RIG_IS_TS950S || RIG_IS_TS950SDX)
{
data_cmd = "DT";
}
datamode = 1;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s, curr_mode=%s, new_mode=%s, datamode=%d\n",
__func__, rig_strvfo(vfo), rig_strrmode(priv->curr_mode), rig_strrmode(mode), datamode);
rig_debug(RIG_DEBUG_VERBOSE,
"%s: vfo=%s, curr_mode=%s, new_mode=%s, datamode=%d\n",
__func__, rig_strvfo(vfo), rig_strrmode(priv->curr_mode), rig_strrmode(mode),
datamode);
// only change mode if needed
if (priv->curr_mode != mode)

Wyświetl plik

@ -411,6 +411,7 @@ static int ft757_open(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s called.\n", __func__);
priv->fakefreq = 1; // turn this on by default
/* FT757GX has a write-only serial port: don't try to read status data */
if (rig->caps->rig_model == RIG_MODEL_FT757)
{

Wyświetl plik

@ -77,6 +77,7 @@ void rig_make_key(char key[33])
{
key[i] = all[my_rand(max)];
}
key[32] = 0;
}

Wyświetl plik

@ -716,23 +716,28 @@ int HAMLIB_API rig_open(RIG *rig)
rs = &rig->state;
rs->rigport.rig = rig;
rs->rigport_deprecated.rig = rig;
// rigctl/rigctld may have deprecated values -- backwards compatility
if (rs->rigport_deprecated.pathname[0] != 0)
{
strcpy(rs->rigport.pathname,rs->rigport_deprecated.pathname);
strcpy(rs->rigport.pathname, rs->rigport_deprecated.pathname);
}
if (rs->pttport_deprecated.type.ptt != RIG_PTT_NONE)
{
rs->pttport.type.ptt = rs->pttport_deprecated.type.ptt;
}
if (rs->dcdport_deprecated.type.dcd != RIG_DCD_NONE)
{
rs->dcdport.type.dcd = rs->dcdport_deprecated.type.dcd;
}
if (rs->pttport_deprecated.pathname[0] != 0)
{
strcpy(rs->pttport.pathname, rs->pttport_deprecated.pathname);
}
if (rs->dcdport_deprecated.pathname[0] != 0)
{
strcpy(rs->dcdport.pathname, rs->dcdport_deprecated.pathname);
@ -1748,7 +1753,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (CHECK_RIG_ARG(rig))
{
RETURNFUNC2 (-RIG_EINVAL);
RETURNFUNC2(-RIG_EINVAL);
}
ELAPSED1;
@ -1756,7 +1761,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (!freq)
{
rig_debug(RIG_DEBUG_TRACE, "%s: freq ptr invalid\n", __func__);
RETURNFUNC2 (-RIG_EINVAL);
RETURNFUNC2(-RIG_EINVAL);
}
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) called vfo=%s\n", __func__, __LINE__,
@ -1806,7 +1811,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (retcode != RIG_OK)
{
RETURNFUNC2 (retcode);
RETURNFUNC2(retcode);
}
if (ptt)
@ -1847,7 +1852,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (caps->get_freq == NULL)
{
RETURNFUNC2 (-RIG_ENAVAIL);
RETURNFUNC2(-RIG_ENAVAIL);
}
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo_opt=%d, model=%d\n", __func__,
@ -1890,7 +1895,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (!caps->set_vfo)
{
RETURNFUNC2 (-RIG_ENAVAIL);
RETURNFUNC2(-RIG_ENAVAIL);
}
TRACE;
@ -1898,7 +1903,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (retcode != RIG_OK)
{
RETURNFUNC2 (retcode);
RETURNFUNC2(retcode);
}
rig_cache_show(rig, __func__, __LINE__);
@ -7099,15 +7104,18 @@ void *async_data_handler(void *arg)
}
#endif
HAMLIB_EXPORT(int) rig_password(RIG *rig, const unsigned char *key1, const unsigned char *key2)
HAMLIB_EXPORT(int) rig_password(RIG *rig, const unsigned char *key1,
const unsigned char *key2)
{
int retval = -RIG_ENIMPL;
ENTERFUNC;
if (rig->caps->password != NULL)
{
retval = rig->caps->password(rig,key1,key2);
retval = rig->caps->password(rig, key1, key2);
//retval = RIG_OK;
}
RETURNFUNC(retval);
}

Wyświetl plik

@ -312,7 +312,8 @@ int main(int argc, char *argv[])
if (amp_file)
{
strncpy(my_amp->state.ampport.pathname, amp_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_amp->state.ampport_deprecated.pathname, amp_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_amp->state.ampport_deprecated.pathname, amp_file,
HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */

Wyświetl plik

@ -1690,18 +1690,23 @@ readline_repeat:
// chk_vfo is the one command we'll allow without a password
// since it's in the initial handshake
int preCmd = 0; // some command are allowed without passoword to satisfy rigctld initialization from rigctl -m 2
int preCmd =
0; // some command are allowed without passoword to satisfy rigctld initialization from rigctl -m 2
if (cmd_entry->arg1 != NULL)
{
if (strcmp(cmd_entry->arg1,"ChkVFO")==0) preCmd = 1;
else if (strcmp(cmd_entry->arg1,"VFO")==0) preCmd = 1;
else if (strcmp(cmd_entry->arg1,"Password")==0) preCmd = 1;
if (strcmp(cmd_entry->arg1, "ChkVFO") == 0) { preCmd = 1; }
else if (strcmp(cmd_entry->arg1, "VFO") == 0) { preCmd = 1; }
else if (strcmp(cmd_entry->arg1, "Password") == 0) { preCmd = 1; }
}
if (use_password && !is_passwordOK && (cmd_entry->arg1 != NULL) && !preCmd)
{
rig_debug(RIG_DEBUG_ERR, "%s: need password=%s for cmd=%s\n", __func__, rigctld_password, cmd_entry->arg1);
return(-RIG_EPROTO);
rig_debug(RIG_DEBUG_ERR, "%s: need password=%s for cmd=%s\n", __func__,
rigctld_password, cmd_entry->arg1);
return (-RIG_EPROTO);
}
retcode = (*cmd_entry->rig_routine)(my_rig,
fout,
fin,
@ -4929,19 +4934,21 @@ declare_proto_rig(pause)
return (RIG_OK);
}
int rigctld_password_check(RIG *rig, const unsigned char *key1, const unsigned char *key2)
int rigctld_password_check(RIG *rig, const unsigned char *key1,
const unsigned char *key2)
{
int retval = -RIG_EINVAL;
//fprintf(fout, "password %s\n", password);
rig_debug(RIG_DEBUG_TRACE, "%s: %s == %s\n", __func__, key1, rigctld_password);
is_passwordOK = 0;
if (strcmp((char*)key1, rigctld_password) == 0)
if (strcmp((char *)key1, rigctld_password) == 0)
{
retval = RIG_OK;
is_passwordOK = 1;
}
return(retval);
return (retval);
}
/* 0x98 */
@ -4951,13 +4958,14 @@ declare_proto_rig(password)
const char *passwd = arg1;
ENTERFUNC;
if (is_rigctld)
{
retval = rigctld_password_check(rig, (unsigned char*)passwd, "key2");
retval = rigctld_password_check(rig, (unsigned char *)passwd, "key2");
}
else
{
retval = rig_password(rig, (unsigned char*) passwd, (unsigned char*)"key2");
retval = rig_password(rig, (unsigned char *) passwd, (unsigned char *)"key2");
//retval = RIG_OK;
}

Wyświetl plik

@ -305,7 +305,7 @@ int main(int argc, char *argv[])
exit(0);
case 'A':
strncpy(rigctld_password, optarg, sizeof(rigctld_password)-1);
strncpy(rigctld_password, optarg, sizeof(rigctld_password) - 1);
break;
case 'm':
@ -679,13 +679,15 @@ int main(int argc, char *argv[])
if (ptt_file)
{
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_rig->state.pttport_deprecated.pathname, ptt_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_rig->state.pttport_deprecated.pathname, ptt_file,
HAMLIB_FILPATHLEN - 1);
}
if (dcd_file)
{
strncpy(my_rig->state.dcdport.pathname, dcd_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_rig->state.dcdport_deprecated.pathname, dcd_file, HAMLIB_FILPATHLEN - 1);
strncpy(my_rig->state.dcdport_deprecated.pathname, dcd_file,
HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */
@ -964,7 +966,8 @@ int main(int argc, char *argv[])
rig_debug(RIG_DEBUG_ERR, "calloc: %s\n", strerror(errno));
exit(1);
}
if (rigctld_password[0] != 0) arg->use_password = 1;
if (rigctld_password[0] != 0) { arg->use_password = 1; }
/* use select to allow for periodic checks for CTRL+C */
FD_ZERO(&set);
@ -984,6 +987,7 @@ int main(int argc, char *argv[])
rig_debug(RIG_DEBUG_VERBOSE, "%s: ctrl_c when retcode==-1\n", __func__);
break;
}
if (errno == EINTR)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: ignoring interrupted system call\n",
@ -1051,6 +1055,7 @@ int main(int argc, char *argv[])
}
}
while (retcode == 0 && !ctrl_c);
rig_debug(RIG_DEBUG_VERBOSE, "%s: while loop done\n", __func__);
#ifdef HAVE_PTHREAD
@ -1190,11 +1195,13 @@ void *handle_socket(void *arg)
if (rig_opened) // only do this if rig is open
{
rig_debug(RIG_DEBUG_TRACE, "%s: doing rigctl_parse vfo_mode=%d, secure=%d\n", __func__,
rig_debug(RIG_DEBUG_TRACE, "%s: doing rigctl_parse vfo_mode=%d, secure=%d\n",
__func__,
handle_data_arg->vfo_mode, handle_data_arg->use_password);
retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0,
mutex_rigctld,
1, 0, &handle_data_arg->vfo_mode, send_cmd_term, &ext_resp, &resp_sep, handle_data_arg->use_password);
1, 0, &handle_data_arg->vfo_mode, send_cmd_term, &ext_resp, &resp_sep,
handle_data_arg->use_password);
if (retcode != 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: rigctl_parse retcode=%d\n", __func__, retcode); }
}

Wyświetl plik

@ -76,6 +76,7 @@ void rig_make_key(char key[33])
{
key[i] = all[my_rand(max)];
}
key[32] = 0;
}
@ -87,7 +88,7 @@ int main()
unsigned char ciphertext[1024];
int ciphertext_length;
int plaintext_length;
memset(ciphertext,0,sizeof(ciphertext));
memset(ciphertext, 0, sizeof(ciphertext));
rig_make_key(key1);
rig_make_key(key2);
printf("key1=%s\n", key1);