From bb6cf68ad2eb7b913513a8824a9b87264bbc668d Mon Sep 17 00:00:00 2001 From: "Alessandro Zummo, IZ1PRB" Date: Fri, 6 Feb 2009 14:15:12 +0000 Subject: [PATCH] implemented set/get_ext_param (voice, fine, xit, rit). enabled on ts450 and ts850 git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2620 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- include/hamlib/rig.h | 5 ++-- kenwood/kenwood.c | 69 +++++++++++++++++++++++++++++++++++--------- kenwood/kenwood.h | 11 ++++++- kenwood/ts450s.c | 22 ++++++++++---- kenwood/ts850.c | 17 +++++++++-- 5 files changed, 100 insertions(+), 24 deletions(-) diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index ff6201ce9..61741c719 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -3,7 +3,7 @@ * Copyright (c) 2000-2003 by Frank Singleton * Copyright (c) 2000-2009 by Stephane Fillod * - * $Id: rig.h,v 1.139 2009-01-25 16:23:06 fillods Exp $ + * $Id: rig.h,v 1.140 2009-02-06 14:15:11 azummo Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -510,7 +510,8 @@ enum rig_conf_e { RIG_CONF_STRING, /*!< String type */ RIG_CONF_COMBO, /*!< Combo type */ RIG_CONF_NUMERIC, /*!< Numeric type integer or real */ - RIG_CONF_CHECKBUTTON /*!< on/off type */ + RIG_CONF_CHECKBUTTON, /*!< on/off type */ + RIG_CONF_BUTTON /*!< Button type */ }; #define RIG_COMBO_MAX 8 diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index 0a046daf1..0916a0e6e 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -3,7 +3,7 @@ * Copyright (c) 2000-2009 by Stephane Fillod * Copyright (C) 2009 Alessandro Zummo * - * $Id: kenwood.c,v 1.112 2009-02-05 21:05:59 azummo Exp $ + * $Id: kenwood.c,v 1.113 2009-02-06 14:15:12 azummo Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -1148,16 +1148,7 @@ int kenwood_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) case RIG_FUNC_AIP: sprintf(buf, "MX%c", (status == 0) ? '0' : '1'); return kenwood_simple_cmd(rig, buf); -/* - case RIG_FUNC_FINE_STEP: - sprintf(buf, "FS%c", (status == 0) ? '0' : '1'); - return kenwood_simple_cmd(rig, buf); - case RIG_FUNC_VOICE: - case RIG_FUNC_RIT: - case RIG_FUNC_XIT: - ... -*/ default: rig_debug(RIG_DEBUG_ERR, "Unsupported set_func %#x", func); return -RIG_EINVAL; @@ -1236,10 +1227,7 @@ int kenwood_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) case RIG_FUNC_AIP: return get_kenwood_func(rig, "MX", status); -/* - case RIG_FUNC_FINE_STEP: - return get_kenwood_func(rig, "FS", status); -*/ + default: rig_debug(RIG_DEBUG_ERR,"Unsupported get_func %#x", func); return -RIG_EINVAL; @@ -1816,6 +1804,59 @@ int kenwood_set_channel(RIG *rig, channel_t *chan) return kenwood_simple_cmd(rig, buf); } +int kenwood_set_ext_parm(RIG *rig, token_t token, value_t val) +{ + char buf[4]; + + switch (token) { + case TOK_VOICE: + return kenwood_simple_cmd(rig, "VR"); + + case TOK_FINE: + sprintf(buf, "FS%c", (val.i == 0) ? '0' : '1'); + return kenwood_simple_cmd(rig, buf); + + case TOK_XIT: + sprintf(buf, "XT%c", (val.i == 0) ? '0' : '1'); + return kenwood_simple_cmd(rig, buf); + + case TOK_RIT: + sprintf(buf, "RT%c", (val.i == 0) ? '0' : '1'); + return kenwood_simple_cmd(rig, buf); + } + + return -RIG_EINVAL; +} + +int kenwood_get_ext_parm(RIG *rig, token_t token, value_t *val) +{ + int err; + struct kenwood_priv_data *priv = rig->state.priv; + + switch (token) { + case TOK_FINE: + return get_kenwood_func(rig, "FS", &val->i); + + case TOK_XIT: + err = kenwood_get_if(rig); + if (err != RIG_OK) + return err; + + val->i = (priv->info[24] == '1') ? 1 : 0; + return RIG_OK; + + case TOK_RIT: + err = kenwood_get_if(rig); + if (err != RIG_OK) + return err; + + val->i = (priv->info[23] == '1') ? 1 : 0; + return RIG_OK; + } + + return -RIG_ENIMPL; +} + /* * kenwood_get_info * supposed to work only for TS2000... diff --git a/kenwood/kenwood.h b/kenwood/kenwood.h index d67ad8781..b5b747880 100644 --- a/kenwood/kenwood.h +++ b/kenwood/kenwood.h @@ -2,7 +2,7 @@ * Hamlib Kenwood backend - main header * Copyright (c) 2000-2009 by Stephane Fillod * - * $Id: kenwood.h,v 1.51 2009-02-03 23:42:53 azummo Exp $ + * $Id: kenwood.h,v 1.52 2009-02-06 14:15:12 azummo Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -23,6 +23,8 @@ #ifndef _KENWOOD_H #define _KENWOOD_H 1 +#include "token.h" + #define BACKEND_VER "0.7" #define EOM_KEN ';' @@ -31,6 +33,11 @@ #define KENWOOD_MODE_TABLE_MAX 10 #define KENWOOD_MAX_BUF_LEN 50 /* max answer len, arbitrary */ +#define TOK_VOICE TOKEN_BACKEND(1) +#define TOK_FINE TOKEN_BACKEND(2) +#define TOK_XIT TOKEN_BACKEND(3) +#define TOK_RIT TOKEN_BACKEND(4) + /* * modes in use by the "MD" command */ @@ -92,6 +99,8 @@ int kenwood_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); int kenwood_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); int kenwood_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); +int kenwood_set_ext_parm(RIG *rig, token_t token, value_t val); +int kenwood_get_ext_parm(RIG *rig, token_t token, value_t *val); int kenwood_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone); int kenwood_set_ctcss_tone_tn(RIG *rig, vfo_t vfo, tone_t tone); int kenwood_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone); diff --git a/kenwood/ts450s.c b/kenwood/ts450s.c index 624ee3f93..6d0cee45f 100644 --- a/kenwood/ts450s.c +++ b/kenwood/ts450s.c @@ -2,7 +2,7 @@ * Hamlib Kenwood backend - TS450S description * Copyright (c) 2000-2004 by Stephane Fillod * - * $Id: ts450s.c,v 1.29 2009-02-03 22:45:59 azummo Exp $ + * $Id: ts450s.c,v 1.30 2009-02-06 14:15:12 azummo Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -39,8 +39,6 @@ #define TS450S_LEVEL_ALL (RIG_LEVEL_STRENGTH|RIG_LEVEL_CWPITCH|RIG_LEVEL_METER|RIG_LEVEL_SWR|RIG_LEVEL_ALC) #define TS450S_VFO (RIG_VFO_A|RIG_VFO_B|RIG_VFO_MEM) -#define TS450S_PARMS (RIG_PARM_ANN) /* optional */ - #define TS450S_VFO_OPS (RIG_OP_UP|RIG_OP_DOWN) #define TS450S_SCAN_OPS (RIG_SCAN_VFO) @@ -58,6 +56,17 @@ static struct kenwood_priv_caps ts450_priv_caps = { .cmdtrm = EOM_KEN, }; +static const struct confparams ts450_ext_parms[] = { + { TOK_FINE, "fine", "Fine", "Fine step mode", + NULL, RIG_CONF_CHECKBUTTON, { } }, + { TOK_VOICE, "voice", "Voice", "Voice recall", + NULL, RIG_CONF_BUTTON, { } }, + { TOK_XIT, "xit", "XIT", "XIT", + NULL, RIG_CONF_CHECKBUTTON, { } }, + { TOK_RIT, "rit", "RIT", "RIT", + NULL, RIG_CONF_CHECKBUTTON, { } }, + { RIG_CONF_END, NULL, } +}; static int ts450_open(RIG *rig) { @@ -119,10 +128,11 @@ const struct rig_caps ts450s_caps = { .has_set_func = TS450S_FUNC_ALL, .has_get_level = TS450S_LEVEL_ALL | RIG_LEVEL_RFPOWER, .has_set_level = RIG_LEVEL_SET(TS450S_LEVEL_ALL), - .has_get_parm = TS450S_PARMS, - .has_set_parm = TS450S_PARMS, + .has_get_parm = 0, + .has_set_parm = 0, .level_gran = {}, /* FIXME: granularity */ .parm_gran = {}, + .extparms = ts450_ext_parms, .ctcss_list = NULL, /* hw dip-switch */ .dcs_list = NULL, .preamp = { RIG_DBLST_END, }, @@ -218,6 +228,8 @@ const struct rig_caps ts450s_caps = { .get_func = kenwood_get_func, .set_level = kenwood_set_level, .get_level = kenwood_get_level, + .set_ext_parm = kenwood_set_ext_parm, + .get_ext_parm = kenwood_get_ext_parm, .vfo_op = kenwood_vfo_op, .set_mem = kenwood_set_mem, .get_mem = kenwood_get_mem_if, diff --git a/kenwood/ts850.c b/kenwood/ts850.c index 6a2768c63..95ef07185 100644 --- a/kenwood/ts850.c +++ b/kenwood/ts850.c @@ -2,7 +2,7 @@ * Hamlib Kenwood backend - TS850 description * Copyright (c) 2000-2004 by Stephane Fillod * -* $Id: ts850.c,v 1.32 2009-02-03 23:42:53 azummo Exp $ +* $Id: ts850.c,v 1.33 2009-02-06 14:15:12 azummo Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -74,6 +74,18 @@ static int ts850_set_xit(RIG * rig, vfo_t vfo, shortfreq_t rit); static int ts850_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); static int ts850_set_channel (RIG * rig, const channel_t * chan); +static const struct confparams ts850_ext_parms[] = { + { TOK_FINE, "fine", "Fine", "Fine step mode", + NULL, RIG_CONF_CHECKBUTTON, { } }, + { TOK_VOICE, "voice", "Voice", "Voice recall", + NULL, RIG_CONF_BUTTON, { } }, + { TOK_XIT, "xit", "XIT", "XIT", + NULL, RIG_CONF_CHECKBUTTON, { } }, + { TOK_RIT, "rit", "RIT", "RIT", + NULL, RIG_CONF_CHECKBUTTON, { } }, + { RIG_CONF_END, NULL, } +}; + /* * ts850 rig capabilities. * Notice that some rigs share the same functions. @@ -109,7 +121,8 @@ const struct rig_caps ts850_caps = { .has_set_parm = RIG_PARM_NONE, .level_gran = {}, .parm_gran = {}, - .ctcss_list = kenwood38_ctcss_list, + .extparms = ts850_ext_parms, + .ctcss_list = kenwood38_ctcss_list, .dcs_list = NULL, .preamp = { RIG_DBLST_END, }, .attenuator = { RIG_DBLST_END, },