From ff8ddf018c6536cf7d3e9fcb42f020bd38742958 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Sun, 23 Feb 2020 11:26:09 -0600 Subject: [PATCH] astyle all C files --- amplifiers/elecraft/kpa.c | 2 +- dummy/amp_dummy.c | 2 +- dummy/dummy.c | 89 +++++---- dummy/flrig.c | 10 +- dummy/netrigctl.c | 46 +++-- dummy/rot_dummy.c | 2 +- dummy/trxmanager.c | 3 +- lib/termios.c | 2 +- rigs/aor/aor.c | 8 +- rigs/aor/ar5000.c | 1 + rigs/aor/ar7030p_utils.c | 3 +- rigs/aor/sr2200.c | 3 +- rigs/drake/drake.c | 5 +- rigs/elad/elad.c | 11 +- rigs/flexradio/dttsp.c | 13 +- rigs/flexradio/sdr1k.c | 3 +- rigs/icmarine/icm710.c | 3 +- rigs/icmarine/icmarine.c | 5 +- rigs/icom/frame.c | 7 +- rigs/icom/ic7100.c | 20 +- rigs/icom/ic7300.c | 106 +++++----- rigs/icom/ic746.c | 276 +++++++++++++++----------- rigs/icom/ic756.c | 13 +- rigs/icom/ic7600.c | 13 +- rigs/icom/ic7800.c | 1 + rigs/icom/ic785x.c | 4 +- rigs/icom/icom.c | 234 +++++++++++++++------- rigs/icom/icr30.c | 19 +- rigs/icom/icr8600.c | 22 +- rigs/icom/id51.c | 7 +- rigs/icom/id5100.c | 2 +- rigs/icom/optoscan.c | 2 +- rigs/kenwood/ic10.c | 10 +- rigs/kenwood/k3.c | 29 ++- rigs/kenwood/kenwood.c | 16 +- rigs/kenwood/pihpsdr.c | 2 +- rigs/kenwood/th.c | 22 +- rigs/kenwood/thg71.c | 2 +- rigs/kenwood/ts570.c | 3 +- rigs/kit/dds60.c | 3 +- rigs/kit/drt1.c | 3 +- rigs/kit/dwt.c | 3 +- rigs/kit/elektor304.c | 2 +- rigs/kit/elektor507.c | 8 +- rigs/kit/fifisdr.c | 2 +- rigs/kit/funcube.c | 6 +- rigs/kit/hiqsdr.c | 3 +- rigs/kit/si570avrusb.c | 17 +- rigs/lowe/lowe.c | 2 +- rigs/pcr/pcr.c | 1 + rigs/racal/ra37xx.c | 12 +- rigs/racal/racal.c | 3 +- rigs/rs/gp2000.c | 1 + rigs/tentec/jupiter.c | 6 +- rigs/tentec/omnivii.c | 4 +- rigs/tentec/orion.c | 7 +- rigs/tentec/paragon.c | 3 +- rigs/tentec/rx331.c | 6 +- rigs/tentec/tentec.c | 3 +- rigs/tentec/tt550.c | 3 +- rigs/winradio/g313-win.c | 3 +- rigs/winradio/winradio.c | 1 + rigs/yaesu/ft100.c | 3 +- rigs/yaesu/ft1000d.c | 6 +- rigs/yaesu/ft1000mp.c | 7 +- rigs/yaesu/ft600.c | 3 +- rigs/yaesu/ft736.c | 4 +- rigs/yaesu/ft747.c | 3 +- rigs/yaesu/ft757gx.c | 6 +- rigs/yaesu/ft767gx.c | 13 +- rigs/yaesu/ft817.c | 26 ++- rigs/yaesu/ft840.c | 4 +- rigs/yaesu/ft847.c | 7 +- rigs/yaesu/ft857.c | 24 ++- rigs/yaesu/ft890.c | 12 +- rigs/yaesu/ft897.c | 3 +- rigs/yaesu/ft900.c | 12 +- rigs/yaesu/ft920.c | 4 +- rigs/yaesu/ft980.c | 4 +- rigs/yaesu/ft990.c | 6 +- rigs/yaesu/ft991.c | 22 +- rigs/yaesu/newcat.c | 34 ++-- rigs/yaesu/vr5000.c | 3 +- rigs/yaesu/vx1700.c | 1 + rotators/gs232a/gs232.c | 2 +- rotators/heathkit/hd1780.c | 2 +- rotators/m2/rc2800.c | 1 + rotators/meade/meade.c | 4 +- rotators/prosistel/prosistel.c | 2 +- rotators/rotorez/rotorez.c | 4 +- rotators/ts7400/include/readADC.c | 1 + rotators/ts7400/include/test7400ADC.c | 1 + rotators/ts7400/ts7400.c | 2 +- src/conf.c | 1 + src/debug.c | 1 + src/mem.c | 3 +- src/microham.c | 4 + src/misc.c | 13 +- src/network.c | 2 +- src/rig.c | 60 ++++-- src/settings.c | 12 +- src/usb_port.c | 2 +- tests/ampctl_parse.c | 5 +- tests/ampctld.c | 2 +- tests/dumpcaps.c | 23 ++- tests/example.c | 25 ++- tests/rigctl.c | 18 +- tests/rigctl_parse.c | 32 +-- tests/rigctlcom.c | 42 ++-- tests/rigmem.c | 4 + tests/rotctl_parse.c | 6 +- tests/rotctld.c | 2 +- tests/sprintflst.c | 33 +-- 113 files changed, 1029 insertions(+), 610 deletions(-) diff --git a/amplifiers/elecraft/kpa.c b/amplifiers/elecraft/kpa.c index 42a2cb03d..50ee44446 100644 --- a/amplifiers/elecraft/kpa.c +++ b/amplifiers/elecraft/kpa.c @@ -67,7 +67,7 @@ int kpa_init(AMP *amp) } amp->state.priv = (struct kpa_priv_data *) - malloc(sizeof(struct kpa_priv_data)); + malloc(sizeof(struct kpa_priv_data)); if (!amp->state.priv) { diff --git a/dummy/amp_dummy.c b/dummy/amp_dummy.c index 5372a4390..07b168348 100644 --- a/dummy/amp_dummy.c +++ b/dummy/amp_dummy.c @@ -63,7 +63,7 @@ static int dummy_amp_init(AMP *amp) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); amp->state.priv = (struct dummy_amp_priv_data *) - malloc(sizeof(struct dummy_amp_priv_data)); + malloc(sizeof(struct dummy_amp_priv_data)); if (!amp->state.priv) { diff --git a/dummy/dummy.c b/dummy/dummy.c index 015ad7fc1..83ece3ac5 100644 --- a/dummy/dummy.c +++ b/dummy/dummy.c @@ -510,45 +510,53 @@ static int dummy_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) case RIG_PTT_SERIAL_DTR: if (rig->state.pttport.fd >= 0) { - if (RIG_OK != (rc = ser_get_dtr(&rig->state.pttport, &status))) return rc; + if (RIG_OK != (rc = ser_get_dtr(&rig->state.pttport, &status))) { return rc; } + *ptt = status ? RIG_PTT_ON : RIG_PTT_OFF; } + break; case RIG_PTT_SERIAL_RTS: if (rig->state.pttport.fd >= 0) { - if (RIG_OK != (rc = ser_get_rts(&rig->state.pttport, &status))) return rc; + if (RIG_OK != (rc = ser_get_rts(&rig->state.pttport, &status))) { return rc; } + *ptt = status ? RIG_PTT_ON : RIG_PTT_OFF; } + break; case RIG_PTT_PARALLEL: if (rig->state.pttport.fd >= 0) { - if (RIG_OK != (rc = par_ptt_get(&rig->state.pttport, ptt))) return rc; + if (RIG_OK != (rc = par_ptt_get(&rig->state.pttport, ptt))) { return rc; } } + break; case RIG_PTT_CM108: if (rig->state.pttport.fd >= 0) { - if (RIG_OK != (rc = cm108_ptt_get(&rig->state.pttport, ptt))) return rc; + if (RIG_OK != (rc = cm108_ptt_get(&rig->state.pttport, ptt))) { return rc; } } + break; case RIG_PTT_GPIO: case RIG_PTT_GPION: if (rig->state.pttport.fd >= 0) { - if (RIG_OK != (rc = gpio_ptt_get(&rig->state.pttport, ptt))) return rc; + if (RIG_OK != (rc = gpio_ptt_get(&rig->state.pttport, ptt))) { return rc; } } + break; default: *ptt = priv->ptt; break; } + return RIG_OK; } @@ -1338,28 +1346,35 @@ static int dummy_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; channel_t *curr = priv->curr; - switch(ant) { - case RIG_ANT_CURR: - break; - case RIG_ANT_1: - case RIG_ANT_2: - case RIG_ANT_3: - case RIG_ANT_4: - curr->ant = ant; - break; - default: - rig_debug(RIG_DEBUG_ERR,"%s: unknown antenna requested=0x%02x\n",__func__, ant); - return -RIG_EINVAL; + switch (ant) + { + case RIG_ANT_CURR: + break; + + case RIG_ANT_1: + case RIG_ANT_2: + case RIG_ANT_3: + case RIG_ANT_4: + curr->ant = ant; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown antenna requested=0x%02x\n", __func__, + ant); + return -RIG_EINVAL; } priv->ant_option[rig_setting2idx(curr->ant)] = option.i; - rig_debug(RIG_DEBUG_VERBOSE, "%s called ant=0x%02x, option=%d, curr->ant=0x%02x\n", __func__, ant, option.i, curr->ant); + rig_debug(RIG_DEBUG_VERBOSE, + "%s called ant=0x%02x, option=%d, curr->ant=0x%02x\n", __func__, ant, option.i, + curr->ant); return RIG_OK; } -static int dummy_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +static int dummy_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; channel_t *curr = priv->curr; @@ -1367,22 +1382,28 @@ static int dummy_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, ant_t rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x\n", __func__, ant); *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; - - switch(ant) { - case RIG_ANT_CURR: - *ant_curr = curr->ant; - break; - case RIG_ANT_1: - case RIG_ANT_2: - case RIG_ANT_3: - case RIG_ANT_4: - *ant_curr = ant; - break; - default: - rig_debug(RIG_DEBUG_ERR,"%s: unknown antenna requested=0x%02x\n",__func__, ant); - return -RIG_EINVAL; + + switch (ant) + { + case RIG_ANT_CURR: + *ant_curr = curr->ant; + break; + + case RIG_ANT_1: + case RIG_ANT_2: + case RIG_ANT_3: + case RIG_ANT_4: + *ant_curr = ant; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown antenna requested=0x%02x\n", __func__, + ant); + return -RIG_EINVAL; } - rig_debug(RIG_DEBUG_TRACE,"%s: ant_curr=0x%02x, idx=%d\n",__func__, *ant_curr, rig_setting2idx(*ant_curr)); + + rig_debug(RIG_DEBUG_TRACE, "%s: ant_curr=0x%02x, idx=%d\n", __func__, *ant_curr, + rig_setting2idx(*ant_curr)); option->i = priv->ant_option[rig_setting2idx(*ant_curr)]; return RIG_OK; diff --git a/dummy/flrig.c b/dummy/flrig.c index b59186629..5315dd7a9 100644 --- a/dummy/flrig.c +++ b/dummy/flrig.c @@ -503,7 +503,7 @@ static int flrig_init(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER); rig->state.priv = (struct flrig_priv_data *)malloc(sizeof( - struct flrig_priv_data)); + struct flrig_priv_data)); if (!rig->state.priv) { @@ -890,10 +890,10 @@ static int flrig_cleanup(RIG *rig) for (i = 0; modeMap[i].mode_hamlib != 0; ++i) { - if (modeMap[i].mode_flrig) - { - free(modeMap[i].mode_flrig); - modeMap[i].mode_flrig = NULL; + if (modeMap[i].mode_flrig) + { + free(modeMap[i].mode_flrig); + modeMap[i].mode_flrig = NULL; } } diff --git a/dummy/netrigctl.c b/dummy/netrigctl.c index 35cc0d280..db6d3c0cb 100644 --- a/dummy/netrigctl.c +++ b/dummy/netrigctl.c @@ -1738,15 +1738,22 @@ static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) char vfostr[6] = ""; int i_ant = 0; - rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x, option=%d\n", __func__, ant, option.i); + rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x, option=%d\n", __func__, + ant, option.i); - switch(ant) { - case RIG_ANT_1: i_ant = 0; break; - case RIG_ANT_2: i_ant = 1; break; - case RIG_ANT_3: i_ant = 2; break; - case RIG_ANT_4: i_ant = 3; break; - default: - rig_debug(RIG_DEBUG_ERR,"%s: more than 4 antennas? ant=0x%02x\n", __func__, ant); + switch (ant) + { + case RIG_ANT_1: i_ant = 0; break; + + case RIG_ANT_2: i_ant = 1; break; + + case RIG_ANT_3: i_ant = 2; break; + + case RIG_ANT_4: i_ant = 3; break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: more than 4 antennas? ant=0x%02x\n", __func__, + ant); } ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo); @@ -1768,7 +1775,8 @@ static int netrigctl_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) } -static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { int ret, len; char cmd[CMD_MAX]; @@ -1783,10 +1791,12 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, an if (ret != RIG_OK) { return ret; } - if (ant == RIG_ANT_CURR) { + if (ant == RIG_ANT_CURR) + { len = sprintf(cmd, "y%s\n", vfostr); } - else { + else + { len = sprintf(cmd, "y%s %d\n", vfostr, ant); } @@ -1802,17 +1812,20 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, an if (ret != 1) { - rig_debug(RIG_DEBUG_ERR, "%s: expected 1 ant integer in '%s', got %d\n", __func__, buf, + rig_debug(RIG_DEBUG_ERR, "%s: expected 1 ant integer in '%s', got %d\n", + __func__, buf, ret); } - if (ant != RIG_ANT_CURR) { + if (ant != RIG_ANT_CURR) + { ret = sscanf(buf, "%d\n", &option->i); } if (ret != 1) { - rig_debug(RIG_DEBUG_ERR, "%s: expected 1 option integer in '%s', got %d\n", __func__, buf, + rig_debug(RIG_DEBUG_ERR, "%s: expected 1 option integer in '%s', got %d\n", + __func__, buf, ret); } @@ -1823,11 +1836,12 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, an return (ret < 0) ? ret : -RIG_EPROTO; } - ret = sscanf(buf, "%d\n",&(option->i)); + ret = sscanf(buf, "%d\n", &(option->i)); if (ret != 1) { - rig_debug(RIG_DEBUG_ERR, "%s: expected 1 option integer in '%s', got %d\n", __func__, buf, + rig_debug(RIG_DEBUG_ERR, "%s: expected 1 option integer in '%s', got %d\n", + __func__, buf, ret); } diff --git a/dummy/rot_dummy.c b/dummy/rot_dummy.c index c8f13d106..a50b7261a 100644 --- a/dummy/rot_dummy.c +++ b/dummy/rot_dummy.c @@ -56,7 +56,7 @@ static int dummy_rot_init(ROT *rot) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rot->state.priv = (struct dummy_rot_priv_data *) - malloc(sizeof(struct dummy_rot_priv_data)); + malloc(sizeof(struct dummy_rot_priv_data)); if (!rot->state.priv) { diff --git a/dummy/trxmanager.c b/dummy/trxmanager.c index c1a64c05a..70e40042b 100644 --- a/dummy/trxmanager.c +++ b/dummy/trxmanager.c @@ -265,7 +265,8 @@ static int trxmanager_init(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, BACKEND_VER); rig->state.priv = (struct trxmanager_priv_data *)malloc( - sizeof(struct trxmanager_priv_data)); + sizeof(struct trxmanager_priv_data)); + if (!rig->state.priv) { return -RIG_ENOMEM; diff --git a/lib/termios.c b/lib/termios.c index 1d24392b8..ac5ccb31e 100644 --- a/lib/termios.c +++ b/lib/termios.c @@ -1404,7 +1404,7 @@ int win32_serial_open(const char *filename, int flags, ...) } else { - strncpy(fullfilename, filename, sizeof(fullfilename)-1); + strncpy(fullfilename, filename, sizeof(fullfilename) - 1); } if (port_opened(fullfilename)) diff --git a/rigs/aor/aor.c b/rigs/aor/aor.c index 3334bc8f5..3e59d3a10 100644 --- a/rigs/aor/aor.c +++ b/rigs/aor/aor.c @@ -461,13 +461,16 @@ int aor_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) mdbuf2_len = strlen(mdbuf2); retval = aor_transaction(rig, mdbuf2, mdbuf2_len, NULL, NULL); + if (retval != RIG_OK) { return retval; } strncpy(mdbuf2, mdbuf + 4, 3); /* Extract first 'BW' part */ mdbuf2_len = strlen(mdbuf2); retval = aor_transaction(rig, mdbuf2, mdbuf2_len, NULL, NULL); + if (retval != RIG_OK) { return retval; } + break; default: @@ -625,6 +628,7 @@ int aor_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) unsigned att = 0; unsigned i; + for (i = 0; i < MAXDBLSTSIZ && !RIG_IS_DBLST_END(rs->attenuator[i]); i++) { if (rs->attenuator[i] == val.i) @@ -1262,6 +1266,7 @@ int aor_get_channel(RIG *rig, channel_t *chan) * find mem_caps in caps, we'll need it later */ int i; + for (i = 0; i < CHANLSTSIZ && !RIG_IS_CHAN_END(chan_list[i]); i++) { if (channel_num >= chan_list[i].startc && @@ -1284,6 +1289,7 @@ int aor_get_channel(RIG *rig, channel_t *chan) * and sizing memorized. */ mem_num = channel_num % 100; + if (mem_num >= 50 && priv->bank_base1 != priv->bank_base2) { bank_base = priv->bank_base2; @@ -1440,7 +1446,7 @@ const char *aor_get_info(RIG *rig) return NULL; } - if (retval > 2) idbuf[2] = '\0'; + if (retval > 2) { idbuf[2] = '\0'; } retval = aor_transaction(rig, "VR" EOM, 3, frmbuf, &frm_len); diff --git a/rigs/aor/ar5000.c b/rigs/aor/ar5000.c index c8ad9e5ed..6377596cd 100644 --- a/rigs/aor/ar5000.c +++ b/rigs/aor/ar5000.c @@ -432,6 +432,7 @@ int format5k_mode(RIG *rig, char *buf, rmode_t mode, pbwidth_t width) if (width != RIG_PASSBAND_NOCHANGE) { int aorwidth; + if (width == RIG_PASSBAND_NORMAL) { width = rig_passband_normal(rig, mode); diff --git a/rigs/aor/ar7030p_utils.c b/rigs/aor/ar7030p_utils.c index 418f44efc..702099b2b 100644 --- a/rigs/aor/ar7030p_utils.c +++ b/rigs/aor/ar7030p_utils.c @@ -428,7 +428,7 @@ int execRoutine(RIG *rig, enum ROUTINE_e rtn) */ static int setAddr(RIG *rig, enum PAGE_e page, unsigned int addr) { - int rc=RIG_OK; + int rc = RIG_OK; unsigned char v; assert(NULL != rig); @@ -459,6 +459,7 @@ static int setAddr(RIG *rig, enum PAGE_e page, unsigned int addr) v = SRH((0x0f0 & addr) >> 4); rc = write_block(&rig->state.rigport, (char *) &v, 1); + if (rc != RIG_OK) { return -RIG_EIO; diff --git a/rigs/aor/sr2200.c b/rigs/aor/sr2200.c index ce13e77b7..771e90a0a 100644 --- a/rigs/aor/sr2200.c +++ b/rigs/aor/sr2200.c @@ -729,7 +729,8 @@ int sr2200_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) switch (level) { - float tmp; + float tmp; + case RIG_LEVEL_STRENGTH: if (ack_len < 7 || ackbuf[0] != 'L' || ackbuf[1] != 'B') { diff --git a/rigs/drake/drake.c b/rigs/drake/drake.c index 44c6c26d2..f7aa4502b 100644 --- a/rigs/drake/drake.c +++ b/rigs/drake/drake.c @@ -110,6 +110,7 @@ int drake_init(RIG *rig) { return -RIG_ENOMEM; } + priv = rig->state.priv; priv->curr_ch = 0; @@ -504,7 +505,8 @@ int drake_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) * drake_get_ant * Assumes rig!=NULL */ -int drake_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int drake_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { int mdbuf_len, retval; char mdbuf[BUFSZ]; @@ -543,6 +545,7 @@ int drake_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_ *ant_curr = RIG_ANT_UNKNOWN; return -RIG_EINVAL; } + return RIG_OK; } diff --git a/rigs/elad/elad.c b/rigs/elad/elad.c index b4397f7ea..e7e7c045a 100644 --- a/rigs/elad/elad.c +++ b/rigs/elad/elad.c @@ -530,6 +530,7 @@ int elad_init(RIG *rig) { return -RIG_ENOMEM; } + priv = rig->state.priv; memset(priv, 0x00, sizeof(struct elad_priv_data)); @@ -1110,8 +1111,8 @@ int elad_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, vfo_t *txvfo) /* find where is the txvfo.. */ /* Elecraft info[30] does not track split VFO when transmitting */ transmitting = '1' == priv->info[28] - && RIG_MODEL_K2 != rig->caps->rig_model - && RIG_MODEL_K3 != rig->caps->rig_model; + && RIG_MODEL_K2 != rig->caps->rig_model + && RIG_MODEL_K3 != rig->caps->rig_model; switch (priv->info[30]) { @@ -2028,7 +2029,7 @@ int get_elad_level(RIG *rig, const char *cmd, float *f) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if ( !f ) + if (!f) { return -RIG_EINVAL; } @@ -2875,7 +2876,8 @@ int elad_set_ant_no_ack(RIG *rig, vfo_t vfo, ant_t ant) /* * get the aerial/antenna in use */ -int elad_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int elad_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { char ackbuf[8]; int offs; @@ -3167,6 +3169,7 @@ int elad_send_morse(RIG *rig, vfo_t vfo, const char *msg) while (msg_len > 0) { int buff_len; + /* * Check with "KY" if char buffer is available. * if not, sleep. diff --git a/rigs/flexradio/dttsp.c b/rigs/flexradio/dttsp.c index 29d2fc9fb..47fe510ae 100644 --- a/rigs/flexradio/dttsp.c +++ b/rigs/flexradio/dttsp.c @@ -378,11 +378,15 @@ static int fetch_meter(RIG *rig, int *label, float *data, int npts) } buf_len = sizeof(float) * npts; - if (sizeof(float)!=4) { - rig_debug(RIG_DEBUG_ERR,"%s: sizeof(float)!=4, instead = %d\n",__func__, (int)sizeof(float)); + + if (sizeof(float) != 4) + { + rig_debug(RIG_DEBUG_ERR, "%s: sizeof(float)!=4, instead = %d\n", __func__, + (int)sizeof(float)); return -RIG_EINTERNAL; } - ret = read_block(&priv->meter_port, (char *)(void*)data, buf_len); + + ret = read_block(&priv->meter_port, (char *)(void *)data, buf_len); if (ret != buf_len) { @@ -483,7 +487,8 @@ int dttsp_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rig->state.priv = (struct dttsp_priv_data *)calloc(1, sizeof(struct dttsp_priv_data)); + rig->state.priv = (struct dttsp_priv_data *)calloc(1, + sizeof(struct dttsp_priv_data)); if (!rig->state.priv) { diff --git a/rigs/flexradio/sdr1k.c b/rigs/flexradio/sdr1k.c index de70dd6aa..3c527e0fb 100644 --- a/rigs/flexradio/sdr1k.c +++ b/rigs/flexradio/sdr1k.c @@ -199,7 +199,8 @@ int sdr1k_init(RIG *rig) { struct sdr1k_priv_data *priv; - rig->state.priv = (struct sdr1k_priv_data *)malloc(sizeof(struct sdr1k_priv_data)); + rig->state.priv = (struct sdr1k_priv_data *)malloc(sizeof( + struct sdr1k_priv_data)); if (!rig->state.priv) { diff --git a/rigs/icmarine/icm710.c b/rigs/icmarine/icm710.c index 077ea022a..d0bd2d091 100644 --- a/rigs/icmarine/icm710.c +++ b/rigs/icmarine/icm710.c @@ -276,7 +276,8 @@ int icm710_init(RIG *rig) priv_caps = (const struct icm710_priv_caps *) caps->priv; - rig->state.priv = (struct icm710_priv_data *)calloc(1, sizeof(struct icm710_priv_data)); + rig->state.priv = (struct icm710_priv_data *)calloc(1, + sizeof(struct icm710_priv_data)); if (!rig->state.priv) { diff --git a/rigs/icmarine/icmarine.c b/rigs/icmarine/icmarine.c index 81d93e79b..2f1ac7247 100644 --- a/rigs/icmarine/icmarine.c +++ b/rigs/icmarine/icmarine.c @@ -136,7 +136,8 @@ int icmarine_init(RIG *rig) priv_caps = (const struct icmarine_priv_caps *) caps->priv; - rig->state.priv = (struct icmarine_priv_data *)malloc(sizeof(struct icmarine_priv_data)); + rig->state.priv = (struct icmarine_priv_data *)malloc(sizeof( + struct icmarine_priv_data)); if (!rig->state.priv) { @@ -578,7 +579,7 @@ int icmarine_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) rig_debug(RIG_DEBUG_TRACE, "%s:\n", __func__); retval = icmarine_transaction(rig, CMD_PTT, - ptt == RIG_PTT_ON ? "TX" : "RX", NULL); + ptt == RIG_PTT_ON ? "TX" : "RX", NULL); if (retval != RIG_OK) { diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c index 78fa2b36d..896ff7587 100644 --- a/rigs/icom/frame.c +++ b/rigs/icom/frame.c @@ -307,7 +307,8 @@ int icom_transaction(RIG *rig, int cmd, int subcmd, { break; } - hl_usleep(500*1000); // pause a half second + + hl_usleep(500 * 1000); // pause a half second } while (retry-- > 0); @@ -563,8 +564,8 @@ void icom2rig_mode(RIG *rig, unsigned char md, int pd, rmode_t *mode, depending on mode */ if (pd >= 0 && (rig->caps->rig_model == RIG_MODEL_IC706MKIIG || - rig->caps->rig_model == RIG_MODEL_IC706 || - rig->caps->rig_model == RIG_MODEL_IC706MKII)) { pd++; } + rig->caps->rig_model == RIG_MODEL_IC706 || + rig->caps->rig_model == RIG_MODEL_IC706MKII)) { pd++; } switch (pd) { diff --git a/rigs/icom/ic7100.c b/rigs/icom/ic7100.c index 33d83cce9..b95abd7cd 100644 --- a/rigs/icom/ic7100.c +++ b/rigs/icom/ic7100.c @@ -102,16 +102,18 @@ #define IC7100_PARM_ALL (RIG_PARM_ANN|RIG_PARM_BACKLIGHT|RIG_PARM_KEYLIGHT|RIG_PARM_BEEP|RIG_PARM_TIME) int ic7100_tokens[] = { TOK_DSTAR_CODE, TOK_DSTAR_DSQL, TOK_DSTAR_CALL_SIGN, TOK_DSTAR_MESSAGE, - TOK_DSTAR_STATUS, TOK_DSTAR_MY_CS, TOK_DSTAR_TX_CS, TOK_DSTAR_TX_MESS, - TOK_BACKEND_NONE }; + TOK_DSTAR_STATUS, TOK_DSTAR_MY_CS, TOK_DSTAR_TX_CS, TOK_DSTAR_TX_MESS, + TOK_BACKEND_NONE + }; -struct cmdparams ic7100_extcmds[] = { - { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x03}, CMD_DAT_BOL, 1 }, - { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x04}, CMD_DAT_LVL, 2 }, - { {.s=RIG_PARM_KEYLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x05}, CMD_DAT_LVL, 2 }, - { {.s=RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x21}, CMD_DAT_TIM, 2 }, - { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x65}, CMD_DAT_INT, 1 }, - { {.s=RIG_PARM_NONE} } +struct cmdparams ic7100_extcmds[] = +{ + { {.s = RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x03}, CMD_DAT_BOL, 1 }, + { {.s = RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x04}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_KEYLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x05}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x21}, CMD_DAT_TIM, 2 }, + { {.s = RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x65}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_NONE} } }; // IC-7100 S-meter calibration data based on manual diff --git a/rigs/icom/ic7300.c b/rigs/icom/ic7300.c index 868eac76c..14cf852ca 100644 --- a/rigs/icom/ic7300.c +++ b/rigs/icom/ic7300.c @@ -57,12 +57,13 @@ #define IC7300_ANTS (RIG_ANT_1) /* ant-1 is Hf-6m */ -struct cmdparams ic7300_extcmds[] = { - { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x23}, CMD_DAT_BOL, 1 }, - { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x81}, CMD_DAT_LVL, 2 }, - { {.s=RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x95}, CMD_DAT_TIM, 2 }, - { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x91}, CMD_DAT_INT, 1 }, - { {.s=RIG_PARM_NONE} } +struct cmdparams ic7300_extcmds[] = +{ + { {.s = RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x23}, CMD_DAT_BOL, 1 }, + { {.s = RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x81}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x95}, CMD_DAT_TIM, 2 }, + { {.s = RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x91}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_NONE} } }; /* @@ -135,12 +136,13 @@ struct cmdparams ic7300_extcmds[] = { #define IC9700_ALL_TX_MODES (RIG_MODE_FM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_DSTAR|RIG_MODE_DD|RIG_MODE_DSTAR) #define IC9700_ALL_RX_MODES (RIG_MODE_FM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_DSTAR|RIG_MODE_DD|RIG_MODE_DSTAR) -struct cmdparams ic9700_extcmds[] = { - { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x29}, CMD_DAT_BOL, 1 }, - { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x52}, CMD_DAT_LVL, 2 }, - { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x03, 0x30}, CMD_DAT_INT, 1 }, - { {.s=RIG_PARM_SCREENSAVER}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x67}, CMD_DAT_INT, 1 }, - { {.s=RIG_PARM_NONE} } +struct cmdparams ic9700_extcmds[] = +{ + { {.s = RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x29}, CMD_DAT_BOL, 1 }, + { {.s = RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x52}, CMD_DAT_LVL, 2 }, + { {.s = RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x03, 0x30}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_SCREENSAVER}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x67}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_NONE} } }; #define IC9700_STR_CAL { 7, \ @@ -470,20 +472,20 @@ const struct rig_caps ic9700_caps = }, // Hopefully any future changes in bandplans can be fixed with firmware updates - // So we use the global REGION2 macros in here + // So we use the global REGION2 macros in here .rx_range_list1 = { // USA Version {MHz(144), MHz(148), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "USA"}, {MHz(430), MHz(450), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "USA"}, {MHz(1240), MHz(1300), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "USA"}, - RIG_FRNG_END, + RIG_FRNG_END, }, .tx_range_list1 = { - {MHz(144),MHz(148),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(100), IC9700_VFOS, RIG_ANT_CURR, "USA"}, - {MHz(430),MHz(450),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "USA"}, - {MHz(1240),MHz(1300),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "USA"}, - {MHz(144),MHz(148),RIG_MODE_AM, W(0.125), W(25), IC9700_VFOS, RIG_ANT_CURR, "USA"}, - {MHz(430),MHz(450),RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "USA"}, - {MHz(1240),MHz(1300),RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "USA"}, + {MHz(144), MHz(148), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(100), IC9700_VFOS, RIG_ANT_CURR, "USA"}, + {MHz(430), MHz(450), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "USA"}, + {MHz(1240), MHz(1300), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "USA"}, + {MHz(144), MHz(148), RIG_MODE_AM, W(0.125), W(25), IC9700_VFOS, RIG_ANT_CURR, "USA"}, + {MHz(430), MHz(450), RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "USA"}, + {MHz(1240), MHz(1300), RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "USA"}, RIG_FRNG_END, }, @@ -491,15 +493,15 @@ const struct rig_caps ic9700_caps = {MHz(144), MHz(146), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "EUR"}, {MHz(430), MHz(440), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "EUR"}, {MHz(1240), MHz(1300), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "EUR"}, - RIG_FRNG_END, + RIG_FRNG_END, }, .tx_range_list2 = { - {MHz(144),MHz(146),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(100), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, - {MHz(430),MHz(440),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, - {MHz(1240),MHz(1300),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, - {MHz(144),MHz(146),RIG_MODE_AM, W(0.125), W(25), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, - {MHz(430),MHz(440),RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, - {MHz(1240),MHz(1300),RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, + {MHz(144), MHz(146), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(100), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, + {MHz(430), MHz(440), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, + {MHz(1240), MHz(1300), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, + {MHz(144), MHz(146), RIG_MODE_AM, W(0.125), W(25), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, + {MHz(430), MHz(440), RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, + {MHz(1240), MHz(1300), RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "EUR"}, RIG_FRNG_END, }, @@ -509,19 +511,19 @@ const struct rig_caps ic9700_caps = {MHz(435), MHz(438), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "ITR"}, {MHz(1240), MHz(1245), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "ITR"}, {MHz(1270), MHz(1298), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "ITR"}, - RIG_FRNG_END, + RIG_FRNG_END, }, .tx_range_list3 = { - {MHz(144),MHz(146),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(100), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, - {MHz(430),MHz(434),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, - {MHz(435),MHz(438),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, - {MHz(1240),MHz(1245),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, - {MHz(1270),MHz(1298),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, - {MHz(144),MHz(146),RIG_MODE_AM, W(0.125), W(25), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, - {MHz(430),MHz(434),RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, - {MHz(435),MHz(438),RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, - {MHz(1240),MHz(1245),RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, - {MHz(1270),MHz(1298),RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, + {MHz(144), MHz(146), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(100), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, + {MHz(430), MHz(434), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, + {MHz(435), MHz(438), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, + {MHz(1240), MHz(1245), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, + {MHz(1270), MHz(1298), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, + {MHz(144), MHz(146), RIG_MODE_AM, W(0.125), W(25), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, + {MHz(430), MHz(434), RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, + {MHz(435), MHz(438), RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, + {MHz(1240), MHz(1245), RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, + {MHz(1270), MHz(1298), RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "ITR"}, RIG_FRNG_END, }, @@ -529,15 +531,15 @@ const struct rig_caps ic9700_caps = {MHz(144), MHz(146), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "TPE"}, {MHz(430), MHz(432), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "TPE"}, {MHz(1260), MHz(1265), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "TPE"}, - RIG_FRNG_END, + RIG_FRNG_END, }, .tx_range_list4 = { - {MHz(144),MHz(146),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(100), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, - {MHz(430),MHz(432),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, - {MHz(1260),MHz(1265),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, - {MHz(144),MHz(146),RIG_MODE_AM, W(0.125), W(25), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, - {MHz(430),MHz(432),RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, - {MHz(1260),MHz(1265),RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, + {MHz(144), MHz(146), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(100), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, + {MHz(430), MHz(432), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, + {MHz(1260), MHz(1265), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, + {MHz(144), MHz(146), RIG_MODE_AM, W(0.125), W(25), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, + {MHz(430), MHz(432), RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, + {MHz(1260), MHz(1265), RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "TPE"}, RIG_FRNG_END, }, @@ -545,15 +547,15 @@ const struct rig_caps ic9700_caps = {MHz(144), MHz(146), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "KOR"}, {MHz(430), MHz(440), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "KOR"}, {MHz(1260), MHz(1300), IC9700_ALL_RX_MODES, -1, -1, IC9700_VFOS, RIG_ANT_CURR, "KOR"}, - RIG_FRNG_END, + RIG_FRNG_END, }, .tx_range_list5 = { - {MHz(144),MHz(146),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(100), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, - {MHz(430),MHz(440),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, - {MHz(1260),MHz(1300),IC9700_ALL_TX_MODES^RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, - {MHz(144),MHz(146),RIG_MODE_AM, W(0.125), W(25), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, - {MHz(430),MHz(440),RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, - {MHz(1260),MHz(1300),RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, + {MHz(144), MHz(146), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(100), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, + {MHz(430), MHz(440), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.5), W(75), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, + {MHz(1260), MHz(1300), IC9700_ALL_TX_MODES ^ RIG_MODE_AM, W(0.1), W(10), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, + {MHz(144), MHz(146), RIG_MODE_AM, W(0.125), W(25), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, + {MHz(430), MHz(440), RIG_MODE_AM, W(0.125), W(18.75), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, + {MHz(1260), MHz(1300), RIG_MODE_AM, W(0.025), W(2.5), IC9700_VFOS, RIG_ANT_CURR, "KOR"}, RIG_FRNG_END, }, diff --git a/rigs/icom/ic746.c b/rigs/icom/ic746.c index 80df250be..5b216e9e1 100644 --- a/rigs/icom/ic746.c +++ b/rigs/icom/ic746.c @@ -964,19 +964,22 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) * chanbuf should contain Cn,Sc, Chan #, Data area */ // Do we get chan_len==1 || chan_len==5 on empty memory? - // The IC746Pro returns 1a 00 00 01 ff on a blank channel + // The IC746Pro returns 1a 00 00 01 ff on a blank channel // So this logic should apply to any Icom with chan_len==5 hopefully - if (chan_len == 5 && chanbuf[4]==0xff) { - rig_debug(RIG_DEBUG_TRACE,"%s: chan %d is empty\n", __func__, chan->channel_num); + if (chan_len == 5 && chanbuf[4] == 0xff) + { + rig_debug(RIG_DEBUG_TRACE, "%s: chan %d is empty\n", __func__, + chan->channel_num); return RIG_OK; } if ((chan_len != freq_len * 2 + 40) && (chan_len != 1)) { - rig_debug(RIG_DEBUG_ERR, "%s: wrong frame len=%d\n", __func__, + rig_debug(RIG_DEBUG_ERR, "%s: wrong frame len=%d\n", __func__, chan_len); return -RIG_ERJCTED; } + /* do this only if not a blank channel */ if (chan_len != 1) { @@ -991,7 +994,9 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) chan->flags = (membuf->chan_flag & 0x01) ? RIG_CHFLAG_SKIP : RIG_CHFLAG_NONE; rig_debug(RIG_DEBUG_TRACE, "%s: chan->flags=0x%02x\n", __func__, chan->flags); /* data mode on */ - rig_debug(RIG_DEBUG_TRACE, "%s: membuf->rx.data=0x%02x\n", __func__, membuf->rx.data); + rig_debug(RIG_DEBUG_TRACE, "%s: membuf->rx.data=0x%02x\n", __func__, + membuf->rx.data); + if (membuf->rx.data) { chan->flags |= RIG_CHFLAG_DATA; } /* @@ -1004,7 +1009,8 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) &chan->mode, &chan->width); chan->rptr_shift = (rptr_shift_t)(membuf->rx.dup >> 8); - rig_debug(RIG_DEBUG_TRACE, "%s: chan->rptr_shift=%d\n", __func__, chan->rptr_shift); + rig_debug(RIG_DEBUG_TRACE, "%s: chan->rptr_shift=%d\n", __func__, + chan->rptr_shift); /* offset is default for the band & is not stored in channel memory. The following retrieves the system default for the band */ @@ -1023,12 +1029,15 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) } chan->rptr_offs = from_bcd(databuf + 3, 6) * 100; - rig_debug(RIG_DEBUG_TRACE, "%s: chan->rptr_offs=%d\n", __func__, (int)chan->rptr_offs); + rig_debug(RIG_DEBUG_TRACE, "%s: chan->rptr_offs=%d\n", __func__, + (int)chan->rptr_offs); chan->ctcss_tone = from_bcd_be(membuf->rx.tone, 6); - rig_debug(RIG_DEBUG_TRACE, "%s: chan->ctcss_tone=%d\n", __func__, chan->ctcss_tone); + rig_debug(RIG_DEBUG_TRACE, "%s: chan->ctcss_tone=%d\n", __func__, + chan->ctcss_tone); chan->ctcss_sql = from_bcd_be(membuf->rx.tone_sql, 6); - rig_debug(RIG_DEBUG_TRACE, "%s: chan->ctcss_sql=%d\n", __func__, chan->ctcss_sql); + rig_debug(RIG_DEBUG_TRACE, "%s: chan->ctcss_sql=%d\n", __func__, + chan->ctcss_sql); chan->dcs_code = from_bcd_be(membuf->rx.dcs.code, 4); rig_debug(RIG_DEBUG_TRACE, "%s: chan->dcs_code=%d\n", __func__, chan->dcs_code); /* The dcs information include in the channel includes polarity information @@ -1040,7 +1049,8 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) &chan->tx_mode, &chan->tx_width); strncpy(chan->channel_desc, membuf->name, 9); chan->channel_desc[9] = '\0'; /* add null terminator */ - rig_debug(RIG_DEBUG_TRACE, "%s: chan->channel_desc=%s\n", __func__, chan->channel_desc); + rig_debug(RIG_DEBUG_TRACE, "%s: chan->channel_desc=%s\n", __func__, + chan->channel_desc); } return RIG_OK; @@ -1052,146 +1062,180 @@ int ic746pro_get_channel(RIG *rig, channel_t *chan) */ int ic746pro_set_channel(RIG *rig, const channel_t *chan) { - struct icom_priv_data *priv; - struct rig_state *rs; - mem_buf_t membuf = {0}; - unsigned char chanbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN]; - int chan_len, ack_len, freq_len, retval; + struct icom_priv_data *priv; + struct rig_state *rs; + mem_buf_t membuf = {0}; + unsigned char chanbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN]; + int chan_len, ack_len, freq_len, retval; - rs = &rig->state; - priv = (struct icom_priv_data *)rs->priv; + rs = &rig->state; + priv = (struct icom_priv_data *)rs->priv; - freq_len = priv->civ_731_mode ? 4 : 5; + freq_len = priv->civ_731_mode ? 4 : 5; - // set memory channel - to_bcd_be(chanbuf, chan->channel_num, 4); - chan_len = 2; + // set memory channel + to_bcd_be(chanbuf, chan->channel_num, 4); + chan_len = 2; - // if good value, we change the memory otherwise clear - if (chan->freq != 0 || chan->mode != 0) + // if good value, we change the memory otherwise clear + if (chan->freq != 0 || chan->mode != 0) { - if (chan->split == RIG_SPLIT_ON) - membuf.chan_flag |= 0x10; - else - membuf.chan_flag |= (chan->flags & RIG_CHFLAG_SKIP) ? 0x01 : 0x00; - - // RX - to_bcd(membuf.rx.freq, chan->freq, freq_len * 2); - - retval = rig2icom_mode(rig, chan->mode, chan->width, - &membuf.rx.mode, &membuf.rx.pb); - - if (retval != RIG_OK) + if (chan->split == RIG_SPLIT_ON) { - return retval; + membuf.chan_flag |= 0x10; + } + else + { + membuf.chan_flag |= (chan->flags & RIG_CHFLAG_SKIP) ? 0x01 : 0x00; } - if(membuf.rx.pb == -1) - membuf.rx.pb = PD_MEDIUM_3; + // RX + to_bcd(membuf.rx.freq, chan->freq, freq_len * 2); - membuf.rx.data = (chan->flags & RIG_CHFLAG_DATA) ? 1 : 0; - membuf.rx.dup = chan->rptr_shift; + retval = rig2icom_mode(rig, chan->mode, chan->width, + &membuf.rx.mode, &membuf.rx.pb); - // not empty otherwise the call fail - if (chan->ctcss_tone == 0) - to_bcd_be(membuf.rx.tone, 885, 6); - else - to_bcd_be(membuf.rx.tone, chan->ctcss_tone, 6); - if (chan->ctcss_sql == 0) - to_bcd_be(membuf.rx.tone_sql, 885, 6); - else - to_bcd_be(membuf.rx.tone_sql, chan->ctcss_sql, 6); - - if (chan->dcs_code == 0) - to_bcd_be(membuf.rx.dcs.code, 23, 4); - else - to_bcd_be(membuf.rx.dcs.code, chan->dcs_code, 4); - - // TX - to_bcd(membuf.tx.freq, chan->tx_freq, freq_len * 2); - - retval = rig2icom_mode(rig, chan->tx_mode, chan->tx_width, - &membuf.tx.mode, &membuf.tx.pb); - - if (retval != RIG_OK) + if (retval != RIG_OK) { - return retval; + return retval; } - if(membuf.tx.pb == -1) - membuf.tx.pb = PD_MEDIUM_3; - - membuf.tx.data = (chan->flags | RIG_CHFLAG_DATA) ? 1 : 0; - membuf.tx.dup = chan->rptr_shift; - - // not empty otherwise the call fail - if (chan->ctcss_tone == 0) - to_bcd_be(membuf.tx.tone, 885, 6); - else - to_bcd_be(membuf.tx.tone, chan->ctcss_tone, 6); - if (chan->ctcss_sql == 0) - to_bcd_be(membuf.tx.tone_sql, 885, 6); - else - to_bcd_be(membuf.tx.tone_sql, chan->ctcss_sql, 6); - - if (chan->dcs_code == 0) - to_bcd_be(membuf.tx.dcs.code, 23, 4); - else - to_bcd_be(membuf.tx.dcs.code, chan->dcs_code, 4); - - // set description - memcpy(membuf.name, chan->channel_desc, sizeof(membuf.name)); - - memcpy(chanbuf+chan_len, &membuf, sizeof(mem_buf_t)); - chan_len += sizeof(mem_buf_t); - - retval = icom_transaction(rig, C_CTL_MEM, S_MEM_CNTNT, - chanbuf, chan_len, ackbuf, &ack_len); - - if (retval != RIG_OK) + if (membuf.rx.pb == -1) { - return retval; + membuf.rx.pb = PD_MEDIUM_3; } - if (ack_len != 1 || ackbuf[0] != ACK) + membuf.rx.data = (chan->flags & RIG_CHFLAG_DATA) ? 1 : 0; + membuf.rx.dup = chan->rptr_shift; + + // not empty otherwise the call fail + if (chan->ctcss_tone == 0) { - rig_debug(RIG_DEBUG_ERR, "icom_set_channel: ack NG (%#.2x), " - "len=%d\n", ackbuf[0], ack_len); - return -RIG_ERJCTED; + to_bcd_be(membuf.rx.tone, 885, 6); + } + else + { + to_bcd_be(membuf.rx.tone, chan->ctcss_tone, 6); + } + + if (chan->ctcss_sql == 0) + { + to_bcd_be(membuf.rx.tone_sql, 885, 6); + } + else + { + to_bcd_be(membuf.rx.tone_sql, chan->ctcss_sql, 6); + } + + if (chan->dcs_code == 0) + { + to_bcd_be(membuf.rx.dcs.code, 23, 4); + } + else + { + to_bcd_be(membuf.rx.dcs.code, chan->dcs_code, 4); + } + + // TX + to_bcd(membuf.tx.freq, chan->tx_freq, freq_len * 2); + + retval = rig2icom_mode(rig, chan->tx_mode, chan->tx_width, + &membuf.tx.mode, &membuf.tx.pb); + + if (retval != RIG_OK) + { + return retval; + } + + if (membuf.tx.pb == -1) + { + membuf.tx.pb = PD_MEDIUM_3; + } + + membuf.tx.data = (chan->flags | RIG_CHFLAG_DATA) ? 1 : 0; + membuf.tx.dup = chan->rptr_shift; + + // not empty otherwise the call fail + if (chan->ctcss_tone == 0) + { + to_bcd_be(membuf.tx.tone, 885, 6); + } + else + { + to_bcd_be(membuf.tx.tone, chan->ctcss_tone, 6); + } + + if (chan->ctcss_sql == 0) + { + to_bcd_be(membuf.tx.tone_sql, 885, 6); + } + else + { + to_bcd_be(membuf.tx.tone_sql, chan->ctcss_sql, 6); + } + + if (chan->dcs_code == 0) + { + to_bcd_be(membuf.tx.dcs.code, 23, 4); + } + else + { + to_bcd_be(membuf.tx.dcs.code, chan->dcs_code, 4); + } + + // set description + memcpy(membuf.name, chan->channel_desc, sizeof(membuf.name)); + + memcpy(chanbuf + chan_len, &membuf, sizeof(mem_buf_t)); + chan_len += sizeof(mem_buf_t); + + retval = icom_transaction(rig, C_CTL_MEM, S_MEM_CNTNT, + chanbuf, chan_len, ackbuf, &ack_len); + + if (retval != RIG_OK) + { + return retval; + } + + if (ack_len != 1 || ackbuf[0] != ACK) + { + rig_debug(RIG_DEBUG_ERR, "icom_set_channel: ack NG (%#.2x), " + "len=%d\n", ackbuf[0], ack_len); + return -RIG_ERJCTED; } } - else + else { - retval = icom_transaction(rig, C_SET_MEM, -1, - chanbuf, chan_len, ackbuf, &ack_len); + retval = icom_transaction(rig, C_SET_MEM, -1, + chanbuf, chan_len, ackbuf, &ack_len); - if (retval != RIG_OK) + if (retval != RIG_OK) { - return retval; + return retval; } - if (ack_len != 1 || ackbuf[0] != ACK) + if (ack_len != 1 || ackbuf[0] != ACK) { - rig_debug(RIG_DEBUG_ERR, "icom_set_channel: ack NG (%#.2x), " - "len=%d\n", ackbuf[0], ack_len); - return -RIG_ERJCTED; + rig_debug(RIG_DEBUG_ERR, "icom_set_channel: ack NG (%#.2x), " + "len=%d\n", ackbuf[0], ack_len); + return -RIG_ERJCTED; } - retval = icom_transaction(rig, C_CLR_MEM, -1, NULL, 0, ackbuf, &ack_len); + retval = icom_transaction(rig, C_CLR_MEM, -1, NULL, 0, ackbuf, &ack_len); - if (retval != RIG_OK) + if (retval != RIG_OK) { - return retval; + return retval; } - if (ack_len != 1 || ackbuf[0] != ACK) + if (ack_len != 1 || ackbuf[0] != ACK) { - rig_debug(RIG_DEBUG_ERR, "icom_set_channel: ack NG (%#.2x), " - "len=%d\n", ackbuf[0], ack_len); - return -RIG_ERJCTED; + rig_debug(RIG_DEBUG_ERR, "icom_set_channel: ack NG (%#.2x), " + "len=%d\n", ackbuf[0], ack_len); + return -RIG_ERJCTED; } } - return RIG_OK; + return RIG_OK; } diff --git a/rigs/icom/ic756.c b/rigs/icom/ic756.c index dc16b26ea..44ac3fbc2 100644 --- a/rigs/icom/ic756.c +++ b/rigs/icom/ic756.c @@ -62,12 +62,13 @@ #define IC756_ANTS (RIG_ANT_1|RIG_ANT_2) -struct cmdparams ic756pro_cmdparms[] = { - { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x20}, CMD_DAT_BOL, 1 }, - { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x09}, CMD_DAT_LVL, 2 }, - { {.s=RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x16}, CMD_DAT_TIM, 2 }, - { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x60}, CMD_DAT_INT, 1 }, - { {.s=RIG_PARM_NONE} } +struct cmdparams ic756pro_cmdparms[] = +{ + { {.s = RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x20}, CMD_DAT_BOL, 1 }, + { {.s = RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x09}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x16}, CMD_DAT_TIM, 2 }, + { {.s = RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x60}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_NONE} } }; #define IC756PRO_STR_CAL { 16, \ diff --git a/rigs/icom/ic7600.c b/rigs/icom/ic7600.c index 62420438d..f1c18c79e 100644 --- a/rigs/icom/ic7600.c +++ b/rigs/icom/ic7600.c @@ -53,12 +53,13 @@ #define IC7600_ANTS (RIG_ANT_1|RIG_ANT_2) -struct cmdparams ic7600_extcmds[] = { - { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x59}, CMD_DAT_BOL, 1 }, - { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x38}, CMD_DAT_LVL, 2 }, - { {.s=RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x54}, CMD_DAT_TIM, 2 }, - { {.s=RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x67}, CMD_DAT_INT, 1 }, - { {.s=RIG_PARM_NONE} } +struct cmdparams ic7600_extcmds[] = +{ + { {.s = RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x59}, CMD_DAT_BOL, 1 }, + { {.s = RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x38}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x54}, CMD_DAT_TIM, 2 }, + { {.s = RIG_LEVEL_VOXDELAY}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x67}, CMD_DAT_INT, 1 }, + { {.s = RIG_PARM_NONE} } }; /* diff --git a/rigs/icom/ic7800.c b/rigs/icom/ic7800.c index 87cc68d41..9c4981e2e 100644 --- a/rigs/icom/ic7800.c +++ b/rigs/icom/ic7800.c @@ -342,6 +342,7 @@ int ic7800_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { /* Convert dB to index */ int i; + for (i = 0; i < 7; i++) { if (val.i == rig->state.attenuator[i]) diff --git a/rigs/icom/ic785x.c b/rigs/icom/ic785x.c index 53a8562c9..a6c73ca41 100644 --- a/rigs/icom/ic785x.c +++ b/rigs/icom/ic785x.c @@ -124,8 +124,8 @@ static struct icom_priv_caps ic785x_priv_caps = 0, /* 731 mode */ 0, /* no XCHG */ ic756pro_ts_sc_list, - .antack_len = 3, - .ant_count = 4, + .antack_len = 3, + .ant_count = 4, .agc_levels_present = 1, .agc_levels = { { .level = RIG_AGC_OFF, .icom_level = 0 }, diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 92a991515..61d6922f2 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -683,6 +683,7 @@ int icom_get_usb_echo_off(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s: retry temp set to 1\n", __func__); retval = icom_transaction(rig, C_RD_FREQ, -1, NULL, 0, ackbuf, &ack_len); + if (retval == RIG_OK) { rig_debug(RIG_DEBUG_VERBOSE, "%s: USB echo on detected\n", @@ -750,9 +751,10 @@ icom_rig_open(RIG *rig) // Now that we're powered up let's try again retval = icom_get_usb_echo_off(rig); - if (retval < 0) { + if (retval < 0) + { rig_debug(RIG_DEBUG_ERR, "%s: Unable to determine USB echo status\n", __func__); - return retval; + return retval; } retval = rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode); @@ -794,22 +796,28 @@ int icom_band_changing(RIG *rig, freq_t test_freq) int retval; // We should be sitting on the VFO we want to change so just get it's frequency - retval = icom_get_freq(rig,RIG_VFO_CURR, &curr_freq); - if (retval != RIG_OK) { - rig_debug(RIG_DEBUG_ERR,"%s: icom_get_freq failed??\n", __func__); + retval = icom_get_freq(rig, RIG_VFO_CURR, &curr_freq); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: icom_get_freq failed??\n", __func__); return 0; // I guess we need to say no change in this case } - + // Make our HF=0, 2M = 1, 70cm = 4, and 23cm=12 freq1 = floor(curr_freq / 1e8); freq2 = floor(test_freq / 1e8); - rig_debug(RIG_DEBUG_TRACE,"%s: lastfreq=%.0f, thisfreq=%.0f\n", __func__, freq1, freq2); - if (freq1 != freq2) { - rig_debug(RIG_DEBUG_TRACE,"%s: Band change detected\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: lastfreq=%.0f, thisfreq=%.0f\n", __func__, + freq1, freq2); + + if (freq1 != freq2) + { + rig_debug(RIG_DEBUG_TRACE, "%s: Band change detected\n", __func__); return 1; } - rig_debug(RIG_DEBUG_TRACE,"%s: Band change not detected\n", __func__); + + rig_debug(RIG_DEBUG_TRACE, "%s: Band change not detected\n", __func__); return 0; } @@ -831,12 +839,15 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) rs = &rig->state; priv = (struct icom_priv_data *) rs->priv; - if (vfo==RIG_VFO_CURR) { - vfo=priv->curr_vfo; - rig_debug(RIG_DEBUG_TRACE,"%s: currVFO asked for so vfo set to %s\n", __func__, rig_strvfo(vfo)); + if (vfo == RIG_VFO_CURR) + { + vfo = priv->curr_vfo; + rig_debug(RIG_DEBUG_TRACE, "%s: currVFO asked for so vfo set to %s\n", __func__, + rig_strvfo(vfo)); } - rig_debug(RIG_DEBUG_TRACE, "%s: set_vfo_curr=%s\n", __func__, rig_strvfo(priv->curr_vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: set_vfo_curr=%s\n", __func__, + rig_strvfo(priv->curr_vfo)); retval = set_vfo_curr(rig, vfo, priv->curr_vfo); if (retval != RIG_OK) @@ -845,6 +856,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) } retval = icom_get_freq(rig, RIG_VFO_CURR, &curr_freq); + if (retval != RIG_OK) { return retval; @@ -858,25 +870,31 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) cmd = C_SET_FREQ; subcmd = -1; - retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf, &ack_len); + retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf, + &ack_len); if (retval != RIG_OK) { - // We might have a failed command if we're changing bands + // We might have a failed command if we're changing bands // For example, IC9700 setting Sub=VHF when Main=VHF will fail // So we'll try a VFO swap and see if that helps things - rig_debug(RIG_DEBUG_VERBOSE, "%s: special check for vfo swap\n",__func__); - if (icom_band_changing(rig, freq)) { + rig_debug(RIG_DEBUG_VERBOSE, "%s: special check for vfo swap\n", __func__); + + if (icom_band_changing(rig, freq)) + { if (rig_has_vfo_op(rig, RIG_OP_XCHG)) { if (RIG_OK != (retval = icom_vfo_op(rig, vfo, RIG_OP_XCHG))) { return retval; } + // Try the command again and fall through to handle errors - retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf, &ack_len); + retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf, + &ack_len); } } + if (retval != RIG_OK) { return retval; @@ -890,12 +908,15 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) return -RIG_ERJCTED; } - if (vfo == RIG_VFO_MAIN) { + if (vfo == RIG_VFO_MAIN) + { priv->main_freq = freq; } - else if (vfo == RIG_VFO_SUB) { + else if (vfo == RIG_VFO_SUB) + { priv->sub_freq = freq; } + priv->curr_freq = freq; return RIG_OK; } @@ -1587,7 +1608,10 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) retval = icom_transaction(rig, C_RD_MODE, -1, NULL, 0, modebuf, &mode_len); - rig_debug(RIG_DEBUG_TRACE,"%s: modebuf[0]=0x%02x, modebuf[1]=0x%02x, mode_len=%d\n", __func__, modebuf[0], modebuf[1], mode_len); + rig_debug(RIG_DEBUG_TRACE, + "%s: modebuf[0]=0x%02x, modebuf[1]=0x%02x, mode_len=%d\n", __func__, modebuf[0], + modebuf[1], mode_len); + if (retval != RIG_OK) { return retval; @@ -1694,19 +1718,24 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) return RIG_OK; } - if (vfo == RIG_VFO_CURR) { - rig_debug(RIG_DEBUG_TRACE,"%s: Asking for currVFO, currVFO=%s\n", __func__, rig_strvfo(priv->curr_vfo)); + if (vfo == RIG_VFO_CURR) + { + rig_debug(RIG_DEBUG_TRACE, "%s: Asking for currVFO, currVFO=%s\n", __func__, + rig_strvfo(priv->curr_vfo)); vfo = priv->curr_vfo; } + if (vfo == RIG_VFO_MAIN && VFO_HAS_A_B_ONLY) { vfo = RIG_VFO_A; - rig_debug(RIG_DEBUG_TRACE,"%s: Rig does not have MAIN/SUB so Main=%s\n", __func__, rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: Rig does not have MAIN/SUB so Main=%s\n", + __func__, rig_strvfo(vfo)); } else if (vfo == RIG_VFO_SUB && VFO_HAS_A_B_ONLY) { vfo = RIG_VFO_B; - rig_debug(RIG_DEBUG_TRACE,"%s: Rig does not have MAIN/SUB so Sub=%s\n", __func__, rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: Rig does not have MAIN/SUB so Sub=%s\n", + __func__, rig_strvfo(vfo)); } /* This method works also in memory mode(RIG_VFO_MEM) */ @@ -1723,8 +1752,10 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) return -RIG_EINVAL; } - if (vfo != priv->curr_vfo) { - rig_debug(RIG_DEBUG_TRACE, "%s: VFO changing from %s to %s\n", __func__, rig_strvfo(priv->curr_vfo), rig_strvfo(vfo)); + if (vfo != priv->curr_vfo) + { + rig_debug(RIG_DEBUG_TRACE, "%s: VFO changing from %s to %s\n", __func__, + rig_strvfo(priv->curr_vfo), rig_strvfo(vfo)); priv->curr_freq = 0; // reset curr_freq so set_freq works 1st time } @@ -1852,6 +1883,7 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) ackbuf[0], ack_len); return -RIG_ERJCTED; } + priv->curr_vfo = vfo; return RIG_OK; } @@ -2857,7 +2889,7 @@ int icom_set_ext_func(RIG *rig, vfo_t vfo, token_t token, int status) int icom_get_ext_func(RIG *rig, vfo_t vfo, token_t token, int *status) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - return icom_get_ext_cmd(rig, vfo, token, (value_t*)status); + return icom_get_ext_cmd(rig, vfo, token, (value_t *)status); } int icom_set_ext_parm(RIG *rig, token_t token, value_t val) @@ -3328,13 +3360,15 @@ int icom_get_split_vfos(const RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo) *rx_vfo = RIG_VFO_A; *tx_vfo = RIG_VFO_B; /* rig doesn't enforce this but convention is needed here */ - rig_debug(RIG_DEBUG_TRACE,"%s: VFO_HAS_A_B_ONLY, rx=%s, tx=%s\n", __func__, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: VFO_HAS_A_B_ONLY, rx=%s, tx=%s\n", __func__, + rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); } else if (VFO_HAS_MAIN_SUB_ONLY) { *rx_vfo = RIG_VFO_MAIN; *tx_vfo = RIG_VFO_SUB; - rig_debug(RIG_DEBUG_TRACE,"%s: VFO_HAS_MAIN_SUB_ONLY, rx=%s, tx=%s\n", __func__, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: VFO_HAS_MAIN_SUB_ONLY, rx=%s, tx=%s\n", + __func__, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); } else if (VFO_HAS_MAIN_SUB_A_B_ONLY) { @@ -3343,7 +3377,8 @@ int icom_get_split_vfos(const RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo) // For now we return Main/Sub *rx_vfo = priv->rx_vfo = RIG_VFO_MAIN; *tx_vfo = priv->tx_vfo = RIG_VFO_SUB; - rig_debug(RIG_DEBUG_TRACE,"%s: VFO_HAS_MAIN_SUB_A_B_ONLY, rx=%s, tx=%s\n", __func__, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: VFO_HAS_MAIN_SUB_A_B_ONLY, rx=%s, tx=%s\n", + __func__, rig_strvfo(*rx_vfo), rig_strvfo(*tx_vfo)); } else { @@ -3423,7 +3458,9 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) { return rc; } - rig_debug(RIG_DEBUG_TRACE,"%s: rx_vfo=%s, tx_vfo=%s\n", __func__, rig_strvfo(rx_vfo), rig_strvfo(tx_vfo)); + + rig_debug(RIG_DEBUG_TRACE, "%s: rx_vfo=%s, tx_vfo=%s\n", __func__, + rig_strvfo(rx_vfo), rig_strvfo(tx_vfo)); if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) { @@ -3452,10 +3489,12 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) } } - if (vfo == RIG_VFO_MAIN) { + if (vfo == RIG_VFO_MAIN) + { priv->main_freq = tx_freq; } - else if (vfo == RIG_VFO_SUB) { + else if (vfo == RIG_VFO_SUB) + { priv->sub_freq = tx_freq; } @@ -4010,9 +4049,12 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) int ack_len = sizeof(ackbuf), rc; int split_sc; - rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo='%s', split=%d, tx_vfo=%s, curr_vfo=%s\n", __func__, rig_strvfo(vfo), split, rig_strvfo(tx_vfo), rig_strvfo(priv->curr_vfo)); + rig_debug(RIG_DEBUG_VERBOSE, + "%s called vfo='%s', split=%d, tx_vfo=%s, curr_vfo=%s\n", __func__, + rig_strvfo(vfo), split, rig_strvfo(tx_vfo), rig_strvfo(priv->curr_vfo)); - if (vfo == RIG_VFO_CURR) { + if (vfo == RIG_VFO_CURR) + { vfo = priv->curr_vfo; } @@ -4023,7 +4065,8 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) // if either VFOA or B is the vfo we set to VFOA when split is turned off if (tx_vfo == RIG_VFO_A || tx_vfo == RIG_VFO_B) { - rig_debug(RIG_DEBUG_TRACE,"%s: set_vfo to VFO_A because tx_vfo=%s\n", __func__, rig_strvfo(tx_vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: set_vfo to VFO_A because tx_vfo=%s\n", __func__, + rig_strvfo(tx_vfo)); rig_set_vfo(rig, RIG_VFO_A); priv->tx_vfo = RIG_VFO_A; priv->rx_vfo = RIG_VFO_A; @@ -4031,7 +4074,8 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) // otherwise if Main or Sub we set Main as the current vfo else if (tx_vfo == RIG_VFO_MAIN || tx_vfo == RIG_VFO_SUB) { - rig_debug(RIG_DEBUG_TRACE,"%s: set_vfo to VFO_MAIN because tx_vfo=%s\n", __func__, rig_strvfo(tx_vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: set_vfo to VFO_MAIN because tx_vfo=%s\n", + __func__, rig_strvfo(tx_vfo)); rig_set_vfo(rig, RIG_VFO_MAIN); priv->tx_vfo = RIG_VFO_MAIN; priv->rx_vfo = RIG_VFO_MAIN; @@ -4046,25 +4090,34 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) /* ensure VFO A is Rx and VFO B is Tx as we assume that elsewhere */ if (VFO_HAS_A_B && (tx_vfo == RIG_VFO_A || tx_vfo == RIG_VFO_B)) { - rig_debug(RIG_DEBUG_TRACE,"%s: set_vfo to VFO_A because tx_vfo=%s\n", __func__, rig_strvfo(tx_vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: set_vfo to VFO_A because tx_vfo=%s\n", __func__, + rig_strvfo(tx_vfo)); + if (RIG_OK != (rc = icom_set_vfo(rig, RIG_VFO_A))) { return rc; } + priv->tx_vfo = RIG_VFO_B; priv->rx_vfo = RIG_VFO_A; } // Does this allow for SATMODE split? - else if (VFO_HAS_MAIN_SUB && (tx_vfo == RIG_VFO_MAIN || tx_vfo == RIG_VFO_SUB)) { - rig_debug(RIG_DEBUG_TRACE,"%s: set_vfo because tx_vfo=%s\n", __func__, rig_strvfo(tx_vfo)); + else if (VFO_HAS_MAIN_SUB && (tx_vfo == RIG_VFO_MAIN || tx_vfo == RIG_VFO_SUB)) + { + rig_debug(RIG_DEBUG_TRACE, "%s: set_vfo because tx_vfo=%s\n", __func__, + rig_strvfo(tx_vfo)); + if (RIG_OK != (rc = icom_set_vfo(rig, tx_vfo))) { return rc; } + split_sc = S_SPLT_ON; } - else { - rig_debug(RIG_DEBUG_ERR,"%s: split on vfo=%s not known\n", __func__, rig_strvfo(vfo)); + else + { + rig_debug(RIG_DEBUG_ERR, "%s: split on vfo=%s not known\n", __func__, + rig_strvfo(vfo)); return -RIG_EINVAL; } @@ -4107,7 +4160,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) int icom_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) { unsigned char splitbuf[MAXFRAMELEN]; - int split_len, retval, satmode=0; + int split_len, retval, satmode = 0; struct icom_priv_data *priv = (struct icom_priv_data *) rig->state.priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -4148,8 +4201,10 @@ int icom_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) } rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode); + // don't care about retval here...only care about satmode=1 - if (satmode) { + if (satmode) + { priv->tx_vfo = RIG_VFO_SUB; priv->rx_vfo = RIG_VFO_MAIN; } @@ -5433,14 +5488,21 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) const struct icom_priv_caps *priv_caps = (const struct icom_priv_caps *) rig->caps->priv; - rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x, option=%d, antack_len=%d\n", __func__, ant, option.i, priv_caps->antack_len); + rig_debug(RIG_DEBUG_VERBOSE, + "%s called, ant=0x%02x, option=%d, antack_len=%d\n", __func__, ant, option.i, + priv_caps->antack_len); + // query the antennas once and find out how many we have - if (ant >= rig_idx2setting(priv_caps->ant_count)) { + if (ant >= rig_idx2setting(priv_caps->ant_count)) + { return -RIG_EINVAL; } - if (ant > RIG_ANT_4) { + + if (ant > RIG_ANT_4) + { return -RIG_EDOM; } + switch (ant) { case RIG_ANT_1: @@ -5465,14 +5527,18 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) } - if (priv_caps->antack_len == 0) { // we need to find out the antack_len + if (priv_caps->antack_len == 0) // we need to find out the antack_len + { ant_t tmp_ant, ant_tx, ant_rx; int ant = 0; value_t tmp_option; retval = rig_get_ant(rig, vfo, ant, &tmp_option, &tmp_ant, &ant_tx, &ant_rx); - if (retval != RIG_OK) { - rig_debug(RIG_DEBUG_ERR,"%s: rig_get_ant error: %s \n", __func__, rigerror(retval)); - return retval; + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: rig_get_ant error: %s \n", __func__, + rigerror(retval)); + return retval; } } @@ -5488,16 +5554,18 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) antopt_len = 1; antopt[0] = option.i; // we have to set the rx option by itself apparently - rig_debug(RIG_DEBUG_TRACE,"%s: setting antopt=%d\n", __func__, antopt[0]); + rig_debug(RIG_DEBUG_TRACE, "%s: setting antopt=%d\n", __func__, antopt[0]); retval = icom_transaction(rig, C_CTL_ANT, i_ant, - antopt, antopt_len, ackbuf, &ack_len); + antopt, antopt_len, ackbuf, &ack_len); + if (retval != RIG_OK) { return retval; } antopt_len = 0; - rig_debug(RIG_DEBUG_TRACE, "%s: antack_len=%d so antopt_len=%d, antopt=0x%02x\n", + rig_debug(RIG_DEBUG_TRACE, + "%s: antack_len=%d so antopt_len=%d, antopt=0x%02x\n", __func__, priv_caps->antack_len, antopt_len, antopt[0]); } else if (priv_caps->antack_len == 2) @@ -5541,7 +5609,8 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) * Assumes rig!=NULL, rig->state.priv!=NULL * only meaningfull for HF */ -int icom_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int icom_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { unsigned char ackbuf[MAXFRAMELEN]; int ack_len = sizeof(ackbuf), retval; @@ -5555,31 +5624,42 @@ int icom_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, ant_t *ant_cur if (ant != RIG_ANT_CURR) { ant = rig_setting2idx(ant); - if (ant >= priv_caps->ant_count) + + if (ant >= priv_caps->ant_count) { - rig_debug(RIG_DEBUG_ERR, "%s: ant index=%d > ant_count=%d\n", __func__, ant, priv_caps->ant_count); + rig_debug(RIG_DEBUG_ERR, "%s: ant index=%d > ant_count=%d\n", __func__, ant, + priv_caps->ant_count); return -RIG_EINVAL; } } + // Should be able to use just C_CTL_ANT for 1 or 2 antennas hopefully - if (ant == RIG_ANT_CURR || priv_caps->ant_count <= 2) { + if (ant == RIG_ANT_CURR || priv_caps->ant_count <= 2) + { retval = icom_transaction(rig, C_CTL_ANT, -1, NULL, 0, ackbuf, &ack_len); } - else if (rig->caps->rig_model == RIG_MODEL_IC785x) { + else if (rig->caps->rig_model == RIG_MODEL_IC785x) + { unsigned char buf[2]; buf[0] = 0x03; - buf[1] = 0x05+ant; + buf[1] = 0x05 + ant; *ant_curr = ant; - retval = icom_transaction(rig, C_CTL_MEM, 0x05, buf, sizeof(buf), ackbuf, &ack_len); - if (retval == RIG_OK) { + retval = icom_transaction(rig, C_CTL_MEM, 0x05, buf, sizeof(buf), ackbuf, + &ack_len); + + if (retval == RIG_OK) + { option->i = ackbuf[4]; return RIG_OK; } } - else { - rig_debug(RIG_DEBUG_ERR,"%s: asking for non-current antenna and ant_count==0?\n", __func__); - rig_debug(RIG_DEBUG_ERR,"%s: need to implement ant control for this rig?\n", __func__); - return -RIG_EINVAL; + else + { + rig_debug(RIG_DEBUG_ERR, + "%s: asking for non-current antenna and ant_count==0?\n", __func__); + rig_debug(RIG_DEBUG_ERR, "%s: need to implement ant control for this rig?\n", + __func__); + return -RIG_EINVAL; } if (retval != RIG_OK) @@ -5600,12 +5680,13 @@ int icom_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, ant_t *ant_cur ackbuf[0], ack_len, ackbuf[1]); return -RIG_ERJCTED; } + rig_debug(RIG_DEBUG_ERR, "%s: ackbuf= 0x%02x 0x%02x 0x%02x\n", __func__, - ackbuf[0], ackbuf[1], ackbuf[2]); + ackbuf[0], ackbuf[1], ackbuf[2]); *ant_curr = rig_idx2setting(ackbuf[1]); - // Note: with IC756/IC-756Pro/IC-7800 and more, ackbuf[2] deals with [RX ANT] + // Note: with IC756/IC-756Pro/IC-7800 and more, ackbuf[2] deals with [RX ANT] // Hopefully any ack_len=3 can fit in the option field if (ack_len == 3) { @@ -6211,19 +6292,24 @@ static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo) rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s, curr_vfo=%s\n", __func__, rig_strvfo(vfo), rig_strvfo(curr_vfo)); - if (vfo == RIG_VFO_CURR) { - rig_debug(RIG_DEBUG_TRACE,"%s: Asking for currVFO, currVFO=%s\n", __func__, rig_strvfo(priv->curr_vfo)); + if (vfo == RIG_VFO_CURR) + { + rig_debug(RIG_DEBUG_TRACE, "%s: Asking for currVFO, currVFO=%s\n", __func__, + rig_strvfo(priv->curr_vfo)); vfo = priv->curr_vfo; } + if (vfo == RIG_VFO_MAIN && VFO_HAS_A_B_ONLY) { vfo = RIG_VFO_A; - rig_debug(RIG_DEBUG_TRACE,"%s: Rig does not have MAIN/SUB so Main=%s\n", __func__, rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: Rig does not have MAIN/SUB so Main=%s\n", + __func__, rig_strvfo(vfo)); } else if (vfo == RIG_VFO_SUB && VFO_HAS_A_B_ONLY) { vfo = RIG_VFO_B; - rig_debug(RIG_DEBUG_TRACE,"%s: Rig does not have MAIN/SUB so Sub=%s\n", __func__, rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: Rig does not have MAIN/SUB so Sub=%s\n", + __func__, rig_strvfo(vfo)); } /* This method works also in memory mode(RIG_VFO_MEM) */ diff --git a/rigs/icom/icr30.c b/rigs/icom/icr30.c index 6296c778c..039c5ce3c 100644 --- a/rigs/icom/icr30.c +++ b/rigs/icom/icr30.c @@ -53,21 +53,24 @@ #define TOK_REC TOKEN_BACKEND(003) int icr30_tokens[] = { TOK_ANL, TOK_EAR, TOK_REC, - TOK_DSTAR_DSQL, TOK_DSTAR_CALL_SIGN, TOK_DSTAR_MESSAGE, TOK_DSTAR_STATUS, - TOK_DSTAR_GPS_DATA, TOK_DSTAR_GPS_MESS, TOK_DSTAR_CODE, TOK_DSTAR_TX_DATA, - TOK_BACKEND_NONE }; + TOK_DSTAR_DSQL, TOK_DSTAR_CALL_SIGN, TOK_DSTAR_MESSAGE, TOK_DSTAR_STATUS, + TOK_DSTAR_GPS_DATA, TOK_DSTAR_GPS_MESS, TOK_DSTAR_CODE, TOK_DSTAR_TX_DATA, + TOK_BACKEND_NONE + }; -struct confparams icr30_ext[] = { +struct confparams icr30_ext[] = +{ { TOK_ANL, "anl", "Auto noise limiter", "", "", RIG_CONF_CHECKBUTTON, {} }, { TOK_EAR, "ear", "Earphone mode", "", "", RIG_CONF_CHECKBUTTON, {} }, { TOK_REC, "record", "Recorder on/off", "", "", RIG_CONF_CHECKBUTTON, {} }, { 0 } }; -struct cmdparams icr30_extcmds[] = { - { {.t=TOK_ANL}, C_CTL_MEM, S_MEM_ANL, SC_MOD_RW, 0, {}, CMD_DAT_BOL, 1 }, - { {.t=TOK_EAR}, C_CTL_MEM, S_MEM_EAR, SC_MOD_RW, 0, {}, CMD_DAT_BOL, 1 }, - { {.t=TOK_REC}, C_CTL_MEM, S_MEM_REC, SC_MOD_WR, 0, {}, CMD_DAT_BOL, 1 }, +struct cmdparams icr30_extcmds[] = +{ + { {.t = TOK_ANL}, C_CTL_MEM, S_MEM_ANL, SC_MOD_RW, 0, {}, CMD_DAT_BOL, 1 }, + { {.t = TOK_EAR}, C_CTL_MEM, S_MEM_EAR, SC_MOD_RW, 0, {}, CMD_DAT_BOL, 1 }, + { {.t = TOK_REC}, C_CTL_MEM, S_MEM_REC, SC_MOD_WR, 0, {}, CMD_DAT_BOL, 1 }, { {0} } }; diff --git a/rigs/icom/icr8600.c b/rigs/icom/icr8600.c index d9b134997..08b8db53f 100644 --- a/rigs/icom/icr8600.c +++ b/rigs/icom/icr8600.c @@ -67,19 +67,21 @@ { 255, 60 }, \ } } -struct cmdparams icr8600_extcmds[] = { - { {.s=RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x38}, CMD_DAT_BOL, 1 }, - { {.s=RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x15}, CMD_DAT_LVL, 2 }, - { {.s=RIG_PARM_KEYLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x16}, CMD_DAT_LVL, 2 }, - { {.s=RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x32}, CMD_DAT_TIM, 2 }, - { {.s=RIG_PARM_NONE} } +struct cmdparams icr8600_extcmds[] = +{ + { {.s = RIG_PARM_BEEP}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x00, 0x38}, CMD_DAT_BOL, 1 }, + { {.s = RIG_PARM_BACKLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x15}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_KEYLIGHT}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x16}, CMD_DAT_LVL, 2 }, + { {.s = RIG_PARM_TIME}, C_CTL_MEM, S_MEM_PARM, SC_MOD_RW, 2, {0x01, 0x32}, CMD_DAT_TIM, 2 }, + { {.s = RIG_PARM_NONE} } }; int icr8600_tokens[] = { TOK_DSTAR_DSQL, TOK_DSTAR_CALL_SIGN, TOK_DSTAR_MESSAGE, TOK_DSTAR_STATUS, - TOK_DSTAR_GPS_DATA, TOK_DSTAR_GPS_MESS, TOK_DSTAR_CODE, TOK_DSTAR_TX_DATA, - TOK_SCOPE_DAT, TOK_SCOPE_STS, TOK_SCOPE_DOP, TOK_SCOPE_MSS, TOK_SCOPE_MOD, TOK_SCOPE_SPN, - TOK_SCOPE_HLD, TOK_SCOPE_REF, TOK_SCOPE_SWP, TOK_SCOPE_TYP, TOK_SCOPE_VBW, TOK_SCOPE_FEF, - TOK_BACKEND_NONE }; + TOK_DSTAR_GPS_DATA, TOK_DSTAR_GPS_MESS, TOK_DSTAR_CODE, TOK_DSTAR_TX_DATA, + TOK_SCOPE_DAT, TOK_SCOPE_STS, TOK_SCOPE_DOP, TOK_SCOPE_MSS, TOK_SCOPE_MOD, TOK_SCOPE_SPN, + TOK_SCOPE_HLD, TOK_SCOPE_REF, TOK_SCOPE_SWP, TOK_SCOPE_TYP, TOK_SCOPE_VBW, TOK_SCOPE_FEF, + TOK_BACKEND_NONE + }; /* * channel caps. diff --git a/rigs/icom/id51.c b/rigs/icom/id51.c index 2fdbab429..6263c5f34 100644 --- a/rigs/icom/id51.c +++ b/rigs/icom/id51.c @@ -67,9 +67,10 @@ #define ID51_PARM_ALL RIG_PARM_NONE int id51_tokens[] = { TOK_DSTAR_DSQL, TOK_DSTAR_CALL_SIGN, TOK_DSTAR_MESSAGE, TOK_DSTAR_STATUS, - TOK_DSTAR_GPS_DATA, TOK_DSTAR_GPS_MESS, TOK_DSTAR_CODE, TOK_DSTAR_TX_DATA, - TOK_DSTAR_MY_CS, TOK_DSTAR_TX_CS, TOK_DSTAR_TX_MESS, - TOK_BACKEND_NONE }; + TOK_DSTAR_GPS_DATA, TOK_DSTAR_GPS_MESS, TOK_DSTAR_CODE, TOK_DSTAR_TX_DATA, + TOK_DSTAR_MY_CS, TOK_DSTAR_TX_CS, TOK_DSTAR_TX_MESS, + TOK_BACKEND_NONE + }; /* * FIXME: real measurement diff --git a/rigs/icom/id5100.c b/rigs/icom/id5100.c index 68d8bff60..1eb439cfe 100644 --- a/rigs/icom/id5100.c +++ b/rigs/icom/id5100.c @@ -199,7 +199,7 @@ const struct rig_caps id5100_caps = .get_parm = icom_get_parm, .set_ext_parm = icom_set_ext_parm, .get_ext_parm = icom_get_ext_parm, - + .set_ptt = icom_set_ptt, .get_ptt = icom_get_ptt, .get_dcd = icom_get_dcd, diff --git a/rigs/icom/optoscan.c b/rigs/icom/optoscan.c index 699f25cf6..b3e5c5189 100644 --- a/rigs/icom/optoscan.c +++ b/rigs/icom/optoscan.c @@ -253,7 +253,7 @@ int optoscan_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length) do { int retval = icom_transaction(rig, C_CTL_MISC, S_OPTO_RDDTMF, - NULL, 0, dtmfbuf, &len); + NULL, 0, dtmfbuf, &len); if (retval != RIG_OK) { diff --git a/rigs/kenwood/ic10.c b/rigs/kenwood/ic10.c index d7c534a52..8226304a9 100644 --- a/rigs/kenwood/ic10.c +++ b/rigs/kenwood/ic10.c @@ -445,7 +445,8 @@ int ic10_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) * ic10_get_ant * Assumes rig!=NULL, ptt!=NULL */ -int ic10_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int ic10_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { char infobuf[50]; int info_len, retval; @@ -741,10 +742,13 @@ int ic10_set_channel(RIG *rig, const channel_t *chan) md ); retval = ic10_transaction(rig, membuf, len, ackbuf, &ack_len); + // I assume we need to check the retval here -- W9MDB // This was found from cppcheck - if (retval != RIG_OK) { - rig_debug(RIG_DEBUG_ERR,"%s: transaction failed: %s\n", __func__, strerror(retval)); + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: transaction failed: %s\n", __func__, + strerror(retval)); return retval; } diff --git a/rigs/kenwood/k3.c b/rigs/kenwood/k3.c index 6dfb31f26..4b08d0733 100644 --- a/rigs/kenwood/k3.c +++ b/rigs/kenwood/k3.c @@ -912,17 +912,20 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { case RIG_MODE_PKTLSB: mode = RIG_MODE_RTTY; - snprintf(cmd_m, sizeof(cmd_m), "DT1"); /* AFSK A mode - AFSK on LSB optimised for RTTY, VFO dial is MARK */ + snprintf(cmd_m, sizeof(cmd_m), + "DT1"); /* AFSK A mode - AFSK on LSB optimised for RTTY, VFO dial is MARK */ break; case RIG_MODE_PKTUSB: mode = RIG_MODE_RTTY; - snprintf(cmd_m, sizeof(cmd_m), "DT0"); /* DATA A mode - AFSK on USB general, VFO dial is suppressed carrier QRG */ + snprintf(cmd_m, sizeof(cmd_m), + "DT0"); /* DATA A mode - AFSK on USB general, VFO dial is suppressed carrier QRG */ break; case RIG_MODE_RTTY: case RIG_MODE_RTTYR: - snprintf(cmd_m, sizeof(cmd_m), "DT2"); /* FSK D mode - direct FSK keying, LSB is "normal", VFO dial is MARK */ + snprintf(cmd_m, sizeof(cmd_m), + "DT2"); /* FSK D mode - direct FSK keying, LSB is "normal", VFO dial is MARK */ break; default: @@ -1215,17 +1218,20 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) { case RIG_MODE_PKTLSB: tx_mode = RIG_MODE_RTTY; - snprintf(cmd_m, sizeof(cmd_m), "DT1"); /* AFSK A mode - AFSK on LSB optimised for RTTY, VFO dial is MARK */ + snprintf(cmd_m, sizeof(cmd_m), + "DT1"); /* AFSK A mode - AFSK on LSB optimised for RTTY, VFO dial is MARK */ break; case RIG_MODE_PKTUSB: tx_mode = RIG_MODE_RTTY; - snprintf(cmd_m, sizeof(cmd_m), "DT0"); /* DATA A mode - AFSK on USB general, VFO dial is suppressed carrier QRG */ + snprintf(cmd_m, sizeof(cmd_m), + "DT0"); /* DATA A mode - AFSK on USB general, VFO dial is suppressed carrier QRG */ break; case RIG_MODE_RTTY: case RIG_MODE_RTTYR: - snprintf(cmd_m, sizeof(cmd_m), "DT2"); /* FSK D mode - direct FSK keying, LSB is "normal", VFO dial is MARK */ + snprintf(cmd_m, sizeof(cmd_m), + "DT2"); /* FSK D mode - direct FSK keying, LSB is "normal", VFO dial is MARK */ break; default: @@ -1542,16 +1548,19 @@ int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) switch (level) { - float firmware_have; - float firmware_need; + float firmware_have; + float firmware_need; + case RIG_LEVEL_STRENGTH: /* As of FW rev 4.37 the K3 supports an 'SMH' command that * offers a higher resolution, 0-100 (mine went to 106), * rawstr value for more precise S-meter reporting. */ firmware_have = 0; - if (priv->fw_rev != NULL) sscanf(priv->fw_rev,"%f",&firmware_have); - sscanf("4.37","%f",&firmware_need); + + if (priv->fw_rev != NULL) { sscanf(priv->fw_rev, "%f", &firmware_have); } + + sscanf("4.37", "%f", &firmware_need); if (firmware_have < firmware_need) { diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 570195bc4..9ae63d1dd 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -223,7 +223,7 @@ const struct confparams kenwood_cfg_params[] = int kenwood_transaction(RIG *rig, const char *cmdstr, char *data, size_t datasize) { - char buffer[KENWOOD_MAX_BUF_LEN]; /* use our own buffer since + char buffer[KENWOOD_MAX_BUF_LEN]; /* use our own buffer since verification may need a longer buffer than the user supplied one */ char cmdtrm[2]; /* Default Command/Reply termination char */ @@ -591,6 +591,7 @@ int kenwood_init(RIG *rig) { return -RIG_ENOMEM; } + priv = rig->state.priv; memset(priv, 0x00, sizeof(struct kenwood_priv_data)); @@ -636,7 +637,7 @@ int kenwood_open(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); // Ensure rig is on - rig_set_powerstat(rig,1); + rig_set_powerstat(rig, 1); if (RIG_MODEL_TS590S == rig->caps->rig_model) @@ -1206,8 +1207,8 @@ int kenwood_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, /* find where is the txvfo.. */ /* Elecraft info[30] does not track split VFO when transmitting */ transmitting = '1' == priv->info[28] - && RIG_MODEL_K2 != rig->caps->rig_model - && RIG_MODEL_K3 != rig->caps->rig_model; + && RIG_MODEL_K2 != rig->caps->rig_model + && RIG_MODEL_K3 != rig->caps->rig_model; switch (priv->info[30]) { @@ -3095,7 +3096,8 @@ int kenwood_set_ant_no_ack(RIG *rig, vfo_t vfo, ant_t ant, value_t option) /* * get the aerial/antenna in use */ -int kenwood_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int kenwood_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { char ackbuf[8]; int offs; @@ -3342,7 +3344,8 @@ int kenwood_get_trn(RIG *rig, int *trn) */ int kenwood_set_powerstat(RIG *rig, powerstat_t status) { - int retval = kenwood_transaction(rig, (status == RIG_POWER_ON) ? "PS1" : "PS0", NULL, 0); + int retval = kenwood_transaction(rig, (status == RIG_POWER_ON) ? "PS1" : "PS0", + NULL, 0); int i = 0; int retry = 3 / rig->state.rigport.retry; @@ -3472,6 +3475,7 @@ int kenwood_send_morse(RIG *rig, vfo_t vfo, const char *msg) while (msg_len > 0) { int buff_len; + /* * Check with "KY" if char buffer is available. * if not, sleep. diff --git a/rigs/kenwood/pihpsdr.c b/rigs/kenwood/pihpsdr.c index 67b8995bd..7e8868e98 100644 --- a/rigs/kenwood/pihpsdr.c +++ b/rigs/kenwood/pihpsdr.c @@ -564,7 +564,7 @@ int pihspdr_get_channel(RIG *rig, channel_t *chan) } int pihspdr_set_channel(RIG *rig, const channel_t *chan) -{ +{ char sqltype; char shift; char buf[128]; diff --git a/rigs/kenwood/th.c b/rigs/kenwood/th.c index 7d35fee48..9ffa69438 100644 --- a/rigs/kenwood/th.c +++ b/rigs/kenwood/th.c @@ -2196,6 +2196,7 @@ int th_get_channel(RIG *rig, channel_t *chan) 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); @@ -2453,21 +2454,21 @@ int th_set_channel(RIG *rig, const channel_t *chan) /* Step can be hexa */ snprintf(membuf, sizeof(membuf), - "%8s,%011"PRIll",%X,%d,%d,%d,%d,%d,%02d,%02d,%03d,%09"PRIll",%d%10s", - req, (int64_t)chan->freq, step, shift, rev, tone, - ctcss, dcs, tonefq, ctcssfq, dcscode, - (int64_t)labs((long)(chan->rptr_offs)), mode, lockoutstr - ); + "%8s,%011"PRIll",%X,%d,%d,%d,%d,%d,%02d,%02d,%03d,%09"PRIll",%d%10s", + req, (int64_t)chan->freq, step, shift, rev, tone, + ctcss, dcs, tonefq, ctcssfq, dcscode, + (int64_t)labs((long)(chan->rptr_offs)), mode, lockoutstr + ); } else { /* Without DCS,mode */ sprintf(membuf, "%s,%011"PRIll",%X,%d,%d,%d,%d,,%02d,,%02d,%09"PRIll"%s", - req, (int64_t)chan->freq, step, shift, rev, tone, - ctcss, tonefq, ctcssfq, - (int64_t)labs((long)(chan->rptr_offs)), lockoutstr - ); + req, (int64_t)chan->freq, step, shift, rev, tone, + ctcss, tonefq, ctcssfq, + (int64_t)labs((long)(chan->rptr_offs)), lockoutstr + ); } retval = kenwood_transaction(rig, membuf, NULL, 0); @@ -2552,7 +2553,8 @@ int th_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) /* * get the aerial/antenna in use */ -int th_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int th_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { char buf[8]; int retval; diff --git a/rigs/kenwood/thg71.c b/rigs/kenwood/thg71.c index d21d969eb..c51915f01 100644 --- a/rigs/kenwood/thg71.c +++ b/rigs/kenwood/thg71.c @@ -508,7 +508,7 @@ int thg71_open(RIG *rig) for (i = 0; i < FRQRANGESIZ; i++) { freq_range_t frng; - char *strl,*stru; + char *strl, *stru; strl = strtok(NULL, ","); stru = strtok(NULL, ","); diff --git a/rigs/kenwood/ts570.c b/rigs/kenwood/ts570.c index 502532955..aef2f143a 100644 --- a/rigs/kenwood/ts570.c +++ b/rigs/kenwood/ts570.c @@ -348,7 +348,8 @@ ts570_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { sprintf(levelbuf, "PA0"); } - else { + else + { int i; for (i = 0; i < MAXDBLSTSIZ; i++) diff --git a/rigs/kit/dds60.c b/rigs/kit/dds60.c index 8d6cf830e..f499d73a1 100644 --- a/rigs/kit/dds60.c +++ b/rigs/kit/dds60.c @@ -172,7 +172,8 @@ int dds60_init(RIG *rig) { struct dds60_priv_data *priv; - rig->state.priv = (struct dds60_priv_data *)malloc(sizeof(struct dds60_priv_data)); + rig->state.priv = (struct dds60_priv_data *)malloc(sizeof( + struct dds60_priv_data)); if (!rig->state.priv) { diff --git a/rigs/kit/drt1.c b/rigs/kit/drt1.c index f8ef1160a..717a406a9 100644 --- a/rigs/kit/drt1.c +++ b/rigs/kit/drt1.c @@ -172,7 +172,8 @@ int drt1_init(RIG *rig) { struct drt1_priv_data *priv; - rig->state.priv = (struct drt1_priv_data *)malloc(sizeof(struct drt1_priv_data)); + rig->state.priv = (struct drt1_priv_data *)malloc(sizeof( + struct drt1_priv_data)); if (!rig->state.priv) { diff --git a/rigs/kit/dwt.c b/rigs/kit/dwt.c index 7be6ff8b0..66038b582 100644 --- a/rigs/kit/dwt.c +++ b/rigs/kit/dwt.c @@ -229,7 +229,8 @@ int dwtdll_init(RIG *rig) { struct dwtdll_priv_data *priv; - rig->state.priv = (struct dwtdll_priv_data *)malloc(sizeof(struct dwtdll_priv_data)); + rig->state.priv = (struct dwtdll_priv_data *)malloc(sizeof( + struct dwtdll_priv_data)); if (!rig->state.priv) { diff --git a/rigs/kit/elektor304.c b/rigs/kit/elektor304.c index 64a619409..829a0d2e9 100644 --- a/rigs/kit/elektor304.c +++ b/rigs/kit/elektor304.c @@ -165,7 +165,7 @@ int elektor304_init(RIG *rig) struct elektor304_priv_data *priv; rig->state.priv = (struct elektor304_priv_data *)malloc(sizeof(struct - elektor304_priv_data)); + elektor304_priv_data)); if (!rig->state.priv) { diff --git a/rigs/kit/elektor507.c b/rigs/kit/elektor507.c index d4bdeea87..4f7415dc8 100644 --- a/rigs/kit/elektor507.c +++ b/rigs/kit/elektor507.c @@ -54,7 +54,8 @@ static int elektor507_set_level(RIG *rig, vfo_t vfo, setting_t level, static int elektor507_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); static int elektor507_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option); -static int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx); +static int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx); static int elektor507_set_conf(RIG *rig, token_t token, const char *val); static int elektor507_get_conf(RIG *rig, token_t token, char *val); @@ -380,7 +381,7 @@ int elektor507_init(RIG *rig) struct elektor507_priv_data *priv; rig->state.priv = (struct elektor507_priv_data *)calloc(sizeof(struct - elektor507_priv_data), 1); + elektor507_priv_data), 1); if (!rig->state.priv) { @@ -1191,7 +1192,8 @@ int elektor507_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) return (ret != 0) ? -RIG_EIO : RIG_OK; } -int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int elektor507_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { struct elektor507_priv_data *priv = (struct elektor507_priv_data *) rig->state.priv; diff --git a/rigs/kit/fifisdr.c b/rigs/kit/fifisdr.c index 76f5e8a32..02a978d19 100644 --- a/rigs/kit/fifisdr.c +++ b/rigs/kit/fifisdr.c @@ -333,7 +333,7 @@ int fifisdr_init(RIG *rig) struct fifisdr_priv_instance_data *priv; rig->state.priv = (struct fifisdr_priv_instance_data *)calloc(sizeof( - struct fifisdr_priv_instance_data), 1); + struct fifisdr_priv_instance_data), 1); if (!rig->state.priv) { diff --git a/rigs/kit/funcube.c b/rigs/kit/funcube.c index 8742e825d..267a004bf 100644 --- a/rigs/kit/funcube.c +++ b/rigs/kit/funcube.c @@ -233,7 +233,8 @@ int funcube_init(RIG *rig) hamlib_port_t *rp = &rig->state.rigport; struct funcube_priv_data *priv; - rig->state.priv = (struct funcube_priv_data *)calloc(sizeof(struct funcube_priv_data), 1); + rig->state.priv = (struct funcube_priv_data *)calloc(sizeof( + struct funcube_priv_data), 1); if (!rig->state.priv) { @@ -262,7 +263,8 @@ int funcubeplus_init(RIG *rig) hamlib_port_t *rp = &rig->state.rigport; struct funcube_priv_data *priv; - rig->state.priv = (struct funcube_priv_data *)calloc(sizeof(struct funcube_priv_data), 1); + rig->state.priv = (struct funcube_priv_data *)calloc(sizeof( + struct funcube_priv_data), 1); if (!rig->state.priv) { diff --git a/rigs/kit/hiqsdr.c b/rigs/kit/hiqsdr.c index 374ca8d7c..d2d0a17e5 100644 --- a/rigs/kit/hiqsdr.c +++ b/rigs/kit/hiqsdr.c @@ -294,7 +294,8 @@ int hiqsdr_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rig->state.priv = (struct hiqsdr_priv_data *)malloc(sizeof(struct hiqsdr_priv_data)); + rig->state.priv = (struct hiqsdr_priv_data *)malloc(sizeof( + struct hiqsdr_priv_data)); if (!rig->state.priv) { diff --git a/rigs/kit/si570avrusb.c b/rigs/kit/si570avrusb.c index 5ae2579b5..8678ca1da 100644 --- a/rigs/kit/si570avrusb.c +++ b/rigs/kit/si570avrusb.c @@ -572,7 +572,7 @@ int si570avrusb_init(RIG *rig) struct si570xxxusb_priv_data *priv; rig->state.priv = (struct si570xxxusb_priv_data *)calloc(sizeof(struct - si570xxxusb_priv_data), 1); + si570xxxusb_priv_data), 1); if (!rig->state.priv) { @@ -613,7 +613,7 @@ int si570peaberry1_init(RIG *rig) struct si570xxxusb_priv_data *priv; rig->state.priv = (struct si570xxxusb_priv_data *)calloc(sizeof(struct - si570xxxusb_priv_data), 1); + si570xxxusb_priv_data), 1); if (!rig->state.priv) { @@ -654,7 +654,7 @@ int si570peaberry2_init(RIG *rig) struct si570xxxusb_priv_data *priv; rig->state.priv = (struct si570xxxusb_priv_data *)calloc(sizeof(struct - si570xxxusb_priv_data), 1); + si570xxxusb_priv_data), 1); if (!rig->state.priv) { @@ -695,7 +695,7 @@ int si570picusb_init(RIG *rig) struct si570xxxusb_priv_data *priv; rig->state.priv = (struct si570xxxusb_priv_data *)calloc(sizeof(struct - si570xxxusb_priv_data), 1); + si570xxxusb_priv_data), 1); if (!rig->state.priv) { @@ -736,7 +736,7 @@ int fasdr_init(RIG *rig) struct si570xxxusb_priv_data *priv; rig->state.priv = (struct si570xxxusb_priv_data *)calloc(sizeof(struct - si570xxxusb_priv_data), 1); + si570xxxusb_priv_data), 1); if (!rig->state.priv) { @@ -983,14 +983,15 @@ static int setBPF(RIG *rig, int enable) { int i; int retval = libusb_control_transfer(udh, REQUEST_TYPE_IN, - REQUEST_FILTERS, enable, (nBytes / 2) - 1, - (unsigned char *) FilterCrossOver, sizeof(FilterCrossOver), - rig->state.rigport.timeout); + REQUEST_FILTERS, enable, (nBytes / 2) - 1, + (unsigned char *) FilterCrossOver, sizeof(FilterCrossOver), + rig->state.rigport.timeout); if (retval < 2) { return -RIG_EIO; } + nBytes = retval; rig_debug(RIG_DEBUG_TRACE, "%s: Filter Bank 1:\n", __func__); diff --git a/rigs/lowe/lowe.c b/rigs/lowe/lowe.c index bd0f171ae..7b236c68b 100644 --- a/rigs/lowe/lowe.c +++ b/rigs/lowe/lowe.c @@ -294,7 +294,7 @@ const char *lowe_get_info(RIG *rig) if (retval != RIG_OK) { - rig_debug(RIG_DEBUG_VERBOSE,"%s: INF didn't work\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s: INF didn't work\n", __func__); // non-fatal } diff --git a/rigs/pcr/pcr.c b/rigs/pcr/pcr.c index e611d0367..1d26cff4b 100644 --- a/rigs/pcr/pcr.c +++ b/rigs/pcr/pcr.c @@ -862,6 +862,7 @@ pcr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (width != RIG_PASSBAND_NOCHANGE) { int pcrfilter; + if (width == RIG_PASSBAND_NORMAL) { width = rig_passband_normal(rig, mode); diff --git a/rigs/racal/ra37xx.c b/rigs/racal/ra37xx.c index fd28d138e..8e819b2da 100644 --- a/rigs/racal/ra37xx.c +++ b/rigs/racal/ra37xx.c @@ -224,7 +224,8 @@ int ra37xx_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ra37xx_priv_data *)malloc(sizeof(struct ra37xx_priv_data)); + rig->state.priv = (struct ra37xx_priv_data *)malloc(sizeof( + struct ra37xx_priv_data)); if (!rig->state.priv) { @@ -377,7 +378,7 @@ int ra37xx_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int ra37xx_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { //struct ra37xx_priv_data *priv = (struct ra37xx_priv_data*)rig->state.priv; - int ra_mode, widthtype, widthnum=0; + int ra_mode, widthtype, widthnum = 0; char buf[BUFSZ]; switch (mode) @@ -407,7 +408,9 @@ int ra37xx_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) rig_passband_normal(rig, mode); } - rig_debug(RIG_DEBUG_TRACE, "%s: widthtype = %i, widthnum = %i not implemented\n", __func__, widthtype, widthnum); + rig_debug(RIG_DEBUG_TRACE, + "%s: widthtype = %i, widthnum = %i not implemented\n", __func__, widthtype, + widthnum); #ifdef XXREMOVEDXX widthtype = 0; /* FIXME: no bandwidth for now */ widthnum = 0; @@ -751,7 +754,8 @@ int ra37xx_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) return ra37xx_transaction(rig, buf, NULL, NULL); } -int ra37xx_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int ra37xx_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { char buf[BUFSZ]; int retval, buflen, ra_ant; diff --git a/rigs/racal/racal.c b/rigs/racal/racal.c index b3bd4d46f..695b1af8e 100644 --- a/rigs/racal/racal.c +++ b/rigs/racal/racal.c @@ -128,7 +128,8 @@ int racal_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct racal_priv_data *)malloc(sizeof(struct racal_priv_data)); + rig->state.priv = (struct racal_priv_data *)malloc(sizeof( + struct racal_priv_data)); if (!rig->state.priv) { diff --git a/rigs/rs/gp2000.c b/rigs/rs/gp2000.c index 45212d641..3ca25f941 100644 --- a/rigs/rs/gp2000.c +++ b/rigs/rs/gp2000.c @@ -470,6 +470,7 @@ gp2000_get_info(RIG *rig) } p = strtok(infobuf, ","); + while (p) { switch (p[0]) diff --git a/rigs/tentec/jupiter.c b/rigs/tentec/jupiter.c index 421a17d23..a63e06ecb 100644 --- a/rigs/tentec/jupiter.c +++ b/rigs/tentec/jupiter.c @@ -294,13 +294,15 @@ int tt538_init(RIG *rig) { struct tt538_priv_data *priv; - rig->state.priv = (struct tt538_priv_data *) malloc(sizeof(struct tt538_priv_data)); + rig->state.priv = (struct tt538_priv_data *) malloc(sizeof( + struct tt538_priv_data)); if (!rig->state.priv) { /* whoops! memory shortage! */ return -RIG_ENOMEM; } + priv = rig->state.priv; memset(priv, 0, sizeof(struct tt538_priv_data)); @@ -816,7 +818,7 @@ int tt538_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) that integer (S units * 256) */ { char hex[5]; - int i; + int i; unsigned int ival; for (i = 0; i < 4; i++) { hex[i] = lvlbuf[i + 1]; } diff --git a/rigs/tentec/omnivii.c b/rigs/tentec/omnivii.c index ced089bb7..0622f7c80 100644 --- a/rigs/tentec/omnivii.c +++ b/rigs/tentec/omnivii.c @@ -330,13 +330,15 @@ int tt588_init(RIG *rig) struct tt588_priv_data *priv; rig_debug(RIG_DEBUG_VERBOSE, "%s:\n", __func__); - rig->state.priv = (struct tt588_priv_data *) malloc(sizeof(struct tt588_priv_data)); + rig->state.priv = (struct tt588_priv_data *) malloc(sizeof( + struct tt588_priv_data)); if (!rig->state.priv) { /* whoops! memory shortage! */ return -RIG_ENOMEM; } + priv = rig->state.priv; memset(priv, 0, sizeof(struct tt588_priv_data)); diff --git a/rigs/tentec/orion.c b/rigs/tentec/orion.c index 9c29bbc48..d96c9f167 100644 --- a/rigs/tentec/orion.c +++ b/rigs/tentec/orion.c @@ -229,9 +229,11 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int tt565_init(RIG *rig) { struct tt565_priv_data *priv; - rig->state.priv = (struct tt565_priv_data *)malloc(sizeof(struct tt565_priv_data)); + rig->state.priv = (struct tt565_priv_data *)malloc(sizeof( + struct tt565_priv_data)); if (!rig->state.priv) { return -RIG_ENOMEM; } /* no memory available */ + priv = rig->state.priv; memset(priv, 0, sizeof(struct tt565_priv_data)); @@ -2116,7 +2118,8 @@ int tt565_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) * * \sa tt565_set_ant */ -int tt565_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int tt565_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { char respbuf[TT565_BUFSIZE]; int resp_len, retval; diff --git a/rigs/tentec/paragon.c b/rigs/tentec/paragon.c index 897672a78..a0cdb8b5a 100644 --- a/rigs/tentec/paragon.c +++ b/rigs/tentec/paragon.c @@ -214,7 +214,8 @@ int tt585_init(RIG *rig) { struct tt585_priv_data *priv; - rig->state.priv = (struct tt585_priv_data *) malloc(sizeof(struct tt585_priv_data)); + rig->state.priv = (struct tt585_priv_data *) malloc(sizeof( + struct tt585_priv_data)); if (!rig->state.priv) { diff --git a/rigs/tentec/rx331.c b/rigs/tentec/rx331.c index aa7134b11..252333ec3 100644 --- a/rigs/tentec/rx331.c +++ b/rigs/tentec/rx331.c @@ -276,7 +276,7 @@ static int rx331_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return retval; } - snprintf(fmt,sizeof(fmt)-1,"%%i%%%ds",BUFSZ); + snprintf(fmt, sizeof(fmt) - 1, "%%i%%%ds", BUFSZ); sscanf(data + 1, fmt, &rig_id, data); if (rig_id != priv->receiver_id) @@ -297,13 +297,15 @@ int rx331_init(RIG *rig) { struct rx331_priv_data *priv; - rig->state.priv = (struct rx331_priv_data *)malloc(sizeof(struct rx331_priv_data)); + rig->state.priv = (struct rx331_priv_data *)malloc(sizeof( + struct rx331_priv_data)); if (!rig->state.priv) { /* whoops! memory shortage! */ return -RIG_ENOMEM; } + priv = rig->state.priv; memset(priv, 0, sizeof(struct rx331_priv_data)); diff --git a/rigs/tentec/tentec.c b/rigs/tentec/tentec.c index 64208d500..dc7bb01bf 100644 --- a/rigs/tentec/tentec.c +++ b/rigs/tentec/tentec.c @@ -111,7 +111,8 @@ int tentec_init(RIG *rig) { struct tentec_priv_data *priv; - rig->state.priv = (struct tentec_priv_data *)malloc(sizeof(struct tentec_priv_data)); + rig->state.priv = (struct tentec_priv_data *)malloc(sizeof( + struct tentec_priv_data)); if (!rig->state.priv) { diff --git a/rigs/tentec/tt550.c b/rigs/tentec/tt550.c index 1396c8432..d699b6ccd 100644 --- a/rigs/tentec/tt550.c +++ b/rigs/tentec/tt550.c @@ -367,7 +367,8 @@ tt550_init(RIG *rig) { struct tt550_priv_data *priv; - rig->state.priv = (struct tt550_priv_data *) malloc(sizeof(struct tt550_priv_data)); + rig->state.priv = (struct tt550_priv_data *) malloc(sizeof( + struct tt550_priv_data)); if (!rig->state.priv) { diff --git a/rigs/winradio/g313-win.c b/rigs/winradio/g313-win.c index 28da35bea..ffd1ae43a 100644 --- a/rigs/winradio/g313-win.c +++ b/rigs/winradio/g313-win.c @@ -233,7 +233,8 @@ int g313_init(RIG *rig) { struct g313_priv_data *priv; - rig->state.priv = (struct g313_priv_data *)malloc(sizeof(struct g313_priv_data)); + rig->state.priv = (struct g313_priv_data *)malloc(sizeof( + struct g313_priv_data)); if (!rig->state.priv) { diff --git a/rigs/winradio/winradio.c b/rigs/winradio/winradio.c index 5f769795b..b57a52578 100644 --- a/rigs/winradio/winradio.c +++ b/rigs/winradio/winradio.c @@ -106,6 +106,7 @@ int wr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) default: return -RIG_EINVAL; } + break; default: return -RIG_EINVAL; diff --git a/rigs/yaesu/ft100.c b/rigs/yaesu/ft100.c index b8eeea341..dd067cc40 100644 --- a/rigs/yaesu/ft100.c +++ b/rigs/yaesu/ft100.c @@ -328,7 +328,8 @@ int ft100_init(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rig->state.priv = (struct ft100_priv_data *) calloc(1, sizeof(struct ft100_priv_data)); + rig->state.priv = (struct ft100_priv_data *) calloc(1, + sizeof(struct ft100_priv_data)); if (!rig->state.priv) { return -RIG_ENOMEM; } diff --git a/rigs/yaesu/ft1000d.c b/rigs/yaesu/ft1000d.c index e017f6d73..16a5e9921 100644 --- a/rigs/yaesu/ft1000d.c +++ b/rigs/yaesu/ft1000d.c @@ -315,7 +315,8 @@ int ft1000d_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ft1000d_priv_data *) calloc(1, sizeof(struct ft1000d_priv_data)); + rig->state.priv = (struct ft1000d_priv_data *) calloc(1, + sizeof(struct ft1000d_priv_data)); if (!rig->state.priv) { @@ -2364,7 +2365,8 @@ int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) } rig_debug(RIG_DEBUG_TRACE, "%s: passed vfo %s\n", __func__, rig_strvfo(vfo)); - rig_debug(RIG_DEBUG_TRACE, "%s: passed level %s\n", __func__, rig_strlevel(level)); + rig_debug(RIG_DEBUG_TRACE, "%s: passed level %s\n", __func__, + rig_strlevel(level)); priv = (struct ft1000d_priv_data *) rig->state.priv; diff --git a/rigs/yaesu/ft1000mp.c b/rigs/yaesu/ft1000mp.c index 04f945e6d..aff157fee 100644 --- a/rigs/yaesu/ft1000mp.c +++ b/rigs/yaesu/ft1000mp.c @@ -599,12 +599,14 @@ int ft1000mp_init(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s: called \n", __func__); - rig->state.priv = (struct ft1000mp_priv_data *) calloc(1, sizeof(struct ft1000mp_priv_data)); + rig->state.priv = (struct ft1000mp_priv_data *) calloc(1, + sizeof(struct ft1000mp_priv_data)); if (!rig->state.priv) /* whoops! memory shortage! */ { return -RIG_ENOMEM; } + priv = rig->state.priv; /* @@ -613,7 +615,8 @@ int ft1000mp_init(RIG *rig) memcpy(priv->pcs, ncmd, sizeof(ncmd)); /* TODO: read pacing from preferences */ - priv->pacing = FT1000MP_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ + priv->pacing = + FT1000MP_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ priv->read_update_delay = FT1000MP_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ priv->current_vfo = RIG_VFO_A; /* default to VFO_A ? */ diff --git a/rigs/yaesu/ft600.c b/rigs/yaesu/ft600.c index f1fec62b9..740e6abec 100644 --- a/rigs/yaesu/ft600.c +++ b/rigs/yaesu/ft600.c @@ -244,7 +244,8 @@ int ft600_init(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rig->state.priv = (struct ft600_priv_data *) calloc(1, sizeof(struct ft600_priv_data)); + rig->state.priv = (struct ft600_priv_data *) calloc(1, + sizeof(struct ft600_priv_data)); if (!rig->state.priv) { return -RIG_ENOMEM; } diff --git a/rigs/yaesu/ft736.c b/rigs/yaesu/ft736.c index 9d9dcc496..5ad632c11 100644 --- a/rigs/yaesu/ft736.c +++ b/rigs/yaesu/ft736.c @@ -225,12 +225,14 @@ int ft736_open(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); - rig->state.priv = (struct ft736_priv_data *) calloc(1, sizeof(struct ft736_priv_data)); + rig->state.priv = (struct ft736_priv_data *) calloc(1, + sizeof(struct ft736_priv_data)); if (!rig->state.priv) { return -RIG_ENOMEM; } + priv = rig->state.priv; priv->split = RIG_SPLIT_OFF; diff --git a/rigs/yaesu/ft747.c b/rigs/yaesu/ft747.c index 80a3fc287..3f98bf71b 100644 --- a/rigs/yaesu/ft747.c +++ b/rigs/yaesu/ft747.c @@ -306,7 +306,8 @@ const struct rig_caps ft747_caps = int ft747_init(RIG *rig) { - rig->state.priv = (struct ft747_priv_data *) calloc(1, sizeof(struct ft747_priv_data)); + rig->state.priv = (struct ft747_priv_data *) calloc(1, + sizeof(struct ft747_priv_data)); if (!rig->state.priv) /* whoops! memory shortage! */ { diff --git a/rigs/yaesu/ft757gx.c b/rigs/yaesu/ft757gx.c index 3e70e495b..6cdafab12 100644 --- a/rigs/yaesu/ft757gx.c +++ b/rigs/yaesu/ft757gx.c @@ -333,7 +333,8 @@ int ft757_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ft757_priv_data *) calloc(1, sizeof(struct ft757_priv_data)); + rig->state.priv = (struct ft757_priv_data *) calloc(1, + sizeof(struct ft757_priv_data)); if (!rig->state.priv) /* whoops! memory shortage! */ { @@ -346,7 +347,8 @@ int ft757_init(RIG *rig) /* TODO: read pacing from preferences */ - priv->pacing = FT757GX_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ + priv->pacing = + FT757GX_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ priv->read_update_delay = FT757GX_DEFAULT_READ_TIMEOUT; /* set update timeout to safe value */ priv->current_vfo = RIG_VFO_A; /* default to VFO_A ? */ diff --git a/rigs/yaesu/ft767gx.c b/rigs/yaesu/ft767gx.c index 89a6a4316..2e4082d85 100644 --- a/rigs/yaesu/ft767gx.c +++ b/rigs/yaesu/ft767gx.c @@ -396,12 +396,14 @@ int ft767_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ft767_priv_data *) calloc(1, sizeof(struct ft767_priv_data)); + rig->state.priv = (struct ft767_priv_data *) calloc(1, + sizeof(struct ft767_priv_data)); if (!rig->state.priv) /* whoops! memory shortage! */ { return -RIG_ENOMEM; } + priv = rig->state.priv; rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); @@ -1475,9 +1477,12 @@ int ft767_send_block_and_ack(RIG *rig, unsigned char *cmd, size_t length) retval = read_block(&rig->state.rigport, (char *) cmd_echo_buf, YAESU_CMD_LENGTH); - if (retval < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed: %s\n", __func__, rigerror(retval)); - return retval; + + if (retval < 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: read_block failed: %s\n", __func__, + rigerror(retval)); + return retval; } /* see if it matches the command we sent */ diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 7a08c0abf..8cc9dfcc8 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -528,8 +528,10 @@ int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return -RIG_ENTARGET; } - if (check_cache_timeout(&p->fm_status_tv)) { + if (check_cache_timeout(&p->fm_status_tv)) + { int n; + if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0) { return n; @@ -647,8 +649,10 @@ int ft817_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) return -RIG_ENTARGET; } - if (check_cache_timeout(&p->tx_status_tv)) { + if (check_cache_timeout(&p->tx_status_tv)) + { int n; + if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_STATUS)) < 0) { return n; @@ -664,8 +668,10 @@ static int ft817_get_pometer_level(RIG *rig, value_t *val) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; - if (check_cache_timeout(&p->tx_status_tv)) { + if (check_cache_timeout(&p->tx_status_tv)) + { int n; + if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_STATUS)) < 0) { return n; @@ -734,8 +740,10 @@ static int ft817_get_raw_smeter_level(RIG *rig, value_t *val) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; - if (check_cache_timeout(&p->rx_status_tv)) { + if (check_cache_timeout(&p->rx_status_tv)) + { int n; + if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_RX_STATUS)) < 0) { return n; @@ -787,13 +795,15 @@ int ft817_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) return -RIG_ENTARGET; } - if (check_cache_timeout(&p->rx_status_tv)) { + if (check_cache_timeout(&p->rx_status_tv)) + { int n; + if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_RX_STATUS)) < 0) { return n; } - } + } /* TODO: consider bit 6 too ??? (CTCSS/DCS code match) */ if (p->rx_status & 0x80) @@ -1007,7 +1017,7 @@ int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) if (ptt_response != ptt) { hl_usleep(1000l * - FT817_RETRY_DELAY); // Wait before next try. Helps with slower rigs cloning FT817 protocol (e.g. MCHF) + FT817_RETRY_DELAY); // Wait before next try. Helps with slower rigs cloning FT817 protocol (e.g. MCHF) } } @@ -1291,7 +1301,7 @@ int ft817_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) { switch (op) { - int n; + int n; case RIG_OP_TOGGLE: rig_force_cache_timeout(&((struct ft817_priv_data *) diff --git a/rigs/yaesu/ft840.c b/rigs/yaesu/ft840.c index 22f2aceaa..a9d7fc48a 100644 --- a/rigs/yaesu/ft840.c +++ b/rigs/yaesu/ft840.c @@ -356,12 +356,14 @@ static int ft840_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ft840_priv_data *) calloc(1, sizeof(struct ft840_priv_data)); + rig->state.priv = (struct ft840_priv_data *) calloc(1, + sizeof(struct ft840_priv_data)); if (!rig->state.priv) /* whoops! memory shortage! */ { return -RIG_ENOMEM; } + priv = rig->state.priv; /* diff --git a/rigs/yaesu/ft847.c b/rigs/yaesu/ft847.c index 350246dce..b7744b8d8 100644 --- a/rigs/yaesu/ft847.c +++ b/rigs/yaesu/ft847.c @@ -532,13 +532,15 @@ int ft847_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ft847_priv_data *) calloc(1, sizeof(struct ft847_priv_data)); + rig->state.priv = (struct ft847_priv_data *) calloc(1, + sizeof(struct ft847_priv_data)); if (!rig->state.priv) { /* whoops! memory shortage! */ return -RIG_ENOMEM; } + priv = rig->state.priv; @@ -548,7 +550,8 @@ int ft847_init(RIG *rig) /* until these are set we won't know what the values are */ priv->freqA = 1; /* 1Hz default */ priv->freqB = 1; /* 1Hz default */ - priv->mode = RIG_MODE_USB; /* mode USB by default to avoid users not setting mode */ + priv->mode = + RIG_MODE_USB; /* mode USB by default to avoid users not setting mode */ priv->width = 1; /* 1Hz default */ return RIG_OK; diff --git a/rigs/yaesu/ft857.c b/rigs/yaesu/ft857.c index 29b669fcc..acd9f1d28 100644 --- a/rigs/yaesu/ft857.c +++ b/rigs/yaesu/ft857.c @@ -576,13 +576,15 @@ int ft857_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return -RIG_ENTARGET; } - if (check_cache_timeout(&p->fm_status_tv)) { + if (check_cache_timeout(&p->fm_status_tv)) + { int n; + if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0) { return n; } - } + } *freq = from_bcd_be(p->fm_status, 8) * 10; @@ -667,8 +669,10 @@ int ft857_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return -RIG_ENTARGET; } - if (check_cache_timeout(&p->fm_status_tv)) { + if (check_cache_timeout(&p->fm_status_tv)) + { int n; + if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0) { return n; @@ -748,12 +752,14 @@ int ft857_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) int ft857_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv; + if (vfo != RIG_VFO_CURR) { return -RIG_ENTARGET; } - if (check_cache_timeout(&p->tx_status_tv)) { + if (check_cache_timeout(&p->tx_status_tv)) + { int n; if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_TX_STATUS)) < 0) @@ -771,8 +777,10 @@ static int ft857_get_pometer_level(RIG *rig, value_t *val) { struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv; - if (check_cache_timeout(&p->tx_status_tv)) { + if (check_cache_timeout(&p->tx_status_tv)) + { int n; + if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_TX_STATUS)) < 0) { return n; @@ -845,13 +853,15 @@ int ft857_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) return -RIG_ENTARGET; } - if (check_cache_timeout(&p->rx_status_tv)) { + if (check_cache_timeout(&p->rx_status_tv)) + { int n; + if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_RX_STATUS)) < 0) { return n; } - } + } /* TODO: consider bit 6 too ??? (CTCSS/DCS code match) */ if (p->rx_status & 0x80) diff --git a/rigs/yaesu/ft890.c b/rigs/yaesu/ft890.c index ea1515309..d5e1517a9 100644 --- a/rigs/yaesu/ft890.c +++ b/rigs/yaesu/ft890.c @@ -292,12 +292,14 @@ static int ft890_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ft890_priv_data *) calloc(1, sizeof(struct ft890_priv_data)); + rig->state.priv = (struct ft890_priv_data *) calloc(1, + sizeof(struct ft890_priv_data)); if (!rig->state.priv) /* whoops! memory shortage! */ { return -RIG_ENOMEM; } + priv = rig->state.priv; /* @@ -1307,9 +1309,13 @@ static int ft890_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit) { err = ft890_send_dynamic_cmd(rig, FT890_NATIVE_CLARIFIER_OPS, CLAR_RX_OFF, 0, 0, 0); - if (err != RIG_OK) { - rig_debug(RIG_DEBUG_ERR,"%s: clarifier off error: %s\n", __func__, strerror(err)); + + if (err != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: clarifier off error: %s\n", __func__, + strerror(err)); } + return err; } diff --git a/rigs/yaesu/ft897.c b/rigs/yaesu/ft897.c index 984c08c07..6f16268c6 100644 --- a/rigs/yaesu/ft897.c +++ b/rigs/yaesu/ft897.c @@ -621,8 +621,9 @@ int ft897_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) } if (check_cache_timeout(&p->tx_status_tv)) - { + { int n; + if ((n = ft897_get_status(rig, FT897_NATIVE_CAT_GET_TX_STATUS)) < 0) { return n; diff --git a/rigs/yaesu/ft900.c b/rigs/yaesu/ft900.c index a06913ffd..27187a15f 100644 --- a/rigs/yaesu/ft900.c +++ b/rigs/yaesu/ft900.c @@ -294,12 +294,14 @@ static int ft900_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ft900_priv_data *) calloc(1, sizeof(struct ft900_priv_data)); + rig->state.priv = (struct ft900_priv_data *) calloc(1, + sizeof(struct ft900_priv_data)); if (!rig->state.priv) /* whoops! memory shortage! */ { return -RIG_ENOMEM; } + priv = rig->state.priv; /* @@ -1313,9 +1315,13 @@ static int ft900_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit) { err = ft900_send_dynamic_cmd(rig, FT900_NATIVE_CLARIFIER_OPS, CLAR_RX_OFF, 0, 0, 0); - if (err != RIG_OK) { - rig_debug(RIG_DEBUG_ERR,"%s: clarifier off error: %s\n", __func__, strerror(err)); + + if (err != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: clarifier off error: %s\n", __func__, + strerror(err)); } + return err; } diff --git a/rigs/yaesu/ft920.c b/rigs/yaesu/ft920.c index 241035b48..e8260f855 100644 --- a/rigs/yaesu/ft920.c +++ b/rigs/yaesu/ft920.c @@ -372,12 +372,14 @@ static int ft920_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ft920_priv_data *) calloc(1, sizeof(struct ft920_priv_data)); + rig->state.priv = (struct ft920_priv_data *) calloc(1, + sizeof(struct ft920_priv_data)); if (!rig->state.priv) { return -RIG_ENOMEM; /* whoops! memory shortage! */ } + priv = rig->state.priv; /* diff --git a/rigs/yaesu/ft980.c b/rigs/yaesu/ft980.c index 8d9f945d8..febd73869 100644 --- a/rigs/yaesu/ft980.c +++ b/rigs/yaesu/ft980.c @@ -737,7 +737,7 @@ int ft980_open(RIG *rig) do { write_block(&rig->state.rigport, (char *) cmd_ON_OFF, - YAESU_CMD_LENGTH); + YAESU_CMD_LENGTH); retval = read_block(&rig->state.rigport, (char *) echo_back, YAESU_CMD_LENGTH); } while (retval != 5 && retry_count2++ < rig->state.rigport.retry); @@ -766,7 +766,7 @@ int ft980_close(RIG *rig) do { write_block(&rig->state.rigport, (char *) cmd_ON_OFF, - YAESU_CMD_LENGTH); + YAESU_CMD_LENGTH); retval = read_block(&rig->state.rigport, (char *) echo_back, YAESU_CMD_LENGTH); } while (retval != 5 && retry_count2++ < rig->state.rigport.retry); diff --git a/rigs/yaesu/ft990.c b/rigs/yaesu/ft990.c index aac063a15..5f647ca5a 100644 --- a/rigs/yaesu/ft990.c +++ b/rigs/yaesu/ft990.c @@ -300,7 +300,8 @@ int ft990_init(RIG *rig) return -RIG_EINVAL; } - rig->state.priv = (struct ft990_priv_data *) calloc(1, sizeof(struct ft990_priv_data)); + rig->state.priv = (struct ft990_priv_data *) calloc(1, + sizeof(struct ft990_priv_data)); if (!rig->state.priv) { @@ -2313,7 +2314,8 @@ int ft990_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) } rig_debug(RIG_DEBUG_TRACE, "%s: passed vfo %s\n", __func__, rig_strvfo(vfo)); - rig_debug(RIG_DEBUG_TRACE, "%s: passed level %s\n", __func__, rig_strlevel(level)); + rig_debug(RIG_DEBUG_TRACE, "%s: passed level %s\n", __func__, + rig_strlevel(level)); priv = (struct ft990_priv_data *) rig->state.priv; diff --git a/rigs/yaesu/ft991.c b/rigs/yaesu/ft991.c index 836850201..35d9278a3 100644 --- a/rigs/yaesu/ft991.c +++ b/rigs/yaesu/ft991.c @@ -103,19 +103,19 @@ const struct rig_caps ft991_caps = // Rig only has 1 model .rx_range_list1 = { - {kHz(30), MHz(56), FT991_ALL_RX_MODES, -1, -1, FT991_VFO_ALL, FT991_ANTS,"Operating"}, - {MHz(118), MHz(164), FT991_ALL_RX_MODES, -1, -1, FT991_VFO_ALL, FT991_ANTS,"Operating"}, - {MHz(420), MHz(470), FT991_ALL_RX_MODES, -1, -1, FT991_VFO_ALL, FT991_ANTS,"Operating"}, + {kHz(30), MHz(56), FT991_ALL_RX_MODES, -1, -1, FT991_VFO_ALL, FT991_ANTS, "Operating"}, + {MHz(118), MHz(164), FT991_ALL_RX_MODES, -1, -1, FT991_VFO_ALL, FT991_ANTS, "Operating"}, + {MHz(420), MHz(470), FT991_ALL_RX_MODES, -1, -1, FT991_VFO_ALL, FT991_ANTS, "Operating"}, RIG_FRNG_END, }, .tx_range_list1 = { - {MHz(1.8), MHz(54),FT991_OTHER_TX_MODES, W(5), W(100), FT991_VFO_ALL, FT991_ANTS,"Operating"}, - {MHz(1.8), MHz(54),FT991_AM_TX_MODES, W(2), W(25), FT991_VFO_ALL, FT991_ANTS,"Operating"}, /* AM class */ - {MHz(144), MHz(148),FT991_OTHER_TX_MODES, W(5), W(100), FT991_VFO_ALL, FT991_ANTS,"Operating"}, - {MHz(144), MHz(148),FT991_AM_TX_MODES, W(2), W(25), FT991_VFO_ALL, FT991_ANTS,"Operating"}, /* AM class */ - {MHz(430), MHz(450),FT991_OTHER_TX_MODES, W(5), W(100), FT991_VFO_ALL, FT991_ANTS,"Operating"}, - {MHz(430), MHz(450),FT991_AM_TX_MODES, W(2), W(25), FT991_VFO_ALL, FT991_ANTS,"Operating"}, /* AM class */ + {MHz(1.8), MHz(54), FT991_OTHER_TX_MODES, W(5), W(100), FT991_VFO_ALL, FT991_ANTS, "Operating"}, + {MHz(1.8), MHz(54), FT991_AM_TX_MODES, W(2), W(25), FT991_VFO_ALL, FT991_ANTS, "Operating"}, /* AM class */ + {MHz(144), MHz(148), FT991_OTHER_TX_MODES, W(5), W(100), FT991_VFO_ALL, FT991_ANTS, "Operating"}, + {MHz(144), MHz(148), FT991_AM_TX_MODES, W(2), W(25), FT991_VFO_ALL, FT991_ANTS, "Operating"}, /* AM class */ + {MHz(430), MHz(450), FT991_OTHER_TX_MODES, W(5), W(100), FT991_VFO_ALL, FT991_ANTS, "Operating"}, + {MHz(430), MHz(450), FT991_AM_TX_MODES, W(2), W(25), FT991_VFO_ALL, FT991_ANTS, "Operating"}, /* AM class */ RIG_FRNG_END, }, @@ -342,7 +342,8 @@ int ft991_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, return err; } - strncat(restore_commands, priv->ret_data, NEWCAT_DATA_LEN-strlen(restore_commands)); + strncat(restore_commands, priv->ret_data, + NEWCAT_DATA_LEN - strlen(restore_commands)); /* Change mode on VFOA */ if (RIG_OK != (err = newcat_set_mode(rig, RIG_VFO_A, tx_mode, @@ -364,6 +365,7 @@ int ft991_init(RIG *rig) rig->caps->version); ret = newcat_init(rig); + if (ret != RIG_OK) { return ret; } rig->state.current_vfo = RIG_VFO_A; diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 73fed9ac9..ed12ad4be 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -287,7 +287,8 @@ int newcat_init(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - rig->state.priv = (struct newcat_priv_data *) calloc(1, sizeof(struct newcat_priv_data)); + rig->state.priv = (struct newcat_priv_data *) calloc(1, + sizeof(struct newcat_priv_data)); if (!rig->state.priv) /* whoops! memory shortage! */ { @@ -805,11 +806,11 @@ int newcat_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) priv->cmd_str[3] = 'C'; break; - case RIG_MODE_AMN: + case RIG_MODE_AMN: priv->cmd_str[3] = 'D'; break; - case RIG_MODE_C4FM: + case RIG_MODE_C4FM: priv->cmd_str[3] = 'E'; break; @@ -1044,7 +1045,9 @@ int newcat_set_vfo(RIG *rig, vfo_t vfo) } err = newcat_get_vfo_mode(rig, &vfo_mode); - if (err != RIG_OK) { + + if (err != RIG_OK) + { return err; } @@ -1175,7 +1178,9 @@ int newcat_get_vfo(RIG *rig, vfo_t *vfo) /* Check to see if RIG is in MEM mode */ err = newcat_get_vfo_mode(rig, &vfo_mode); - if (err != RIG_OK) { + + if (err != RIG_OK) + { return err; } @@ -2450,7 +2455,8 @@ int newcat_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) } -int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; int err; @@ -3399,7 +3405,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) case RIG_LEVEL_STRENGTH: // Yaesu's return straight s-meter answers - + if (newcat_is_rig(rig, RIG_MODEL_FT991)) { // value of 0.448 determined by data from W6HN @@ -3416,11 +3422,11 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) // +35db SM0203 80 // +50db SM0237 90 // +60db SM0255 100 - // 114dB range over 0-255 referenced to S0 of -54dB - val->i = atoi(retlvl) * (114.0/255.0) - 54; + // 114dB range over 0-255 referenced to S0 of -54dB + val->i = atoi(retlvl) * (114.0 / 255.0) - 54; } else // some Yaesu's return straight s-meter answers - { + { // Return dbS9 -- does >S9 mean 10dB increments? If not, add to rig driver if (val->i > 0) { val->i = (atoi(retlvl) - 9) * 10; } else { val->i = (atoi(retlvl) - 9) * 6; } // Return dbS9 does >S9 mean 10dB increments? @@ -4607,8 +4613,8 @@ int newcat_get_channel(RIG *rig, channel_t *chan) case 'E': chan->mode = RIG_MODE_C4FM; break; - default: - rig_debug(RIG_DEBUG_ERR,"%s: unknown mode=%c\n", __func__, *retval); + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown mode=%c\n", __func__, *retval); chan->mode = RIG_MODE_LSB; } @@ -4946,7 +4952,9 @@ int newcat_get_tx_vfo(RIG *rig, vfo_t *tx_vfo) /* Check to see if RIG is in MEM mode */ err = newcat_get_vfo_mode(rig, &vfo_mode); - if (err != RIG_OK) { + + if (err != RIG_OK) + { return err; } diff --git a/rigs/yaesu/vr5000.c b/rigs/yaesu/vr5000.c index 41d15ac3c..0ab198ea1 100644 --- a/rigs/yaesu/vr5000.c +++ b/rigs/yaesu/vr5000.c @@ -247,7 +247,8 @@ struct vr5000_priv_data int vr5000_init(RIG *rig) { - rig->state.priv = (struct vr5000_priv_data *) calloc(1, sizeof(struct vr5000_priv_data)); + rig->state.priv = (struct vr5000_priv_data *) calloc(1, + sizeof(struct vr5000_priv_data)); if (!rig->state.priv) { return -RIG_ENOMEM; } diff --git a/rigs/yaesu/vx1700.c b/rigs/yaesu/vx1700.c index 2688434ee..a8c0e25de 100644 --- a/rigs/yaesu/vx1700.c +++ b/rigs/yaesu/vx1700.c @@ -603,6 +603,7 @@ static int vx1700_init(RIG *rig) rig->state.priv = calloc(1, sizeof(struct vx1700_priv_data)); if (rig->state.priv == NULL) { return -RIG_ENOMEM; } + priv = rig->state.priv; priv->ch = 1; diff --git a/rotators/gs232a/gs232.c b/rotators/gs232a/gs232.c index 0255644dc..c93b4c215 100644 --- a/rotators/gs232a/gs232.c +++ b/rotators/gs232a/gs232.c @@ -378,7 +378,7 @@ const struct rot_caps f1tetracker_rot_caps = .get_position = NULL, /* no position feedback available */ .set_position = gs232_rot_set_position, -#ifdef XXREMOVEDXX +#ifdef XXREMOVEDXX .stop = gs232_rot_stop, #endif }; diff --git a/rotators/heathkit/hd1780.c b/rotators/heathkit/hd1780.c index d443249a7..ab2df2073 100644 --- a/rotators/heathkit/hd1780.c +++ b/rotators/heathkit/hd1780.c @@ -121,7 +121,7 @@ static int hd1780_rot_init(ROT *rot) } rot->state.priv = (struct hd1780_rot_priv_data *) - malloc(sizeof(struct hd1780_rot_priv_data)); + malloc(sizeof(struct hd1780_rot_priv_data)); if (!rot->state.priv) { diff --git a/rotators/m2/rc2800.c b/rotators/m2/rc2800.c index ba2ac2e5c..131ef6671 100644 --- a/rotators/m2/rc2800.c +++ b/rotators/m2/rc2800.c @@ -74,6 +74,7 @@ static int rc2800_parse(char *s, char *device, float *value) rig_debug(RIG_DEBUG_TRACE, "%s: device return->%s", __func__, s); len = strlen(s); + if (len == 0) { return -RIG_EPROTO; diff --git a/rotators/meade/meade.c b/rotators/meade/meade.c index ac5265b47..4a4fe0f13 100644 --- a/rotators/meade/meade.c +++ b/rotators/meade/meade.c @@ -166,7 +166,7 @@ static int meade_init(ROT *rot) struct meade_priv_data *priv; rot->state.priv = (struct meade_priv_data *) - calloc(1, sizeof(struct meade_priv_data)); + calloc(1, sizeof(struct meade_priv_data)); if (!rot->state.priv) { @@ -329,7 +329,7 @@ static int meade_get_position(ROT *rot, azimuth_t *az, elevation_t *el) // GZ returns DDD*MM# or DDD*MM'SS# // GA returns sDD*MM# or sDD*MM'SS# 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); + &az_seconds, &el_degrees, &el_minutes, &el_seconds, &eom); if (n != 7 || eom != '#') { diff --git a/rotators/prosistel/prosistel.c b/rotators/prosistel/prosistel.c index c715ff7f0..4ca323deb 100644 --- a/rotators/prosistel/prosistel.c +++ b/rotators/prosistel/prosistel.c @@ -118,7 +118,7 @@ transaction_write: } //check if reply match issued command - if ( cmdstr && data[0] == 0x02 && data[3] == cmdstr[2]) + if (cmdstr && data[0] == 0x02 && data[3] == cmdstr[2]) { rig_debug(RIG_DEBUG_VERBOSE, "%s Command %c reply received\n", __func__, data[3]); diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c index 285c67b51..1f9e38602 100644 --- a/rotators/rotorez/rotorez.c +++ b/rotators/rotorez/rotorez.c @@ -366,7 +366,7 @@ static int rotorez_rot_init(ROT *rot) } rot->state.priv = (struct rotorez_rot_priv_data *) - malloc(sizeof(struct rotorez_rot_priv_data)); + malloc(sizeof(struct rotorez_rot_priv_data)); if (!rot->state.priv) { @@ -375,7 +375,7 @@ static int rotorez_rot_init(ROT *rot) rot->state.rotport.type.rig = RIG_PORT_SERIAL; - ((struct rotorez_rot_priv_data*)rot->state.priv)->az = 0; + ((struct rotorez_rot_priv_data *)rot->state.priv)->az = 0; return RIG_OK; } diff --git a/rotators/ts7400/include/readADC.c b/rotators/ts7400/include/readADC.c index 53c4a68b7..87551397b 100644 --- a/rotators/ts7400/include/readADC.c +++ b/rotators/ts7400/include/readADC.c @@ -48,6 +48,7 @@ int read_calibration(int buf[NUM_CHANNELS][2]) if (fread(cal, NUM_CHANNELS * 4, 1, f) == 1) { fclose(f); + for (j = 0; j < 2; j++) for (i = 0; i < NUM_CHANNELS; i++) { diff --git a/rotators/ts7400/include/test7400ADC.c b/rotators/ts7400/include/test7400ADC.c index b3bfdf018..efea91015 100644 --- a/rotators/ts7400/include/test7400ADC.c +++ b/rotators/ts7400/include/test7400ADC.c @@ -46,6 +46,7 @@ int read_calibration(int buf[NUM_CHANNELS][2]) if (fread(cal, NUM_CHANNELS * 4, 1, f) == 1) { fclose(f); + for (j = 0; j < 2; j++) for (i = 0; i < NUM_CHANNELS; i++) { diff --git a/rotators/ts7400/ts7400.c b/rotators/ts7400/ts7400.c index dbabb3591..786b5c60c 100644 --- a/rotators/ts7400/ts7400.c +++ b/rotators/ts7400/ts7400.c @@ -56,7 +56,7 @@ static int ts7400_rot_init(ROT *rot) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rot->state.priv = (struct ts7400_rot_priv_data *) - malloc(sizeof(struct ts7400_rot_priv_data)); + malloc(sizeof(struct ts7400_rot_priv_data)); if (!rot->state.priv) { diff --git a/src/conf.c b/src/conf.c index 31d899d96..4f1170da3 100644 --- a/src/conf.c +++ b/src/conf.c @@ -581,6 +581,7 @@ static int frontend_get_conf(RIG *rig, token_t token, char *val) break; #if 0 // needs to be replace? + case TOK_ITU_REGION: sprintf(val, "%d", rs->itu_region == 1 ? RIG_ITU_REGION1 : RIG_ITU_REGION2); diff --git a/src/debug.c b/src/debug.c index f138a072e..d5d5bb1a8 100644 --- a/src/debug.c +++ b/src/debug.c @@ -87,6 +87,7 @@ void dump_hex(const unsigned char ptr[], size_t size) for (i = 0; i < size; ++i) { unsigned char c; + if (i % DUMP_HEX_WIDTH == 0) { /* new line */ diff --git a/src/mem.c b/src/mem.c index 2c2bab5bc..4df58a043 100644 --- a/src/mem.c +++ b/src/mem.c @@ -448,7 +448,8 @@ static int generic_save_channel(RIG *rig, channel_t *chan) if (mem_cap->ant) { ant_t ant_tx, ant_rx; - rig_get_ant(rig, RIG_VFO_CURR, RIG_ANT_CURR, &vdummy, &chan->ant, &ant_tx, &ant_rx); + rig_get_ant(rig, RIG_VFO_CURR, RIG_ANT_CURR, &vdummy, &chan->ant, &ant_tx, + &ant_rx); } if (mem_cap->tuning_step) diff --git a/src/microham.c b/src/microham.c index 055e415f4..e9ee336b3 100644 --- a/src/microham.c +++ b/src/microham.c @@ -766,6 +766,7 @@ static void *read_device(void *p) { int ret; int maxdev; + // // setting uh_is_initialized to zero in the main thread // tells this one that it is all over now @@ -1136,6 +1137,7 @@ int uh_open_ptt() if (!uh_is_initialized) { start_thread(); + if (!uh_is_initialized) { return -1; @@ -1151,6 +1153,7 @@ int uh_open_wkey() if (!uh_is_initialized) { start_thread(); + if (!uh_is_initialized) { return -1; @@ -1177,6 +1180,7 @@ int uh_open_radio(int baud, int databits, int stopbits, int rtscts) if (!uh_is_initialized) { start_thread(); + if (!uh_is_initialized) { return -1; diff --git a/src/misc.c b/src/misc.c index 5f0f0d0f3..41e166c9f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -419,7 +419,7 @@ int HAMLIB_API rig_strrmodes(rmode_t modes, char *buf, int buflen) if (modes == RIG_MODE_NONE) { - snprintf(buf,buflen,"NONE"); + snprintf(buf, buflen, "NONE"); return RIG_OK; } @@ -428,10 +428,13 @@ int HAMLIB_API rig_strrmodes(rmode_t modes, char *buf, int buflen) if (modes & mode_str[i].mode) { char modebuf[16]; - if (strlen(buf)==0) snprintf(modebuf, sizeof(modebuf), "%s", mode_str[i].str); - else snprintf(modebuf, sizeof(modebuf)," %s", mode_str[i].str); - strncat(buf, modebuf, buflen-strlen(buf)-1); - if (strlen(buf) > buflen-10) return -RIG_ETRUNC; + + if (strlen(buf) == 0) { snprintf(modebuf, sizeof(modebuf), "%s", mode_str[i].str); } + else { snprintf(modebuf, sizeof(modebuf), " %s", mode_str[i].str); } + + strncat(buf, modebuf, buflen - strlen(buf) - 1); + + if (strlen(buf) > buflen - 10) { return -RIG_ETRUNC; } } } diff --git a/src/network.c b/src/network.c index c116b4697..a9d0e52f7 100644 --- a/src/network.c +++ b/src/network.c @@ -98,7 +98,7 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg) 0, NULL)) { - rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, (char*)lpMsgBuf); + rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, (char *)lpMsgBuf); LocalFree(lpMsgBuf); } else diff --git a/src/rig.c b/src/rig.c index a91bcd415..a803a45b1 100644 --- a/src/rig.c +++ b/src/rig.c @@ -408,6 +408,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model) rs->lo_freq = 0; #if 0 // this is no longer applicable -- replace it with something? + // we need to be able to figure out what model radio we have // before we can set up the rig_state with the rig's specific freq range // if we can't figure out what model rig we have this is impossible @@ -431,6 +432,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model) sizeof(struct freq_range_list)*FRQRANGESIZ); break; } + #endif rs->vfo_list = 0; rs->mode_list = 0; @@ -696,7 +698,9 @@ int HAMLIB_API rig_open(RIG *rig) case RIG_PTT_GPIO: case RIG_PTT_GPION: - rs->pttport.fd = gpio_open(&rs->pttport, 1, RIG_PTT_GPION == rs->pttport.type.ptt ? 0 : 1); + rs->pttport.fd = gpio_open(&rs->pttport, 1, + RIG_PTT_GPION == rs->pttport.type.ptt ? 0 : 1); + if (rs->pttport.fd < 0) { rig_debug(RIG_DEBUG_ERR, @@ -771,7 +775,9 @@ int HAMLIB_API rig_open(RIG *rig) case RIG_DCD_GPIO: case RIG_DCD_GPION: - rs->dcdport.fd = gpio_open(&rs->dcdport, 0, RIG_DCD_GPION == rs->dcdport.type.dcd ? 0 : 1); + rs->dcdport.fd = gpio_open(&rs->dcdport, 0, + RIG_DCD_GPION == rs->dcdport.type.dcd ? 0 : 1); + if (rs->dcdport.fd < 0) { rig_debug(RIG_DEBUG_ERR, @@ -1057,28 +1063,41 @@ static int twiddling(RIG *rig) caps = rig->caps; - if ( caps->get_freq) { // gotta have get_freq of course + if (caps->get_freq) // gotta have get_freq of course + { freq_t curr_freq = 0; int retval2; int elapsed; retval2 = caps->get_freq(rig, RIG_VFO_CURR, &curr_freq); - if (retval2 == RIG_OK && rig->state.current_freq != curr_freq) { - rig_debug(RIG_DEBUG_TRACE,"%s: Somebody twiddling the VFO? last_freq=%.0f, curr_freq=%.0f\n", __func__, rig->state.current_freq, curr_freq); - if (rig->state.current_freq == 0) { + + if (retval2 == RIG_OK && rig->state.current_freq != curr_freq) + { + rig_debug(RIG_DEBUG_TRACE, + "%s: Somebody twiddling the VFO? last_freq=%.0f, curr_freq=%.0f\n", __func__, + rig->state.current_freq, curr_freq); + + if (rig->state.current_freq == 0) + { rig->state.current_freq = curr_freq; return 0; // not twiddling as first time freq is being set } + rig->state.twiddling = time(NULL); // update last twiddle time rig->state.current_freq = curr_freq; // we have a new freq to remember } + elapsed = time(NULL) - rig->state.twiddling; - if (elapsed < 3) { - rig_debug(RIG_DEBUG_TRACE,"%s: Twiddle elapsed < 3, elapsed=%d\n", __func__, elapsed); + + if (elapsed < 3) + { + rig_debug(RIG_DEBUG_TRACE, "%s: Twiddle elapsed < 3, elapsed=%d\n", __func__, + elapsed); return 1; // would be better as error but other software won't handle it } } - return 0; // + + return 0; // } /** @@ -1129,8 +1148,10 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) if ((caps->targetable_vfo & RIG_TARGETABLE_FREQ) || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) { - if (twiddling(rig)) { - rig_debug(RIG_DEBUG_TRACE,"%s: Ignoring set_freq due to VFO twiddling\n", __func__); + if (twiddling(rig)) + { + rig_debug(RIG_DEBUG_TRACE, "%s: Ignoring set_freq due to VFO twiddling\n", + __func__); return RIG_OK; // would be better as error but other software won't handle errors } @@ -1139,6 +1160,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) else { int rc2; + if (!caps->set_vfo) { return -RIG_ENTARGET; @@ -1152,8 +1174,10 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) return retcode; } - if (twiddling(rig)) { - rig_debug(RIG_DEBUG_TRACE,"%s: Ignoring set_freq due to VFO twiddling\n", __func__); + if (twiddling(rig)) + { + rig_debug(RIG_DEBUG_TRACE, "%s: Ignoring set_freq due to VFO twiddling\n", + __func__); return RIG_OK; // would be better as error but other software won't handle errors } @@ -1223,6 +1247,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; @@ -1620,8 +1645,10 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo) return -RIG_ENAVAIL; } - if (twiddling(rig)) { - rig_debug(RIG_DEBUG_TRACE,"%s: Ignoring set_vfo due to VFO twiddling\n", __func__); + if (twiddling(rig)) + { + rig_debug(RIG_DEBUG_TRACE, "%s: Ignoring set_vfo due to VFO twiddling\n", + __func__); return RIG_OK; // would be better as error but other software won't handle errors } @@ -3609,7 +3636,8 @@ int HAMLIB_API rig_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) * * \sa rig_set_ant() */ -int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) +int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { const struct rig_caps *caps; int retcode, rc2; diff --git a/src/settings.c b/src/settings.c index 4d69e13df..adfc04da6 100644 --- a/src/settings.c +++ b/src/settings.c @@ -765,9 +765,9 @@ int HAMLIB_API rig_get_ext_level(RIG *rig, * \sa rig_get_ext_func() */ int HAMLIB_API rig_set_ext_func(RIG *rig, - vfo_t vfo, - token_t token, - int status) + vfo_t vfo, + token_t token, + int status) { const struct rig_caps *caps; int retcode; @@ -831,9 +831,9 @@ int HAMLIB_API rig_set_ext_func(RIG *rig, * \sa rig_set_ext_func() */ int HAMLIB_API rig_get_ext_func(RIG *rig, - vfo_t vfo, - token_t token, - int *status) + vfo_t vfo, + token_t token, + int *status) { const struct rig_caps *caps; int retcode; diff --git a/src/usb_port.c b/src/usb_port.c index f0c259212..15807cd39 100644 --- a/src/usb_port.c +++ b/src/usb_port.c @@ -184,7 +184,7 @@ static libusb_device_handle *find_and_open_device(const hamlib_port_t *port) */ if (strncasecmp(string, port->parm.usb.product, - sizeof(port->parm.usb.product)-1) != 0) + sizeof(port->parm.usb.product) - 1) != 0) { rig_debug(RIG_DEBUG_WARN, diff --git a/tests/ampctl_parse.c b/tests/ampctl_parse.c index 8593c6d62..e33acc384 100644 --- a/tests/ampctl_parse.c +++ b/tests/ampctl_parse.c @@ -470,7 +470,7 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc) char arg3[MAXARGSZ + 1], *p3 = NULL; char arg4[MAXARGSZ + 1], *p4 = NULL; #ifdef __USEP5P6__ // to avoid cppcheck warning - char *p5 = NULL; + char *p5 = NULL; char *p6 = NULL; #endif @@ -480,6 +480,7 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc) if (interactive) { static int last_was_ret = 1; + if (prompt) { fprintf_flush(fout, "\nAmplifier command: "); @@ -847,6 +848,7 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc) } #ifdef HAVE_LIBREADLINE + if (interactive && prompt && have_rl) { int j, x; @@ -1324,6 +1326,7 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc) #endif } + #endif // HAVE_LIBREADLINE /* diff --git a/tests/ampctld.c b/tests/ampctld.c index 35d866247..4d0f3956c 100644 --- a/tests/ampctld.c +++ b/tests/ampctld.c @@ -135,7 +135,7 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg) NULL)) { - rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, (char*)lpMsgBuf); + rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, (char *)lpMsgBuf); LocalFree(lpMsgBuf); } else diff --git a/tests/dumpcaps.c b/tests/dumpcaps.c index 0150897f8..32981c843 100644 --- a/tests/dumpcaps.c +++ b/tests/dumpcaps.c @@ -435,52 +435,52 @@ int dumpcaps(RIG *rig, FILE *fout) fprintf(fout, "\n"); label1 = caps->tx_range_list1->label; - label1 = label1==NULL?"TBD":label1; + label1 = label1 == NULL ? "TBD" : label1; fprintf(fout, "TX ranges #1 for %s:\n", label1); range_print(fout, caps->tx_range_list1, 0); labelrx1 = caps->rx_range_list1->label; - labelrx1 = labelrx1==NULL?"TBD":labelrx1; + labelrx1 = labelrx1 == NULL ? "TBD" : labelrx1; fprintf(fout, "RX ranges #1 for %s:\n", labelrx1); range_print(fout, caps->rx_range_list1, 1); label2 = caps->rx_range_list2->label; - label2 = label2==NULL?"TBD":label2; + label2 = label2 == NULL ? "TBD" : label2; fprintf(fout, "TX ranges #2 for %s:\n", label2); range_print(fout, caps->tx_range_list2, 0); label2 = caps->rx_range_list2->label; - label2 = label2==NULL?"TBD":label2; + label2 = label2 == NULL ? "TBD" : label2; fprintf(fout, "RX ranges #2 for %s:\n", label2); range_print(fout, caps->rx_range_list2, 1); label3 = caps->rx_range_list3->label; - label3 = label3==NULL?"TBD":label3; + label3 = label3 == NULL ? "TBD" : label3; fprintf(fout, "TX ranges #3 for %s:\n", label3); range_print(fout, caps->tx_range_list3, 0); label3 = caps->rx_range_list3->label; - label3 = label3==NULL?"TBD":label3; + label3 = label3 == NULL ? "TBD" : label3; fprintf(fout, "RX ranges #3 for %s:\n", label3); range_print(fout, caps->rx_range_list3, 1); label4 = caps->rx_range_list4->label; - label4 = label4==NULL?"TBD":label4; + label4 = label4 == NULL ? "TBD" : label4; fprintf(fout, "TX ranges #4 for %s:\n", label4); range_print(fout, caps->tx_range_list5, 0); label4 = caps->rx_range_list4->label; - label4 = label4==NULL?"TBD":label4; + label4 = label4 == NULL ? "TBD" : label4; fprintf(fout, "RX ranges #4 for %s:\n", label4); range_print(fout, caps->rx_range_list5, 1); label5 = caps->rx_range_list5->label; - label5 = label5==NULL?"TBD":label5; + label5 = label5 == NULL ? "TBD" : label5; fprintf(fout, "TX ranges #5 for %s:\n", label5); range_print(fout, caps->tx_range_list5, 0); label5 = caps->rx_range_list5->label; - label5 = label5==NULL?"TBD":label5; + label5 = label5 == NULL ? "TBD" : label5; fprintf(fout, "RX ranges #5 for %s:\n", label5); range_print(fout, caps->rx_range_list5, 1); @@ -793,7 +793,8 @@ int dumpcaps(RIG *rig, FILE *fout) fprintf(fout, "Can send DTMF:\t%c\n", caps->send_dtmf != NULL ? 'Y' : 'N'); fprintf(fout, "Can recv DTMF:\t%c\n", caps->recv_dtmf != NULL ? 'Y' : 'N'); fprintf(fout, "Can send Morse:\t%c\n", caps->send_morse != NULL ? 'Y' : 'N'); - fprintf(fout, "Can send Voice:\t%c\n", caps->send_voice_mem != NULL ? 'Y' : 'N'); + fprintf(fout, "Can send Voice:\t%c\n", + caps->send_voice_mem != NULL ? 'Y' : 'N'); fprintf(fout, "Can decode Events:\t%c\n", diff --git a/tests/example.c b/tests/example.c index b6f212ca4..5d751991f 100644 --- a/tests/example.c +++ b/tests/example.c @@ -64,13 +64,15 @@ int main() /* Main VFO frequency */ status = rig_get_freq(my_rig, RIG_VFO_CURR, &freq); - if (status != RIG_OK) printf("Get freq failed?? Err=%s\n", rigerror(status)); + + if (status != RIG_OK) { printf("Get freq failed?? Err=%s\n", rigerror(status)); } printf("VFO freq. = %.1f Hz\n", freq); /* Current mode */ status = rig_get_mode(my_rig, RIG_VFO_CURR, &mode, &width); - if (status != RIG_OK) printf("Get mode failed?? Err=%s\n", rigerror(status)); + + if (status != RIG_OK) { printf("Get mode failed?? Err=%s\n", rigerror(status)); } switch (mode) { @@ -145,15 +147,20 @@ int main() printf("LEVEL_STRENGTH returns %d\n", strength.i); - const freq_range_t *range = rig_get_range(&my_rig->state.rx_range_list[0],14074000,RIG_MODE_USB); + const freq_range_t *range = rig_get_range(&my_rig->state.rx_range_list[0], + 14074000, RIG_MODE_USB); if (status != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s: error rig_get_ragne: %s\n", __func__, rigerror(status)); } - if (range) { - char vfolist[256]; - sprintf_vfo(vfolist,my_rig->state.vfo_list); - printf("Range start=%"PRIfreq", end=%"PRIfreq", low_power=%d, high_power=%d, vfos=%s\n",range->startf, range->endf, range->low_power, range->high_power, vfolist); + + if (range) + { + char vfolist[256]; + sprintf_vfo(vfolist, my_rig->state.vfo_list); + printf("Range start=%"PRIfreq", end=%"PRIfreq", low_power=%d, high_power=%d, vfos=%s\n", + range->startf, range->endf, range->low_power, range->high_power, vfolist); } - else { - printf("Not rx range list found\n"); + else + { + printf("Not rx range list found\n"); } }; diff --git a/tests/rigctl.c b/tests/rigctl.c index f1c8e2059..c062c924f 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -428,7 +428,8 @@ int main(int argc, char *argv[]) { interactive = 0; } - else { + else + { interactive = 1; } @@ -509,14 +510,19 @@ int main(int argc, char *argv[]) exit(0); } - i=0; - do { // we'll try 5 times and sleep 200ms between tries + i = 0; + + do // we'll try 5 times and sleep 200ms between tries + { retcode = rig_open(my_rig); - if (retcode != RIG_OK) { + + if (retcode != RIG_OK) + { hl_usleep(200000); - rig_debug(RIG_DEBUG_TRACE, "%s: error opening rig, try#%d\n", __func__, i+1); + rig_debug(RIG_DEBUG_TRACE, "%s: error opening rig, try#%d\n", __func__, i + 1); } - } while (retcode != RIG_OK && ++i < 5); + } + while (retcode != RIG_OK && ++i < 5); if (retcode != RIG_OK) { diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 54d03ac94..258837854 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -288,7 +288,7 @@ static struct test_table test_list[] = { 'Z', "set_xit", ACTION(set_xit), ARG_IN, "XIT" }, { 'z', "get_xit", ACTION(get_xit), ARG_OUT, "XIT" }, { 'Y', "set_ant", ACTION(set_ant), ARG_IN, "Antenna", "Option" }, - { 'y', "get_ant", ACTION(get_ant), ARG_IN1 | ARG_OUT2 |ARG_NOVFO, "AntCurr", "Option", "AntTx", "AntRx" }, + { 'y', "get_ant", ACTION(get_ant), ARG_IN1 | ARG_OUT2 | ARG_NOVFO, "AntCurr", "Option", "AntTx", "AntRx" }, { 0x87, "set_powerstat", ACTION(set_powerstat), ARG_IN | ARG_NOVFO, "Power Status" }, { 0x88, "get_powerstat", ACTION(get_powerstat), ARG_OUT | ARG_NOVFO, "Power Status" }, { 0x89, "send_dtmf", ACTION(send_dtmf), ARG_IN, "Digits" }, @@ -297,7 +297,7 @@ static struct test_table test_list[] = { 'w', "send_cmd", ACTION(send_cmd), ARG_IN1 | ARG_IN_LINE | ARG_OUT2 | ARG_NOVFO, "Cmd", "Reply" }, { 'W', "send_cmd_rx", ACTION(send_cmd), ARG_IN | ARG_OUT2 | ARG_NOVFO, "Cmd", "Reply"}, { 'b', "send_morse", ACTION(send_morse), ARG_IN | ARG_IN_LINE, "Morse" }, - { 0x94, "send_voice_mem", ACTION(send_voice_mem), ARG_IN , "Voice Mem#" }, + { 0x94, "send_voice_mem", ACTION(send_voice_mem), ARG_IN, "Voice Mem#" }, { 0x8b, "get_dcd", ACTION(get_dcd), ARG_OUT, "DCD" }, { '2', "power2mW", ACTION(power2mW), ARG_IN1 | ARG_IN2 | ARG_IN3 | ARG_OUT1 | ARG_NOVFO, "Power [0.0..1.0]", "Frequency", "Mode", "Power mW" }, { '4', "mW2power", ACTION(mW2power), ARG_IN1 | ARG_IN2 | ARG_IN3 | ARG_OUT1 | ARG_NOVFO, "Power mW", "Frequency", "Mode", "Power [0.0..1.0]" }, @@ -386,8 +386,9 @@ void hash_sort_by_model_id() { HASH_SORT(models, hash_model_id_sort); } - else { - rig_debug(RIG_DEBUG_ERR,"%s: models empty?\n", __func__); + else + { + rig_debug(RIG_DEBUG_ERR, "%s: models empty?\n", __func__); } } @@ -462,7 +463,7 @@ static int scanfc(FILE *fin, const char *format, void *p) { int ret; *(char *)p = 0; - + ret = fscanf(fin, format, p); if (ret < 0) @@ -1006,6 +1007,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } #ifdef HAVE_LIBREADLINE + if (interactive && prompt && have_rl) { int j, x; @@ -1530,6 +1532,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, #endif } + #endif // HAVE_LIBREADLINE if (sync_cb) { sync_cb(1); } /* lock if necessary */ @@ -3038,14 +3041,16 @@ declare_proto_rig(get_parm) { case RIG_CONF_STRING: memset(buffer, '0', sizeof(buffer)); - buffer[sizeof(buffer)-1] = 0; + buffer[sizeof(buffer) - 1] = 0; val.s = buffer; break; + case RIG_CONF_BINARY: memset(buffer, 0, sizeof(buffer)); val.b.d = (unsigned char *)buffer; val.b.l = RIG_BIN_MAX; break; + default: break; } @@ -3977,7 +3982,7 @@ declare_proto_rig(set_ant) CHKSCN1ARG(sscanf(arg1, "%d", &ant)); CHKSCN1ARG(sscanf(arg2, "%d", &option.i)); // assuming they are integer values - return rig_set_ant(rig, vfo, rig_idx2setting(ant-1), option); + return rig_set_ant(rig, vfo, rig_idx2setting(ant - 1), option); } @@ -3993,23 +3998,26 @@ declare_proto_rig(get_ant) if (ant == 0) // then we want the current antenna info { - status = rig_get_ant(rig, vfo, RIG_ANT_CURR, &option, &ant_curr, &ant_tx, &ant_rx); + status = rig_get_ant(rig, vfo, RIG_ANT_CURR, &option, &ant_curr, &ant_tx, + &ant_rx); } else { - status = rig_get_ant(rig, vfo, rig_idx2setting(ant-1), &option, &ant_curr, &ant_tx, &ant_rx); + status = rig_get_ant(rig, vfo, rig_idx2setting(ant - 1), &option, &ant_curr, + &ant_tx, &ant_rx); } if (status != RIG_OK) { return status; } + if ((interactive && prompt) || (interactive && !prompt && ext_resp)) { fprintf(fout, "%s: ", cmd->arg1); } - sprintf_ant(antbuf,ant_curr); + sprintf_ant(antbuf, ant_curr); fprintf(fout, "%s%c", antbuf, resp_sep); //fprintf(fout, "%d%c", rig_setting2idx(ant_curr)+1, resp_sep); @@ -4025,7 +4033,7 @@ declare_proto_rig(get_ant) fprintf(fout, "%s: ", cmd->arg3); } - sprintf_ant(antbuf,ant_tx); + sprintf_ant(antbuf, ant_tx); fprintf(fout, "%s%c", antbuf, resp_sep); //fprintf(fout, "%d%c", rig_setting2idx(ant_tx)+1, resp_sep); @@ -4034,7 +4042,7 @@ declare_proto_rig(get_ant) fprintf(fout, "%s: ", cmd->arg4); } - sprintf_ant(antbuf,ant_rx); + sprintf_ant(antbuf, ant_rx); fprintf(fout, "%s%c", antbuf, resp_sep); //fprintf(fout, "%d%c", rig_setting2idx(ant_rx)+1, resp_sep); diff --git a/tests/rigctlcom.c b/tests/rigctlcom.c index 9190c3fbd..364649de8 100644 --- a/tests/rigctlcom.c +++ b/tests/rigctlcom.c @@ -967,7 +967,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } return retval; @@ -1032,7 +1033,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } return retval; @@ -1075,7 +1077,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } return retval; @@ -1098,7 +1101,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } } @@ -1118,7 +1122,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } return retval; @@ -1141,7 +1146,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } } @@ -1162,7 +1168,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } return retval; @@ -1212,7 +1219,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } return retval; @@ -1248,7 +1256,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } return retval; @@ -1268,7 +1277,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } return retval; @@ -1318,7 +1328,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } return retval; @@ -1353,7 +1364,8 @@ static int handle_ts2000(void *arg) if (retval == -RIG_ENIMPL || retval == -RIG_ENAVAIL) { char *responsetmp = "?;"; - return write_block2((void *)__func__, &my_com, responsetmp, strlen(responsetmp)); + return write_block2((void *)__func__, &my_com, responsetmp, + strlen(responsetmp)); } } @@ -1421,14 +1433,14 @@ static int handle_ts2000(void *arg) { freq_t freq; - sscanf((char*)arg + 2, "%"SCNfreq, &freq); + sscanf((char *)arg + 2, "%"SCNfreq, &freq); return rig_set_freq(my_rig, RIG_VFO_A, freq); } else if (strncmp(arg, "FB0", 3) == 0) { freq_t freq; - sscanf((char*)arg + 2, "%"SCNfreq, &freq); + sscanf((char *)arg + 2, "%"SCNfreq, &freq); return rig_set_freq(my_rig, RIG_VFO_A, freq); } else if (strncmp(arg, "MD", 2) == 0) @@ -1437,7 +1449,7 @@ static int handle_ts2000(void *arg) mode_t mode = 0; int imode = 0; - sscanf((char*)arg + 2, "%d", &imode); + sscanf((char *)arg + 2, "%d", &imode); switch (imode) { diff --git a/tests/rigmem.c b/tests/rigmem.c index 88e7bc2b2..ca9ecb6e0 100644 --- a/tests/rigmem.c +++ b/tests/rigmem.c @@ -315,6 +315,7 @@ int main(int argc, char *argv[]) if (!strcmp(argv[optind], "save")) { #ifdef HAVE_XML2 + if (xml) { retcode = xml_save(rig, argv[optind + 1]); @@ -328,6 +329,7 @@ int main(int argc, char *argv[]) else if (!strcmp(argv[optind], "load")) { #ifdef HAVE_XML2 + if (xml) { retcode = xml_load(rig, argv[optind + 1]); @@ -341,6 +343,7 @@ int main(int argc, char *argv[]) else if (!strcmp(argv[optind], "save_parm")) { #ifdef HAVE_XML2 + if (xml) { retcode = xml_parm_save(rig, argv[optind + 1]); @@ -354,6 +357,7 @@ int main(int argc, char *argv[]) else if (!strcmp(argv[optind], "load_parm")) { #ifdef HAVE_XML2 + if (xml) { retcode = xml_parm_load(rig, argv[optind + 1]); diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index 37f84cb68..9dee1390c 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -519,6 +519,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc, /* cmd, internal, rotctld */ #ifdef HAVE_LIBREADLINE + if (!(interactive && prompt && have_rl)) #endif { @@ -893,6 +894,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc, } #ifdef HAVE_LIBREADLINE + if (interactive && prompt && have_rl) { int j, x; @@ -1369,6 +1371,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc, #endif } + #endif // HAVE_LIBREADLINE /* @@ -1446,7 +1449,8 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc, } else { - if (cmd_entry->name != NULL) { + if (cmd_entry->name != NULL) + { fprintf(fout, "%s: error = %s\n", cmd_entry->name, rigerror(retcode)); } } diff --git a/tests/rotctld.c b/tests/rotctld.c index 84e2e00ba..23ed83546 100644 --- a/tests/rotctld.c +++ b/tests/rotctld.c @@ -134,7 +134,7 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg) NULL)) { - rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, (char*)lpMsgBuf); + rig_debug(lvl, "%s: Network error %d: %s\n", msg, e, (char *)lpMsgBuf); LocalFree(lpMsgBuf); } else diff --git a/tests/sprintflst.c b/tests/sprintflst.c index 7a8d75508..634974ad1 100644 --- a/tests/sprintflst.c +++ b/tests/sprintflst.c @@ -113,19 +113,28 @@ int sprintf_ant(char *str, ant_t ant) { if (ant & (1UL << i)) { - switch(i) { - case 0: ant_name = "ANT1";break; - case 1: ant_name = "ANT2";break; - case 2: ant_name = "ANT3";break; - case 3: ant_name = "ANT4";break; - case 4: ant_name = "ANT5";break; - case 30: ant_name = "ANT_UNKNOWN";break; - case 31: ant_name = "ANT_CURR";break; - default: - ant_name = "ANT_UNK"; - rig_debug(RIG_DEBUG_ERR,"%s: unknown ant=%d\n", __func__, i); - break; + switch (i) + { + case 0: ant_name = "ANT1"; break; + + case 1: ant_name = "ANT2"; break; + + case 2: ant_name = "ANT3"; break; + + case 3: ant_name = "ANT4"; break; + + case 4: ant_name = "ANT5"; break; + + case 30: ant_name = "ANT_UNKNOWN"; break; + + case 31: ant_name = "ANT_CURR"; break; + + default: + ant_name = "ANT_UNK"; + rig_debug(RIG_DEBUG_ERR, "%s: unknown ant=%d\n", __func__, i); + break; } + len += sprintf(str + len, "%s ", ant_name); } }