ts570,ts850,ts870s,ts140,ts480,ts680: use kenwood_simple_cmd where possible

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2616 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.9
Alessandro Zummo, IZ1PRB 2009-02-03 22:56:07 +00:00
rodzic ba57679b78
commit b510ceb1cb
6 zmienionych plików z 61 dodań i 102 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TS140 description
* Copyright (c) 2000-2008 by Stephane Fillod
*
* $Id: ts140.c,v 1.12 2009-02-03 22:13:54 azummo Exp $
* $Id: ts140.c,v 1.13 2009-02-03 22:56:06 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
@ -51,12 +51,10 @@ static struct kenwood_priv_caps ts140_priv_caps = {
static int ts140_set_vfo(RIG *rig, vfo_t vfo)
{
char cmdbuf[16], ackbuf[50];
int cmd_len, retval;
size_t ack_len;
char cmdbuf[16];
int retval;
char vfo_function;
ack_len = 0;
switch (vfo) {
case RIG_VFO_VFO:
case RIG_VFO_A: vfo_function = VFO_A; break;
@ -69,12 +67,8 @@ static int ts140_set_vfo(RIG *rig, vfo_t vfo)
return -RIG_EINVAL;
}
cmd_len = sprintf(cmdbuf, "FN%c", vfo_function); /* The 680 and 140 need this to set the VFO on the radio */
ack_len = 0;
retval = kenwood_transaction (rig, cmdbuf, cmd_len, ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
return RIG_OK;
sprintf(cmdbuf, "FN%c", vfo_function); /* The 680 and 140 need this to set the VFO on the radio */
return kenwood_simple_cmd(rig, cmdbuf);
}
/*

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TS480 description
* Copyright (c) 2000-2004 by Stephane Fillod and Juergen Rinas
*
* $Id: ts480.c,v 1.11 2009-02-03 22:13:55 azummo Exp $
* $Id: ts480.c,v 1.12 2009-02-03 22:56:06 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
@ -49,12 +49,10 @@
static int
kenwood_ts480_set_ptt (RIG * rig, vfo_t vfo, ptt_t ptt)
{
char ackbuf[50];
size_t ack_len = 0;
if (RIG_PTT_ON == ptt)
return kenwood_transaction (rig, "TX1", 3, ackbuf, &ack_len);
return kenwood_transaction (rig, "RX", 2, ackbuf, &ack_len);
return kenwood_simple_cmd(rig, "TX1");
return kenwood_simple_cmd(rig, "RX");
}
/*
@ -105,31 +103,29 @@ kenwood_ts480_get_info (RIG * rig)
int
kenwood_ts480_set_level (RIG * rig, vfo_t vfo, setting_t level, value_t val)
{
char levelbuf[16], ackbuf[50];
int level_len, retval;
size_t ack_len;
char levelbuf[16];
int kenwood_val;
switch (level)
{
case RIG_LEVEL_RFPOWER:
kenwood_val = val.f * 100; /* level for TS480SAT is from 0.. 100W in SSB */
level_len = sprintf (levelbuf, "PC%03d", kenwood_val);
sprintf (levelbuf, "PC%03d", kenwood_val);
break;
case RIG_LEVEL_AF:
kenwood_val = val.f * 255; /* possible values for TS480 are 000.. 255 */
level_len = sprintf (levelbuf, "AG0%03d", kenwood_val);
sprintf (levelbuf, "AG0%03d", kenwood_val);
break;
case RIG_LEVEL_RF:
kenwood_val = val.f * 100; /* possible values for TS480 are 000.. 100 */
level_len = sprintf (levelbuf, "RG%03d", kenwood_val);
sprintf (levelbuf, "RG%03d", kenwood_val);
break;
case RIG_LEVEL_SQL:
kenwood_val = val.f * 255; /* possible values for TS480 are 000.. 255 */
level_len = sprintf (levelbuf, "SQ0%03d", kenwood_val);
sprintf (levelbuf, "SQ0%03d", kenwood_val);
break;
case RIG_LEVEL_AGC: /* possible values for TS480 000(=off), 001(=fast), 002(=slow) */
@ -149,7 +145,7 @@ kenwood_ts480_set_level (RIG * rig, vfo_t vfo, setting_t level, value_t val)
rig_debug (RIG_DEBUG_ERR, "Unsupported agc value");
return -RIG_EINVAL;
};
level_len = sprintf (levelbuf, "GT%03d", kenwood_val);
sprintf (levelbuf, "GT%03d", kenwood_val);
break;
default:
@ -157,12 +153,7 @@ kenwood_ts480_set_level (RIG * rig, vfo_t vfo, setting_t level, value_t val)
return -RIG_EINVAL;
}
ack_len = 0;
retval = kenwood_transaction (rig, levelbuf, level_len, ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
return RIG_OK;
return kenwood_simple_cmd(rig, levelbuf);
}

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TS570 description
* Copyright (c) 2001-2005 by Stephane Fillod
*
* $Id: ts570.c,v 1.40 2009-02-03 22:13:55 azummo Exp $
* $Id: ts570.c,v 1.41 2009-02-03 22:56:06 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
@ -151,35 +151,32 @@ static char mode_to_char(rmode_t mode)
static int ts570_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
char buf[16],ackbuf[16];
int buf_len, kmode, retval;
size_t ack_len;
char buf[16];
int kmode, retval;
if ((kmode = mode_to_char(mode)) == RIG_MODE_NONE)
return -RIG_EINVAL;
buf_len = sprintf(buf, "MD%c", kmode);
ack_len = 0;
retval = kenwood_transaction (rig, buf, buf_len, ackbuf, &ack_len);
sprintf(buf, "MD%c", kmode);
retval = kenwood_simple_cmd(rig, buf);
if (retval != RIG_OK) return retval;
ack_len = 0;
switch (mode)
{
case RIG_MODE_CW:
case RIG_MODE_CWR:
case RIG_MODE_RTTY:
case RIG_MODE_RTTYR:
buf_len = sprintf(buf, "FW%04d", (int)width);
retval = kenwood_transaction (rig, buf, buf_len, ackbuf, &ack_len);
sprintf(buf, "FW%04d", (int)width);
retval = kenwood_simple_cmd(rig, buf);
if (retval != RIG_OK) return retval;
break;
case RIG_MODE_USB:
case RIG_MODE_LSB:
case RIG_MODE_FM:
case RIG_MODE_AM:
buf_len = sprintf(buf, "SL%02d", (int)width/50);
retval = kenwood_transaction (rig, buf, buf_len, ackbuf, &ack_len);
sprintf(buf, "SL%02d", (int)width/50);
retval = kenwood_simple_cmd(rig, buf);
if (retval != RIG_OK) return retval;
break;
default:
@ -195,25 +192,22 @@ static int ts570_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
*/
int ts570_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
char fctbuf[16], ackbuf[16];
int fct_len;
size_t ack_len;
char fctbuf[6];
/* Filter unimplemented RIG_FUNC_TUNER and allow settings 0..2 for
* RIG_FUNC_NR.
* Send all other requests to kenwood_set_func()
*/
ack_len = 0;
switch (func) {
case RIG_FUNC_NR:
if ((status < 0) || (status >2))
return -RIG_EINVAL;
fct_len = sprintf(fctbuf,"NR%01d", status);
return kenwood_transaction (rig, fctbuf, fct_len, ackbuf, &ack_len);
sprintf(fctbuf,"NR%01d", status);
return kenwood_simple_cmd(rig, fctbuf);
case RIG_FUNC_TUNER:
fct_len = sprintf(fctbuf,"AC %c0", (0==status)?'0':'1');
return kenwood_transaction (rig, fctbuf, fct_len, ackbuf, &ack_len);
sprintf(fctbuf,"AC %c0", (0==status)?'0':'1');
return kenwood_simple_cmd(rig, fctbuf);
default:
return kenwood_set_func(rig, vfo, func, status);
@ -282,43 +276,39 @@ int ts570_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
int
ts570_set_level (RIG * rig, vfo_t vfo, setting_t level, value_t val)
{
char levelbuf[16], ackbuf[16];
int level_len;
size_t ack_len;
char levelbuf[16];
int kenwood_val;
int i;
ack_len = 0; /* no answer for set functions */
switch (level)
{
case RIG_LEVEL_PREAMP:
kenwood_val = val.i;
/* set the preamplifier if a correct value is entered */
if (kenwood_val == 0)
level_len = sprintf(levelbuf, "PA0");
sprintf(levelbuf, "PA0");
else
for (i=0; i<MAXDBLSTSIZ; i++)
if (kenwood_val == rig->state.preamp[i])
{
level_len = sprintf(levelbuf, "PA%01d", i+1);
sprintf(levelbuf, "PA%01d", i+1);
break; /* found - stop searching */
}
else
return -RIG_EINVAL;
return kenwood_transaction (rig, levelbuf, level_len, ackbuf, &ack_len);
return kenwood_simple_cmd(rig, levelbuf);
case RIG_LEVEL_RFPOWER:
/* level for TS570D is from 0.. 100W in SSB and CW */
kenwood_val = val.f * 100;
level_len = sprintf (levelbuf, "PC%03d", kenwood_val);
return kenwood_transaction (rig, levelbuf, level_len, ackbuf, &ack_len);
sprintf (levelbuf, "PC%03d", kenwood_val);
return kenwood_simple_cmd(rig, levelbuf);
case RIG_LEVEL_MICGAIN:
/* level is from 0..100 */
kenwood_val = val.f * 100;
level_len = sprintf (levelbuf, "MG%03d", kenwood_val);
return kenwood_transaction (rig, levelbuf, level_len, ackbuf, &ack_len);
sprintf (levelbuf, "MG%03d", kenwood_val);
return kenwood_simple_cmd(rig, levelbuf);
default:
return kenwood_set_level (rig, vfo, level, val);
@ -464,7 +454,7 @@ int ts570_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
}
/* set RX VFO */
cmd_len = sprintf(cmdbuf, "FR%c%c", vfo_function, cmd_trm(rig));
retval = kenwood_transaction (rig, cmdbuf, cmd_len, NULL, 0);
retval = kenwood_simple_cmd(rig, cmdbuf);
if (retval != RIG_OK)
return retval;
}
@ -481,7 +471,7 @@ int ts570_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
}
/* set TX VFO */
cmd_len = sprintf(cmdbuf, "FT%c%c", vfo_function, cmd_trm(rig));
retval = kenwood_transaction (rig, cmdbuf, cmd_len, NULL, 0);
retval = kenwood_simple_cmd(rig, cmdbuf);
if (retval != RIG_OK)
return retval;
@ -496,7 +486,7 @@ int ts570_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
/* and then set it to both vfo's */
vfo_function = ackbuf[2];
cmd_len = sprintf(cmdbuf, "FT%c%c", vfo_function, cmd_trm(rig));
retval = kenwood_transaction(rig, cmdbuf, cmd_len, NULL, 0);
retval = kenwood_simple_cmd(rig, cmdbuf);
if (retval != RIG_OK)
return retval;
}

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TS680 description
* Copyright (c) 2000-2008 by Stephane Fillod
*
* $Id: ts680.c,v 1.11 2009-02-03 22:13:55 azummo Exp $
* $Id: ts680.c,v 1.12 2009-02-03 22:56:06 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
@ -51,10 +51,9 @@ static struct kenwood_priv_caps ts680_priv_caps = {
static int ts680_set_vfo(RIG *rig, vfo_t vfo)
{
char cmdbuf[16], ackbuf[16];
int cmd_len, retval;
char cmdbuf[16];
int retval;
char vfo_function;
size_t ack_len;
switch (vfo) {
case RIG_VFO_VFO:
@ -68,12 +67,8 @@ static int ts680_set_vfo(RIG *rig, vfo_t vfo)
return -RIG_EINVAL;
}
cmd_len = sprintf(cmdbuf, "FN%c", vfo_function); /* The 680 and 140 need this to set the VFO on the radio */
ack_len = 0;
retval = kenwood_transaction (rig, cmdbuf, cmd_len, ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
return RIG_OK;
sprintf(cmdbuf, "FN%c", vfo_function); /* The 680 and 140 need this to set the VFO on the radio */
return kenwood_simple_cmd(rig, cmdbuf);
}
/*

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TS850 description
* Copyright (c) 2000-2004 by Stephane Fillod
*
* $Id: ts850.c,v 1.29 2009-02-03 22:13:55 azummo Exp $
* $Id: ts850.c,v 1.30 2009-02-03 22:56:06 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
@ -308,9 +308,8 @@ static char mode_to_char(rmode_t mode)
int ts850_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
{
const struct rig_caps *caps;
char tonebuf[16], ackbuf[16];
int i, tone_len;
size_t ack_len;
char tonebuf[16];
int i;
caps = rig->caps;
@ -321,10 +320,9 @@ int ts850_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
if (caps->ctcss_list[i] != tone)
return -RIG_EINVAL;
tone_len = sprintf(tonebuf,"TN%03d", i+1);
sprintf(tonebuf,"TN%03d", i+1);
ack_len = 0;
return kenwood_transaction (rig, tonebuf, tone_len, ackbuf, &ack_len);
return kenwood_simple_cmd(rig, tonebuf);
}
int ts850_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TS870S description
* Copyright (c) 2000-2008 by Stephane Fillod
*
* $Id: ts870s.c,v 1.52 2009-02-03 22:13:55 azummo Exp $
* $Id: ts870s.c,v 1.53 2009-02-03 22:56:07 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
@ -146,9 +146,8 @@ static int ts870s_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
static int ts870s_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
char buf[16],ackbuf[16];
int buf_len, kmode, retval;
size_t ack_len;
char buf[16];
int kmode, retval;
switch (mode)
{
@ -166,36 +165,28 @@ static int ts870s_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
return -RIG_EINVAL;
}
buf_len = sprintf(buf, "MD%c", kmode);
ack_len = 0;
retval = kenwood_transaction (rig, buf, buf_len, ackbuf, &ack_len);
sprintf(buf, "MD%c", kmode);
retval = kenwood_simple_cmd(rig, buf);
if (retval != RIG_OK) return retval;
/*
* This rig will simply use an IF bandpass which is closest to width,
* so we don't need to check the value...
*/
buf_len = sprintf(buf, "FW%04d", (int)width/10);
ack_len = 0;
retval = kenwood_transaction (rig, buf, buf_len, ackbuf, &ack_len);
if (retval != RIG_OK) return retval;
return RIG_OK;
sprintf(buf, "FW%04d", (int)width/10);
return kenwood_simple_cmd(rig, buf);
}
int ts870s_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
char levelbuf[16], ackbuf[50];
int level_len;
char levelbuf[16];
int intval;
size_t ack_len;
ack_len = 0;
switch (level) {
case RIG_LEVEL_RFPOWER:
intval = val.f * 100;
level_len = sprintf(levelbuf, "PC%03d", intval);
return kenwood_transaction (rig, levelbuf, level_len, ackbuf, &ack_len);
sprintf(levelbuf, "PC%03d", intval);
return kenwood_simple_cmd(rig, levelbuf);
break;
default: