Coding style edits

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@3055 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.13
Nate Bargmann, N0NB 2011-02-18 02:03:49 +00:00
rodzic d78648a170
commit 55736a7427
3 zmienionych plików z 107 dodań i 106 usunięć

Wyświetl plik

@ -16,9 +16,9 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* See the file 'COPYING.LIB' in the main Hamlib distribution directory for * See the file 'COPYING.LIB' in the main Hamlib distribution directory for
* the complete text of the GNU Lesser Public License version 2. * the complete text of the GNU Lesser Public License version 2.
* *
*/ */
#include <string.h> #include <string.h>
@ -35,13 +35,13 @@ static const struct elec_ext_id_str elec_ext_id_str_lst[] = {
{ K23, "K23" }, { K23, "K23" },
{ K30, "K30" }, { K30, "K30" },
{ K31, "K31" }, { K31, "K31" },
{ EXT_LEVEL_NONE, NULL }, /* end marker */ { EXT_LEVEL_NONE, NULL }, /* end marker */
}; };
/* Private Elecraft extra levels definitions /* Private Elecraft extra levels definitions
* *
* Token definitions for .cfgparams in rig_caps * Token definitions for .cfgparams in rig_caps
* See enum rig_conf_e and struct confparams in rig.h * See enum rig_conf_e and struct confparams in rig.h
*/ */
const struct confparams elecraft_ext_levels[] = { const struct confparams elecraft_ext_levels[] = {
@ -63,13 +63,13 @@ int elecraft_get_extension_level(RIG *rig, const char *cmd, int *ext_level);
/* Shared backend function definitions */ /* Shared backend function definitions */
/* elecraft_open() /* elecraft_open()
* *
* First checks for ID of '017' then tests for an Elecraft radio/backend using * First checks for ID of '017' then tests for an Elecraft radio/backend using
* the K2; command. Here we also test for a K3 and if that fails, assume a K2. * the K2; command. Here we also test for a K3 and if that fails, assume a K2.
* Finally, save the value for later reading. * Finally, save the value for later reading.
* *
*/ */
int elecraft_open(RIG *rig) int elecraft_open(RIG *rig)
{ {
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@ -81,10 +81,10 @@ int elecraft_open(RIG *rig)
char id[KENWOOD_MAX_BUF_LEN]; char id[KENWOOD_MAX_BUF_LEN];
/* Actual read extension levels from radio. /* Actual read extension levels from radio.
* *
* The value stored in the k?_ext_lvl variables map to * The value stored in the k?_ext_lvl variables map to
* elec_ext_id_str_lst.level and is only written to by the * elec_ext_id_str_lst.level and is only written to by the
* elecraft_get_extension_level() private function during elecraft_open() * elecraft_get_extension_level() private function during elecraft_open()
* and thereafter shall be treated as READ ONLY! * and thereafter shall be treated as READ ONLY!
*/ */
struct kenwood_priv_data *priv = rig->state.priv; struct kenwood_priv_data *priv = rig->state.priv;
@ -95,34 +95,34 @@ int elecraft_open(RIG *rig)
return err; return err;
switch(rig->caps->rig_model) { switch(rig->caps->rig_model) {
case RIG_MODEL_K2: case RIG_MODEL_K2:
err = elecraft_get_extension_level(rig, "K2", &priv->k2_ext_lvl); err = elecraft_get_extension_level(rig, "K2", &priv->k2_ext_lvl);
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;
rig_debug(RIG_DEBUG_ERR, "%s: K2 level is %d, %s\n", __func__, rig_debug(RIG_DEBUG_ERR, "%s: K2 level is %d, %s\n", __func__,
priv->k2_ext_lvl, elec_ext_id_str_lst[priv->k2_ext_lvl].id); priv->k2_ext_lvl, elec_ext_id_str_lst[priv->k2_ext_lvl].id);
break; break;
case RIG_MODEL_K3: case RIG_MODEL_K3:
err = elecraft_get_extension_level(rig, "K2", &priv->k2_ext_lvl); err = elecraft_get_extension_level(rig, "K2", &priv->k2_ext_lvl);
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;
rig_debug(RIG_DEBUG_ERR, "%s: K2 level is %d, %s\n", __func__, rig_debug(RIG_DEBUG_ERR, "%s: K2 level is %d, %s\n", __func__,
priv->k2_ext_lvl, elec_ext_id_str_lst[priv->k2_ext_lvl].id); priv->k2_ext_lvl, elec_ext_id_str_lst[priv->k2_ext_lvl].id);
err = elecraft_get_extension_level(rig, "K3", &priv->k3_ext_lvl); err = elecraft_get_extension_level(rig, "K3", &priv->k3_ext_lvl);
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;
rig_debug(RIG_DEBUG_ERR, "%s: K3 level is %d, %s\n", __func__, rig_debug(RIG_DEBUG_ERR, "%s: K3 level is %d, %s\n", __func__,
priv->k3_ext_lvl, elec_ext_id_str_lst[priv->k3_ext_lvl].id); priv->k3_ext_lvl, elec_ext_id_str_lst[priv->k3_ext_lvl].id);
break; break;
default: default:
rig_debug(RIG_DEBUG_ERR, "%s: unrecognized rig model %d\n", rig_debug(RIG_DEBUG_ERR, "%s: unrecognized rig model %d\n",
__func__, rig->caps->rig_model); __func__, rig->caps->rig_model);
return -RIG_EINVAL; return -RIG_EINVAL;
} }
return RIG_OK; return RIG_OK;

Wyświetl plik

@ -21,7 +21,7 @@
#ifndef _ELECRAFT_H #ifndef _ELECRAFT_H
#define _ELECRAFT_H 1 #define _ELECRAFT_H 1
#include "hamlib/rig.h" #include <hamlib/rig.h>
/* The Elecraft Programmer's Reference details the extension level that /* The Elecraft Programmer's Reference details the extension level that
* a K2 or K3 may have in effect which modify certain commands. * a K2 or K3 may have in effect which modify certain commands.
@ -35,7 +35,7 @@ enum elec_ext_id_e {
K22, /* K2 Extended mode */ K22, /* K2 Extended mode */
K23, /* K2 Extended mode/rtty_off */ K23, /* K2 Extended mode/rtty_off */
K30, /* K3 Normal mode */ K30, /* K3 Normal mode */
K31 /* K3 Extended mode */ K31 /* K3 Extended mode */
}; };
struct elec_ext_id_str { struct elec_ext_id_str {
@ -45,19 +45,19 @@ struct elec_ext_id_str {
/* Data sub-modes are provided from the K3 via the DT command */ /* Data sub-modes are provided from the K3 via the DT command */
enum k3_data_submodes_e { enum k3_data_submodes_e {
K3_MODE_DATA_A = 0, /* DT0; */ K3_MODE_DATA_A = 0, /* DT0; */
K3_MODE_AFSK_A, /* DT1; */ K3_MODE_AFSK_A, /* DT1; */
K3_MODE_FSK_D, /* DT2; */ K3_MODE_FSK_D, /* DT2; */
K3_MODE_PSK_D /* DT3; */ K3_MODE_PSK_D /* DT3; */
}; };
/* Private tokens used for ext_lvl function in Elecraft backends. /* Private tokens used for ext_lvl function in Elecraft backends.
* Extra levels which are rig specific should be coded in * Extra levels which are rig specific should be coded in
* the individual rig files and token #s >= 101. * the individual rig files and token #s >= 101.
*/ */
#define TOK_IF_FREQ TOKEN_BACKEND(101) /* K3 FI command */ #define TOK_IF_FREQ TOKEN_BACKEND(101) /* K3 FI command */
#define TOK_TX_STAT TOKEN_BACKEND(102) /* K3 TQ command */ #define TOK_TX_STAT TOKEN_BACKEND(102) /* K3 TQ command */
/* Token structure assigned to .cfgparams in rig_caps */ /* Token structure assigned to .cfgparams in rig_caps */
extern const struct confparams elecraft_ext_levels[]; extern const struct confparams elecraft_ext_levels[];

Wyświetl plik

@ -39,7 +39,7 @@
#define K2_FUNC_ALL (RIG_FUNC_NB|RIG_FUNC_LOCK) #define K2_FUNC_ALL (RIG_FUNC_NB|RIG_FUNC_LOCK)
#define K2_LEVEL_ALL (RIG_LEVEL_ATT|RIG_LEVEL_PREAMP|RIG_LEVEL_AGC|RIG_LEVEL_SQL|\ #define K2_LEVEL_ALL (RIG_LEVEL_ATT|RIG_LEVEL_PREAMP|RIG_LEVEL_AGC|RIG_LEVEL_SQL|\
RIG_LEVEL_STRENGTH|RIG_LEVEL_RFPOWER|RIG_LEVEL_KEYSPD) RIG_LEVEL_STRENGTH|RIG_LEVEL_RFPOWER|RIG_LEVEL_KEYSPD)
#define K2_VFO (RIG_VFO_A|RIG_VFO_B) #define K2_VFO (RIG_VFO_A|RIG_VFO_B)
#define K2_VFO_OP (RIG_OP_UP|RIG_OP_DOWN) #define K2_VFO_OP (RIG_OP_UP|RIG_OP_DOWN)
@ -59,7 +59,7 @@ static struct kenwood_priv_caps k2_priv_caps = {
/* K2 Filter list, four per mode */ /* K2 Filter list, four per mode */
struct k2_filt_s { struct k2_filt_s {
shortfreq_t width; /* Filter width in Hz */ shortfreq_t width; /* Filter width in Hz */
char fslot; /* Crystal filter slot number--1-4 */ char fslot; /* Crystal filter slot number--1-4 */
char afslot; /* AF filter slot number--0-2 */ char afslot; /* AF filter slot number--0-2 */
}; };
@ -103,13 +103,13 @@ int k2_pop_fw_lst(RIG *rig, const char *cmd);
const struct rig_caps k2_caps = { const struct rig_caps k2_caps = {
.rig_model = RIG_MODEL_K2, .rig_model = RIG_MODEL_K2,
.model_name = "K2", .model_name = "K2",
.mfg_name = "Elecraft", .mfg_name = "Elecraft",
.version = "20110118", .version = "20110118",
.copyright = "LGPL", .copyright = "LGPL",
.status = RIG_STATUS_BETA, .status = RIG_STATUS_BETA,
.rig_type = RIG_TYPE_TRANSCEIVER, .rig_type = RIG_TYPE_TRANSCEIVER,
.ptt_type = RIG_PTT_RIG, .ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_RIG, .dcd_type = RIG_DCD_RIG,
.port_type = RIG_PORT_SERIAL, .port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800, .serial_rate_min = 4800,
.serial_rate_max = 4800, .serial_rate_max = 4800,
@ -117,10 +117,10 @@ const struct rig_caps k2_caps = {
.serial_stop_bits = 2, .serial_stop_bits = 2,
.serial_parity = RIG_PARITY_NONE, .serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE, .serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0, /* Timing between bytes */ .write_delay = 0, /* Timing between bytes */
.post_write_delay = 100, /* Timing between command strings */ .post_write_delay = 100, /* Timing between command strings */
.timeout = 600, /* FA and FB make take up to 500 ms on band change */ .timeout = 600, /* FA and FB make take up to 500 ms on band change */
.retry = 3, .retry = 3,
.has_get_func = K2_FUNC_ALL, .has_get_func = K2_FUNC_ALL,
.has_set_func = K2_FUNC_ALL, .has_set_func = K2_FUNC_ALL,
@ -128,19 +128,19 @@ const struct rig_caps k2_caps = {
.has_set_level = RIG_LEVEL_SET(K2_LEVEL_ALL), .has_set_level = RIG_LEVEL_SET(K2_LEVEL_ALL),
.has_get_parm = RIG_PARM_NONE, .has_get_parm = RIG_PARM_NONE,
.has_set_parm = RIG_PARM_NONE, /* FIXME: parms */ .has_set_parm = RIG_PARM_NONE, /* FIXME: parms */
.level_gran = {}, /* FIXME: granularity */ .level_gran = {}, /* FIXME: granularity */
.parm_gran = {}, .parm_gran = {},
.extlevels = elecraft_ext_levels, .extlevels = elecraft_ext_levels,
.extparms = kenwood_cfg_params, .extparms = kenwood_cfg_params,
.preamp = { 14, RIG_DBLST_END, }, .preamp = { 14, RIG_DBLST_END, },
.attenuator = { 10, RIG_DBLST_END, }, .attenuator = { 10, RIG_DBLST_END, },
.max_rit = Hz(9990), .max_rit = Hz(9990),
.max_xit = Hz(9990), .max_xit = Hz(9990),
.max_ifshift = Hz(0), .max_ifshift = Hz(0),
.vfo_ops = K2_VFO_OP, .vfo_ops = K2_VFO_OP,
.targetable_vfo = RIG_TARGETABLE_FREQ, .targetable_vfo = RIG_TARGETABLE_FREQ,
.transceive = RIG_TRN_RIG, .transceive = RIG_TRN_RIG,
.bank_qty = 0, .bank_qty = 0,
.chan_desc_sz = 0, .chan_desc_sz = 0,
.chan_list = { RIG_CHAN_END }, .chan_list = { RIG_CHAN_END },
@ -193,7 +193,7 @@ const struct rig_caps k2_caps = {
.priv = (void *)&k2_priv_caps, .priv = (void *)&k2_priv_caps,
.rig_init = kenwood_init, .rig_init = kenwood_init,
.rig_cleanup = kenwood_cleanup, .rig_cleanup = kenwood_cleanup,
.rig_open = k2_open, .rig_open = k2_open,
.set_freq = kenwood_set_freq, .set_freq = kenwood_set_freq,
.get_freq = kenwood_get_freq, .get_freq = kenwood_get_freq,
@ -214,8 +214,8 @@ const struct rig_caps k2_caps = {
.get_func = kenwood_get_func, .get_func = kenwood_get_func,
.set_ext_parm = kenwood_set_ext_parm, .set_ext_parm = kenwood_set_ext_parm,
.get_ext_parm = kenwood_get_ext_parm, .get_ext_parm = kenwood_get_ext_parm,
.set_level = kenwood_set_level, .set_level = kenwood_set_level,
.get_level = kenwood_get_level, .get_level = kenwood_get_level,
.get_ext_level = k2_get_ext_level, .get_ext_level = k2_get_ext_level,
.vfo_op = kenwood_vfo_op, .vfo_op = kenwood_vfo_op,
.set_trn = kenwood_set_trn, .set_trn = kenwood_set_trn,
@ -223,7 +223,7 @@ const struct rig_caps k2_caps = {
.get_trn = kenwood_get_trn, .get_trn = kenwood_get_trn,
.set_ant = kenwood_set_ant, .set_ant = kenwood_set_ant,
.get_ant = kenwood_get_ant, .get_ant = kenwood_get_ant,
.send_morse = kenwood_send_morse, .send_morse = kenwood_send_morse,
}; };
@ -279,23 +279,23 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
/* Select the filter array per mode. */ /* Select the filter array per mode. */
switch(mode) { switch(mode) {
case RIG_MODE_LSB: case RIG_MODE_LSB:
case RIG_MODE_USB: case RIG_MODE_USB:
flt = &k2_fwmd_ssb; flt = &k2_fwmd_ssb;
break; break;
case RIG_MODE_CW: case RIG_MODE_CW:
case RIG_MODE_CWR: case RIG_MODE_CWR:
flt = &k2_fwmd_cw; flt = &k2_fwmd_cw;
break; break;
case RIG_MODE_RTTY: case RIG_MODE_RTTY:
case RIG_MODE_RTTYR: case RIG_MODE_RTTYR:
if (priv->k2_md_rtty == 0) if (priv->k2_md_rtty == 0)
return -RIG_EINVAL; /* RTTY module not installed */ return -RIG_EINVAL; /* RTTY module not installed */
else else
flt = &k2_fwmd_rtty; flt = &k2_fwmd_rtty;
break; break;
default: default:
return -RIG_EINVAL; return -RIG_EINVAL;
} }
/* Step through the filter list looking for the best match /* Step through the filter list looking for the best match
@ -303,7 +303,7 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
* that is wide enough for the width without being too narrow * that is wide enough for the width without being too narrow
* if possible. * if possible.
*/ */
if (width > flt->filt_list[0].width || ((flt->filt_list[0].width >= width) if (width > flt->filt_list[0].width || ((flt->filt_list[0].width >= width)
&& (width > flt->filt_list[1].width))) { && (width > flt->filt_list[1].width))) {
width = flt->filt_list[0].width; width = flt->filt_list[0].width;
f = '1'; f = '1';
@ -316,12 +316,13 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
} else if ((flt->filt_list[3].width >= width) && (width >= freq)) { } else if ((flt->filt_list[3].width >= width) && (width >= freq)) {
width = flt->filt_list[3].width; width = flt->filt_list[3].width;
f = '4'; f = '4';
} else } else {
return -RIG_EINVAL; return -RIG_EINVAL;
}
/* Construct the filter command and set the radio mode and width*/ /* Construct the filter command and set the radio mode and width*/
snprintf(fcmd, 8, "FW0000%c", f); snprintf(fcmd, 8, "FW0000%c", f);
/* kenwood_set_mode() ignores width value for K2/K3/TS-570 */ /* kenwood_set_mode() ignores width value for K2/K3/TS-570 */
err = kenwood_set_mode(rig, vfo, mode, width); err = kenwood_set_mode(rig, vfo, mode, width);
if (err != RIG_OK) if (err != RIG_OK)
@ -393,13 +394,13 @@ int k2_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
/* TQ command is a quick transmit status query--K2/K3 only. /* TQ command is a quick transmit status query--K2/K3 only.
* *
* token Defined in elecraft.h or this file * token Defined in elecraft.h or this file
* val Type depends on token type from confparams structure: * val Type depends on token type from confparams structure:
* NUMERIC: val.f * NUMERIC: val.f
* COMBO: val.i, starting from 0 Index to a string table. * COMBO: val.i, starting from 0 Index to a string table.
* STRING: val.cs for set, val.s for get * STRING: val.cs for set, val.s for get
* CHECKBUTTON: val.i 0/1 * CHECKBUTTON: val.i 0/1
*/ */
int k2_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val) int k2_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
{ {
@ -415,22 +416,22 @@ int k2_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
cfp = rig_ext_lookup_tok(rig, token); cfp = rig_ext_lookup_tok(rig, token);
switch(token) { switch(token) {
case TOK_TX_STAT: case TOK_TX_STAT:
err = kenwood_safe_transaction(rig, "TQ", buf, KENWOOD_MAX_BUF_LEN, 4); err = kenwood_safe_transaction(rig, "TQ", buf, KENWOOD_MAX_BUF_LEN, 4);
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;
if (cfp->type == RIG_CONF_CHECKBUTTON) { if (cfp->type == RIG_CONF_CHECKBUTTON) {
val->i = atoi(&buf[2]); val->i = atoi(&buf[2]);
} else { } else {
rig_debug(RIG_DEBUG_ERR, "%s: protocol error, invalid token type\n", rig_debug(RIG_DEBUG_ERR, "%s: protocol error, invalid token type\n",
__func__); __func__);
return -RIG_EPROTO; return -RIG_EPROTO;
} }
break; break;
default: default:
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported get_ext_level %d\n", rig_debug(RIG_DEBUG_ERR, "%s: Unsupported get_ext_level %d\n",
__func__, token); __func__, token);
return -RIG_EINVAL; return -RIG_EINVAL;
} }
return RIG_OK; return RIG_OK;
@ -507,7 +508,7 @@ int k2_probe_mdfw(RIG *rig, struct kenwood_priv_data *priv)
strcpy(cmd, "MD3"); /* CW */ strcpy(cmd, "MD3"); /* CW */
else if (c == 2) else if (c == 2)
strcpy(cmd, "MD6"); /* RTTY */ strcpy(cmd, "MD6"); /* RTTY */
else { /* Oops! */ else { /* Oops! */
err = k2_mdfw_rest(rig, mode, fw); err = k2_mdfw_rest(rig, mode, fw);
if (err != RIG_OK) if (err != RIG_OK)
return err; return err;