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

@ -204,7 +204,7 @@ const struct rig_caps adt_200a_caps =
.power2mW = adat_power2mW, .power2mW = adat_power2mW,
.mW2power = adat_mW2power, .mW2power = adat_mW2power,
.get_powerstat = adat_get_powerstat, .get_powerstat = adat_get_powerstat,
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
}; };

Wyświetl plik

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

Wyświetl plik

@ -2630,7 +2630,8 @@ static int netrigctl_power2mW(RIG *rig, unsigned int *mwpower, float power,
RETURNFUNC(RIG_OK); 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 cmdbuf[256];
char buf[BUF_MAX]; char buf[BUF_MAX];

Wyświetl plik

@ -75,9 +75,9 @@
*/ */
struct gs100_priv_data struct gs100_priv_data
{ {
freq_t freq_rx; ///< currently just for backup and TRX emulation freq_t freq_rx; ///< currently just for backup and TRX emulation
freq_t freq_tx; ///< currently just for backup and TRX emulation freq_t freq_tx; ///< currently just for backup and TRX emulation
int param_mem; ///< last value of configuration table selection int param_mem; ///< last value of configuration table selection
}; };
/* Imported Functions --------------------------------------------------------*/ /* Imported Functions --------------------------------------------------------*/
@ -107,248 +107,269 @@ static int gomx_transaction(RIG *rig, char *message, char *response);
/* GS100 transceiver control init */ /* GS100 transceiver control init */
static int gs100_init(RIG *rig) 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; ENTERFUNC;
if (!rig || !rig->caps) if (!rig || !rig->caps)
{ {
RETURNFUNC(-RIG_EINVAL); RETURNFUNC(-RIG_EINVAL);
} }
priv = (struct gs100_priv_data *)malloc(sizeof(struct gs100_priv_data)); priv = (struct gs100_priv_data *)malloc(sizeof(struct gs100_priv_data));
if (!priv)
{
RETURNFUNC(-RIG_ENOMEM);
}
rig->state.priv = (void *)priv; if (!priv)
{
RETURNFUNC(-RIG_ENOMEM);
}
rig->state.priv = (void *)priv;
#ifdef _LOCAL_SIMULATION_ #ifdef _LOCAL_SIMULATION_
rig->state.rigport.type.rig = RIG_PORT_NONE; // just simulation rig->state.rigport.type.rig = RIG_PORT_NONE; // just simulation
priv->freq_rx = rig->caps->rx_range_list1->startf; priv->freq_rx = rig->caps->rx_range_list1->startf;
priv->freq_tx = rig->caps->tx_range_list1->startf; priv->freq_tx = rig->caps->tx_range_list1->startf;
#endif #endif
priv->param_mem = -1; // means undefined last selection priv->param_mem = -1; // means undefined last selection
RETURNFUNC(RIG_OK); RETURNFUNC(RIG_OK);
} }
/* GS100 transceiver control deinit */ /* GS100 transceiver control deinit */
static int gs100_cleanup(RIG *rig) 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; ENTERFUNC;
if (rig->state.priv) if (rig->state.priv)
{ {
free(rig->state.priv); free(rig->state.priv);
} }
rig->state.priv = NULL; rig->state.priv = NULL;
RETURNFUNC(RIG_OK); RETURNFUNC(RIG_OK);
} }
/* GS100 transceiver open */ /* GS100 transceiver open */
static int gs100_open(RIG *rig) static int gs100_open(RIG *rig)
{ {
ENTERFUNC; ENTERFUNC;
if (rig->caps->rig_model == RIG_MODEL_GS100) if (rig->caps->rig_model == RIG_MODEL_GS100)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s: OPENING'\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s: OPENING'\n", __func__);
} }
RETURNFUNC(RIG_OK); RETURNFUNC(RIG_OK);
} }
/* GS100 transceiver close */ /* GS100 transceiver close */
static int gs100_close(RIG *rig) static int gs100_close(RIG *rig)
{ {
ENTERFUNC; ENTERFUNC;
if (rig->caps->rig_model == RIG_MODEL_GS100) if (rig->caps->rig_model == RIG_MODEL_GS100)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s: CLOSING'\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s: CLOSING'\n", __func__);
} }
RETURNFUNC(RIG_OK); RETURNFUNC(RIG_OK);
} }
/* GS100 transceiver set configuration */ /* GS100 transceiver set configuration */
static int gs100_set_conf(RIG *rig, token_t token, const char *val) 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; ENTERFUNC;
priv = (struct gs100_priv_data *)rig->state.priv; priv = (struct gs100_priv_data *)rig->state.priv;
switch (token) switch (token)
{ {
case 0: case 0:
break; break;
case 1: case 1:
break; break;
default: default:
RETURNFUNC(-RIG_EINVAL); RETURNFUNC(-RIG_EINVAL);
} }
RETURNFUNC(RIG_OK); RETURNFUNC(RIG_OK);
} }
/* GS100 transceiver get configuration */ /* GS100 transceiver get configuration */
static int gs100_get_conf(RIG *rig, token_t token, char *val) 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; ENTERFUNC;
priv = (struct gs100_priv_data *)rig->state.priv; priv = (struct gs100_priv_data *)rig->state.priv;
switch (token) switch (token)
{ {
case 0: case 0:
break; break;
default: default:
RETURNFUNC(-RIG_EINVAL); RETURNFUNC(-RIG_EINVAL);
} }
RETURNFUNC(RIG_OK); RETURNFUNC(RIG_OK);
} }
/* GS100 transceiver set receiver frequency */ /* GS100 transceiver set receiver frequency */
static int gs100_set_freq(RIG *rig, vfo_t vfo, freq_t freq) 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
char fstr[20], value[20]; *)rig->state.priv;
int retval; char fstr[20], value[20];
int retval;
ENTERFUNC; ENTERFUNC;
// reporting // reporting
sprintf_freq(fstr, sizeof(fstr), freq); sprintf_freq(fstr, sizeof(fstr), freq);
rig_debug(RIG_DEBUG_VERBOSE, "%s: fstr = '%s'\n", __func__, fstr); rig_debug(RIG_DEBUG_VERBOSE, "%s: fstr = '%s'\n", __func__, fstr);
#ifdef _LOCAL_SIMULATION_ #ifdef _LOCAL_SIMULATION_
priv->freq_rx = freq; priv->freq_rx = freq;
#endif #endif
// range check - GS100 don't do it! // 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 // perform set command
sprintf(value, "%1.0lf", freq); sprintf(value, "%1.0lf", freq);
retval = gomx_set(rig, GOM_CONFIG_TAB_RX, "freq", value); retval = gomx_set(rig, GOM_CONFIG_TAB_RX, "freq", value);
if (retval != RIG_OK) RETURNFUNC(retval);
RETURNFUNC(retval); if (retval != RIG_OK) { RETURNFUNC(retval); }
RETURNFUNC(retval);
} }
/* GS100 transceiver get receiver frequency */ /* GS100 transceiver get receiver frequency */
static int gs100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) 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
char resp[20]; *)rig->state.priv;
int retval; char resp[20];
freq_t f; int retval;
freq_t f;
ENTERFUNC; ENTERFUNC;
// perform the get command // perform the get command
retval = gomx_get(rig, GOM_CONFIG_TAB_RX, "freq", resp); 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_ #ifdef _LOCAL_SIMULATION_
*freq = priv->freq_rx; *freq = priv->freq_rx;
#else #else
retval = sscanf(resp, "%lf", &f); retval = sscanf(resp, "%lf", &f);
#endif #endif
// relevance check // relevance check
if (retval != 1) RETURNFUNC(-RIG_EPROTO); 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); if (f < rig->caps->rx_range_list1->startf
|| f > rig->caps->rx_range_list1->endf) { RETURNFUNC(-RIG_EDOM); }
*freq = f;
RETURNFUNC(RIG_OK);
} }
/* GS100 transceiver set transmitter frequency */ /* GS100 transceiver set transmitter frequency */
static int gs100_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq) 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
char fstr[20], value[20]; *)rig->state.priv;
int retval; char fstr[20], value[20];
int retval;
ENTERFUNC; ENTERFUNC;
// reporting // reporting
sprintf_freq(fstr, sizeof(fstr), freq); sprintf_freq(fstr, sizeof(fstr), freq);
rig_debug(RIG_DEBUG_VERBOSE, "%s: fstr = '%s'\n", __func__, fstr); rig_debug(RIG_DEBUG_VERBOSE, "%s: fstr = '%s'\n", __func__, fstr);
#ifdef _LOCAL_SIMULATION_ #ifdef _LOCAL_SIMULATION_
priv->freq_tx = freq; priv->freq_tx = freq;
#endif #endif
// range check - GS100 don't do it! // 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 // perform set command
sprintf(value, "%1.0lf", freq); sprintf(value, "%1.0lf", freq);
retval = gomx_set(rig, GOM_CONFIG_TAB_TX, "freq", value); retval = gomx_set(rig, GOM_CONFIG_TAB_TX, "freq", value);
if (retval != RIG_OK) RETURNFUNC(retval);
RETURNFUNC(RIG_OK); if (retval != RIG_OK) { RETURNFUNC(retval); }
RETURNFUNC(RIG_OK);
} }
/* GS100 transceiver get transmitter frequency */ /* GS100 transceiver get transmitter frequency */
static int gs100_get_tx_freq(RIG *rig, vfo_t vfo, freq_t *freq) 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
char resp[20]; *)rig->state.priv;
int retval; char resp[20];
freq_t f; int retval;
freq_t f;
ENTERFUNC; ENTERFUNC;
// perform the get command // perform the get command
retval = gomx_get(rig, GOM_CONFIG_TAB_TX, "freq", resp); 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_ #ifdef _LOCAL_SIMULATION_
*freq = priv->freq_tx; *freq = priv->freq_tx;
#else #else
retval = sscanf(resp, "%lf", &f); retval = sscanf(resp, "%lf", &f);
#endif #endif
// relevance check // relevance check
if (retval != 1) RETURNFUNC(-RIG_EPROTO); 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); if (f < rig->caps->tx_range_list1->startf
|| f > rig->caps->tx_range_list1->endf) { RETURNFUNC(-RIG_EDOM); }
*freq = f;
RETURNFUNC(RIG_OK);
} }
/* GS100 transceiver get info */ /* GS100 transceiver get info */
static const char *gs100_get_info(RIG *rig) 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 --------------------------*/ /* The HAMLIB RIG Capabilities Structure Definition --------------------------*/
@ -362,57 +383,59 @@ static const char *gs100_get_info(RIG *rig)
struct rig_caps GS100_caps = struct rig_caps GS100_caps =
{ {
RIG_MODEL(RIG_MODEL_GS100), RIG_MODEL(RIG_MODEL_GS100),
.model_name = "GS100", .model_name = "GS100",
.mfg_name = "GOMSPACE", .mfg_name = "GOMSPACE",
.version = "20211117.0", .version = "20211117.0",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_ALPHA, .status = RIG_STATUS_ALPHA,
.rig_type = RIG_TYPE_TRANSCEIVER, .rig_type = RIG_TYPE_TRANSCEIVER,
.targetable_vfo = 0, .targetable_vfo = 0,
.ptt_type = RIG_PTT_NONE, .ptt_type = RIG_PTT_NONE,
.dcd_type = RIG_DCD_NONE, .dcd_type = RIG_DCD_NONE,
.port_type = RIG_PORT_SERIAL, .port_type = RIG_PORT_SERIAL,
.serial_rate_min = 115200, .serial_rate_min = 115200,
.serial_rate_max = 500000, .serial_rate_max = 500000,
.serial_data_bits = 8, .serial_data_bits = 8,
.serial_stop_bits = 1, .serial_stop_bits = 1,
.serial_parity = RIG_PARITY_NONE, .serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE, .serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 1, .write_delay = 1,
.post_write_delay = 1, .post_write_delay = 1,
.timeout = 250, .timeout = 250,
.retry = 0, .retry = 0,
.has_get_func = GS100_FUNC, .has_get_func = GS100_FUNC,
.has_set_func = GS100_FUNC, .has_set_func = GS100_FUNC,
.has_get_level = GS100_LEVEL, .has_get_level = GS100_LEVEL,
.has_set_level = GS100_LEVEL, .has_set_level = GS100_LEVEL,
.has_get_parm = GS100_PARM, .has_get_parm = GS100_PARM,
.has_set_parm = GS100_PARM, .has_set_parm = GS100_PARM,
.vfo_ops = GS100_VFO_OPS, .vfo_ops = GS100_VFO_OPS,
.rx_range_list1 = { { .rx_range_list1 = { {
.startf = MHz(430), .endf = MHz(440), .modes = GS100_MODES, .startf = MHz(430), .endf = MHz(440), .modes = GS100_MODES,
.low_power = -1, .high_power = -1, GS100_VFOS, .low_power = -1, .high_power = -1, GS100_VFOS,
.label = "GS100#1" .label = "GS100#1"
}, RIG_FRNG_END, }, }, RIG_FRNG_END,
},
.tx_range_list1 = { { .tx_range_list1 = { {
.startf = MHz(430), .endf = MHz(440), .modes = GS100_MODES, .startf = MHz(430), .endf = MHz(440), .modes = GS100_MODES,
.low_power = -1, .high_power = -1, GS100_VFOS, .low_power = -1, .high_power = -1, GS100_VFOS,
.label = "GS100#1" .label = "GS100#1"
}, RIG_FRNG_END, }, }, RIG_FRNG_END,
.tuning_steps = { {GS100_MODES, Hz(10)}, RIG_TS_END, }, },
.priv = NULL, .tuning_steps = { {GS100_MODES, Hz(10)}, RIG_TS_END, },
.rig_init = gs100_init, .priv = NULL,
.rig_cleanup = gs100_cleanup, .rig_init = gs100_init,
.rig_open = gs100_open, .rig_cleanup = gs100_cleanup,
.rig_close = gs100_close, .rig_open = gs100_open,
.set_conf = gs100_set_conf, .rig_close = gs100_close,
.get_conf = gs100_get_conf, .set_conf = gs100_set_conf,
.set_freq = gs100_set_freq, .get_conf = gs100_get_conf,
.get_freq = gs100_get_freq, .set_freq = gs100_set_freq,
.set_split_freq = gs100_set_tx_freq, .get_freq = gs100_get_freq,
.get_split_freq = gs100_get_tx_freq, .set_split_freq = gs100_set_tx_freq,
.get_info = gs100_get_info, .get_split_freq = gs100_get_tx_freq,
.get_info = gs100_get_info,
}; };
/* Private functions ---------------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/
@ -420,111 +443,132 @@ struct rig_caps GS100_caps =
/* Set variable in the GS100 configuration table */ /* Set variable in the GS100 configuration table */
static int gomx_set(RIG *rig, int table, char *varname, char *varvalue) 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
int retval; *)rig->state.priv;
char msg[BUFSZ], resp[BUFSZ]; int retval;
char msg[BUFSZ], resp[BUFSZ];
assert(rig != NULL); assert(rig != NULL);
assert(varname != NULL); assert(varname != NULL);
assert(varvalue != 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) if (!PARAM_MEM_MINIMAL || table != priv->param_mem)
{ {
// select the configuration table // select the configuration table
priv->param_mem = table; priv->param_mem = table;
sprintf(msg, "param mem %d\n", table); sprintf(msg, "param mem %d\n", table);
retval = gomx_transaction(rig, msg, resp);
if (retval != RIG_OK) { return (retval); }
}
// set the variable
sprintf(msg, "param set %s %s\n", varname, varvalue);
retval = gomx_transaction(rig, msg, resp); retval = gomx_transaction(rig, msg, resp);
if (retval != RIG_OK) return(retval);
}
// set the variable if (retval != RIG_OK) { return (retval); }
sprintf(msg, "param set %s %s\n", varname, varvalue);
retval = gomx_transaction(rig, msg, resp);
if (retval != RIG_OK) return(retval);
// check response // check response
if (strlen(resp) > 0) return(-RIG_EPROTO); if (strlen(resp) > 0) { return (-RIG_EPROTO); }
return(RIG_OK);
return (RIG_OK);
} }
/* Get variable from the GS100 configuration table */ /* Get variable from the GS100 configuration table */
static int gomx_get(RIG *rig, int table, char *varname, char *varvalue) 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
int retval; *)rig->state.priv;
char msg[BUFSZ], resp[BUFSZ], *c; int retval;
char msg[BUFSZ], resp[BUFSZ], *c;
assert(rig != NULL); assert(rig != NULL);
assert(varname != NULL); assert(varname != NULL);
assert(varvalue != NULL); assert(varvalue != NULL);
rig_debug(RIG_DEBUG_TRACE, "%s: table=%d, '%s'\n", __func__, table, varname); rig_debug(RIG_DEBUG_TRACE, "%s: table=%d, '%s'\n", __func__, table, varname);
if (!PARAM_MEM_MINIMAL || table != priv->param_mem) if (!PARAM_MEM_MINIMAL || table != priv->param_mem)
{ {
// select the configuration table // select the configuration table
priv->param_mem = table; priv->param_mem = table;
sprintf(msg, "param mem %d\n", table); sprintf(msg, "param mem %d\n", table);
retval = gomx_transaction(rig, msg, resp);
if (retval != RIG_OK) { return (retval); }
}
// get the variable
sprintf(msg, "param get %s\n", varname);
retval = gomx_transaction(rig, msg, resp); retval = gomx_transaction(rig, msg, resp);
if (retval != RIG_OK) return(retval);
}
// get the variable if (retval != RIG_OK) { return (retval); }
sprintf(msg, "param get %s\n", varname);
retval = gomx_transaction(rig, msg, resp);
if (retval != RIG_OK) return(retval);
// check response and extract the value // check response and extract the value
if ((c = strchr(resp, '=')) == NULL) return(-RIG_EPROTO); if ((c = strchr(resp, '=')) == NULL) { return (-RIG_EPROTO); }
if (sscanf(c + 1, "%s", varvalue) != 1) return(-RIG_EPROTO);
return(RIG_OK); if (sscanf(c + 1, "%s", varvalue) != 1) { return (-RIG_EPROTO); }
return (RIG_OK);
} }
/* Sends a message to the GS100 and parses response lines */ /* Sends a message to the GS100 and parses response lines */
static int gomx_transaction(RIG *rig, char *message, char *response) 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
struct rig_state *rs; *)rig->state.priv;
int retval, n = 0; struct rig_state *rs;
char buf[BUFSZ]; int retval, n = 0;
char buf[BUFSZ];
assert(rig != NULL); assert(rig != NULL);
assert(message != NULL); assert(message != NULL);
assert(response != 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 // access to private variables
rs = &rig->state; rs = &rig->state;
priv = (struct gs100_priv_data *)rs->priv; priv = (struct gs100_priv_data *)rs->priv;
// send message to the transceiver // send message to the transceiver
rig_flush(&rs->rigport); rig_flush(&rs->rigport);
retval = write_block(&rs->rigport, (uint8_t*)message, strlen(message)); retval = write_block(&rs->rigport, (uint8_t *)message, strlen(message));
if (retval != RIG_OK) return(retval);
while (1) if (retval != RIG_OK) { return (retval); }
{
// 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);
n++;
// prompt is always the last line
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);
}
// report the response while (1)
rig_debug(RIG_DEBUG_VERBOSE, "%s: returning response='%s'\n", __func__, response == NULL ? "NULL" : response); {
return(RIG_OK); // 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); }
n++;
// prompt is always the last line
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); }
}
// report the response
rig_debug(RIG_DEBUG_VERBOSE, "%s: returning response='%s'\n", __func__,
response == NULL ? "NULL" : response);
return (RIG_OK);
} }
/* System Integration Functions ----------------------------------------------*/ /* System Integration Functions ----------------------------------------------*/
@ -532,16 +576,16 @@ static int gomx_transaction(RIG *rig, char *message, char *response)
/* Init RIG backend function */ /* Init RIG backend function */
DECLARE_INITRIG_BACKEND(gomspace) DECLARE_INITRIG_BACKEND(gomspace)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s: _init called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s: _init called\n", __func__);
rig_register(&GS100_caps); rig_register(&GS100_caps);
return(RIG_OK); return (RIG_OK);
} }
/* Probe RIG backend function */ /* Probe RIG backend function */
DECLARE_PROBERIG_BACKEND(gomspace) DECLARE_PROBERIG_BACKEND(gomspace)
{ {
return(RIG_MODEL_GS100); return (RIG_MODEL_GS100);
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/

Wyświetl plik

@ -832,32 +832,33 @@ int kenwood_open(RIG *rig)
if (RIG_OK != err) 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; rig->state.rigport.retry = retry_save;
priv->fw_rev_uint = 100; priv->fw_rev_uint = 100;
} }
else else
{ {
/* store the data after the "FV" which should be a f/w version /* store the data after the "FV" which should be a f/w version
string of the form n.n e.g. 1.07 */ string of the form n.n e.g. 1.07 */
priv->fw_rev = &fw_version[2]; priv->fw_rev = &fw_version[2];
dot_pos = strchr(fw_version, '.'); dot_pos = strchr(fw_version, '.');
if (dot_pos) if (dot_pos)
{ {
priv->fw_rev_uint = atoi(&fw_version[2]) * 100 + atoi(dot_pos + 1); priv->fw_rev_uint = atoi(&fw_version[2]) * 100 + atoi(dot_pos + 1);
} }
else else
{ {
rig_debug(RIG_DEBUG_ERR, "%s: cannot get f/w version\n", __func__); rig_debug(RIG_DEBUG_ERR, "%s: cannot get f/w version\n", __func__);
rig->state.rigport.retry = retry_save; rig->state.rigport.retry = retry_save;
RETURNFUNC(-RIG_EPROTO); RETURNFUNC(-RIG_EPROTO);
} }
} }
rig_debug(RIG_DEBUG_TRACE, "%s: found f/w version %.1f\n", __func__, 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) if (!RIG_IS_XG3 && -RIG_ETIMEOUT == err)
@ -1049,8 +1050,8 @@ int kenwood_get_if(RIG *rig)
ENTERFUNC; ENTERFUNC;
RETURNFUNC (kenwood_safe_transaction(rig, "IF", priv->info, RETURNFUNC(kenwood_safe_transaction(rig, "IF", priv->info,
KENWOOD_MAX_BUF_LEN, caps->if_len)); KENWOOD_MAX_BUF_LEN, caps->if_len));
} }
@ -1106,6 +1107,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo)
break; break;
#if 0 // VFO_RX really should NOT be VFO_CURR as VFO_CURR could be either VFO #if 0 // VFO_RX really should NOT be VFO_CURR as VFO_CURR could be either VFO
case RIG_VFO_RX: case RIG_VFO_RX:
vfo_function = rig->state.rx_vfo == RIG_VFO_B ? '1' : '0'; vfo_function = rig->state.rx_vfo == RIG_VFO_B ? '1' : '0';
break; break;
@ -2259,7 +2261,8 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
c = 'A' + kmode - 10; 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) 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 (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) if (RIG_IS_TS950S || RIG_IS_TS950SDX)
{ {
data_cmd = "DT"; data_cmd = "DT";
} }
datamode = 1; datamode = 1;
} }
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s, curr_mode=%s, new_mode=%s, datamode=%d\n", rig_debug(RIG_DEBUG_VERBOSE,
__func__, rig_strvfo(vfo), rig_strrmode(priv->curr_mode), rig_strrmode(mode), datamode); "%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 // only change mode if needed
if (priv->curr_mode != mode) 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__); rig_debug(RIG_DEBUG_VERBOSE, "%s called.\n", __func__);
priv->fakefreq = 1; // turn this on by default priv->fakefreq = 1; // turn this on by default
/* FT757GX has a write-only serial port: don't try to read status data */ /* FT757GX has a write-only serial port: don't try to read status data */
if (rig->caps->rig_model == RIG_MODEL_FT757) 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[i] = all[my_rand(max)];
} }
key[32] = 0; key[32] = 0;
} }

