kopia lustrzana https://github.com/Hamlib/Hamlib
Fix some cppcheck warning in icom
rodzic
ab6a692192
commit
2e9129bd06
|
@ -166,6 +166,9 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
|
|||
Unhold_Decode(rig);
|
||||
return retval;
|
||||
}
|
||||
if (retval < 1) {
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
switch (buf[retval - 1])
|
||||
{
|
||||
|
@ -227,6 +230,9 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
|
|||
/* other error: return it */
|
||||
return frm_len;
|
||||
}
|
||||
if (frm_len < 1) {
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
switch (buf[frm_len - 1])
|
||||
{
|
||||
|
|
|
@ -905,9 +905,9 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan)
|
|||
{
|
||||
struct icom_priv_data *priv;
|
||||
struct rig_state *rs;
|
||||
unsigned char chanbuf[46], databuf[32];
|
||||
unsigned char chanbuf[46];
|
||||
mem_buf_t *membuf;
|
||||
int chan_len, freq_len, retval, data_len, sc, band;
|
||||
int chan_len, freq_len, retval, data_len;
|
||||
|
||||
rs = &rig->state;
|
||||
priv = (struct icom_priv_data *)rs->priv;
|
||||
|
@ -991,12 +991,14 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan)
|
|||
|
||||
/* offset is default for the band & is not stored in channel memory.
|
||||
The following retrieves the system default for the band */
|
||||
band = (int) chan->freq / 1000000; /* hf, 2m or 6 m */
|
||||
int band = (int) chan->freq / 1000000; /* hf, 2m or 6 m */
|
||||
|
||||
int sc;
|
||||
if (band < 50) { sc = S_MEM_HF_DUP_OFST; }
|
||||
else if (band < 108) { sc = S_MEM_6M_DUP_OFST; }
|
||||
else { sc = S_MEM_2M_DUP_OFST; }
|
||||
|
||||
unsigned char databuf[32];
|
||||
retval = icom_transaction(rig, C_CTL_MEM, sc,
|
||||
NULL, 0, databuf, &data_len);
|
||||
|
||||
|
|
|
@ -330,7 +330,6 @@ const struct rig_caps ic7800_caps =
|
|||
int ic7800_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||
{
|
||||
unsigned char cmdbuf[MAXFRAMELEN];
|
||||
int i;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
|
@ -340,6 +339,7 @@ int ic7800_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
if (val.i != 0)
|
||||
{
|
||||
/* Convert dB to index */
|
||||
int i;
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
if (val.i == rig->state.attenuator[i])
|
||||
|
|
47
icom/icom.c
47
icom/icom.c
|
@ -44,9 +44,9 @@
|
|||
// So we need to distinguish between them
|
||||
#define VFO_HAS_A_B ((rig->state.vfo_list & (RIG_VFO_A|RIG_VFO_B)) == (RIG_VFO_A|RIG_VFO_B))
|
||||
#define VFO_HAS_MAIN_SUB ((rig->state.vfo_list & (RIG_VFO_MAIN|RIG_VFO_SUB)) == (RIG_VFO_MAIN|RIG_VFO_SUB))
|
||||
#define VFO_HAS_MAIN_SUB_ONLY (!VFO_HAS_A_B & VFO_HAS_MAIN_SUB)
|
||||
#define VFO_HAS_MAIN_SUB_ONLY ((!VFO_HAS_A_B) & VFO_HAS_MAIN_SUB)
|
||||
#define VFO_HAS_MAIN_SUB_A_B_ONLY (VFO_HAS_A_B & VFO_HAS_MAIN_SUB)
|
||||
#define VFO_HAS_A_B_ONLY (VFO_HAS_A_B & !VFO_HAS_MAIN_SUB)
|
||||
#define VFO_HAS_A_B_ONLY (VFO_HAS_A_B & (!VFO_HAS_MAIN_SUB))
|
||||
|
||||
static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo);
|
||||
|
||||
|
@ -715,8 +715,6 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
// Newer Icoms can read main/sub frequency
|
||||
int cmd = C_RD_FREQ;
|
||||
int subcmd = -1;
|
||||
unsigned char data;
|
||||
int datalen = 0;
|
||||
|
||||
// Pick the appropriate VFO when VFO_TX is requested
|
||||
if (vfo == RIG_VFO_TX)
|
||||
|
@ -726,28 +724,28 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
|
||||
if (priv->split_on)
|
||||
{
|
||||
vfo = rig->state.vfo_list & RIG_VFO_B ? RIG_VFO_B : RIG_VFO_SUB;
|
||||
vfo = (rig->state.vfo_list & RIG_VFO_B) ? RIG_VFO_B : RIG_VFO_SUB;
|
||||
}
|
||||
else
|
||||
{
|
||||
vfo = rig->state.vfo_list & RIG_VFO_B ? RIG_VFO_A : RIG_VFO_MAIN;
|
||||
vfo = (rig->state.vfo_list & RIG_VFO_B) ? RIG_VFO_A : RIG_VFO_MAIN;
|
||||
}
|
||||
}
|
||||
|
||||
retval = set_vfo_curr(rig, vfo, priv->curr_vfo);
|
||||
if (retval != RIG_OK) { return retval; }
|
||||
|
||||
// Pick the appropriate VFO when VFO_RX is requested
|
||||
if (vfo == RIG_VFO_RX)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: VFO_RX requested, vfo=%s\n", __func__,
|
||||
rig_strvfo(vfo));
|
||||
vfo = rig->state.vfo_list & RIG_VFO_B ? RIG_VFO_A : RIG_VFO_MAIN;
|
||||
vfo = (rig->state.vfo_list & RIG_VFO_B) ? RIG_VFO_A : RIG_VFO_MAIN;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: using vfo=%s\n", __func__, rig_strvfo(vfo));
|
||||
|
||||
retval = icom_transaction(rig, cmd, subcmd, datalen == 0 ? NULL : &data,
|
||||
datalen, freqbuf, &freq_len);
|
||||
retval = icom_transaction(rig, cmd, subcmd, NULL, 0, freqbuf, &freq_len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
|
@ -995,9 +993,11 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef XXREMOVEDXX
|
||||
// not referenced anywhere
|
||||
int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width)
|
||||
{
|
||||
int retval, rfstatus, i;
|
||||
int retval, rfstatus;
|
||||
unsigned char ackbuf[MAXFRAMELEN];
|
||||
unsigned char flt_ext;
|
||||
value_t rfwidth;
|
||||
|
@ -1017,6 +1017,7 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width)
|
|||
{
|
||||
if (!rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_RF, &rfstatus) && (rfstatus))
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < RTTY_FIL_NB; i++)
|
||||
{
|
||||
if (rtty_fil[i] == width)
|
||||
|
@ -1071,6 +1072,7 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width)
|
|||
|
||||
return RIG_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* icom_set_mode_with_data
|
||||
|
@ -1393,6 +1395,8 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
#ifdef XXREMOVEDXX
|
||||
// not implemented yet
|
||||
/*
|
||||
* icom_get_vfo
|
||||
* The IC-9700 has introduced the ability to see MAIN/SUB selection
|
||||
|
@ -1425,6 +1429,7 @@ int icom_get_vfo(RIG *rig, vfo_t *vfo)
|
|||
*vfo = ackbuf[2] == 0 ? RIG_VFO_A : RIG_VFO_B;
|
||||
return RIG_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* icom_get_vfo
|
||||
|
@ -3995,14 +4000,14 @@ int icom_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
|
|||
const struct rig_caps *caps;
|
||||
unsigned char tonebuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN];
|
||||
int tone_len, ack_len = sizeof(ackbuf), retval;
|
||||
int i;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
caps = rig->caps;
|
||||
|
||||
if (caps->ctcss_list)
|
||||
{
|
||||
for (i = 0; caps->ctcss_list[i] != 0 && i < FULL_CTCSS_LIST_COUNT; i++)
|
||||
int i;
|
||||
for (i = 0; caps->ctcss_list[i] != 0; i++)
|
||||
{
|
||||
if (caps->ctcss_list[i] == tone)
|
||||
{
|
||||
|
@ -4075,7 +4080,7 @@ int icom_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
|
|||
if (!caps->ctcss_list) { return RIG_OK; }
|
||||
|
||||
/* check this tone exists. That's better than nothing. */
|
||||
for (i = 0; caps->ctcss_list[i] != 0 && i < FULL_CTCSS_LIST_COUNT; i++)
|
||||
for (i = 0; caps->ctcss_list[i] != 0; i++)
|
||||
{
|
||||
if (caps->ctcss_list[i] == *tone)
|
||||
{
|
||||
|
@ -4101,7 +4106,7 @@ int icom_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
|
|||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
caps = rig->caps;
|
||||
|
||||
for (i = 0; caps->ctcss_list[i] != 0 && i < FULL_CTCSS_LIST_COUNT; i++)
|
||||
for (i = 0; caps->ctcss_list[i] != 0; i++)
|
||||
{
|
||||
if (caps->ctcss_list[i] == tone)
|
||||
{
|
||||
|
@ -4170,7 +4175,7 @@ int icom_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
|
|||
*tone = from_bcd_be(tonebuf + 2, tone_len * 2);
|
||||
|
||||
/* check this tone exists. That's better than nothing. */
|
||||
for (i = 0; caps->ctcss_list[i] != 0 && i < FULL_CTCSS_LIST_COUNT; i++)
|
||||
for (i = 0; caps->ctcss_list[i] != 0; i++)
|
||||
{
|
||||
if (caps->ctcss_list[i] == *tone)
|
||||
{
|
||||
|
@ -4196,7 +4201,7 @@ int icom_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
|
|||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
caps = rig->caps;
|
||||
|
||||
for (i = 0; caps->dcs_list[i] != 0 && i < COMMON_DCS_LIST_COUNT; i++)
|
||||
for (i = 0; caps->dcs_list[i] != 0; i++)
|
||||
{
|
||||
if (caps->dcs_list[i] == code)
|
||||
{
|
||||
|
@ -4269,7 +4274,7 @@ int icom_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code)
|
|||
*code = from_bcd_be(codebuf + 3, code_len * 2);
|
||||
|
||||
/* check this code exists. That's better than nothing. */
|
||||
for (i = 0; caps->dcs_list[i] != 0 && i < COMMON_DCS_LIST_COUNT; i++)
|
||||
for (i = 0; caps->dcs_list[i] != 0; i++)
|
||||
{
|
||||
if (caps->dcs_list[i] == *code)
|
||||
{
|
||||
|
@ -4295,7 +4300,7 @@ int icom_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code)
|
|||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
caps = rig->caps;
|
||||
|
||||
for (i = 0; caps->dcs_list[i] != 0 && i < COMMON_DCS_LIST_COUNT; i++)
|
||||
for (i = 0; caps->dcs_list[i] != 0; i++)
|
||||
{
|
||||
if (caps->dcs_list[i] == code)
|
||||
{
|
||||
|
@ -4368,7 +4373,7 @@ int icom_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code)
|
|||
*code = from_bcd_be(codebuf + 3, code_len * 2);
|
||||
|
||||
/* check this code exists. That's better than nothing. */
|
||||
for (i = 0; caps->dcs_list[i] != 0 && i < COMMON_DCS_LIST_COUNT; i++)
|
||||
for (i = 0; caps->dcs_list[i] != 0; i++)
|
||||
{
|
||||
if (caps->dcs_list[i] == *code)
|
||||
{
|
||||
|
@ -5371,7 +5376,7 @@ DECLARE_PROBERIG_BACKEND(icom)
|
|||
/* read out the bytes we just sent
|
||||
* TODO: check this is what we expect
|
||||
*/
|
||||
frm_len = read_icom_frame(port, buf, sizeof(buf));
|
||||
read_icom_frame(port, buf, sizeof(buf));
|
||||
|
||||
/* this is the reply */
|
||||
frm_len = read_icom_frame(port, buf, sizeof(buf));
|
||||
|
@ -5445,7 +5450,7 @@ DECLARE_PROBERIG_BACKEND(icom)
|
|||
/* read out the bytes we just sent
|
||||
* TODO: check this is what we expect
|
||||
*/
|
||||
frm_len = read_icom_frame(port, buf, sizeof(buf));
|
||||
read_icom_frame(port, buf, sizeof(buf));
|
||||
|
||||
/* this is the reply */
|
||||
frm_len = read_icom_frame(port, buf, sizeof(buf));
|
||||
|
|
|
@ -245,7 +245,7 @@ int optoscan_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code)
|
|||
int optoscan_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length)
|
||||
{
|
||||
unsigned char dtmfbuf[MAXFRAMELEN], digit;
|
||||
int len, retval, digitpos;
|
||||
int len, digitpos;
|
||||
unsigned char xlate[] = {'0', '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', 'A', 'B', 'C', 'D',
|
||||
'*', '#'
|
||||
|
@ -254,7 +254,7 @@ int optoscan_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length)
|
|||
|
||||
do
|
||||
{
|
||||
retval = icom_transaction(rig, C_CTL_MISC, S_OPTO_RDDTMF,
|
||||
int retval = icom_transaction(rig, C_CTL_MISC, S_OPTO_RDDTMF,
|
||||
NULL, 0, dtmfbuf, &len);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
|
@ -271,7 +271,7 @@ int optoscan_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length)
|
|||
|
||||
digit = dtmfbuf[2];
|
||||
|
||||
if (digit < 0x16)
|
||||
if (digit < 16)
|
||||
{
|
||||
digits[digitpos] = xlate[digit];
|
||||
digitpos++;
|
||||
|
@ -495,15 +495,13 @@ int optoscan_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
{
|
||||
struct optostat status_block;
|
||||
unsigned char lvlbuf[MAXFRAMELEN];
|
||||
int lvl_len = 0;
|
||||
int lvl_cn, lvl_sc; /* Command Number, Subcommand */
|
||||
int icom_val;
|
||||
int cmdhead;
|
||||
int retval;
|
||||
|
||||
if (level != RIG_LEVEL_AF)
|
||||
{
|
||||
int lvl_cn, lvl_sc; /* Command Number, Subcommand */
|
||||
switch (level)
|
||||
{
|
||||
case RIG_LEVEL_RAWSTR:
|
||||
|
@ -516,6 +514,7 @@ 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);
|
||||
|
||||
|
@ -527,7 +526,7 @@ int optoscan_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
/*
|
||||
* strbuf should contain Cn,Sc,Data area
|
||||
*/
|
||||
cmdhead = (lvl_sc == -1) ? 1 : 2;
|
||||
int cmdhead = (lvl_sc == -1) ? 1 : 2;
|
||||
lvl_len -= cmdhead;
|
||||
|
||||
if (lvlbuf[0] != ACK && lvlbuf[0] != lvl_cn)
|
||||
|
|
Ładowanie…
Reference in New Issue