Fix some cppcheck warnings

Fix declarations after statements
Remove some !rig checks...we either don't need them or need them everywhere with a new error code
If you pass a NULL rig you get what you deserve :-)
This commit is contained in:
Michael Black 2019-12-09 17:12:13 -06:00
parent 8e0ddf743c
commit fb73e5abd7
No known key found for this signature in database
GPG Key ID: 6599353EC683404D
71 changed files with 1306 additions and 1819 deletions

View File

@ -100,6 +100,7 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
int err;
int len = 0;
char responsebuf[KPABUFSZ];
int loop;
rig_debug(RIG_DEBUG_VERBOSE, "%s called, cmd=%s\n", __func__, cmd);
@ -109,12 +110,12 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
rs = &amp->state;
int loop = 3;
loop = 3;
do // wake up the amp by sending ; until we receive ;
{
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
char c = ';';
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
err = write_block(&rs->ampport, &c, 1);
if (err != RIG_OK) { return err; }
@ -132,8 +133,9 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
if (response) // if response expected get it
{
int len;
responsebuf[0] = 0;
int len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1);
len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1);
if (len < 0)
{
@ -151,13 +153,14 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len)
do
{
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
int len;
char c = ';';
rig_debug(RIG_DEBUG_VERBOSE, "%s waiting for ;\n", __func__);
err = write_block(&rs->ampport, &c, 1);
if (err != RIG_OK) { return err; }
int len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1);
len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1);
if (len < 0) { return len; }
}
@ -187,17 +190,19 @@ const char *kpa_get_info(AMP *amp)
int kpa_get_freq(AMP *amp, freq_t *freq)
{
char responsebuf[KPABUFSZ];
int retval;
unsigned long tfreq;
int nargs;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!amp) { return -RIG_EINVAL; }
int retval = kpa_transaction(amp, "^FR;", responsebuf, sizeof(responsebuf));
retval = kpa_transaction(amp, "^FR;", responsebuf, sizeof(responsebuf));
if (retval != RIG_OK) { return retval; }
unsigned long tfreq;
int nargs = sscanf(responsebuf, "^FR%lu", &tfreq);
nargs = sscanf(responsebuf, "^FR%lu", &tfreq);
if (nargs != 1)
{
@ -213,19 +218,21 @@ int kpa_get_freq(AMP *amp, freq_t *freq)
int kpa_set_freq(AMP *amp, freq_t freq)
{
char responsebuf[KPABUFSZ];
int retval;
unsigned long tfreq;
int nargs;
char cmd[KPABUFSZ];
rig_debug(RIG_DEBUG_VERBOSE, "%s called, freq=%"PRIfreq"\n", __func__, freq);
if (!amp) { return -RIG_EINVAL; }
char cmd[KPABUFSZ];
sprintf(cmd, "^FR%05ld;", (long)freq / 1000);
int retval = kpa_transaction(amp, cmd, NULL, 0);
retval = kpa_transaction(amp, cmd, NULL, 0);
if (retval != RIG_OK) { return retval; }
unsigned long tfreq;
int nargs = sscanf(responsebuf, "^FR%lu", &tfreq);
nargs = sscanf(responsebuf, "^FR%lu", &tfreq);
if (nargs != 1)
{
@ -249,6 +256,20 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
{
char responsebuf[KPABUFSZ];
char *cmd;
int retval;
int fault;
int i;
int nargs;
int antenna;
int pwrpeak;
int pwrref;
int pwrfwd;
int pwrinput;
float float_value = 0;
int int_value = 0, int_value2 = 0;
struct amp_state *rs = &amp->state;
struct kpa_priv_data *priv = amp->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -256,12 +277,12 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
// get the current antenna selected
cmd = "^AE;";
int retval = kpa_transaction(amp, cmd, responsebuf, sizeof(responsebuf));
retval = kpa_transaction(amp, cmd, responsebuf, sizeof(responsebuf));
if (retval != RIG_OK) { return retval; }
int antenna = 0;
int nargs = sscanf(responsebuf, "^AE%d", &antenna);
antenna = 0;
nargs = sscanf(responsebuf, "^AE%d", &antenna);
if (nargs != 1)
{
@ -312,10 +333,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
if (retval != RIG_OK) { return retval; }
float float_value = 0;
int int_value = 0, int_value2 = 0;
struct amp_state *rs = &amp->state;
switch (level)
{
case AMP_LEVEL_SWR:
@ -381,7 +398,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
case AMP_LEVEL_PWR_INPUT:
cmd = "^PWI;";
int pwrinput;
nargs = sscanf(responsebuf, "^SW%d", &pwrinput);
if (nargs != 1)
@ -398,7 +414,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
case AMP_LEVEL_PWR_FWD:
cmd = "^PWF;";
int pwrfwd;
nargs = sscanf(responsebuf, "^SW%d", &pwrfwd);
if (nargs != 1)
@ -415,7 +430,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
case AMP_LEVEL_PWR_REFLECTED:
cmd = "^PWR;";
int pwrref;
nargs = sscanf(responsebuf, "^SW%d", &pwrref);
if (nargs != 1)
@ -432,7 +446,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
case AMP_LEVEL_PWR_PEAK:
cmd = "^PWK;";
int pwrpeak;
nargs = sscanf(responsebuf, "^SW%d", &pwrpeak);
if (nargs != 1)
@ -449,7 +462,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
case AMP_LEVEL_FAULT:
cmd = "^SF;";
int fault;
nargs = sscanf(responsebuf, "^SW%d", &fault);
if (nargs != 1)
@ -459,8 +471,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
return -RIG_EPROTO;
}
int i;
for (i = 0; kpa_fault_list[i].errmsg != NULL; ++i)
{
if (kpa_fault_list[i].code == fault)
@ -471,7 +481,6 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
}
rig_debug(RIG_DEBUG_ERR, "%s unknown fault from %s\n", __func__, responsebuf);
struct kpa_priv_data *priv = amp->state.priv;
sprintf(priv->tmpbuf, "Unknown fault code=0x%02x", fault);
val->s = priv->tmpbuf;
return RIG_OK;
@ -490,6 +499,11 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val)
int kpa_get_powerstat(AMP *amp, powerstat_t *status)
{
char responsebuf[KPABUFSZ];
int retval;
int operate;
int ampon;
int nargs = sscanf(responsebuf, "^ON%d", &ampon);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -497,13 +511,10 @@ int kpa_get_powerstat(AMP *amp, powerstat_t *status)
if (!amp) { return -RIG_EINVAL; }
int retval = kpa_transaction(amp, "^ON;", responsebuf, sizeof(responsebuf));
retval = kpa_transaction(amp, "^ON;", responsebuf, sizeof(responsebuf));
if (retval != RIG_OK) { return retval; }
int ampon;
int nargs = sscanf(responsebuf, "^ON%d", &ampon);
if (nargs != 1)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s Error: ^ON response='%s'\n", __func__,
@ -527,7 +538,6 @@ int kpa_get_powerstat(AMP *amp, powerstat_t *status)
if (retval != RIG_OK) { return retval; }
int operate;
nargs = sscanf(responsebuf, "^ON%d", &operate);
if (nargs != 1)
@ -544,12 +554,13 @@ int kpa_get_powerstat(AMP *amp, powerstat_t *status)
int kpa_set_powerstat(AMP *amp, powerstat_t status)
{
int retval;
char *cmd = NULL;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!amp) { return -RIG_EINVAL; }
char *cmd = NULL;
switch (status)
{
case RIG_POWER_UNKNOWN: break;
@ -568,7 +579,7 @@ int kpa_set_powerstat(AMP *amp, powerstat_t status)
}
int retval = kpa_transaction(amp, cmd, NULL, 0);
retval = kpa_transaction(amp, cmd, NULL, 0);
if (retval != RIG_OK) { return retval; }
@ -577,10 +588,12 @@ int kpa_set_powerstat(AMP *amp, powerstat_t status)
int kpa_reset(AMP *amp, amp_reset_t reset)
{
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
// toggling from standby to operate supposed to reset
int retval = kpa_set_powerstat(amp, RIG_POWER_STANDBY);
retval = kpa_set_powerstat(amp, RIG_POWER_STANDBY);
if (retval != RIG_OK)
{

View File

@ -1143,6 +1143,7 @@ static int parse_chan_line(RIG *rig, channel_t *chan, char *basep,
/* mode and width */
if (mem_caps->mode && mem_caps->width)
{
int retval;
char *tag2p;
tagp = strstr(basep, "MD");
@ -1161,7 +1162,7 @@ static int parse_chan_line(RIG *rig, channel_t *chan, char *basep,
tag2p = tagp;
}
int retval = priv->parse_aor_mode(rig, tagp[2], tag2p[2], &chan->mode,
retval = priv->parse_aor_mode(rig, tagp[2], tag2p[2], &chan->mode,
&chan->width);
if (retval != RIG_OK)
@ -1254,6 +1255,8 @@ int aor_get_channel(RIG *rig, channel_t *chan)
}
else
{
int mem_num;
char bank_base;
/*
* find mem_caps in caps, we'll need it later
@ -1280,8 +1283,7 @@ int aor_get_channel(RIG *rig, channel_t *chan)
* MW should be called the first time instead,
* and sizing memorized.
*/
int mem_num = channel_num % 100;
char bank_base;
mem_num = channel_num % 100;
if (mem_num >= 50 && priv->bank_base1 != priv->bank_base2)
{
bank_base = priv->bank_base2;

View File

@ -402,6 +402,7 @@ int ar3030_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
char *rfp;
int freq_len, retval;
char freqbuf[BUFSZ];
long lfreq;
/*
* D Rn Gn Bn Tn Fnnnnnnnn C
@ -422,7 +423,6 @@ int ar3030_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
return -RIG_EPROTO;
}
long lfreq;
sscanf(rfp + 1, "%ld", &lfreq);
*freq = lfreq;
rig_debug(RIG_DEBUG_ERR, "%s: read lfreq=%ld, freq=%.6f\n", __func__, lfreq,

View File

@ -268,6 +268,8 @@ static int ar7030p_init(RIG *rig)
}
else
{
int i;
rig->state.priv = (void *) priv;
rig->state.rigport.type.rig = RIG_PORT_SERIAL;
@ -279,8 +281,6 @@ static int ar7030p_init(RIG *rig)
memset(priv->mem, 0, sizeof(priv->mem));
int i;
for (i = 0; i < NB_CHAN; i++)
{
priv->mem[ i ].channel_num = i;
@ -377,11 +377,11 @@ static int ar7030p_open(RIG *rig)
if (RIG_OK == rc)
{
int i;
/* Load calibration table */
rig->state.str_cal.size = rig->caps->str_cal.size;
int i;
for (i = 0; i < rig->state.str_cal.size; i++)
{
rc = readByte(rig, EEPROM1, SM_CAL + i, &v);
@ -603,11 +603,11 @@ static int ar7030p_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
}
else
{
int i;
/* TODO - get filter BWs at startup */
ar_filter = (unsigned char) 6;
int i;
for (i = 1; i <= 6; i++)
{
if (width <= filterTab[ i ])
@ -1632,6 +1632,8 @@ static int ar7030p_get_channel(RIG *rig, channel_t *chan)
if (RIG_OK == rc)
{
int i;
/* Squelch values */
/* TODO - fix magic numbers */
if (100 > ch)
@ -1704,8 +1706,6 @@ static int ar7030p_get_channel(RIG *rig, channel_t *chan)
/* Memory ID values */
p = (unsigned char *) chan->channel_desc;
int i;
for (i = 0; i < 14; i++)
{
if (176 > ch)

View File

@ -343,6 +343,7 @@ int sr2200_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
char freqbuf[BUFSZ], ackbuf[BUFSZ], *rfp;
int freq_len, ret_freq_len;
int retval;
ret_freq_len = BUFSZ;
@ -367,7 +368,7 @@ int sr2200_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
strcpy(freqbuf + freq_len, EOM);
freq_len += strlen(EOM);
int retval = sr2200_transaction(rig, freqbuf, freq_len, ackbuf, &ret_freq_len);
retval = sr2200_transaction(rig, freqbuf, freq_len, ackbuf, &ret_freq_len);
if (retval != RIG_OK)
{
@ -728,6 +729,7 @@ int sr2200_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
switch (level)
{
float tmp;
case RIG_LEVEL_STRENGTH:
if (ack_len < 7 || ackbuf[0] != 'L' || ackbuf[1] != 'B')
{
@ -802,7 +804,6 @@ int sr2200_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return -RIG_EPROTO;
}
float tmp;
sscanf(ackbuf + 2, "%f", &tmp);
if (tmp != 0.0)

View File

@ -221,11 +221,14 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
{
char cmd_buf[MAXCMDLEN];
int retval, cmd_len;
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s\n", __func__, cmd);
char *p;
char xon;
char xoff;
struct rig_state *rs = &rig->state;
struct barrett_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s\n", __func__, cmd);
cmd_len = snprintf(cmd_buf, sizeof(cmd_buf), "%s%s", cmd, EOM);
serial_flush(&rs->rigport);
@ -261,9 +264,9 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
rig_debug(RIG_DEBUG_VERBOSE, "%s: retval=%d\n", __func__, retval);
dump_hex((const unsigned char *)priv->ret_data, strlen(priv->ret_data));
char *p = priv->ret_data;
char xon = p[0];
char xoff = p[strlen(p) - 1];
p = priv->ret_data;
xon = p[0];
xoff = p[strlen(p) - 1];
if (xon == 0x13 && xoff == 0x11)
{
@ -288,6 +291,8 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
if (result != NULL)
{
int n = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s: setting result\n", __func__);
if (priv->ret_data[0] == 0x13) // we'll return from the 1st good char
@ -300,8 +305,6 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
}
// See how many CR's we have
int n = 0;
for (p = *result; *p; ++p)
{
if (*p == 0x0d)
@ -332,6 +335,7 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result)
int barrett_init(RIG *rig)
{
struct barrett_priv_data *priv = (struct barrett_priv_data *)calloc(1, sizeof(struct barrett_priv_data));
rig_debug(RIG_DEBUG_VERBOSE, "%s version %s\n", __func__,
rig->caps->version);
@ -340,7 +344,6 @@ int barrett_init(RIG *rig)
return -RIG_EINVAL;
}
struct barrett_priv_data *priv = (struct barrett_priv_data *)calloc(1, sizeof(struct barrett_priv_data));
if (!priv)
{
@ -386,12 +389,11 @@ int barrett_cleanup(RIG *rig)
int barrett_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
int retval;
char *response = NULL;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
*freq = 0;
char *response = NULL;
if (vfo == RIG_VFO_B) // We treat the TX VFO as VFO_B and RX VFO as VFO_A
{
retval = barrett_transaction(rig, "IT", 0, &response);
@ -435,8 +437,8 @@ int barrett_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// If we are not explicity asking for VFO_B then we'll set the receive side also
if (vfo != RIG_VFO_B)
{
sprintf((char *) cmd_buf, "TR%08.0f", freq);
char *response = NULL;
sprintf((char *) cmd_buf, "TR%08.0f", freq);
retval = barrett_transaction(rig, cmd_buf, 0, &response);
if (retval < 0)
@ -457,8 +459,8 @@ int barrett_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|| vfo == RIG_VFO_B) // if we aren't in split mode we have to set the TX VFO too
{
sprintf((char *) cmd_buf, "TT%08.0f", freq);
char *response = NULL;
sprintf((char *) cmd_buf, "TT%08.0f", freq);
retval = barrett_transaction(rig, cmd_buf, 0, &response);
if (retval < 0)
@ -485,6 +487,7 @@ int barrett_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
char cmd_buf[MAXCMDLEN];
char *response;
rig_debug(RIG_DEBUG_VERBOSE, "%s: ptt=%d\n", __func__, ptt);
@ -493,7 +496,7 @@ int barrett_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
// WSJT-X is just a little faster without the network timing
usleep(100 * 1000);
sprintf(cmd_buf, "XP%d", ptt);
char *response = NULL;
response = NULL;
retval = barrett_transaction(rig, cmd_buf, 0, &response);
if (retval < 0)
@ -522,6 +525,7 @@ int barrett_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
int retval;
char *response = NULL;
char c;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
@ -533,7 +537,7 @@ int barrett_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
return retval;
}
char c = response[0];
c = response[0];
if (c == '1' || c == '0')
{
@ -612,10 +616,12 @@ int barrett_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
*/
int barrett_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
char *result=NULL;
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
char *result = NULL;
int retval = barrett_transaction(rig, "IB", 0, &result);
retval = barrett_transaction(rig, "IB", 0, &result);
if (retval != RIG_OK)
{
@ -686,13 +692,14 @@ int barrett_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
{
// The 2050 only has one RX and one TX VFO -- it's not treated as VFOA/VFOB
char cmd_buf[MAXCMDLEN];
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s freq=%g\n", __func__,
rig_strvfo(vfo), tx_freq);
sprintf((char *) cmd_buf, "TT%08.0f" EOM, tx_freq);
int retval = barrett_transaction(rig, cmd_buf, 0, NULL);
retval = barrett_transaction(rig, cmd_buf, 0, NULL);
if (retval < 0)
{
@ -742,6 +749,8 @@ int barrett_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
switch (level)
{
int strength;
int n;
case RIG_LEVEL_STRENGTH:
retval = barrett_transaction(rig, "IAL", 0, &response);
@ -752,8 +761,7 @@ int barrett_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return retval;
}
int strength;
int n = sscanf(response, "%2d", &strength);
n = sscanf(response, "%2d", &strength);
if (n == 1)
{
@ -787,10 +795,11 @@ int barrett_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
const char *barrett_get_info(RIG *rig)
{
char *response = NULL;
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int retval = barrett_transaction(rig, "IVF", 0, &response);
retval = barrett_transaction(rig, "IVF", 0, &response);
if (retval == RIG_OK)
{

View File

@ -137,10 +137,10 @@ static int dra818_setvolume(RIG *rig)
int dra818_init(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: dra818_init called\n", __func__);
struct dra818_priv *priv = calloc(sizeof(*priv), 1);
rig_debug(RIG_DEBUG_VERBOSE, "%s: dra818_init called\n", __func__);
if (!priv)
{
return -RIG_ENOMEM;
@ -285,13 +285,14 @@ int dra818_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
{
struct dra818_priv *priv = rig->state.priv;
char cmd[80];
char response[8];
int r;
sprintf(cmd, "S+%03d.%04d\r\n",
(int)(priv->rx_freq / 1000000), (int)((priv->rx_freq % 1000000) / 100));
write_block(&rig->state.rigport, cmd, strlen(cmd));
char response[8];
int r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1);
r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1);
if (r != 5)
{

View File

@ -234,6 +234,9 @@ static int check_vfo(vfo_t vfo)
static char *xml_build(char *cmd, char *value, char *xmlbuf, int xmlbuflen)
{
char xml[4096]; // we shouldn't need more the 4096 bytes for this
char tmp[32];
char *header;
int n;
// We want at least a 4K buf to play with
if (xmlbuflen < 4096)
@ -242,10 +245,10 @@ static char *xml_build(char *cmd, char *value, char *xmlbuf, int xmlbuflen)
return NULL;
}
char *header =
header =
"POST /RPC2 HTTP/1.1\r\n" "User-Agent: XMLRPC++ 0.8\r\n"
"Host: 127.0.0.1:12345\r\n" "Content-type: text/xml\r\n";
int n = snprintf(xmlbuf, xmlbuflen, "%s", header);
n = snprintf(xmlbuf, xmlbuflen, "%s", header);
if (n != strlen(header))
{
@ -272,7 +275,6 @@ static char *xml_build(char *cmd, char *value, char *xmlbuf, int xmlbuflen)
strncat(xml, "</methodCall>\r\n", sizeof(xml) - 1);
strncat(xmlbuf, "Content-length: ", xmlbuflen - 1);
char tmp[32];
snprintf(tmp, sizeof(tmp), "%d\r\n\r\n", (int)strlen(xml));
strncat(xmlbuf, tmp, xmlbuflen - 1);
strncat(xmlbuf, xml, xmlbuflen - 1);
@ -347,6 +349,8 @@ static char *xml_parse2(char *xml, char *value, int valueLen)
*/
static char *xml_parse(char *xml, char *value, int value_len)
{
char *next;
char *pxml;
/* first off we should have an OK on the 1st line */
if (strstr(xml, " 200 OK") == NULL)
{
@ -356,14 +360,14 @@ static char *xml_parse(char *xml, char *value, int value_len)
rig_debug(RIG_DEBUG_TRACE, "%s XML:\n%s\n", __func__, xml);
// find the xml skipping the other stuff above it
char *pxml = strstr(xml, "<?xml");
pxml = strstr(xml, "<?xml");
if (pxml == NULL)
{
return NULL;
}
char *next = strchr(pxml + 1, '<');
next = strchr(pxml + 1, '<');
if (value != NULL)
{
@ -386,15 +390,17 @@ static char *xml_parse(char *xml, char *value, int value_len)
static int read_transaction(RIG *rig, char *xml, int xml_len)
{
int retval;
int retry;
char *delims;
char *terminator = "</methodResponse>";
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct rig_state *rs = &rig->state;
rs->rigport.timeout = 1000; // 2 second read string timeout
int retry = 5;
char *delims = "\n";
retry = 5;
delims = "\n";
xml[0] = 0;
do
@ -491,11 +497,10 @@ static int write_transaction(RIG *rig, char *xml, int xml_len)
*/
static int flrig_init(RIG *rig)
{
struct flrig_priv_data *priv = (struct flrig_priv_data *)malloc(sizeof(struct flrig_priv_data));
rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER);
struct flrig_priv_data *priv = (struct flrig_priv_data *)malloc(sizeof(
struct flrig_priv_data));
if (!priv)
{
@ -585,18 +590,21 @@ static rmode_t modeMapGetHamlib(const char *modeFLRig)
static void modeMapAdd(rmode_t *modes, rmode_t mode_hamlib, char *mode_flrig)
{
int i;
int len1;
rig_debug(RIG_DEBUG_TRACE, "%s:mode_flrig=%s\n", __func__, mode_flrig);
// if we already have it just return
// We get ERROR if the mode is not known so non-ERROR is OK
if (modeMapGetHamlib(mode_flrig) != RIG_MODE_NONE) { return; }
int len1 = strlen(mode_flrig) + 3; /* bytes needed for allocating */
len1 = strlen(mode_flrig) + 3; /* bytes needed for allocating */
for (i = 0; modeMap[i].mode_hamlib != 0; ++i)
{
if (modeMap[i].mode_hamlib == mode_hamlib)
{
int len2;
*modes |= modeMap[i].mode_hamlib;
/* we will pipe delimit all the entries for easier matching */
@ -613,7 +621,7 @@ static void modeMapAdd(rmode_t *modes, rmode_t mode_hamlib, char *mode_flrig)
}
}
int len2 = strlen(modeMap[i].mode_flrig); /* current len w/o null */
len2 = strlen(modeMap[i].mode_flrig); /* current len w/o null */
modeMap[i].mode_flrig = realloc(modeMap[i].mode_flrig,
strlen(modeMap[i].mode_flrig) + len1);
@ -636,13 +644,16 @@ static int flrig_open(RIG *rig)
{
int retval;
char xml[MAXXMLLEN];
char *pxml;
char value[MAXXMLLEN];
rmode_t modes;
char *p;
char *pr;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char *pxml = xml_build("rig.get_xcvr", NULL, xml, sizeof(xml));
pxml = xml_build("rig.get_xcvr", NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -727,9 +738,8 @@ static int flrig_open(RIG *rig)
read_transaction(rig, xml, sizeof(xml));
xml_parse(xml, value, sizeof(value));
rig_debug(RIG_DEBUG_TRACE, "%s: modes=%s\n", __func__, value);
rmode_t modes = 0;
char *p;
char *pr = value;
modes = 0;
pr = value;
/* The following modes in FLRig are not implemented yet
A1A
@ -877,10 +887,14 @@ static int flrig_cleanup(RIG *rig)
*/
static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
int retries = 10;
char xml[MAXXMLLEN];
char value[MAXCMDLEN];
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
@ -896,13 +910,10 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
__func__, rig_strvfo(vfo));
}
int retries = 10;
char xml[MAXXMLLEN];
char value[MAXCMDLEN];
do
{
char *pxml;
int retval;
if (vfo == RIG_VFO_A)
{
@ -913,7 +924,7 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
pxml = xml_build("rig.get_vfoB", NULL, xml, sizeof(xml));
}
int retval = write_transaction(rig, pxml, strlen(pxml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
{
@ -963,12 +974,14 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
static int flrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
int retval;
char value[MAXXMLLEN];
char xml[MAXXMLLEN];
char *pxml;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.0f\n", __func__,
rig_strvfo(vfo), freq);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -985,11 +998,8 @@ static int flrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
vfo = RIG_VFO_B; // if split always TX on VFOB
}
char value[MAXXMLLEN];
sprintf(value,
"<params><param><value><double>%.0f</double></value></param></params>", freq);
char xml[MAXXMLLEN];
char *pxml;
if (vfo == RIG_VFO_B)
{
@ -1032,10 +1042,13 @@ static int flrig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
static int flrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
char xml[MAXXMLLEN];
char *pxml;
char cmd_buf[MAXCMDLEN];
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: ptt=%d\n", __func__, ptt);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
@ -1044,12 +1057,10 @@ static int flrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
return -RIG_EINVAL;
}
char cmd_buf[MAXCMDLEN];
sprintf(cmd_buf,
"<params><param><value><i4>%d</i4></value></param></params>",
ptt);
char xml[MAXXMLLEN];
char *pxml = xml_build("rig.set_ptt", cmd_buf, xml, sizeof(xml));
pxml = xml_build("rig.set_ptt", cmd_buf, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1071,14 +1082,16 @@ static int flrig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
static int flrig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
int retval;
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
char *pxml;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char xml[MAXXMLLEN];
char *pxml = xml_build("rig.get_ptt", NULL, xml, sizeof(xml));
pxml = xml_build("rig.get_ptt", NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
@ -1088,7 +1101,6 @@ static int flrig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
}
read_transaction(rig, xml, sizeof(xml));
char value[MAXCMDLEN];
xml_parse(xml, value, sizeof(value));
*ptt = atoi(value);
rig_debug(RIG_DEBUG_TRACE, "%s: '%s'\n", __func__, value);
@ -1106,11 +1118,11 @@ static int flrig_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode,
pbwidth_t width)
{
int retval;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n",
__func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
switch (vfo)
{
case RIG_VFO_CURR:
@ -1147,11 +1159,19 @@ static int flrig_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode,
static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
int retval;
int needBW;
int vfoSwitched;
char xml[MAXXMLLEN];
char *pxml = NULL;
char cmd_buf[MAXCMDLEN];
char *p;
char *pttmode;
char *ttmode;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n",
__func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
// if ptt is on do not set mode
if (priv->ptt)
@ -1181,7 +1201,7 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
// Switch to VFOB if appropriate since we can't set mode directly
// MDB
int vfoSwitched = 0;
vfoSwitched = 0;
rig_debug(RIG_DEBUG_TRACE, "%s: curr_vfo = %s\n", __func__,
rig_strvfo(priv->curr_vfo));
@ -1206,22 +1226,20 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
}
// Set the mode
char *ttmode = strdup(modeMapGetFLRig(mode));
ttmode = strdup(modeMapGetFLRig(mode));
rig_debug(RIG_DEBUG_TRACE, "%s: got ttmode = %s\n", __func__,
ttmode == NULL ? "NULL" : ttmode);
char *pttmode = ttmode;
pttmode = ttmode;
if (ttmode[0] == '|') { pttmode = &ttmode[1]; } // remove first pipe symbol
char *p = strchr(pttmode, '|');
p = strchr(pttmode, '|');
if (p) { *p = 0; } // remove any other pipe
char cmd_buf[MAXCMDLEN];
sprintf(cmd_buf, "<params><param><value>%s</value></param></params>", pttmode);
free(ttmode);
char xml[MAXXMLLEN];
char *pxml = NULL;
pxml = NULL;
if (!priv->has_get_modeA)
{
@ -1253,7 +1271,7 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
rig_debug(RIG_DEBUG_TRACE, "%s: response=%s\n", __func__, xml);
// Determine if we need to update the bandwidth
int needBW = 0;
needBW = 0;
if (vfo == RIG_VFO_A)
{
@ -1336,12 +1354,17 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
int retval;
int vfoSwitched;
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
char *pxml;
char *cmdp;
vfo_t curr_vfo;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -1349,7 +1372,7 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
return -RIG_EINVAL;
}
vfo_t curr_vfo = priv->curr_vfo;
curr_vfo = priv->curr_vfo;
if (vfo == RIG_VFO_CURR)
{
@ -1369,7 +1392,7 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
}
// Switch to VFOB if appropriate
int vfoSwitched = 0;
vfoSwitched = 0;
if (priv->has_get_modeA == 0 && vfo == RIG_VFO_B && curr_vfo != RIG_VFO_B)
{
@ -1388,8 +1411,7 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
}
}
char xml[MAXXMLLEN];
char *cmdp = "rig.get_mode"; /* default to old way */
cmdp = "rig.get_mode"; /* default to old way */
if (priv->has_get_modeA) /* change to new way if we can */
{
@ -1402,7 +1424,7 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
if (vfo == RIG_VFO_B) { cmdp = "rig.get_modeB"; }
}
char *pxml = xml_build(cmdp, NULL, xml, sizeof(xml));
pxml = xml_build(cmdp, NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1411,7 +1433,6 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
}
read_transaction(rig, xml, sizeof(xml));
char value[MAXCMDLEN];
xml_parse(xml, value, sizeof(value));
retval = modeMapGetHamlib(value);
@ -1502,12 +1523,15 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
static int flrig_set_vfo(RIG *rig, vfo_t vfo)
{
int retval;
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
char *pxml;
struct rig_state *rs = &rig->state;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct rig_state *rs = &rig->state;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
@ -1527,11 +1551,9 @@ static int flrig_set_vfo(RIG *rig, vfo_t vfo)
vfo = priv->curr_vfo;
}
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
sprintf(value, "<params><param><value>%s</value></param></params>",
vfo == RIG_VFO_A ? "A" : "B");
char *pxml = xml_build("rig.set_AB", value, xml, sizeof(xml));
pxml = xml_build("rig.set_AB", value, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1570,13 +1592,15 @@ static int flrig_set_vfo(RIG *rig, vfo_t vfo)
static int flrig_get_vfo(RIG *rig, vfo_t *vfo)
{
int retval;
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
char *pxml;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char xml[MAXXMLLEN];
char *pxml = xml_build("rig.get_AB", NULL, xml, sizeof(xml));
pxml = xml_build("rig.get_AB", NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1585,7 +1609,6 @@ static int flrig_get_vfo(RIG *rig, vfo_t *vfo)
}
read_transaction(rig, xml, sizeof(xml));
char value[MAXCMDLEN];
xml_parse(xml, value, sizeof(value));
rig_debug(RIG_DEBUG_TRACE, "%s: vfo value=%s\n", __func__, value);
@ -1626,12 +1649,15 @@ static int flrig_get_vfo(RIG *rig, vfo_t *vfo)
static int flrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
{
int retval;
char xml[MAXXMLLEN];
char *pxml;
char value[MAXCMDLEN];
freq_t qtx_freq;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__,
rig_strvfo(vfo), tx_freq);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -1640,19 +1666,16 @@ static int flrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
}
// we always split on VFOB so if no change just return
freq_t qtx_freq;
retval = flrig_get_freq(rig, RIG_VFO_B, &qtx_freq);
if (retval != RIG_OK) { return retval; }
if (tx_freq == qtx_freq) { return RIG_OK; }
char xml[MAXXMLLEN];
char value[MAXCMDLEN];
sprintf(value,
"<params><param><value><double>%.6f</double></value></param></params>",
tx_freq);
char *pxml = xml_build("rig.set_vfoB", value, xml, sizeof(xml));
pxml = xml_build("rig.set_vfoB", value, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1673,12 +1696,13 @@ static int flrig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
*/
static int flrig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
{
int retval;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
int retval = flrig_get_freq(rig, RIG_VFO_B, tx_freq);
retval = flrig_get_freq(rig, RIG_VFO_B, tx_freq);
priv->curr_freqB = *tx_freq;
return retval;
}
@ -1690,19 +1714,22 @@ static int flrig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
static int flrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
{
int retval;
vfo_t qtx_vfo;
split_t qsplit;
char xml[MAXXMLLEN];
char value[MAXCMDLEN];
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char *pxml;
rig_debug(RIG_DEBUG_TRACE, "%s: tx_vfo=%s\n", __func__,
rig_strvfo(tx_vfo));
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (tx_vfo == RIG_VFO_SUB || tx_vfo == RIG_VFO_TX)
{
tx_vfo = RIG_VFO_B;
}
vfo_t qtx_vfo;
split_t qsplit;
retval = flrig_get_split_vfo(rig, RIG_VFO_A, &qsplit, &qtx_vfo);
if (retval != RIG_OK) { return retval; }
@ -1715,11 +1742,9 @@ static int flrig_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo)
return RIG_OK; // just return OK and ignore this
}
char xml[MAXXMLLEN];
char value[MAXCMDLEN];
sprintf(value, "<params><param><value><i4>%d</i4></value></param></params>",
split);
char *pxml = xml_build("rig.set_split", value, xml, sizeof(xml));
pxml = xml_build("rig.set_split", value, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1742,12 +1767,14 @@ static int flrig_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
vfo_t *tx_vfo)
{
int retval;
char value[MAXCMDLEN];
char xml[MAXXMLLEN];
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char *pxml;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
char xml[MAXXMLLEN];
char *pxml = xml_build("rig.get_split", NULL, xml, sizeof(xml));
pxml = xml_build("rig.get_split", NULL, xml, sizeof(xml));
retval = write_transaction(rig, pxml, strlen(pxml));
if (retval < 0)
@ -1755,7 +1782,6 @@ static int flrig_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
return retval;
}
char value[MAXCMDLEN];
read_transaction(rig, xml, sizeof(xml));
xml_parse(xml, value, sizeof(value));
@ -1775,10 +1801,12 @@ static int flrig_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
rmode_t mode, pbwidth_t width)
{
int retval;
rmode_t qmode;
pbwidth_t qwidth;
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct flrig_priv_data *priv = (struct flrig_priv_data *) rig->state.priv;
if (vfo != RIG_VFO_CURR && vfo != RIG_VFO_TX)
{
@ -1800,8 +1828,6 @@ static int flrig_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
}
// Make VFOB mode match VFOA mode, keep VFOB width
rmode_t qmode;
pbwidth_t qwidth;
retval = flrig_get_mode(rig, RIG_VFO_B, &qmode, &qwidth);
if (retval != RIG_OK) { return retval; }

View File

@ -106,6 +106,8 @@ static int netrigctl_transaction(RIG *rig, char *cmd, int len, char *buf)
*/
static int netrigctl_vfostr(RIG *rig, char *vfostr, int len, vfo_t vfo)
{
struct netrigctl_priv_data *priv;
if (len < 5)
{
rig_debug(RIG_DEBUG_ERR, "%s: len must be >=5, len=%d\n", __func__, len);
@ -114,7 +116,6 @@ static int netrigctl_vfostr(RIG *rig, char *vfostr, int len, vfo_t vfo)
vfostr[0] = 0;
struct netrigctl_priv_data *priv;
priv = (struct netrigctl_priv_data *)rig->state.priv;
if (vfo == RIG_VFO_CURR)
@ -132,13 +133,14 @@ static int netrigctl_vfostr(RIG *rig, char *vfostr, int len, vfo_t vfo)
static int netrigctl_init(RIG *rig)
{
struct netrigctl_priv_data *priv = (struct netrigctl_priv_data *)malloc(sizeof(
struct netrigctl_priv_data));
if (!rig || !rig->caps)
{
return -RIG_EINVAL;
}
struct netrigctl_priv_data *priv = (struct netrigctl_priv_data *)malloc(sizeof(
struct netrigctl_priv_data));
if (!priv)
@ -177,11 +179,11 @@ static int netrigctl_open(RIG *rig)
int prot_ver;
char cmd[CMD_MAX];
char buf[BUF_MAX];
struct netrigctl_priv_data *priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct netrigctl_priv_data *priv;
priv = (struct netrigctl_priv_data *)rig->state.priv;
len = sprintf(cmd, "\\chk_vfo\n");
@ -519,10 +521,10 @@ static int netrigctl_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -546,10 +548,10 @@ static int netrigctl_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -575,10 +577,10 @@ static int netrigctl_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -605,10 +607,10 @@ static int netrigctl_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -644,10 +646,10 @@ static int netrigctl_set_vfo(RIG *rig, vfo_t vfo)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -672,13 +674,13 @@ static int netrigctl_get_vfo(RIG *rig, vfo_t *vfo)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
struct netrigctl_priv_data *priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct netrigctl_priv_data *priv;
priv = (struct netrigctl_priv_data *)rig->state.priv;
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -709,10 +711,10 @@ static int netrigctl_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -737,10 +739,10 @@ static int netrigctl_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -764,10 +766,10 @@ static int netrigctl_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -793,10 +795,10 @@ static int netrigctl_set_rptr_shift(RIG *rig, vfo_t vfo,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -822,10 +824,10 @@ static int netrigctl_get_rptr_shift(RIG *rig, vfo_t vfo,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -852,10 +854,10 @@ static int netrigctl_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -880,10 +882,10 @@ static int netrigctl_get_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t *rptr_offs)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -908,10 +910,10 @@ static int netrigctl_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -936,10 +938,10 @@ static int netrigctl_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -964,10 +966,10 @@ static int netrigctl_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -992,10 +994,10 @@ static int netrigctl_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1020,10 +1022,10 @@ static int netrigctl_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1048,10 +1050,10 @@ static int netrigctl_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1076,10 +1078,10 @@ static int netrigctl_set_dcs_sql(RIG *rig, vfo_t vfo, unsigned int code)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1103,10 +1105,10 @@ static int netrigctl_get_dcs_sql(RIG *rig, vfo_t vfo, unsigned int *code)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1131,10 +1133,10 @@ static int netrigctl_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1159,10 +1161,10 @@ static int netrigctl_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1187,10 +1189,10 @@ static int netrigctl_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1216,10 +1218,10 @@ static int netrigctl_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1255,10 +1257,10 @@ static int netrigctl_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1284,10 +1286,10 @@ static int netrigctl_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1323,10 +1325,10 @@ static int netrigctl_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1351,10 +1353,10 @@ static int netrigctl_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1379,10 +1381,10 @@ static int netrigctl_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1407,10 +1409,10 @@ static int netrigctl_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1435,10 +1437,10 @@ static int netrigctl_set_ts(RIG *rig, vfo_t vfo, shortfreq_t ts)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1463,10 +1465,10 @@ static int netrigctl_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A);
if (ret != RIG_OK) { return ret; }
@ -1491,10 +1493,10 @@ static int netrigctl_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1519,10 +1521,10 @@ static int netrigctl_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1549,6 +1551,7 @@ static int netrigctl_set_level(RIG *rig, vfo_t vfo, setting_t level,
char cmd[CMD_MAX];
char buf[BUF_MAX];
char lstr[32];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -1561,7 +1564,6 @@ static int netrigctl_set_level(RIG *rig, vfo_t vfo, setting_t level,
sprintf(lstr, "%d", val.i);
}
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1589,10 +1591,10 @@ static int netrigctl_get_level(RIG *rig, vfo_t vfo, setting_t level,
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1733,10 +1735,10 @@ static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1761,10 +1763,10 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t *ant)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1812,10 +1814,10 @@ static int netrigctl_set_mem(RIG *rig, vfo_t vfo, int ch)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }
@ -1840,10 +1842,10 @@ static int netrigctl_get_mem(RIG *rig, vfo_t vfo, int *ch)
int ret, len;
char cmd[CMD_MAX];
char buf[BUF_MAX];
char vfostr[6] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char vfostr[6] = "";
ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo);
if (ret != RIG_OK) { return ret; }

View File

@ -236,13 +236,14 @@ static int vfo_curr(RIG *rig, vfo_t vfo)
*/
static int read_transaction(RIG *rig, char *response, int response_len)
{
struct rig_state *rs = &rig->state;
char *delims = "\n";
int len;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct rig_state *rs = &rig->state;
char *delims = "\n";
int len = read_string(&rs->rigport, response, response_len, delims,
strlen(delims));
len = read_string(&rs->rigport, response, response_len, delims,
strlen(delims));
if (len <= 0)
{
@ -259,12 +260,11 @@ static int read_transaction(RIG *rig, char *response, int response_len)
*/
static int trxmanager_init(RIG *rig)
{
rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER);
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)malloc(
sizeof(struct trxmanager_priv_data));
rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER);
if (!priv)
{
return -RIG_ENOMEM;
@ -297,14 +297,14 @@ static int trxmanager_init(RIG *rig)
static int trxmanager_open(RIG *rig)
{
int retval;
char *cmd;
char response[MAXCMDLEN] = "";
rig_debug(RIG_DEBUG_VERBOSE, "%s version %s\n", __func__, BACKEND_VER);
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s version %s\n", __func__, BACKEND_VER);
rs->rigport.timeout = 10000; // long timeout for antenna switching/tuning
retval = read_transaction(rig, response, sizeof(response));
@ -325,7 +325,7 @@ static int trxmanager_open(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s connected to %s\n", __func__, priv->info);
// Turn off active messages
char *cmd = "AI0;";
cmd = "AI0;";
retval = write_block(&rs->rigport, cmd, strlen(cmd));
if (retval < 0)
@ -404,14 +404,17 @@ static int trxmanager_cleanup(RIG *rig)
static int trxmanager_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
int n;
char vfoab;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -432,9 +435,7 @@ static int trxmanager_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
__func__, rig_strvfo(vfo));
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
char vfoab = vfo == RIG_VFO_A ? 'R' : 'T';
vfoab = vfo == RIG_VFO_A ? 'R' : 'T';
snprintf(cmd, sizeof(cmd), "X%c;", vfoab);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -451,7 +452,7 @@ static int trxmanager_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
}
*freq = 0;
int n = sscanf(&response[2], "%lg", freq);
n = sscanf(&response[2], "%lg", freq);
if (n != 1)
{
@ -474,14 +475,17 @@ static int trxmanager_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
static int trxmanager_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__,
rig_strvfo(vfo), freq);
char vfoab;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__,
rig_strvfo(vfo), freq);
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -501,9 +505,7 @@ static int trxmanager_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
vfo = RIG_VFO_B; // if split always TX on VFOB
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
char vfoab = vfo == RIG_VFO_A ? 'A' : 'B';
vfoab = vfo == RIG_VFO_A ? 'A' : 'B';
snprintf(cmd, sizeof(cmd), "F%c%011lu;", vfoab, (unsigned long)freq);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -530,11 +532,12 @@ static int trxmanager_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
static int trxmanager_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: ptt=%d\n", __func__, ptt);
struct rig_state *rs = &rig->state;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -542,9 +545,6 @@ static int trxmanager_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
return -RIG_EINVAL;
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "%s;", ptt == 1 ? "TX" : "RX");
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -576,14 +576,14 @@ static int trxmanager_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
static int trxmanager_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
int retval;
char cptt;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
struct rig_state *rs = &rig->state;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "IF;");
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -607,7 +607,7 @@ static int trxmanager_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
rig_debug(RIG_DEBUG_VERBOSE, "%s: IF response len=%d\n", __func__,
(int)strlen(response));
char cptt = response[28];
cptt = response[28];
*ptt = cptt == '0' ? 0 : 1;
return RIG_OK;
@ -635,12 +635,14 @@ static int trxmanager_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
pbwidth_t width)
{
int retval;
char ttmode;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n",
__func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width);
struct rig_state *rs = &rig->state;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -648,7 +650,7 @@ static int trxmanager_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
return -RIG_EINVAL;
}
char ttmode = FLRIG_MODE_USB;
ttmode = FLRIG_MODE_USB;
switch (mode)
{
@ -707,8 +709,6 @@ static int trxmanager_set_mode(RIG *rig, vfo_t vfo, rmode_t mode,
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "MD%c;", ttmode);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -740,14 +740,18 @@ static int trxmanager_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
pbwidth_t *width)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
int n;
long iwidth = 0;
char tmode;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -768,8 +772,6 @@ static int trxmanager_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
rig_debug(RIG_DEBUG_TRACE, "%s: using vfo=%s\n", __func__,
rig_strvfo(vfo));
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "MD;");
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -785,8 +787,7 @@ static int trxmanager_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
rig_debug(RIG_DEBUG_ERR, "%s read_transaction failed\n", __func__);
}
char tmode;
int n = sscanf(response, "MD%c;", &tmode);
n = sscanf(response, "MD%c;", &tmode);
if (n != 1 || strlen(response) != 6)
{
@ -865,7 +866,6 @@ static int trxmanager_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
return -RIG_EPROTO;
}
long iwidth = 0;
n = sscanf(response, "BW%ld;", &iwidth);
if (n != 1)
@ -883,14 +883,16 @@ static int trxmanager_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode,
static int trxmanager_set_vfo(RIG *rig, vfo_t vfo)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -909,8 +911,6 @@ static int trxmanager_set_vfo(RIG *rig, vfo_t vfo)
vfo = priv->vfo_curr;
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "FN%d;", vfo == RIG_VFO_A ? 0 : 1);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -936,13 +936,14 @@ static int trxmanager_get_vfo(RIG *rig, vfo_t *vfo)
// TRXManager does not swap vfos
// So we maintain our own internal state during set_vfo
// This keeps the hamlib interface consistent with other rigs
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
char vfoab;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
char vfoab = priv->vfo_curr;
vfoab = priv->vfo_curr;
switch (vfoab)
{
@ -981,12 +982,13 @@ static int trxmanager_get_vfo(RIG *rig, vfo_t *vfo)
static int trxmanager_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
{
int retval;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__,
rig_strvfo(vfo), tx_freq);
struct rig_state *rs = &rig->state;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n",
@ -994,8 +996,6 @@ static int trxmanager_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
return -RIG_EINVAL;
}
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "XT%011lu;", (unsigned long) tx_freq);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -1021,9 +1021,10 @@ static int trxmanager_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq)
*/
static int trxmanager_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__,
rig_strvfo(vfo));
int retval = trxmanager_get_freq(rig, RIG_VFO_B, tx_freq);
retval = trxmanager_get_freq(rig, RIG_VFO_B, tx_freq);
return retval;
}
@ -1035,12 +1036,15 @@ static int trxmanager_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
vfo_t tx_vfo)
{
int retval;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
split_t tsplit;
vfo_t ttx_vfo;
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: tx_vfo=%s\n", __func__,
rig_strvfo(tx_vfo));
struct rig_state *rs = &rig->state;
if (tx_vfo == RIG_VFO_SUB || tx_vfo == RIG_VFO_TX)
{
tx_vfo = RIG_VFO_B;
@ -1056,8 +1060,6 @@ static int trxmanager_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
}
#endif
split_t tsplit;
vfo_t ttx_vfo;
retval = trxmanager_get_split_vfo(rig, vfo, &tsplit, &ttx_vfo);
if (retval < 0)
@ -1067,8 +1069,6 @@ static int trxmanager_set_split_vfo(RIG *rig, vfo_t vfo, split_t split,
if (tsplit == split) { return RIG_OK; } // don't need to change it
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "SP%c;", split ? '1' : '0');
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -1102,14 +1102,15 @@ static int trxmanager_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
vfo_t *tx_vfo)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
int tsplit = 0;
int n;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
snprintf(cmd, sizeof(cmd), "SP;");
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -1127,8 +1128,7 @@ static int trxmanager_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split,
}
*tx_vfo = RIG_VFO_B;
int tsplit = 0;
int n = sscanf(response, "SP%d", &tsplit);
n = sscanf(response, "SP%d", &tsplit);
if (n == 0)
{
@ -1149,13 +1149,14 @@ static int trxmanager_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
rmode_t mode, pbwidth_t width)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
struct rig_state *rs = &rig->state;
struct trxmanager_priv_data *priv = (struct trxmanager_priv_data *)
rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
if (vfo != RIG_VFO_CURR && vfo != RIG_VFO_TX)
{
return -RIG_ENTARGET;
@ -1163,8 +1164,6 @@ static int trxmanager_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
// assume split is on B
//
char cmd[MAXCMDLEN];
char response[MAXCMDLEN] = "";
snprintf(cmd, sizeof(cmd), "XT%011lu;", (unsigned long)freq);
retval = write_block(&rs->rigport, cmd, strlen(cmd));
@ -1182,8 +1181,9 @@ static int trxmanager_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq,
if (strlen(response) != 16 || strstr(response, cmd) == NULL)
{
FILE *fp;
rig_debug(RIG_DEBUG_ERR, "%s invalid response='%s'\n", __func__, response);
FILE *fp = fopen("debug.txt", "w+");
fp = fopen("debug.txt", "w+");
fprintf(fp, "XT response=%s\n", response);
fclose(fp);
return -RIG_EPROTO;

File diff suppressed because it is too large Load Diff

View File

@ -49,6 +49,7 @@ elad_fdm_duo_get_info(RIG *rig)
{
char firmbuf[50];
int retval;
size_t firm_len;
retval = elad_transaction(rig, "TY", firmbuf, sizeof(firmbuf));
@ -57,7 +58,7 @@ elad_fdm_duo_get_info(RIG *rig)
return NULL;
}
size_t firm_len = strlen(firmbuf);
firm_len = strlen(firmbuf);
if (firm_len != 5)
{

View File

@ -245,6 +245,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
char cmdbuf[BUFSZ + 1];
char respbuf[BUFSZ + 1];
char *p;
char *strip;
int cmd_len = 0;
unsigned csum = 0;
@ -321,7 +322,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
}
/* strip from *checksum and after */
char *strip = strrchr(respbuf, '*');
strip = strrchr(respbuf, '*');
if (strip)
{
@ -572,9 +573,11 @@ int icmarine_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
*/
int icmarine_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s:\n", __func__);
int retval = icmarine_transaction(rig, CMD_PTT,
retval = icmarine_transaction(rig, CMD_PTT,
ptt == RIG_PTT_ON ? "TX" : "RX", NULL);
if (retval != RIG_OK)

View File

@ -502,6 +502,9 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
if (level != RIG_LEVEL_AF)
{
int lvl_cn, lvl_sc; /* Command Number, Subcommand */
unsigned char lvlbuf[MAXFRAMELEN];
int cmdhead;
switch (level)
{
case RIG_LEVEL_RAWSTR:
@ -514,7 +517,6 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
return -RIG_EINVAL;
}
unsigned char lvlbuf[MAXFRAMELEN];
retval = icom_transaction(rig, lvl_cn, lvl_sc, NULL, 0,
lvlbuf, &lvl_len);
@ -526,7 +528,7 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
/*
* strbuf should contain Cn,Sc,Data area
*/
int cmdhead = (lvl_sc == -1) ? 1 : 2;
cmdhead = (lvl_sc == -1) ? 1 : 2;
lvl_len -= cmdhead;
if (lvlbuf[0] != ACK && lvlbuf[0] != lvl_cn)

View File

@ -275,9 +275,9 @@ ioptron_get_info(ROT *rot)
{
static char info[16];
char str[6];
int retval;
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
int retval;
retval = ioptron_transaction(rot, ":MountInfo#", str, sizeof(str));

View File

@ -1404,9 +1404,11 @@ int jrc_set_chan(RIG *rig, const channel_t *chan)
struct jrc_priv_caps *priv = (struct jrc_priv_caps *)rig->caps->priv;
char cmdbuf[BUFSZ];
int retval, cmd_len;
rmode_t mode;
pbwidth_t width;
channel_t current;
/* read first to get current values */
channel_t current;
current.channel_num = chan->channel_num;
if ((retval = jrc_get_chan(rig, &current)) != RIG_OK) { return retval; }
@ -1418,8 +1420,8 @@ int jrc_set_chan(RIG *rig, const channel_t *chan)
cmdbuf[4] = '1';
}
rmode_t mode = chan->mode;
pbwidth_t width = chan->width;
mode = chan->mode;
width = chan->width;
if (RIG_MODE_NONE == mode) { mode = current.mode; }
@ -1512,6 +1514,8 @@ int jrc_get_chan(RIG *rig, channel_t *chan)
if (mem_len != 6)
{
char freqbuf[BUFSZ];
if (membuf[4] == '1')
{
chan->levels[rig_setting2idx(RIG_LEVEL_ATT)].i = 20;
@ -1520,7 +1524,6 @@ int jrc_get_chan(RIG *rig, channel_t *chan)
jrc2rig_mode(rig, membuf[6], membuf[5],
&chan->mode, &chan->width);
char freqbuf[BUFSZ];
strncpy(freqbuf, membuf + 7, priv->max_freq_len);
freqbuf[priv->max_freq_len] = 0x00;
chan->freq = strtol(freqbuf, NULL, 10);

View File

@ -93,11 +93,13 @@ int elecraft_get_firmware_revision_level(RIG *rig, const char *cmd,
int elecraft_open(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called, rig version=%s\n", __func__,
rig->caps->version);
int err;
char id[KENWOOD_MAX_BUF_LEN];
struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called, rig version=%s\n", __func__,
rig->caps->version);
/* Actual read extension levels from radio.
*
@ -106,8 +108,6 @@ int elecraft_open(RIG *rig)
* elecraft_get_extension_level() private function during elecraft_open()
* and thereafter shall be treated as READ ONLY!
*/
struct kenwood_priv_data *priv = rig->state.priv;
/* As k3_fw_rev is declared static, it is persistent so the structure
* can point to it. This way was chosen to allow the compiler to
* calculate the size of the array to resolve a bug found by gcc 4.8.x
@ -245,16 +245,16 @@ int elecraft_open(RIG *rig)
int verify_kenwood_id(RIG *rig, char *id)
{
int err;
char *idptr;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !id)
if (!id)
{
return -RIG_EINVAL;
}
int err;
char *idptr;
/* Check for an Elecraft K2|K3 which returns "017" */
err = kenwood_get_id(rig, id);
@ -297,17 +297,17 @@ int verify_kenwood_id(RIG *rig, char *id)
int elecraft_get_extension_level(RIG *rig, const char *cmd, int *ext_level)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !ext_level)
{
return -RIG_EINVAL;
}
int err, i;
char buf[KENWOOD_MAX_BUF_LEN];
char *bufptr;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!ext_level)
{
return -RIG_EINVAL;
}
err = kenwood_safe_transaction(rig, cmd, buf, KENWOOD_MAX_BUF_LEN, 3);
if (err != RIG_OK)
@ -342,17 +342,17 @@ int elecraft_get_extension_level(RIG *rig, const char *cmd, int *ext_level)
int elecraft_get_firmware_revision_level(RIG *rig, const char *cmd,
char *fw_rev, size_t fw_rev_sz)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !fw_rev)
{
return -RIG_EINVAL;
}
int err;
char *bufptr;
char buf[KENWOOD_MAX_BUF_LEN];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!fw_rev)
{
return -RIG_EINVAL;
}
/* Get the actual firmware revision number. */
err = kenwood_transaction(rig, cmd, buf, sizeof(buf));

View File

@ -34,16 +34,16 @@
int verify_flexradio_id(RIG *rig, char *id)
{
int err;
char *idptr;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !id)
if (!id)
{
return -RIG_EINVAL;
}
int err;
char *idptr;
/* Check for a Flex 6700 which returns "904" */
err = kenwood_get_id(rig, id);
@ -110,19 +110,12 @@ int verify_flexradio_id(RIG *rig, char *id)
int flexradio_open(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
struct kenwood_priv_data *priv = rig->state.priv;
int err;
char id[FLEXRADIO_MAX_BUF_LEN];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
//struct flexradio_priv_data *priv = rig->state.priv;
/* Use check for "ID017;" to verify rig is reachable */

View File

@ -94,21 +94,18 @@ static int dsp_bw_dig[DSP_BW_NUM] =
static int flex6k_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char modebuf[10];
int index;
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !mode || !width)
if (!mode || !width)
{
return -RIG_EINVAL;
}
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char modebuf[10];
int index;
int retval;
retval = kenwood_safe_transaction(rig, "MD", modebuf, 6, 3);
if (retval != RIG_OK)
@ -243,23 +240,14 @@ static int flex6k_find_width(rmode_t mode, pbwidth_t width, int *ridx)
static int flex6k_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char buf[10];
char kmode;
int idx;
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
kmode = rmode2kenwood(mode, caps->mode_table);
if (kmode < 0)

View File

@ -256,16 +256,11 @@ const struct rig_caps k2_caps =
*/
int k2_open(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = elecraft_open(rig);
if (err != RIG_OK)
@ -292,12 +287,6 @@ int k2_open(RIG *rig)
int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
char f;
@ -305,6 +294,8 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
struct kenwood_priv_data *priv = rig->state.priv;
shortfreq_t freq = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
/* Select the filter array per mode. */
switch (mode)
{
@ -391,6 +382,8 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (width != RIG_PASSBAND_NOCHANGE)
{
char fcmd[16];
err = kenwood_transaction(rig, "K22", NULL, 0);
if (err != RIG_OK)
@ -399,7 +392,6 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
}
/* Construct the filter command and set the radio mode and width*/
char fcmd[16];
snprintf(fcmd, 8, "FW0000%c", f);
/* Set the filter slot */
@ -430,19 +422,19 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
int k2_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !mode || !width)
{
return -RIG_EINVAL;
}
int err;
char buf[KENWOOD_MAX_BUF_LEN];
char tmp[16];
char *bufptr;
pbwidth_t temp_w;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!mode || !width)
{
return -RIG_EINVAL;
}
err = kenwood_get_mode(rig, vfo, mode, &temp_w);
if (err != RIG_OK)
@ -496,17 +488,17 @@ int k2_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
*/
int k2_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !val)
{
return -RIG_EINVAL;
}
char buf[KENWOOD_MAX_BUF_LEN];
int err;
const struct confparams *cfp;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!val)
{
return -RIG_EINVAL;
}
cfp = rig_ext_lookup_tok(rig, token);
switch (token)
@ -549,19 +541,19 @@ int k2_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
*/
int k2_probe_mdfw(RIG *rig, struct kenwood_priv_data *priv)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !priv)
{
return -RIG_EINVAL;
}
int err, i, c;
char buf[KENWOOD_MAX_BUF_LEN];
char mode[16];
char fw[16];
char cmd[16];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!priv)
{
return -RIG_EINVAL;
}
/* The K2 extension level has been stored by elecraft_open(). Now set rig
* to K22 for detailed query of mode and filter width values...
*/
@ -683,15 +675,15 @@ int k2_probe_mdfw(RIG *rig, struct kenwood_priv_data *priv)
/* Restore mode, filter, and ext_lvl to original values */
int k2_mdfw_rest(RIG *rig, const char *mode, const char *fw)
{
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !mode || !fw)
if (!mode || !fw)
{
return -RIG_EINVAL;
}
int err;
if (strlen(mode) != 3 || strlen(fw) != 7)
{
return -RIG_EINVAL;
@ -725,19 +717,19 @@ int k2_mdfw_rest(RIG *rig, const char *mode, const char *fw)
/* Populate k2_filt_lst_s structure for each mode */
int k2_pop_fw_lst(RIG *rig, const char *cmd)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !cmd)
{
return -RIG_EINVAL;
}
int err, f;
char fcmd[16];
char buf[KENWOOD_MAX_BUF_LEN];
char tmp[16];
struct k2_filt_lst_s *flt;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!cmd)
{
return -RIG_EINVAL;
}
/* Store filter data in the correct structure depending on mode */
if (strcmp(cmd, "MD1") == 0)
{
@ -766,6 +758,8 @@ int k2_pop_fw_lst(RIG *rig, const char *cmd)
for (f = 1; f < 5; f++)
{
char *bufptr = buf;
snprintf(fcmd, 8, "FW0000%d", f);
err = kenwood_transaction(rig, fcmd, NULL, 0);
@ -787,8 +781,6 @@ int k2_pop_fw_lst(RIG *rig, const char *cmd)
* f = crystal filter slot number--1-4
* a = audio filter slot number--0-2
*/
char *bufptr = buf;
strncpy(tmp, bufptr + 2, 4);
tmp[4] = '\0';
flt->filt_list[f - 1].width = atoi(tmp);

View File

@ -783,18 +783,18 @@ const struct rig_caps kx2_caps =
int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !mode || !width)
{
return -RIG_EINVAL;
}
char buf[KENWOOD_MAX_BUF_LEN];
int err;
rmode_t temp_m;
pbwidth_t temp_w;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!mode || !width)
{
return -RIG_EINVAL;
}
err = kenwood_get_mode(rig, vfo, &temp_m, &temp_w);
if (err != RIG_OK)
@ -903,16 +903,11 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
char cmd_m[4];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (mode)
{
case RIG_MODE_PKTLSB:
@ -947,6 +942,7 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
if (width != RIG_PASSBAND_NOCHANGE)
{
char cmd_s[64];
/* and set the requested bandwidth. On my K3, the bandwidth is rounded
* down to the nearest 50 Hz, i.e. sending BW0239; will cause the bandwidth
* to be set to 2.350 kHz. As the width must be divided by 10, 10 Hz values
@ -979,7 +975,6 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
width = pb_wid;
}
char cmd_s[64];
snprintf(cmd_s, sizeof(cmd_s), "BW%04ld", width / 10);
err = kenwood_transaction(rig, cmd_s, NULL, 0);
@ -1015,15 +1010,10 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
int k3_set_vfo(RIG *rig, vfo_t vfo)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (vfo)
{
case RIG_VFO_B:
@ -1058,15 +1048,10 @@ int k3_set_vfo(RIG *rig, vfo_t vfo)
*/
int k3_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char buf[10];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (token)
{
case TOK_RIT_CLR:
@ -1112,16 +1097,16 @@ int k3_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
*/
int k3_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
{
char buf[KENWOOD_MAX_BUF_LEN];
int err;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !val)
if (!val)
{
return -RIG_EINVAL;
}
char buf[KENWOOD_MAX_BUF_LEN];
int err;
switch (token)
{
case TOK_IF_FREQ:
@ -1180,14 +1165,9 @@ int k3_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
*/
int k3_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int err;
if (!rig)
{
return -RIG_EINVAL;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = set_rit_xit(rig, rit);
@ -1206,14 +1186,9 @@ int k3_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit)
*/
int k3_set_xit(RIG *rig, vfo_t vfo, shortfreq_t rit)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int err;
if (!rig)
{
return -RIG_EINVAL;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = set_rit_xit(rig, rit);
@ -1231,16 +1206,14 @@ int k3_set_xit(RIG *rig, vfo_t vfo, shortfreq_t rit)
*/
int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char buf[32];
char kmode;
int err;
char cmd_m[4];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (tx_mode)
{
case RIG_MODE_PKTLSB:
@ -1283,10 +1256,6 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
#endif
struct kenwood_priv_caps *caps = kenwood_caps(rig);
char buf[32];
char kmode;
kmode = rmode2kenwood(tx_mode, caps->mode_table);
if (kmode < 0)
@ -1306,6 +1275,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
if (tx_width != RIG_PASSBAND_NOCHANGE)
{
char cmd_s[32];
/* and set the requested bandwidth. On my K3, the bandwidth is rounded
* down to the nearest 50 Hz, i.e. sending BW0239; will cause the bandwidth
* to be set to 2.350 kHz. As the width must be divided by 10, 10 Hz values
@ -1338,7 +1308,6 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
tx_width = pb_wid;
}
char cmd_s[32];
snprintf(cmd_s, sizeof(cmd_s), "BW$%04ld", tx_width / 10);
err = kenwood_transaction(rig, cmd_s, NULL, 0);
@ -1358,19 +1327,18 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width)
int k3_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
pbwidth_t *tx_width)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !tx_mode || !tx_width)
{
return -RIG_EINVAL;
}
char buf[KENWOOD_MAX_BUF_LEN];
int err;
rmode_t temp_m;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!tx_mode || !tx_width)
{
return -RIG_EINVAL;
}
err = kenwood_safe_transaction(rig, "MD$", buf, KENWOOD_MAX_BUF_LEN, 4);
if (err != RIG_OK)
@ -1460,16 +1428,11 @@ int k3_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode,
int k3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char levelbuf[16];
int kenwood_val;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (RIG_LEVEL_IS_FLOAT(level))
{
kenwood_val = val.f * 255;
@ -1571,18 +1534,18 @@ int k3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
*/
int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !val)
{
return -RIG_EINVAL;
}
char lvlbuf[50];
int retval;
int lvl;
struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!val)
{
return -RIG_EINVAL;
}
switch (level)
{
float firmware_have;
@ -1867,15 +1830,10 @@ int kx3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
int k3_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char buf[10];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (func)
{
case RIG_FUNC_APF:
@ -1906,7 +1864,7 @@ int k3_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !status)
if (!status)
{
return -RIG_EINVAL;
}
@ -1942,14 +1900,9 @@ int k3_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
*/
int set_rit_xit(RIG *rig, shortfreq_t rit)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int err;
if (!rig)
{
return -RIG_EINVAL;
}
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (rit == 0)
{
@ -1990,18 +1943,12 @@ int set_rit_xit(RIG *rig, shortfreq_t rit)
int k3_set_nb_level(RIG *rig, float dsp_nb, float if_nb)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char lvlbuf[16];
int dsp_nb_raw = 0;
int if_nb_raw = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (dsp_nb >= 0)
{
dsp_nb_raw = (int)(dsp_nb * 21.0f);
@ -2044,19 +1991,13 @@ int k3_set_nb_level(RIG *rig, float dsp_nb, float if_nb)
int k3_get_nb_level(RIG *rig, float *dsp_nb, float *if_nb)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char lvlbuf[16];
int retval;
int dsp_nb_raw;
int if_nb_raw;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = kenwood_safe_transaction(rig, "NL", lvlbuf, sizeof(lvlbuf), 6);
if (retval != RIG_OK)
@ -2082,20 +2023,14 @@ int k3_get_nb_level(RIG *rig, float *dsp_nb, float *if_nb)
int k3_get_bar_graph_level(RIG *rig, float *smeter, float *pwr, float *alc,
int *mode_tx)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char lvlbuf[16];
int retval;
int tm_raw;
int bg_raw;
char mode;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
// Determine transmit metering mode: 0 = RF POWER, 1 = ALC
retval = get_kenwood_func(rig, "TM", &tm_raw);
@ -2185,18 +2120,12 @@ int k3_get_bar_graph_level(RIG *rig, float *smeter, float *pwr, float *alc,
int kx3_get_bar_graph_level(RIG *rig, float *level)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char lvlbuf[16];
int retval;
int bg_raw;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = kenwood_safe_transaction(rig, "BG", lvlbuf, sizeof(lvlbuf), 4);
if (retval != RIG_OK)

File diff suppressed because it is too large Load Diff

View File

@ -337,18 +337,20 @@ const struct rig_caps pihpsdr_caps =
int pihspdr_get_channel(RIG *rig, channel_t *chan)
{
int err;
int tmp;
char buf[52];
char cmd[8];
size_t length;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !chan || chan->vfo != RIG_VFO_MEM)
if (!chan || chan->vfo != RIG_VFO_MEM)
{
return -RIG_EINVAL;
}
int err;
char buf[52];
char cmd[8];
struct kenwood_priv_caps *caps = kenwood_caps(rig);
/* put channel num in the command string */
sprintf(cmd, "MR0%03d;", chan->channel_num);
@ -359,7 +361,7 @@ int pihspdr_get_channel(RIG *rig, channel_t *chan)
return err;
}
size_t length = strlen(buf);
length = strlen(buf);
memset(chan, 0x00, sizeof(channel_t));
chan->vfo = RIG_VFO_MEM;
@ -384,7 +386,6 @@ int pihspdr_get_channel(RIG *rig, channel_t *chan)
Tuning step depends on this number and the mode,
just save it for now */
buf[ 40 ] = '\0';
int tmp;
tmp = atoi(&buf[ 38]);
/* Offset frequency */
buf[ 38 ] = '\0';
@ -563,22 +564,20 @@ int pihspdr_get_channel(RIG *rig, channel_t *chan)
}
int pihspdr_set_channel(RIG *rig, const channel_t *chan)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !chan)
{
return -RIG_EINVAL;
}
{
char sqltype;
char shift;
char buf[128];
char mode, tx_mode = 0;
int err;
int tone = 0;
int tstep;
short code;
short dcscode;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
mode = rmode2kenwood(chan->mode, caps->mode_table);
if (mode < 0)
@ -601,7 +600,7 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
}
/* find tone */
char sqltype = '0';
sqltype = '0';
if (chan->ctcss_tone)
{
@ -622,7 +621,7 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
}
/* find CTCSS code */
short code = 0;
code = 0;
if (chan->ctcss_sql)
{
@ -643,7 +642,7 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
}
/* find DCS code */
short dcscode = 0;
dcscode = 0;
if (chan->dcs_code)
{
@ -663,7 +662,7 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
dcscode = 0;
}
char shift = '0';
shift = '0';
if (chan->rptr_shift == RIG_RPT_SHIFT_PLUS)
{
@ -675,7 +674,7 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
shift = '2';
}
int tstep = 0;
tstep = 0;
if ((chan->mode == RIG_MODE_AM) || (chan->mode == RIG_MODE_FM))
{
@ -770,16 +769,11 @@ int pihspdr_set_channel(RIG *rig, const channel_t *chan)
int pihpsdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char levelbuf[16];
int i, kenwood_val;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (RIG_LEVEL_IS_FLOAT(level))
{
kenwood_val = val.f * 255;
@ -1331,15 +1325,10 @@ int pihpsdr_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
to not use the TS-2000 backend open function */
int pihpsdr_open(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char id[KENWOOD_MAX_BUF_LEN];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
/* get id in buffer, will be null terminated */
kenwood_get_id(rig, id);

View File

@ -52,6 +52,7 @@ th_decode_event(RIG *rig)
{
char asyncbuf[128];
int retval;
int async_len;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -64,7 +65,7 @@ th_decode_event(RIG *rig)
rig_debug(RIG_DEBUG_TRACE, "%s: Decoding message\n", __func__);
size_t async_len = strlen(asyncbuf);
async_len = strlen(asyncbuf);
if (async_len > 3 && asyncbuf[0] == 'B' && asyncbuf[1] == 'U'
&& asyncbuf[2] == 'F')
@ -435,6 +436,7 @@ th_set_vfo(RIG *rig, vfo_t vfo)
/* set band */
if (vfo != RIG_VFO_MEM)
{
int retval;
switch (vfo)
{
@ -453,7 +455,7 @@ th_set_vfo(RIG *rig, vfo_t vfo)
return kenwood_wrong_vfo(__func__, vfo);
}
int retval = kenwood_simple_transaction(rig, cmd, 5);
retval = kenwood_simple_transaction(rig, cmd, 5);
if (retval != RIG_OK)
{
@ -507,6 +509,7 @@ th_get_vfo_char(RIG *rig, vfo_t *vfo, char *vfoch)
{
char cmdbuf[10], buf[10], vfoc;
int retval;
size_t length;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -519,7 +522,7 @@ th_get_vfo_char(RIG *rig, vfo_t *vfo, char *vfoch)
return retval;
}
size_t length = strlen(buf);
length = strlen(buf);
switch (length)
{
@ -1695,6 +1698,7 @@ th_get_info(RIG *rig)
{
static char firmbuf[50];
int retval;
size_t firm_len;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -1705,7 +1709,7 @@ th_get_info(RIG *rig)
return NULL;
}
size_t firm_len = strlen(firmbuf);
firm_len = strlen(firmbuf);
if (firm_len < 3)
{
@ -2191,6 +2195,7 @@ int th_get_channel(RIG *rig, channel_t *chan)
/* If not set already by special channels.. */
if (chan->channel_desc[0] == '\0')
{
size_t ack_len;
if (chan_caps[1].type == RIG_MTYPE_PRIO)
{
sprintf(membuf, "MNA %sI-%01d", mr_extra, channel_num);
@ -2208,7 +2213,7 @@ int th_get_channel(RIG *rig, channel_t *chan)
return retval;
}
size_t ack_len = strlen(ackbuf);
ack_len = strlen(ackbuf);
if (ack_len > rig->caps->chan_desc_sz)
{
@ -2428,6 +2433,7 @@ int th_set_channel(RIG *rig, const channel_t *chan)
if (chan_caps->mem_caps.flags && chan_caps->mem_caps.dcs_sql)
{
int mode;
if (!priv->mode_table)
{
@ -2436,7 +2442,7 @@ int th_set_channel(RIG *rig, const channel_t *chan)
return -RIG_ENIMPL;
}
int mode = rmode2kenwood(chan->mode, priv->mode_table);
mode = rmode2kenwood(chan->mode, priv->mode_table);
if (mode == -1)
{

View File

@ -196,19 +196,20 @@ static int thd72_set_vfo(RIG *rig, vfo_t vfo)
static int thd72_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
int retval;
char vfobuf[16];
struct kenwood_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
char vfonum = '0';
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
if (vfo == RIG_VFO_B || priv->split)
{
vfonum = '1';
}
sprintf(vfobuf, "BC %c", vfonum);
int retval = kenwood_transaction(rig, vfobuf, NULL, 0);
retval = kenwood_transaction(rig, vfobuf, NULL, 0);
if (retval != RIG_OK)
{
@ -222,6 +223,7 @@ static int thd72_get_vfo(RIG *rig, vfo_t *vfo)
{
int retval;
char c, buf[10];
size_t length;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -232,7 +234,7 @@ static int thd72_get_vfo(RIG *rig, vfo_t *vfo)
return retval;
}
size_t length = strlen(buf);
length = strlen(buf);
if (length == 4)
{
@ -431,6 +433,8 @@ static int thd72_set_freq_item(RIG *rig, vfo_t vfo, int item, int val)
static int thd72_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
int retval;
int tsindex;
shortfreq_t ts;
char buf[64], fbuf[11];
rig_debug(RIG_DEBUG_TRACE, "%s: called, vfo=%s, freq=%f\n", __func__,
@ -444,11 +448,11 @@ static int thd72_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
return retval;
}
int tsindex = buf[16] - '0';
tsindex = buf[16] - '0';
if (buf[16] >= 'A') { tsindex = buf[16] - 'A' + 10; }
shortfreq_t ts = thd72tuningstep[tsindex];
ts = thd72tuningstep[tsindex];
rig_debug(RIG_DEBUG_VERBOSE, "%s: tsindex=%d, stepsize=%d\n", __func__, tsindex,
(int)ts);
freq = roundl(freq / ts) * ts;
@ -461,6 +465,8 @@ static int thd72_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
static int thd72_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
int retval;
int tsindex;
shortfreq_t ts;
char buf[64];
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -472,8 +478,8 @@ static int thd72_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
return retval;
}
int tsindex = buf[16] - '0';
shortfreq_t ts = thd72tuningstep[tsindex];
tsindex = buf[16] - '0';
ts = thd72tuningstep[tsindex];
rig_debug(RIG_DEBUG_VERBOSE, "%s: tsindex=%d, stepsize=%d\n", __func__, tsindex,
(int)ts);
sscanf(buf + 5, "%"SCNfreq, freq);
@ -1360,6 +1366,7 @@ static int thd72_get_channel(RIG *rig, channel_t *chan)
if (chan->vfo == RIG_VFO_MEM) /* memory channel */
{
int len;
char cmd[16];
sprintf(cmd, "ME %03d", chan->channel_num);
retval = kenwood_transaction(rig, cmd, buf, sizeof(buf));
@ -1384,7 +1391,7 @@ static int thd72_get_channel(RIG *rig, channel_t *chan)
return retval;
}
int len = strlen(buf);
len = strlen(buf);
memcpy(chan->channel_desc, buf + 7, len - 7);
}
else /* current channel */

View File

@ -202,6 +202,7 @@ static int thd74_get_vfo(RIG *rig, vfo_t *vfo)
{
int retval;
char c, buf[10];
size_t length;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
@ -212,7 +213,7 @@ static int thd74_get_vfo(RIG *rig, vfo_t *vfo)
return retval;
}
size_t length = strlen(buf);
length = strlen(buf);
if (length == 4)
{
@ -863,11 +864,6 @@ int thd74_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
switch (ptt)
{
case RIG_PTT_ON:
@ -1286,6 +1282,7 @@ static int thd74_get_channel(RIG *rig, channel_t *chan)
if (chan->vfo == RIG_VFO_MEM) /* memory channel */
{
int len;
char cmd[16];
sprintf(cmd, "ME %03d", chan->channel_num);
retval = kenwood_transaction(rig, cmd, buf, sizeof(buf));
@ -1310,7 +1307,7 @@ static int thd74_get_channel(RIG *rig, channel_t *chan)
return retval;
}
int len = strlen(buf);
len = strlen(buf);
memcpy(chan->channel_desc, buf + 7, len - 7);
}
else /* current channel */

View File

@ -508,9 +508,10 @@ int thg71_open(RIG *rig)
for (i = 0; i < FRQRANGESIZ; i++)
{
freq_range_t frng;
char *stru;
strl = strtok(NULL, ",");
char *stru = strtok(NULL, ",");
stru = strtok(NULL, ",");
if (strl == NULL && stru == NULL)
{

View File

@ -370,6 +370,13 @@ const struct rig_caps ts2000_caps =
int ts2000_get_channel(RIG *rig, channel_t *chan)
{
int err;
int tmp;
size_t length;
char buf[52];
char cmd[8];
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !chan || chan->vfo != RIG_VFO_MEM)
@ -377,11 +384,6 @@ int ts2000_get_channel(RIG *rig, channel_t *chan)
return -RIG_EINVAL;
}
int err;
char buf[52];
char cmd[8];
struct kenwood_priv_caps *caps = kenwood_caps(rig);
/* put channel num in the command string */
sprintf(cmd, "MR0%03d;", chan->channel_num);
@ -392,7 +394,7 @@ int ts2000_get_channel(RIG *rig, channel_t *chan)
return err;
}
size_t length = strlen(buf);
length = strlen(buf);
memset(chan, 0x00, sizeof(channel_t));
chan->vfo = RIG_VFO_MEM;
@ -417,7 +419,6 @@ int ts2000_get_channel(RIG *rig, channel_t *chan)
Tuning step depends on this number and the mode,
just save it for now */
buf[ 40 ] = '\0';
int tmp;
tmp = atoi(&buf[ 38]);
/* Offset frequency */
buf[ 38 ] = '\0';
@ -597,21 +598,25 @@ int ts2000_get_channel(RIG *rig, channel_t *chan)
int ts2000_set_channel(RIG *rig, const channel_t *chan)
{
char sqltype = '0';
char buf[128];
char mode, tx_mode = 0;
char shift = '0';
short dcscode = 0;
short code = 0;
int tstep = 0;
int err;
int tone = 0;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !chan)
if (!chan)
{
return -RIG_EINVAL;
}
char buf[128];
char mode, tx_mode = 0;
int err;
int tone = 0;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
mode = rmode2kenwood(chan->mode, caps->mode_table);
if (mode < 0)
@ -634,7 +639,6 @@ int ts2000_set_channel(RIG *rig, const channel_t *chan)
}
/* find tone */
char sqltype = '0';
if (chan->ctcss_tone)
{
@ -655,7 +659,6 @@ int ts2000_set_channel(RIG *rig, const channel_t *chan)
}
/* find CTCSS code */
short code = 0;
if (chan->ctcss_sql)
{
@ -676,7 +679,6 @@ int ts2000_set_channel(RIG *rig, const channel_t *chan)
}
/* find DCS code */
short dcscode = 0;
if (chan->dcs_code)
{
@ -696,8 +698,6 @@ int ts2000_set_channel(RIG *rig, const channel_t *chan)
dcscode = 0;
}
char shift = '0';
if (chan->rptr_shift == RIG_RPT_SHIFT_PLUS)
{
shift = '1';
@ -708,7 +708,6 @@ int ts2000_set_channel(RIG *rig, const channel_t *chan)
shift = '2';
}
int tstep = 0;
if ((chan->mode == RIG_MODE_AM) || (chan->mode == RIG_MODE_FM))
{

View File

@ -52,6 +52,7 @@ kenwood_ts480_get_info(RIG *rig)
{
char firmbuf[50];
int retval;
size_t firm_len;
retval = kenwood_transaction(rig, "TY", firmbuf, sizeof(firmbuf));
@ -60,7 +61,7 @@ kenwood_ts480_get_info(RIG *rig)
return NULL;
}
size_t firm_len = strlen(firmbuf);
firm_len = strlen(firmbuf);
if (firm_len != 5)
{

View File

@ -763,6 +763,7 @@ int ts570_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
{
char infobuf[50];
int retval;
size_t info_len;
retval = kenwood_transaction(rig, "IF", infobuf, sizeof(infobuf));
@ -771,7 +772,7 @@ int ts570_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
return retval;
}
size_t info_len = strlen(infobuf);
info_len = strlen(infobuf);
if (info_len != 37 || infobuf[1] != 'F')
{

View File

@ -435,16 +435,11 @@ const struct rig_caps ts590sg_caps =
*/
const char *ts590_get_info(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return "*rig == NULL";
}
char firmbuf[10];
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = kenwood_safe_transaction(rig, "TY", firmbuf, 10, 6);
if (retval != RIG_OK)

View File

@ -171,11 +171,11 @@ const struct rig_caps xg3_caps =
*/
int xg3_init(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct xg3_priv_data *priv;
int i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
priv = (struct xg3_priv_data *)malloc(sizeof(struct xg3_priv_data));
if (!priv)
@ -212,14 +212,10 @@ int xg3_init(RIG *rig)
*/
int xg3_open(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
int err;
ptt_t ptt;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = elecraft_open(rig);
@ -228,7 +224,6 @@ int xg3_open(RIG *rig)
return err;
}
ptt_t ptt;
xg3_get_ptt(rig, RIG_VFO_A, &ptt); // set our PTT status
return RIG_OK;
@ -237,15 +232,10 @@ int xg3_open(RIG *rig)
int xg3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char levelbuf[16];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (level)
{
case RIG_LEVEL_RFPOWER:
@ -272,18 +262,13 @@ int xg3_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
*/
int xg3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig || !val)
{
return -RIG_EINVAL;
}
char cmdbuf[32], replybuf[32];
int retval;
size_t replysize = sizeof(replybuf);
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (level)
{
case RIG_LEVEL_RFPOWER:
@ -344,10 +329,10 @@ int xg3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
*/
int xg3_get_vfo(RIG *rig, vfo_t *vfo)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!vfo)
{
return -RIG_EINVAL;
@ -362,10 +347,10 @@ int xg3_get_vfo(RIG *rig, vfo_t *vfo)
*/
int xg3_set_vfo(RIG *rig, vfo_t vfo)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!vfo)
{
return -RIG_EINVAL;
@ -384,17 +369,12 @@ int xg3_set_vfo(RIG *rig, vfo_t vfo)
*/
int xg3_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
int err;
vfo_t tvfo;
char cmdbuf[20];
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
char cmdbuf[20];
tvfo = (vfo == RIG_VFO_CURR ||
vfo == RIG_VFO_VFO) ? rig->state.current_vfo : vfo;
@ -422,7 +402,7 @@ int xg3_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
sprintf(cmdbuf, "F,%011ld", (long)freq);
}
int err = kenwood_transaction(rig, cmdbuf, NULL, 0);
err = kenwood_transaction(rig, cmdbuf, NULL, 0);
return err;
}
@ -432,21 +412,21 @@ int xg3_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
*/
int xg3_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct rig_state *rs;
if (!rig || !freq)
{
return -RIG_EINVAL;
}
char freqbuf[50];
int freqsize = sizeof(freqbuf);
char cmdbuf[16];
int retval;
int offset;
vfo_t tvfo;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!freq)
{
return -RIG_EINVAL;
}
tvfo = (vfo == RIG_VFO_CURR ||
vfo == RIG_VFO_VFO) ? rig->state.current_vfo : vfo;
rs = &rig->state;
@ -491,7 +471,7 @@ int xg3_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
return retval;
}
int offset = tvfo == RIG_VFO_A ? 2 : 5;
offset = tvfo == RIG_VFO_A ? 2 : 5;
sscanf(freqbuf + offset, "%" SCNfreq, freq);
@ -503,10 +483,10 @@ int xg3_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
*/
int xg3_set_powerstat(RIG *rig, powerstat_t status)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (status == RIG_POWER_OFF)
{
const char *cmd = "X";
@ -525,24 +505,20 @@ int xg3_set_powerstat(RIG *rig, powerstat_t status)
*/
int xg3_get_powerstat(RIG *rig, powerstat_t *status)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
const char *cmd = "G"; // any command to test will do
char reply[32];
int retval = kenwood_transaction(rig, cmd, NULL, 0);
struct rig_state *rs = &rig->state;
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (retval != RIG_OK)
{
return retval;
}
struct rig_state *rs = &rig->state;
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
char reply[32];
retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1);
if (retval != RIG_OK)
{
*status = RIG_POWER_OFF; // Error indicates power is off
@ -563,11 +539,11 @@ int xg3_get_powerstat(RIG *rig, powerstat_t *status)
*/
int xg3_set_mem(RIG *rig, vfo_t vfo, int ch)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char cmdbuf[32];
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (ch < 0 || ch > 11)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s invalid channel#%02d\n", __func__, ch);
@ -592,13 +568,13 @@ int xg3_set_mem(RIG *rig, vfo_t vfo, int ch)
*/
int xg3_get_mem(RIG *rig, vfo_t vfo, int *ch)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char cmdbuf[32];
char reply[32];
int retval;
struct rig_state *rs = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
sprintf(cmdbuf, "C;");
retval = kenwood_transaction(rig, cmdbuf, NULL, 0);
@ -624,12 +600,11 @@ int xg3_get_mem(RIG *rig, vfo_t vfo, int *ch)
*/
int xg3_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
int retval;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
retval = kenwood_simple_transaction(rig,
(ptt == RIG_PTT_ON) ? "O,01" : "O,00", 0);
@ -646,18 +621,17 @@ int xg3_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
*/
int xg3_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
char pttbuf[6];
int retval;
struct xg3_priv_data *priv = (struct xg3_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!ptt)
{
return -RIG_EINVAL;
}
char pttbuf[6];
int retval;
retval = kenwood_safe_transaction(rig, "O", pttbuf, 6, 4);
if (retval != RIG_OK)
@ -676,12 +650,12 @@ int xg3_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
*/
int xg3_set_parm(RIG *rig, setting_t parm, value_t val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int ival;
char cmdbuf[16];
int retval = -RIG_EINVAL;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (parm)
{
case RIG_PARM_BACKLIGHT:
@ -705,12 +679,12 @@ int xg3_set_parm(RIG *rig, setting_t parm, value_t val)
*/
int xg3_get_parm(RIG *rig, setting_t parm, value_t *val)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
int ival;
char replybuf[6];
int retval = -RIG_EINVAL;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
switch (parm)
{
case RIG_PARM_BACKLIGHT:

View File

@ -149,11 +149,12 @@ static int rshfiq_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
char cmdstr[15];
char stopset[2];
stopset[0] = '\r';
stopset[1] = '\n';
int retval;
serial_flush(&rig->state.rigport);
stopset[0] = '\r';
stopset[1] = '\n';
snprintf(cmdstr, sizeof(cmdstr), "*f?\r");
rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, cmdstr);
@ -186,11 +187,12 @@ static int rshfiq_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
static int rshfiq_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
char cmdstr[5];
int retval;
cmdstr[0] = '*';
cmdstr[1] = 'x';
cmdstr[3] = '\r';
cmdstr[4] = 0;
int retval;
if (ptt == RIG_PTT_ON)
{

View File

@ -981,7 +981,7 @@ static int setBPF(RIG *rig, int enable)
if (nBytes > 2)
{
int i;
int retval = libusb_control_transfer(udh, REQUEST_TYPE_IN,
REQUEST_FILTERS, enable, (nBytes / 2) - 1,
(unsigned char *) FilterCrossOver, sizeof(FilterCrossOver),
@ -995,8 +995,6 @@ static int setBPF(RIG *rig, int enable)
rig_debug(RIG_DEBUG_TRACE, "%s: Filter Bank 1:\n", __func__);
int i;
for (i = 0; i < (nBytes / 2) - 1; i++)
{
rig_debug(RIG_DEBUG_TRACE, " CrossOver[%d] = %f\n",

View File

@ -69,11 +69,11 @@
static int rc2800_parse(char *s, char *device, float *value)
{
int msgtype = 0, errcode = 0;
int len;
rig_debug(RIG_DEBUG_TRACE, "%s: device return->%s", __func__, s);
int len = strlen(s);
len = strlen(s);
if (len == 0)
{
return -RIG_EPROTO;

View File

@ -320,6 +320,7 @@ static int meade_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
char eom;
size_t return_str_size;
int az_degrees, az_minutes, az_seconds, el_degrees, el_minutes, el_seconds;
int n;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -327,7 +328,7 @@ static int meade_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
rig_debug(RIG_DEBUG_VERBOSE, "%s: returned '%s'\n", __func__, return_str);
// GZ returns DDD*MM# or DDD*MM'SS#
// GA returns sDD*MM# or sDD*MM'SS#
int n = sscanf(return_str, "%d%*c%d:%d#%d%*c%d:%d%c", &az_degrees, &az_minutes,
n = sscanf(return_str, "%d%*c%d:%d#%d%*c%d:%d%c", &az_degrees, &az_minutes,
&az_seconds, &el_degrees, &el_minutes, &el_seconds, &eom);
if (n != 7 || eom != '#')
@ -432,10 +433,10 @@ static int meade_move(ROT *rot, int direction, int speed)
static const char *meade_get_info(ROT *rot)
{
static char buf[256]; // this is not thread-safe but not important either
struct meade_priv_data *priv = (struct meade_priv_data *)rot->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
static char buf[256]; // this is not thread-safe but not important either
sprintf(buf, "Meade telescope rotator with LX200 protocol.\nModel: %s",
priv->product_name);
return buf;

View File

@ -198,6 +198,7 @@ static int prosistel_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
char data[20];
float posval;
int retval;
int n;
num_sprintf(cmdstr, STX"A?"CR);
retval = prosistel_transaction(rot, cmdstr, data, sizeof(data));
@ -209,7 +210,7 @@ static int prosistel_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el)
// Example response of 100 azimuth
// 02 41 2c 3f 2c 31 30 30 30 2c 52 0d .A,?,1000,R.
int n = sscanf(data, "%*cA,?,%f,%*c.", &posval);
n = sscanf(data, "%*cA,?,%f,%*c.", &posval);
if (n != 1)
{

View File

@ -233,6 +233,10 @@ gp2000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
char buf[RESPSZ];
int buf_len, retval;
int nmode;
char *pmode = "UNKNOWN";
int n = sscanf(buf, "%*cI%d", &nmode);
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
@ -246,10 +250,6 @@ gp2000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
return retval;
}
int nmode;
char *pmode = "UNKNOWN";
int n = sscanf(buf, "%*cI%d", &nmode);
if (n != 1)
{
return -RIG_EPROTO;
@ -450,6 +450,12 @@ gp2000_get_info(RIG *rig)
{
static char infobuf[128];
int info_len, retval;
int addr = -1;
char type[32] = "unk type";
char rigid[32] = "unk rigid";
char sernum[32] = "unk sernum";
char *p;
rig_debug(RIG_DEBUG_VERBOSE, "%s\n", __func__);
@ -463,13 +469,7 @@ gp2000_get_info(RIG *rig)
return NULL;
}
int addr = -1;
char type[32] = "unk type";
char rigid[32] = "unk rigid";
char sernum[32] = "unk sernum";
char *p = strtok(infobuf, ",");
p = strtok(infobuf, ",");
while (p)
{
switch (p[0])

View File

@ -80,6 +80,9 @@
int cm108_open(hamlib_port_t *port)
{
int fd;
#ifdef HAVE_LINUX_HIDRAW_H
struct hidraw_devinfo hiddevinfo;
#endif
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -102,13 +105,10 @@ int cm108_open(hamlib_port_t *port)
#ifdef HAVE_LINUX_HIDRAW_H
// CM108 detection copied from Thomas Sailer's soundmodem code
rig_debug(RIG_DEBUG_VERBOSE,
"%s: checking for cm108 (or compatible) device\n",
__func__);
struct hidraw_devinfo hiddevinfo;
if (!ioctl(fd, HIDIOCGRAWINFO, &hiddevinfo)
&& ((hiddevinfo.vendor == 0x0d8c
// CM108/108B/109/119/119A
@ -163,6 +163,18 @@ int cm108_close(hamlib_port_t *port)
*/
int cm108_ptt_set(hamlib_port_t *p, ptt_t pttx)
{
ssize_t nw;
char out_rep[] =
{
0x00, // report number
// HID output report
0x00,
(pttx == RIG_PTT_ON) ? (1 << p->parm.cm108.ptt_bitnum) : 0, // set GPIO
1 << p->parm.cm108.ptt_bitnum, // Data direction register (1=output)
0x00
};
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
// For a CM108 USB audio device PTT is wired up to one of the GPIO
@ -192,18 +204,6 @@ int cm108_ptt_set(hamlib_port_t *p, ptt_t pttx)
p->parm.cm108.ptt_bitnum,
(pttx == RIG_PTT_ON) ? 1 : 0);
char out_rep[] =
{
0x00, // report number
// HID output report
0x00,
(pttx == RIG_PTT_ON) ? (1 << p->parm.cm108.ptt_bitnum) : 0, // set GPIO
1 << p->parm.cm108.ptt_bitnum, // Data direction register (1=output)
0x00
};
ssize_t nw;
if (p->fd == -1)
{
return -RIG_EINVAL;

View File

@ -84,6 +84,7 @@ void dump_hex(const unsigned char ptr[], size_t size)
for (i = 0; i < size; ++i)
{
char c;
if (i % DUMP_HEX_WIDTH == 0)
{
/* new line */
@ -91,7 +92,7 @@ void dump_hex(const unsigned char ptr[], size_t size)
memset(line + 4, ' ', sizeof(line) - 4 - 1);
}
char c = ptr[i];
c = ptr[i];
/* hex print */
sprintf(line + 8 + 3 * (i % DUMP_HEX_WIDTH), "%02x", c);
@ -141,6 +142,7 @@ void HAMLIB_API rig_set_debug_time_stamp(int flag)
char *date_strget(char *buf, int buflen)
{
char tmp[16];
time_t mytime;
struct tm *mytm;
struct timeval tv;
@ -148,7 +150,6 @@ char *date_strget(char *buf, int buflen)
mytm = gmtime(&mytime);
gettimeofday(&tv, NULL);
strftime(buf, buflen, "%Y-%m-%d:%H:%M:%S.", mytm);
char tmp[16];
sprintf(tmp, "%06ld", (long)tv.tv_usec);
strcat(buf, tmp);
return buf;

View File

@ -34,6 +34,7 @@ int gpio_open(hamlib_port_t *port, int output, int on_value)
char pathname[FILPATHLEN * 2];
FILE *fexp, *fdir;
int fd;
char *dir;
port->parm.gpio.on_value = on_value;
@ -69,7 +70,7 @@ int gpio_open(hamlib_port_t *port, int output, int on_value)
return -RIG_EIO;
}
char *dir = output ? "out" : "in";
dir = output ? "out" : "in";
rig_debug(RIG_DEBUG_VERBOSE, "Setting direction of GPIO%s to %s\n",
port->pathname, dir);
fprintf(fdir, "%s\n", dir);

View File

@ -561,13 +561,15 @@ int HAMLIB_API read_block(hamlib_port_t *p, char *rxbuffer, size_t count)
while (count > 0)
{
int retval;
int rd_count;
tv = tv_timeout; /* select may have updated it */
FD_ZERO(&rfds);
FD_SET(p->fd, &rfds);
efds = rfds;
int retval = port_select(p, p->fd + 1, &rfds, NULL, &efds, &tv);
retval = port_select(p, p->fd + 1, &rfds, NULL, &efds, &tv);
if (retval == 0)
{
@ -612,7 +614,7 @@ int HAMLIB_API read_block(hamlib_port_t *p, char *rxbuffer, size_t count)
* grab bytes from the rig
* The file descriptor must have been set up non blocking.
*/
int rd_count = port_read(p, rxbuffer + total_count, count);
rd_count = port_read(p, rxbuffer + total_count, count);
if (rd_count < 0)
{
@ -695,13 +697,15 @@ int HAMLIB_API read_string(hamlib_port_t *p,
while (total_count < rxmax - 1)
{
int rd_count;
int retval;
tv = tv_timeout; /* select may have updated it */
FD_ZERO(&rfds);
FD_SET(p->fd, &rfds);
efds = rfds;
int retval = port_select(p, p->fd + 1, &rfds, NULL, &efds, &tv);
retval = port_select(p, p->fd + 1, &rfds, NULL, &efds, &tv);
if (retval == 0)
{
@ -751,7 +755,7 @@ int HAMLIB_API read_string(hamlib_port_t *p,
* read 1 character from the rig, (check if in stop set)
* The file descriptor must have been set up non blocking.
*/
int rd_count = port_read(p, &rxbuffer[total_count], 1);
rd_count = port_read(p, &rxbuffer[total_count], 1);
/* if we get 0 bytes or an error something is wrong */
if (rd_count <= 0)

View File

@ -956,6 +956,7 @@ int get_chan_all_cb_generic(RIG *rig, chan_cb_t chan_cb, rig_ptr_t arg)
for (i = 0; !RIG_IS_CHAN_END(chan_list[i]) && i < CHANLSTSIZ; i++)
{
int retval;
/*
* setting chan to NULL means the application
@ -963,7 +964,7 @@ int get_chan_all_cb_generic(RIG *rig, chan_cb_t chan_cb, rig_ptr_t arg)
* future data for channel channel_num
*/
chan = NULL;
int retval = chan_cb(rig, &chan, chan_list[i].startc, chan_list, arg);
retval = chan_cb(rig, &chan, chan_list[i].startc, chan_list, arg);
if (retval != RIG_OK)
{
@ -1590,7 +1591,7 @@ const chan_t *HAMLIB_API rig_lookup_mem_caps(RIG *rig, int ch)
for (i = 0; i < CHANLSTSIZ && !RIG_IS_CHAN_END(chan_list[i]); i++)
{
int j;
unsigned char *p1, *p2;
p1 = (unsigned char *)&chan_list_all.mem_caps;
p2 = (unsigned char *)&chan_list[i].mem_caps;
@ -1598,7 +1599,6 @@ const chan_t *HAMLIB_API rig_lookup_mem_caps(RIG *rig, int ch)
/* It's kind of hackish, we just want to do update set with:
* chan_list_all.mem_caps |= chan_list[i].mem_caps
*/
int j;
for (j = 0; j < sizeof(channel_cap_t); j++)
{
p1[j] |= p2[j];

View File

@ -477,11 +477,11 @@ static void parseFrame(unsigned char *frame)
if ((frame[0] & 0x08) == 0 && incontrol)
{
int i;
// end of a control sequence
controlstring[numcontrolbytes++] = byte;
DEBUG("%10d:FromControl:", TIME);
int i;
for (i = 0; i < numcontrolbytes; i++) { DEBUG(" %02x", controlstring[i]); }
DEBUG(".\n");
@ -534,6 +534,8 @@ static void writeRadio(unsigned char *bytes, int len)
for (i = 0; i < len; i++)
{
int ret;
seq[0] = 0x28;
seq[1] = 0x80 | bytes[i];
seq[2] = 0x80;
@ -549,7 +551,6 @@ static void writeRadio(unsigned char *bytes, int len)
seq[0] |= 0x04;
}
int ret;
if ((ret = write(uh_device_fd, seq, 4)) < 4)
{
MYERROR("WriteRadio failed with %d\n", ret);
@ -620,6 +621,8 @@ static void writeWkey(unsigned char *bytes, int len)
for (i = 0; i < len; i++)
{
int ret;
seq[ 0] = 0x08;
seq[ 1] = 0x80;
seq[ 2] = 0x80;
@ -643,7 +646,6 @@ static void writeWkey(unsigned char *bytes, int len)
seq[ 8] |= 0x01;
}
int ret;
if ((ret = write(uh_device_fd, seq, 12)) < 12)
{
MYERROR("WriteWINKEY failed with %d\n", ret);
@ -680,6 +682,8 @@ static void writeControl(unsigned char *data, int len)
for (i = 0; i < len; i++)
{
int ret;
// encode statusbyte in first frame
seq[0] = 0x08;
seq[1] = 0x80;
@ -705,7 +709,6 @@ static void writeControl(unsigned char *data, int len)
seq[4] |= 0x01;
}
int ret;
if ((ret = write(uh_device_fd, seq, 8)) < 8)
{
MYERROR("WriteControl failed, ret=%d\n", ret);
@ -761,6 +764,8 @@ static void *read_device(void *p)
// terminates if the device is closed.
for (;;)
{
int ret;
int maxdev;
//
// setting uh_is_initialized to zero in the main thread
// tells this one that it is all over now
@ -792,7 +797,7 @@ static void *read_device(void *p)
FD_SET(uh_wkey_pair[0], &fds);
// determine max of these fd's for use in select()
int maxdev = uh_device_fd;
maxdev = uh_device_fd;
if (uh_radio_pair[0] > maxdev)
{
@ -811,7 +816,7 @@ static void *read_device(void *p)
tv.tv_usec = 100000;
tv.tv_sec = 0;
int ret = select(maxdev + 1, &fds, NULL, NULL, &tv);
ret = select(maxdev + 1, &fds, NULL, NULL, &tv);
//
// select returned error, or nothing has arrived:

View File

@ -229,6 +229,7 @@ int network_open(hamlib_port_t *rp, int default_port)
do
{
char msg[1024];
fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (fd < 0)
@ -243,7 +244,6 @@ int network_open(hamlib_port_t *rp, int default_port)
break;
}
char msg[1024];
snprintf(msg, sizeof(msg), "connect to %s failed, (trying next interface)",
rp->pathname);
handle_error(RIG_DEBUG_WARN, msg);

View File

@ -128,8 +128,6 @@ int par_open(hamlib_port_t *port)
{
int fd;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
#ifdef HAVE_LINUX_PPDEV_H
int mode;
#endif
@ -138,6 +136,8 @@ int par_open(hamlib_port_t *port)
HANDLE handle;
#endif
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!port->pathname[0])
{
return -RIG_EINVAL;
@ -240,20 +240,24 @@ int par_close(hamlib_port_t *port)
*/
int HAMLIB_API par_write_data(hamlib_port_t *port, unsigned char data)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
#ifdef HAVE_LINUX_PPDEV_H
int status;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
status = ioctl(port->fd, PPWDATA, &data);
return status == 0 ? RIG_OK : -RIG_EIO;
#elif defined(HAVE_DEV_PPBUS_PPI_H)
int status;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
status = ioctl(port->fd, PPISDATA, &data);
return status == 0 ? RIG_OK : -RIG_EIO;
#elif defined(__WIN64__) || defined(__WIN32__)
unsigned int dummy = 0;
intptr_t handle;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
handle = _get_osfhandle(port->fd);
@ -281,14 +285,16 @@ int HAMLIB_API par_write_data(hamlib_port_t *port, unsigned char data)
*/
int HAMLIB_API par_read_data(hamlib_port_t *port, unsigned char *data)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
#ifdef HAVE_LINUX_PPDEV_H
int status;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
status = ioctl(port->fd, PPRDATA, data);
return status == 0 ? RIG_OK : -RIG_EIO;
#elif defined(HAVE_DEV_PPBUS_PPI_H)
int status;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
status = ioctl(port->fd, PPIGDATA, &data);
return status == 0 ? RIG_OK : -RIG_EIO;
#elif defined(__WIN64__) || defined(__WIN32__)
@ -297,6 +303,8 @@ int HAMLIB_API par_read_data(hamlib_port_t *port, unsigned char *data)
intptr_t handle;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
handle = _get_osfhandle(port->fd);
if (handle != (intptr_t)INVALID_HANDLE_VALUE)
@ -333,13 +341,13 @@ int HAMLIB_API par_read_data(hamlib_port_t *port, unsigned char *data)
*/
int HAMLIB_API par_write_control(hamlib_port_t *port, unsigned char control)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
#ifdef HAVE_LINUX_PPDEV_H
int status;
unsigned char ctrl = control ^ CP_ACTIVE_LOW_BITS;
status = ioctl(port->fd, PPWCONTROL, &ctrl);
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (status < 0)
{
rig_debug(RIG_DEBUG_ERR,
@ -352,6 +360,8 @@ int HAMLIB_API par_write_control(hamlib_port_t *port, unsigned char control)
#elif defined(HAVE_DEV_PPBUS_PPI_H)
int status;
unsigned char ctrl = control ^ CP_ACTIVE_LOW_BITS;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
status = ioctl(port->fd, PPISCTRL, &ctrl);
return status == 0 ? RIG_OK : -RIG_EIO;
#elif defined(__WIN64__) || defined(__WIN32__)
@ -364,6 +374,8 @@ int HAMLIB_API par_write_control(hamlib_port_t *port, unsigned char control)
| C1284_NSELECTIN);
intptr_t handle;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (ctr & 0x20)
{
rig_debug(RIG_DEBUG_WARN,
@ -409,11 +421,12 @@ int HAMLIB_API par_write_control(hamlib_port_t *port, unsigned char control)
*/
int HAMLIB_API par_read_control(hamlib_port_t *port, unsigned char *control)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
#ifdef HAVE_LINUX_PPDEV_H
int status;
unsigned char ctrl;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
status = ioctl(port->fd, PPRCONTROL, &ctrl);
if (status < 0)
@ -429,6 +442,8 @@ int HAMLIB_API par_read_control(hamlib_port_t *port, unsigned char *control)
#elif defined(HAVE_DEV_PPBUS_PPI_H)
int status;
unsigned char ctrl;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
status = ioctl(port->fd, PPIGCTRL, &ctrl);
*control = ctrl ^ CP_ACTIVE_LOW_BITS;
return status == 0 ? RIG_OK : -RIG_EIO;
@ -438,6 +453,7 @@ int HAMLIB_API par_read_control(hamlib_port_t *port, unsigned char *control)
intptr_t handle;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
handle = _get_osfhandle(port->fd);
if (handle != (intptr_t)INVALID_HANDLE_VALUE)
@ -476,12 +492,12 @@ int HAMLIB_API par_read_control(hamlib_port_t *port, unsigned char *control)
*/
int HAMLIB_API par_read_status(hamlib_port_t *port, unsigned char *status)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
#ifdef HAVE_LINUX_PPDEV_H
int ret;
unsigned char sta;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
ret = ioctl(port->fd, PPRSTATUS, &sta);
*status = sta ^ SP_ACTIVE_LOW_BITS;
return ret == 0 ? RIG_OK : -RIG_EIO;
@ -490,6 +506,7 @@ int HAMLIB_API par_read_status(hamlib_port_t *port, unsigned char *status)
int ret;
unsigned char sta;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
ret = ioctl(port->fd, PPIGSTATUS, &sta);
*status = sta ^ SP_ACTIVE_LOW_BITS;
return ret == 0 ? RIG_OK : -RIG_EIO;
@ -500,6 +517,7 @@ int HAMLIB_API par_read_status(hamlib_port_t *port, unsigned char *status)
intptr_t handle;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
handle = _get_osfhandle(port->fd);
if (handle != (intptr_t)INVALID_HANDLE_VALUE)

View File

@ -1094,6 +1094,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
int rc2;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -1142,7 +1143,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
retcode = caps->set_freq(rig, vfo, freq);
/* try and revert even if we had an error above */
int rc2 = caps->set_vfo(rig, curr_vfo);
rc2 = caps->set_vfo(rig, curr_vfo);
if (RIG_OK == retcode)
{
@ -1205,6 +1206,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
}
else
{
int rc2;
if (!caps->set_vfo)
{
return -RIG_ENAVAIL;
@ -1220,7 +1222,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
retcode = caps->get_freq(rig, vfo, freq);
/* try and revert even if we had an error above */
int rc2 = caps->set_vfo(rig, curr_vfo);
rc2 = caps->set_vfo(rig, curr_vfo);
if (RIG_OK == retcode)
{
@ -1297,6 +1299,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
}
else
{
int rc2;
if (!caps->set_vfo)
{
@ -1313,7 +1316,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
retcode = caps->set_mode(rig, vfo, mode, width);
/* try and revert even if we had an error above */
int rc2 = caps->set_vfo(rig, curr_vfo);
rc2 = caps->set_vfo(rig, curr_vfo);
/* return the first error code */
if (RIG_OK == retcode)
@ -1383,6 +1386,7 @@ int HAMLIB_API rig_get_mode(RIG *rig,
}
else
{
int rc2;
if (!caps->set_vfo)
{
@ -1399,7 +1403,7 @@ int HAMLIB_API rig_get_mode(RIG *rig,
retcode = caps->get_mode(rig, vfo, mode, width);
/* try and revert even if we had an error above */
int rc2 = caps->set_vfo(rig, curr_vfo);
rc2 = caps->set_vfo(rig, curr_vfo);
if (RIG_OK == retcode)
{
@ -1720,9 +1724,10 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
if (retcode == RIG_OK)
{
int rc2;
retcode = caps->set_ptt(rig, vfo, ptt);
/* try and revert even if we had an error above */
int rc2 = caps->set_vfo(rig, curr_vfo);
rc2 = caps->set_vfo(rig, curr_vfo);
/* return the first error code */
if (RIG_OK == retcode)

View File

@ -627,6 +627,7 @@ int HAMLIB_API rot_get_position(ROT *rot,
{
const struct rot_caps *caps;
const struct rot_state *rs;
int retval;
rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -643,7 +644,7 @@ int HAMLIB_API rot_get_position(ROT *rot,
return -RIG_ENAVAIL;
}
int retval = caps->get_position(rot, azimuth, elevation);
retval = caps->get_position(rot, azimuth, elevation);
if (retval != RIG_OK) { return retval; }

View File

@ -376,10 +376,11 @@ int usb_port_open(hamlib_port_t *port)
*/
int usb_port_close(hamlib_port_t *port)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
libusb_device_handle *udh = port->handle;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
libusb_release_interface(udh, port->parm.usb.iface);
libusb_close(udh);

View File

@ -506,8 +506,18 @@ int tt538_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
int tt538_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
int cmd_len, resp_len, retval;
int rpb;
unsigned char cmdbuf[16], respbuf[32];
char ttmode;
/* Find bandwidth according to response from table. */
static int pbwidth[39] =
{
8000, 6000, 5700, 5400, 5100, 4800, 4500, 4200,
3900, 3600, 3300, 3000, 2850, 2700, 2550, 2400,
2250, 2100, 1950, 1800, 1650, 1500, 1350, 1200,
1050, 900, 750, 675, 600, 525, 450, 375,
330, 300, 260, 225, 180, 165, 150
};
/* Query mode */
cmd_len = sprintf((char *) cmdbuf, "?M" EOM);
@ -580,16 +590,7 @@ int tt538_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
return -RIG_EPROTO;
}
/* Find bandwidth according to response from table. */
static int pbwidth[39] =
{
8000, 6000, 5700, 5400, 5100, 4800, 4500, 4200,
3900, 3600, 3300, 3000, 2850, 2700, 2550, 2400,
2250, 2100, 1950, 1800, 1650, 1500, 1350, 1200,
1050, 900, 750, 675, 600, 525, 450, 375,
330, 300, 260, 225, 180, 165, 150
};
int rpb = respbuf[1];
rpb = respbuf[1];
if (rpb >= 0 && rpb <= 38)
{

View File

@ -378,6 +378,7 @@ static char which_vfo(const RIG *rig, vfo_t vfo)
int tt588_get_vfo(RIG *rig, vfo_t *vfo)
{
static int getinfo = TRUE;
struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv;
if (getinfo) // this is the first call to this package so we do this here
{
@ -385,8 +386,6 @@ int tt588_get_vfo(RIG *rig, vfo_t *vfo)
tt588_get_info(rig);
}
struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv;
*vfo = priv->vfo_curr;
if (check_vfo(*vfo) == FALSE)
@ -601,11 +600,11 @@ int tt588_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
int cmd_len, resp_len, retval;
unsigned char cmdbuf[16], respbuf[32];
char ttmode;
struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
struct tt588_priv_data *priv = (struct tt588_priv_data *) rig->state.priv;
if (check_vfo(vfo) == FALSE)
{
rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo));
@ -981,10 +980,11 @@ int tt588_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
// transmit reply example S<0x8f><0x01> 0x0f=15 watts, 0x01
// it appears 0x01 refelected = 0W since 0 means not read yet
int strength;
int reflected = (int)lvlbuf[2];
reflected = reflected > 0 ? reflected - 1 : 0;
// computer transmit power
int strength = (int)(lvlbuf[1] & 0x7f) - reflected;
strength = (int)(lvlbuf[1] & 0x7f) - reflected;
rig_debug(RIG_DEBUG_TRACE, "%s: strength fwd=%d, rev=%d\n", __func__, strength,
reflected);

View File

@ -129,9 +129,10 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
/* Allow transaction re-tries according to capabilities. */
for (itry = 0; itry < rig->caps->retry; itry++)
{
int retval;
rs = &rig->state;
serial_flush(&rs->rigport); /* discard pending i/p */
int retval = write_block(&rs->rigport, cmd, cmd_len);
retval = write_block(&rs->rigport, cmd, cmd_len);
if (retval != RIG_OK)
{
@ -1332,8 +1333,9 @@ int tt565_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
}
else /* look at main rx info */
{
char *raw_field2;
raw_field = lvlbuf + 4;
char *raw_field2 = strchr(raw_field, 'S'); /* position may vary */
raw_field2 = strchr(raw_field, 'S'); /* position may vary */
if (raw_field2) { *raw_field2 = '\0'; } /* valid string */
}

View File

@ -247,6 +247,7 @@ static int rx331_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
int rig_id;
int retval;
char str[BUFSZ];
char fmt[16];
struct rig_state *rs;
struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv;
@ -275,7 +276,6 @@ static int rx331_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
return retval;
}
char fmt[16];
snprintf(fmt,sizeof(fmt)-1,"%%i%%%ds",BUFSZ);
sscanf(data + 1, fmt, &rig_id, data);

View File

@ -371,6 +371,7 @@ int main(int argc, char *argv[])
if (rd_hist || sv_hist)
{
int hist_path_size;
if (!(hist_dir = getenv("AMPCTL_HIST_DIR")))
{
hist_dir = getenv("HOME");
@ -383,7 +384,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Warning: %s is not a directory!\n", hist_dir);
}
int hist_path_size = sizeof(char) * (strlen(hist_dir) + strlen(hist_file) + 1);
hist_path_size = sizeof(char) * (strlen(hist_dir) + strlen(hist_file) + 1);
hist_path = (char *)calloc(hist_path_size, sizeof(char));
snprintf(hist_path, hist_path_size, "%s%s", hist_dir, hist_file);

View File

@ -1049,8 +1049,8 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc)
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg1) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg1);
strcat(pmptstr, ": ");
@ -1107,8 +1107,8 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc)
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg1) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg1);
strcat(pmptstr, ": ");
@ -1168,8 +1168,8 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc)
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg2) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg2);
strcat(pmptstr, ": ");
@ -1229,8 +1229,8 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc)
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg3) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg3);
strcat(pmptstr, ": ");
@ -1290,8 +1290,8 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc)
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg4) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg4);
strcat(pmptstr, ": ");

View File

@ -176,6 +176,9 @@ int main(int argc, char *argv[])
pthread_attr_t attr;
#endif
struct handle_data *arg;
#if HAVE_SIGACTION
struct sigaction act;
#endif
while (1)
{
@ -498,7 +501,6 @@ int main(int argc, char *argv[])
that will consequently fail with EPIPE. All child threads will
inherit this disposition which is what we want. */
#if HAVE_SIGACTION
struct sigaction act;
memset(&act, 0, sizeof act);
act.sa_handler = SIG_IGN;
act.sa_flags = SA_RESTART;

View File

@ -271,6 +271,7 @@ static char *mystrtok(char *s, char delim)
{
static size_t pos = 0, length = 0;
static char *str = 0;
size_t i, ent_pos;
if (s != NULL)
{
@ -287,7 +288,7 @@ static char *mystrtok(char *s, char delim)
return NULL;
}
size_t i, ent_pos = pos;
ent_pos = pos;
for (i = pos; i < length;)
{
@ -729,6 +730,7 @@ int set_channel_data(RIG *rig,
{
int i, j, n;
const channel_cap_t *mem_caps;
memset(chan, 0, sizeof(channel_t));
chan->vfo = RIG_VFO_CURR;
@ -754,7 +756,7 @@ int set_channel_data(RIG *rig,
printf("Requested channel number %d, list number %d\n", n, j);
const channel_cap_t *mem_caps = &rig->state.chan_list[j].mem_caps;
mem_caps = &rig->state.chan_list[j].mem_caps;
if (mem_caps->bank_num)
{

View File

@ -157,6 +157,7 @@ int main(int argc, char *argv[])
char send_cmd_term = '\r'; /* send_cmd termination char */
int ext_resp = 0;
char resp_sep = '\n';
int i;
while (1)
{
@ -513,7 +514,7 @@ int main(int argc, char *argv[])
exit(0);
}
int i=0;
i=0;
do { // we'll try 5 times and sleep 200ms between tries
retcode = rig_open(my_rig);
if (retcode != RIG_OK) {
@ -581,6 +582,7 @@ int main(int argc, char *argv[])
if (rd_hist || sv_hist)
{
int hist_path_size;
if (!(hist_dir = getenv("RIGCTL_HIST_DIR")))
{
hist_dir = getenv("HOME");
@ -592,7 +594,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Warning: %s is not a directory!\n", hist_dir);
}
int hist_path_size = sizeof(char) * (strlen(hist_dir) + strlen(hist_file) + 1);
hist_path_size = sizeof(char) * (strlen(hist_dir) + strlen(hist_file) + 1);
hist_path = (char *)calloc(hist_path_size, sizeof(char));
snprintf(hist_path, hist_path_size, "%s%s", hist_dir, hist_file);

View File

@ -1259,8 +1259,8 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg1) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg1);
strcat(pmptstr, ": ");
@ -1322,8 +1322,8 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg1) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg1);
strcat(pmptstr, ": ");
@ -1388,8 +1388,8 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg2) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg2);
strcat(pmptstr, ": ");
@ -1454,8 +1454,8 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg3) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg3);
strcat(pmptstr, ": ");
@ -1641,12 +1641,12 @@ void usage_rig(FILE *fout)
for (i = 0; test_list[i].cmd != 0; i++)
{
int nbspaces = 18;
fprintf(fout,
"%c: %-16s(",
isprint(test_list[i].cmd) ? test_list[i].cmd : '?',
test_list[i].name);
int nbspaces = 18;
if (test_list[i].arg1 && (test_list[i].flags & ARG_IN1))
{
@ -1797,6 +1797,8 @@ int set_conf(RIG *my_rig, char *conf_parms)
while (p && *p != '\0')
{
int ret;
/* FIXME: left hand value of = cannot be null */
char *q = strchr(p, '=');
@ -1813,7 +1815,7 @@ int set_conf(RIG *my_rig, char *conf_parms)
*n++ = '\0';
}
int ret = rig_set_conf(my_rig, rig_token_lookup(my_rig, p), q);
ret = rig_set_conf(my_rig, rig_token_lookup(my_rig, p), q);
if (ret != RIG_OK)
{

View File

@ -206,6 +206,7 @@ int main(int argc, char *argv[])
int serial_rate2 = 115200; /* virtual com port default speed */
char *civaddr = NULL; /* NULL means no need to set conf */
char conf_parms[MAXCONFLEN] = "";
int status;
printf("rigctlcom Version 1.1\n");
@ -574,7 +575,7 @@ int main(int argc, char *argv[])
my_com.parm.serial.parity = RIG_PARITY_NONE;
my_com.parm.serial.handshake = RIG_HANDSHAKE_NONE;
int status = port_open(&my_com);
status = port_open(&my_com);
if (status != RIG_OK)
{
@ -794,6 +795,8 @@ static int handle_ts2000(void *arg)
else if (strcmp(arg, "FA;") == 0)
{
freq_t freq = 0;
char response[32];
int retval = rig_get_freq(my_rig, RIG_VFO_A, &freq);
if (retval != RIG_OK)
@ -803,13 +806,12 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "FA%011"PRIll";", (uint64_t)freq);
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
else if (strcmp(arg, "FB;") == 0)
{
char response[32];
freq_t freq = 0;
int retval = rig_get_freq(my_rig, RIG_VFO_B, &freq);
@ -820,8 +822,6 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "FB%011"PRIll";", (uint64_t)freq);
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
@ -864,8 +864,10 @@ static int handle_ts2000(void *arg)
}
else if (strcmp(arg, "FR;") == 0)
{
char response[32];
vfo_t vfo;
int retval = rig_get_vfo(my_rig, &vfo);
int nvfo = 0;
if (retval != RIG_OK)
{
@ -874,7 +876,6 @@ static int handle_ts2000(void *arg)
return retval;
}
int nvfo = 0;
if (vfo == RIG_VFO_A) { nvfo = 0; }
else if (vfo == RIG_VFO_B) { nvfo = 1; }
@ -884,7 +885,6 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "FR%c;", nvfo + '0');
return write_block2((void *)__func__, &my_com, response, strlen(response));
@ -892,8 +892,10 @@ static int handle_ts2000(void *arg)
}
else if (strcmp(arg, "FT;") == 0)
{
char response[32];
vfo_t vfo, vfo_curr = RIG_VFO_A;
split_t split;
int nvfo = 0;
int retval = rig_get_split_vfo(my_rig, vfo_curr, &split, &vfo);
if (retval != RIG_OK)
@ -903,7 +905,6 @@ static int handle_ts2000(void *arg)
return retval;
}
int nvfo = 0;
if (vfo == RIG_VFO_A) { nvfo = 0; }
else if (vfo == RIG_VFO_B) { nvfo = 1; }
@ -913,7 +914,6 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "FT%c;", nvfo + '0');
return write_block2((void *)__func__, &my_com, response, strlen(response));
@ -921,6 +921,7 @@ static int handle_ts2000(void *arg)
}
else if (strcmp(arg, "TN;") == 0)
{
char response[32];
tone_t val;
int retval = rig_get_ctcss_tone(my_rig, RIG_VFO_CURR, &val);
@ -931,16 +932,17 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "TN%02d;", val);
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
else if (strncmp(arg, "TN", 2) == 0)
{
tone_t val;
int ival = 0;
int retval;
sscanf(arg, "TN%d", &ival);
tone_t val = ival;
int retval = rig_set_ctcss_tone(my_rig, RIG_VFO_CURR, val);
val = ival;
retval = rig_set_ctcss_tone(my_rig, RIG_VFO_CURR, val);
if (retval != RIG_OK)
{
@ -952,8 +954,10 @@ static int handle_ts2000(void *arg)
}
else if (strcmp(arg, "PA;") == 0)
{
char response[32];
int valA;
int retval = rig_get_func(my_rig, RIG_VFO_A, RIG_FUNC_AIP, &valA);
int valB;
if (retval != RIG_OK)
{
@ -969,7 +973,6 @@ static int handle_ts2000(void *arg)
return retval;
}
int valB;
retval = rig_get_func(my_rig, RIG_VFO_B, RIG_FUNC_AIP, &valB);
if (retval != RIG_OK)
@ -979,7 +982,6 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "PA%c%c;", valA + '0', valB + '0');
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
@ -987,6 +989,7 @@ static int handle_ts2000(void *arg)
{
int valA = 0;
int valB = 0;
int retval;
int n = sscanf(arg, "PA%1d%1d", &valA, &valB);
if (n != 2)
@ -995,7 +998,7 @@ static int handle_ts2000(void *arg)
(char *)arg);
}
int retval = rig_set_func(my_rig, RIG_VFO_A, RIG_FUNC_AIP, valA);
retval = rig_set_func(my_rig, RIG_VFO_A, RIG_FUNC_AIP, valA);
if (retval != RIG_OK)
{
@ -1017,6 +1020,7 @@ static int handle_ts2000(void *arg)
}
else if (strcmp(arg, "XT;") == 0)
{
char response[32];
int val;
int retval = rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_XIT, &val);
@ -1034,15 +1038,15 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "XT%c;", val + '0');
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
else if (strncmp(arg, "XT", 2) == 0)
{
int val = 0;
int retval;
sscanf(arg, "XT%d", &val);
int retval = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_XIT, val);
retval = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_XIT, val);
if (retval != RIG_OK)
{
@ -1060,6 +1064,7 @@ static int handle_ts2000(void *arg)
}
else if (strcmp(arg, "NR;") == 0)
{
char response[32];
int val;
int retval = rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_NR, &val);
@ -1076,15 +1081,15 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "NR%c;", val + '0');
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
else if (strncmp(arg, "NR", 2) == 0)
{
int val = 0;
int retval;
sscanf(arg, "NR%d", &val);
int retval = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_NR, val);
retval = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_NR, val);
if (retval != RIG_OK)
{
@ -1101,6 +1106,7 @@ static int handle_ts2000(void *arg)
}
else if (strcmp(arg, "NB;") == 0)
{
char response[32];
int val;
int retval = rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_NB, &val);
@ -1118,15 +1124,14 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "NB%c;", val + '0');
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
else if (strncmp(arg, "NB", 2) == 0)
{
int val = 0;
sscanf(arg, "NB%d", &val);
int retval = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_NB, val);
sscanf(arg, "NB%d", &val);
if (retval != RIG_OK)
{
@ -1146,6 +1151,8 @@ static int handle_ts2000(void *arg)
{
value_t val;
int retval = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AF, &val);
char response[32];
int level;
if (retval != RIG_OK)
{
@ -1161,8 +1168,7 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
int level = val.f * 255;
level = val.f * 255;
snprintf(response, sizeof(response), "AG0%03d;", level);
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
@ -1170,6 +1176,8 @@ static int handle_ts2000(void *arg)
{
int level = 0;
int n = sscanf(arg, "AG%d", &level);
int retval;
value_t val;
if (n != 1)
{
@ -1178,9 +1186,8 @@ static int handle_ts2000(void *arg)
return -RIG_EPROTO;
}
value_t val;
val.f = level / 255.0;
int retval = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AF, val);
retval = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AF, val);
if (retval != RIG_OK)
{
@ -1192,8 +1199,10 @@ static int handle_ts2000(void *arg)
}
else if (strcmp(arg, "PR;") == 0)
{
char response[32];
value_t val;
int retval = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_COMP, &val);
int speechLevel;
if (retval != RIG_OK)
{
@ -1209,15 +1218,16 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
int speechLevel = val.f * 255;
speechLevel = val.f * 255;
snprintf(response, sizeof(response), "PR%03d;", speechLevel);
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
else if (strncmp(arg, "PR", 2) == 0)
{
value_t val;
int speechLevel = 0;
int n = sscanf(arg, "PR%d", &speechLevel);
int retval;
if (n != 1)
{
@ -1226,9 +1236,8 @@ static int handle_ts2000(void *arg)
return -RIG_EPROTO;
}
value_t val;
val.f = speechLevel / 255.0;
int retval = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_COMP, val);
retval = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_COMP, val);
if (retval != RIG_OK)
{
@ -1248,6 +1257,8 @@ static int handle_ts2000(void *arg)
{
value_t val;
int retval = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AGC, &val);
char response[32];
int agcLevel;
if (retval != RIG_OK)
{
@ -1263,8 +1274,7 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
int agcLevel = val.f * 255;
agcLevel = val.f * 255;
snprintf(response, sizeof(response), "GT%03d;", agcLevel);
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
@ -1272,6 +1282,8 @@ static int handle_ts2000(void *arg)
{
int agcLevel = 0;
int n = sscanf(arg, "GT%d", &agcLevel);
int retval;
value_t val;
if (n != 1)
{
@ -1280,9 +1292,8 @@ static int handle_ts2000(void *arg)
return -RIG_EPROTO;
}
value_t val;
val.f = agcLevel / 255.0;
int retval = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AGC, val);
retval = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_AGC, val);
if (retval != RIG_OK)
{
@ -1294,8 +1305,10 @@ static int handle_ts2000(void *arg)
}
else if (strcmp(arg, "SQ;") == 0)
{
char response[32];
value_t val;
int retval = rig_get_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_SQL, &val);
int sqlev;
if (retval != RIG_OK)
{
@ -1311,8 +1324,7 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
int sqlev = val.f * 255;
sqlev = val.f * 255;
snprintf(response, sizeof(response), "SQ%03d;", sqlev);
return write_block2((void *)__func__, &my_com, response, strlen(response));
}
@ -1320,6 +1332,8 @@ static int handle_ts2000(void *arg)
{
int sqlev = 0;
int n = sscanf(arg, "SQ%d", &sqlev);
int retval;
value_t val;
if (n != 1)
{
@ -1328,9 +1342,8 @@ static int handle_ts2000(void *arg)
return -RIG_EPROTO;
}
value_t val;
val.f = sqlev / 255.0;
int retval = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_SQL, val);
retval = rig_set_level(my_rig, RIG_VFO_CURR, RIG_LEVEL_SQL, val);
if (retval != RIG_OK)
{
@ -1350,6 +1363,7 @@ static int handle_ts2000(void *arg)
{
vfo_t vfo, vfo_curr = RIG_VFO_A;
split_t split;
char response[32];
int retval = rig_get_split_vfo(my_rig, vfo_curr, &split, &vfo);
if (retval != RIG_OK)
@ -1359,7 +1373,6 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "DC%c;", split + '0');
return write_block2((void *)__func__, &my_com, response, strlen(response));
@ -1370,6 +1383,8 @@ static int handle_ts2000(void *arg)
vfo_t vfo_curr = RIG_VFO_A;
split_t split;
int isplit;
int retval;
char response[32];
// Expecting DCnn -- but we dont' care about the control param
int n = sscanf(arg, "DC%d", &isplit);
@ -1380,7 +1395,7 @@ static int handle_ts2000(void *arg)
}
split = isplit;
int retval = rig_set_split_vfo(my_rig, vfo_curr, split, RIG_VFO_SUB);
retval = rig_set_split_vfo(my_rig, vfo_curr, split, RIG_VFO_SUB);
if (retval != RIG_OK)
{
@ -1389,7 +1404,6 @@ static int handle_ts2000(void *arg)
return retval;
}
char response[32];
snprintf(response, sizeof(response), "DC%c;", split + '0');
return write_block2((void *)__func__, &my_com, response, strlen(response));
@ -1419,6 +1433,7 @@ static int handle_ts2000(void *arg)
}
else if (strncmp(arg, "MD", 2) == 0)
{
char response[32];
mode_t mode = 0;
int imode = 0;
@ -1447,8 +1462,6 @@ static int handle_ts2000(void *arg)
case 9: mode = RIG_MODE_RTTYR; break;
}
char response[32];
snprintf(response, sizeof(response), "MD%c;", mode + '0');
return write_block2((void *)__func__, &my_com, response, strlen(response));
}

View File

@ -248,6 +248,9 @@ int main(int argc, char *argv[])
int reuseaddr = 1;
char host[NI_MAXHOST];
char serv[NI_MAXSERV];
#if HAVE_SIGACTION
struct sigaction act;
#endif
#ifdef HAVE_PTHREAD
pthread_t thread;
@ -723,7 +726,6 @@ int main(int argc, char *argv[])
}
#if HAVE_SIGACTION
struct sigaction act;
#ifdef SIGPIPE
/* Ignore SIGPIPE as we will handle it at the write()/send() calls
@ -781,6 +783,9 @@ int main(int argc, char *argv[])
*/
do
{
fd_set set;
struct timeval timeout;
arg = malloc(sizeof(struct handle_data));
if (!arg)
@ -790,8 +795,6 @@ int main(int argc, char *argv[])
}
/* use select to allow for periodic checks for CTRL+C */
fd_set set;
struct timeval timeout;
FD_ZERO(&set);
FD_SET(sock_listen, &set);
timeout.tv_sec = 5;

View File

@ -427,6 +427,8 @@ int set_conf(RIG *rig, char *conf_parms)
while (p && *p != '\0')
{
int ret;
/* FIXME: left hand value of = cannot be null */
char *q = strchr(p, '=');
@ -443,7 +445,7 @@ int set_conf(RIG *rig, char *conf_parms)
*n++ = '\0';
}
int ret = rig_set_conf(rig, rig_token_lookup(rig, p), q);
ret = rig_set_conf(rig, rig_token_lookup(rig, p), q);
if (ret != RIG_OK)
{

View File

@ -393,6 +393,7 @@ int main(int argc, char *argv[])
if (rd_hist || sv_hist)
{
int hist_path_size;
if (!(hist_dir = getenv("ROTCTL_HIST_DIR")))
{
hist_dir = getenv("HOME");
@ -405,7 +406,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "Warning: %s is not a directory!\n", hist_dir);
}
int hist_path_size = sizeof(char) * (strlen(hist_dir) + strlen(hist_file) + 1);
hist_path_size = sizeof(char) * (strlen(hist_dir) + strlen(hist_file) + 1);
hist_path = (char *)calloc(hist_path_size, sizeof(char));
snprintf(hist_path, hist_path_size, "%s%s", hist_dir, hist_file);

View File

@ -1076,8 +1076,8 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg1) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg1);
strcat(pmptstr, ": ");
@ -1134,8 +1134,8 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg1) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg1);
strcat(pmptstr, ": ");
@ -1195,8 +1195,8 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg2) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg2);
strcat(pmptstr, ": ");
@ -1256,8 +1256,8 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg3) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg3);
strcat(pmptstr, ": ");
@ -1317,8 +1317,8 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
x = 0;
char pmptstr[(strlen(cmd_entry->arg4) + 3)];
x = 0;
strcpy(pmptstr, cmd_entry->arg4);
strcat(pmptstr, ": ");
@ -1798,6 +1798,8 @@ declare_proto_rot(move)
/* 'C' */
declare_proto_rot(inter_set_conf)
{
char buf[256];
rot_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
if (!arg2 || arg2[0] == '\0')
@ -1807,7 +1809,6 @@ declare_proto_rot(inter_set_conf)
return -RIG_EINVAL;
}
char buf[256];
sprintf(buf, "%s=%s", arg1, arg2);
return set_conf(rot, buf);
}

View File

@ -175,6 +175,9 @@ int main(int argc, char *argv[])
pthread_attr_t attr;
#endif
struct handle_data *arg;
#if HAVE_SIGACTION
struct sigaction act;
#endif
while (1)
{
@ -512,7 +515,6 @@ int main(int argc, char *argv[])
that will consequently fail with EPIPE. All child threads will
inherit this disposition which is what we want. */
#if HAVE_SIGACTION
struct sigaction act;
memset(&act, 0, sizeof act);
act.sa_handler = SIG_IGN;
act.sa_flags = SA_RESTART;

View File

@ -3191,6 +3191,7 @@ int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch)
int n;
int err;
int rl;
int retry;
char temp[5];
char *p;
@ -3206,7 +3207,7 @@ int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch)
priv = (struct ft1000d_priv_data *)rig->state.priv;
rig_s = &rig->state;
int retry = rig_s->rigport.retry;
retry = rig_s->rigport.retry;
do
{

View File

@ -1285,11 +1285,12 @@ int ft817_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
{
switch (op)
{
int n;
case RIG_OP_TOGGLE:
rig_force_cache_timeout(&((struct ft817_priv_data *)
rig->state.priv)->fm_status_tv);
int n = ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_VFOAB);
n = ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_VFOAB);
usleep(100 * 1000); // rig needs a little time to do this
return n;

View File

@ -519,9 +519,10 @@ int ft891_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
int ft891_init(RIG *rig)
{
int ret;
rig_debug(RIG_DEBUG_VERBOSE, "%s called, version %s\n", __func__,
rig->caps->version);
int ret = newcat_init(rig);
ret = newcat_init(rig);
if (ret != RIG_OK) { return ret; }

View File

@ -1505,6 +1505,7 @@ static int ft900_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
struct ft900_priv_data *priv;
unsigned char *p;
int err;
cal_table_t cal = FT900_STR_CAL_SMETER;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -1520,6 +1521,7 @@ static int ft900_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
switch (level)
{
case RIG_LEVEL_STRENGTH:
err = ft900_get_update_data(rig, FT900_NATIVE_READ_METER,
FT900_STATUS_FLAGS_LENGTH);
@ -1544,8 +1546,6 @@ static int ft900_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
* is life when mapping non-linear S-meters to a linear scale.
*
*/
cal_table_t cal = FT900_STR_CAL_SMETER;
if (priv->ptt)
{
cal = (cal_table_t)FT900_STR_CAL_POWER;

View File

@ -368,10 +368,12 @@ int ft991_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode,
int ft991_init(RIG *rig)
{
int ret;
rig_debug(RIG_DEBUG_VERBOSE, "%s called, version %s\n", __func__,
rig->caps->version);
int ret = newcat_init(rig);
ret = newcat_init(rig);
if (ret != RIG_OK) { return ret; }
rig->state.current_vfo = RIG_VFO_A;

View File

@ -287,11 +287,6 @@ int newcat_init(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
priv = (struct newcat_priv_data *) calloc(1, sizeof(struct newcat_priv_data));
if (!priv) /* whoops! memory shortage! */
@ -329,11 +324,6 @@ int newcat_cleanup(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
if (rig->state.priv)
{
free(rig->state.priv);
@ -354,18 +344,11 @@ int newcat_cleanup(RIG *rig)
int newcat_open(RIG *rig)
{
struct newcat_priv_data *priv = rig->state.priv;
struct rig_state *rig_s = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
struct newcat_priv_data *priv = rig->state.priv;
struct rig_state *rig_s = &rig->state;
rig_debug(RIG_DEBUG_TRACE, "%s: write_delay = %i msec\n",
__func__, rig_s->rigport.write_delay);
@ -397,15 +380,10 @@ int newcat_open(RIG *rig)
int newcat_close(RIG *rig)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
struct newcat_priv_data *priv = rig->state.priv;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!no_restore_ai && priv->trn_state >= 0)
{
/* restore AI state */
@ -426,12 +404,6 @@ int newcat_close(RIG *rig)
int newcat_set_conf(RIG *rig, token_t token, const char *val)
{
if (rig == NULL)
{
return -RIG_EARG;
}
int ret = RIG_OK;
struct newcat_priv_data *priv;
@ -444,9 +416,9 @@ int newcat_set_conf(RIG *rig, token_t token, const char *val)
switch (token)
{
case TOK_FAST_SET_CMD: ;
char *end;
long value;
case TOK_FAST_SET_CMD: ;
//using strtol because atoi can lead to undefined behaviour
value = strtol(val, &end, 10);
@ -482,12 +454,6 @@ int newcat_set_conf(RIG *rig, token_t token, const char *val)
int newcat_get_conf(RIG *rig, token_t token, char *val)
{
if (rig == NULL)
{
return -RIG_EARG;
}
int ret = RIG_OK;
struct newcat_priv_data *priv;
@ -530,10 +496,12 @@ int newcat_get_conf(RIG *rig, token_t token, char *val)
int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
char c;
char target_vfo;
int err;
const struct rig_caps *caps;
struct newcat_priv_data *priv;
char c;
int err;
int special_60m = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -572,7 +540,6 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
/* vfo should now be modified to a valid VFO constant. */
/* DX3000/DX5000 can only do VFO_MEM on 60M */
/* So we will not change freq in that case */
int special_60m = 0;
special_60m = newcat_is_rig(rig, RIG_MODEL_FTDX3000);
/* duplicate the following line to add more rigs */
special_60m |= newcat_is_rig(rig, RIG_MODEL_FTDX5000);
@ -602,7 +569,7 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
return -RIG_ENIMPL; /* Only VFO_A or VFO_B are valid */
}
char target_vfo = 'A' == c ? '0' : '1';
target_vfo = 'A' == c ? '0' : '1';
if (RIG_MODEL_FT450 == caps->rig_model)
{
@ -1160,7 +1127,7 @@ int newcat_get_vfo(RIG *rig, vfo_t *vfo)
vfo_t vfo_mode;
char const *command = "VS";
if (!rig || !vfo)
if (!vfo)
{
return -RIG_EINVAL;
}
@ -1628,6 +1595,7 @@ int newcat_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
char *retval;
char rit_on;
int err;
int offset = 0;
if (!newcat_valid_command(rig, "IF"))
{
@ -1650,7 +1618,6 @@ int newcat_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit)
// e.g. FT450 has 27 byte IF response, FT991 has 28 byte if response (one more byte for P2 VFO A Freq)
// so we now check to ensure we know the length of the response
int offset = 0;
switch (strlen(priv->ret_data))
{
@ -1726,6 +1693,7 @@ int newcat_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
char *retval;
char xit_on;
int err;
int offset = 0;
if (!newcat_valid_command(rig, "IF"))
{
@ -1748,7 +1716,6 @@ int newcat_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
// e.g. FT450 has 27 byte IF response, FT991 has 28 byte if response (one more byte for P2 VFO A Freq)
// so we now check to ensure we know the length of the response
int offset = 0;
switch (strlen(priv->ret_data))
{
@ -2557,11 +2524,6 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
/* Set Main or SUB vfo */
err = newcat_set_vfo_from_alias(rig, &vfo);
@ -3086,11 +3048,6 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
/* Set Main or SUB vfo */
err = newcat_set_vfo_from_alias(rig, &vfo);
@ -3548,11 +3505,6 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
/* Set Main or SUB vfo */
err = newcat_set_vfo_from_alias(rig, &vfo);
@ -3724,11 +3676,6 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
switch (func)
{
case RIG_FUNC_ANF:
@ -4126,11 +4073,6 @@ int newcat_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return -RIG_EINVAL;
}
/* Set Main or SUB vfo */
err = newcat_set_vfo_from_alias(rig, &vfo);
@ -4665,11 +4607,6 @@ const char *newcat_get_info(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!rig)
{
return NULL;
}
/* Build the command string */
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "ID;");
@ -4717,12 +4654,6 @@ ncboolean newcat_valid_command(RIG *rig, char const *const command)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
rig_debug(RIG_DEBUG_TRACE, "%s %s\n", __func__, command);
if (!rig)
{
rig_debug(RIG_DEBUG_ERR, "%s: Rig argument is invalid\n", __func__);
return FALSE;
}
caps = rig->caps;
if (!caps)
@ -6046,6 +5977,7 @@ int newcat_get_vfo_mode(RIG *rig, vfo_t *vfo_mode)
{
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
int err;
int offset = 0;
char command[] = "IF";
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -6066,8 +5998,6 @@ int newcat_get_vfo_mode(RIG *rig, vfo_t *vfo_mode)
/* vfo, mem, P7 ************************** */
// e.g. FT450 has 27 byte IF response, FT991 has 28 byte if response (one more byte for P2 VFO A Freq)
// so we now check to ensure we know the length of the response
int offset = 0;
switch (strlen(priv->ret_data))
{
case 27: offset = 21; priv->width_frequency = 8; break;