Wyświetl plik

@ -1128,7 +1128,7 @@ int HAMLIB_API rig_token_foreach(RIG *rig,
return RIG_OK; return RIG_OK;
} }
} }
for (cfp = rig->caps->extlevels; cfp && cfp->name; cfp ++) for (cfp = rig->caps->extlevels; cfp && cfp->name; cfp ++)
{ {
if ((*cfunc)(cfp, data) == 0) if ((*cfunc)(cfp, data) == 0)

Wyświetl plik

@ -716,23 +716,28 @@ int HAMLIB_API rig_open(RIG *rig)
rs = &rig->state; rs = &rig->state;
rs->rigport.rig = rig; rs->rigport.rig = rig;
rs->rigport_deprecated.rig = rig; rs->rigport_deprecated.rig = rig;
// rigctl/rigctld may have deprecated values -- backwards compatility // rigctl/rigctld may have deprecated values -- backwards compatility
if (rs->rigport_deprecated.pathname[0] != 0) 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) if (rs->pttport_deprecated.type.ptt != RIG_PTT_NONE)
{ {
rs->pttport.type.ptt = rs->pttport_deprecated.type.ptt; rs->pttport.type.ptt = rs->pttport_deprecated.type.ptt;
} }
if (rs->dcdport_deprecated.type.dcd != RIG_DCD_NONE) if (rs->dcdport_deprecated.type.dcd != RIG_DCD_NONE)
{ {
rs->dcdport.type.dcd = rs->dcdport_deprecated.type.dcd; rs->dcdport.type.dcd = rs->dcdport_deprecated.type.dcd;
} }
if (rs->pttport_deprecated.pathname[0] != 0) if (rs->pttport_deprecated.pathname[0] != 0)
{ {
strcpy(rs->pttport.pathname, rs->pttport_deprecated.pathname); strcpy(rs->pttport.pathname, rs->pttport_deprecated.pathname);
} }
if (rs->dcdport_deprecated.pathname[0] != 0) if (rs->dcdport_deprecated.pathname[0] != 0)
{ {
strcpy(rs->dcdport.pathname, rs->dcdport_deprecated.pathname); 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)) if (CHECK_RIG_ARG(rig))
{ {
RETURNFUNC2 (-RIG_EINVAL); RETURNFUNC2(-RIG_EINVAL);
} }
ELAPSED1; ELAPSED1;
@ -1756,7 +1761,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (!freq) if (!freq)
{ {
rig_debug(RIG_DEBUG_TRACE, "%s: freq ptr invalid\n", __func__); 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__, 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) if (retcode != RIG_OK)
{ {
RETURNFUNC2 (retcode); RETURNFUNC2(retcode);
} }
if (ptt) 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) 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__, 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) if (!caps->set_vfo)
{ {
RETURNFUNC2 (-RIG_ENAVAIL); RETURNFUNC2(-RIG_ENAVAIL);
} }
TRACE; TRACE;
@ -1898,7 +1903,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
if (retcode != RIG_OK) if (retcode != RIG_OK)
{ {
RETURNFUNC2 (retcode); RETURNFUNC2(retcode);
} }
rig_cache_show(rig, __func__, __LINE__); rig_cache_show(rig, __func__, __LINE__);
@ -4057,7 +4062,7 @@ int HAMLIB_API rig_set_split_mode(RIG *rig,
if (tx_vfo & (RIG_VFO_CURR | RIG_VFO_TX)) if (tx_vfo & (RIG_VFO_CURR | RIG_VFO_TX))
{ {
rig_debug(RIG_DEBUG_WARN, "%s(%d): Unhandled TXVFO=%s, tx_mode=%s\n", __func__, rig_debug(RIG_DEBUG_WARN, "%s(%d): Unhandled TXVFO=%s, tx_mode=%s\n", __func__,
__LINE__, rig_strvfo(tx_vfo), rig_strrmode(tx_mode)); __LINE__, rig_strvfo(tx_vfo), rig_strrmode(tx_mode));
} }
// code below here should be dead code now -- but maybe we have VFO situatiuon we need to handle // code below here should be dead code now -- but maybe we have VFO situatiuon we need to handle
@ -7099,15 +7104,18 @@ void *async_data_handler(void *arg)
} }
#endif #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; int retval = -RIG_ENIMPL;
ENTERFUNC; ENTERFUNC;
if (rig->caps->password != NULL) if (rig->caps->password != NULL)
{ {
retval = rig->caps->password(rig,key1,key2); retval = rig->caps->password(rig, key1, key2);
//retval = RIG_OK; //retval = RIG_OK;
} }
RETURNFUNC(retval); RETURNFUNC(retval);
} }

Wyświetl plik

@ -312,7 +312,8 @@ int main(int argc, char *argv[])
if (amp_file) if (amp_file)
{ {
strncpy(my_amp->state.ampport.pathname, amp_file, HAMLIB_FILPATHLEN - 1); 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 */ /* 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 // chk_vfo is the one command we'll allow without a password
// since it's in the initial handshake // 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 (cmd_entry->arg1 != NULL)
{ {
if (strcmp(cmd_entry->arg1,"ChkVFO")==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, "VFO") == 0) { preCmd = 1; }
else if (strcmp(cmd_entry->arg1,"Password")==0) preCmd = 1; else if (strcmp(cmd_entry->arg1, "Password") == 0) { preCmd = 1; }
} }
if (use_password && !is_passwordOK && (cmd_entry->arg1 != NULL) && !preCmd) 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); rig_debug(RIG_DEBUG_ERR, "%s: need password=%s for cmd=%s\n", __func__,
return(-RIG_EPROTO); rigctld_password, cmd_entry->arg1);
return (-RIG_EPROTO);
} }
retcode = (*cmd_entry->rig_routine)(my_rig, retcode = (*cmd_entry->rig_routine)(my_rig,
fout, fout,
fin, fin,
@ -4929,19 +4934,21 @@ declare_proto_rig(pause)
return (RIG_OK); 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; int retval = -RIG_EINVAL;
//fprintf(fout, "password %s\n", password); //fprintf(fout, "password %s\n", password);
rig_debug(RIG_DEBUG_TRACE, "%s: %s == %s\n", __func__, key1, rigctld_password); rig_debug(RIG_DEBUG_TRACE, "%s: %s == %s\n", __func__, key1, rigctld_password);
is_passwordOK = 0; is_passwordOK = 0;
if (strcmp((char*)key1, rigctld_password) == 0)
{ if (strcmp((char *)key1, rigctld_password) == 0)
retval = RIG_OK; {
retval = RIG_OK;
is_passwordOK = 1; is_passwordOK = 1;
} }
return(retval); return (retval);
} }
/* 0x98 */ /* 0x98 */
@ -4951,14 +4958,15 @@ declare_proto_rig(password)
const char *passwd = arg1; const char *passwd = arg1;
ENTERFUNC; ENTERFUNC;
if (is_rigctld) if (is_rigctld)
{ {
retval = rigctld_password_check(rig, (unsigned char*)passwd, "key2"); retval = rigctld_password_check(rig, (unsigned char *)passwd, "key2");
} }
else else
{ {
retval = rig_password(rig, (unsigned char*) passwd, (unsigned char*)"key2"); retval = rig_password(rig, (unsigned char *) passwd, (unsigned char *)"key2");
//retval = RIG_OK; //retval = RIG_OK;
} }
if (retval == RIG_OK) if (retval == RIG_OK)

Wyświetl plik

@ -305,7 +305,7 @@ int main(int argc, char *argv[])
exit(0); exit(0);
case 'A': case 'A':
strncpy(rigctld_password, optarg, sizeof(rigctld_password)-1); strncpy(rigctld_password, optarg, sizeof(rigctld_password) - 1);
break; break;
case 'm': case 'm':
@ -679,13 +679,15 @@ int main(int argc, char *argv[])
if (ptt_file) if (ptt_file)
{ {
strncpy(my_rig->state.pttport.pathname, ptt_file, HAMLIB_FILPATHLEN - 1); 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) if (dcd_file)
{ {
strncpy(my_rig->state.dcdport.pathname, dcd_file, HAMLIB_FILPATHLEN - 1); 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 */ /* 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)); rig_debug(RIG_DEBUG_ERR, "calloc: %s\n", strerror(errno));
exit(1); 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 */ /* use select to allow for periodic checks for CTRL+C */
FD_ZERO(&set); FD_ZERO(&set);
@ -979,11 +982,12 @@ int main(int argc, char *argv[])
rig_debug(RIG_DEBUG_ERR, "%s: select() failed: %s\n", __func__, rig_debug(RIG_DEBUG_ERR, "%s: select() failed: %s\n", __func__,
strerror(errno_stored)); strerror(errno_stored));
if (ctrl_c) if (ctrl_c)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s: ctrl_c when retcode==-1\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s: ctrl_c when retcode==-1\n", __func__);
break; break;
} }
if (errno == EINTR) if (errno == EINTR)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s: ignoring interrupted system call\n", 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); while (retcode == 0 && !ctrl_c);
rig_debug(RIG_DEBUG_VERBOSE, "%s: while loop done\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s: while loop done\n", __func__);
#ifdef HAVE_PTHREAD #ifdef HAVE_PTHREAD
@ -1190,11 +1195,13 @@ void *handle_socket(void *arg)
if (rig_opened) // only do this if rig is open 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); handle_data_arg->vfo_mode, handle_data_arg->use_password);
retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0, retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0,
mutex_rigctld, 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); } 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[i] = all[my_rand(max)];
} }
key[32] = 0; key[32] = 0;
} }
@ -87,39 +88,39 @@ int main()
unsigned char ciphertext[1024]; unsigned char ciphertext[1024];
int ciphertext_length; int ciphertext_length;
int plaintext_length; int plaintext_length;
memset(ciphertext,0,sizeof(ciphertext)); memset(ciphertext, 0, sizeof(ciphertext));
rig_make_key(key1); rig_make_key(key1);
rig_make_key(key2); rig_make_key(key2);
printf("key1=%s\n", key1); printf("key1=%s\n", key1);
printf("key2=%s\n", key2); printf("key2=%s\n", key2);
ciphertext_length = AESStringCrypt((unsigned char *) key1, ciphertext_length = AESStringCrypt((unsigned char *) key1,
strlen(key1), strlen(key1),
(unsigned char *) key2, (unsigned char *) key2,
strlen(key2), strlen(key2),
(unsigned char *) ciphertext); (unsigned char *) ciphertext);
for (int i = 0; i < ciphertext_length; ++i) { printf("%02x", ciphertext[i]); } for (int i = 0; i < ciphertext_length; ++i) { printf("%02x", ciphertext[i]); }
printf("\n"); printf("\n");
if (ciphertext_length == AESSTRINGCRYPT_ERROR) if (ciphertext_length == AESSTRINGCRYPT_ERROR)
{ {
printf("Error encrypting the string\n"); printf("Error encrypting the string\n");
} }
printf("Ciphertext length: %d\n", ciphertext_length); printf("Ciphertext length: %d\n", ciphertext_length);
memset(plaintext, 0, sizeof(plaintext)); memset(plaintext, 0, sizeof(plaintext));
printf("Decrypting...\n"); printf("Decrypting...\n");
plaintext_length = AESStringDecrypt((unsigned char *) key1, plaintext_length = AESStringDecrypt((unsigned char *) key1,
strlen(key1), strlen(key1),
(unsigned char *) ciphertext, (unsigned char *) ciphertext,
ciphertext_length, ciphertext_length,
(unsigned char *) plaintext); (unsigned char *) plaintext);
if (plaintext_length == AESSTRINGCRYPT_ERROR) if (plaintext_length == AESSTRINGCRYPT_ERROR)
{ {
printf("Error decrypting the string\n"); printf("Error decrypting the string\n");
} }
printf("Decrypted plaintext length: %d, %s\n", plaintext_length, plaintext); printf("Decrypted plaintext length: %d, %s\n", plaintext_length, plaintext);
} }