more functionality, mode and frequency get by Matt Dawson

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1913 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.4
Joop Stakenborg, PG4I 2005-01-31 16:15:56 +00:00
rodzic 862027b3e0
commit c056b80e4d
2 zmienionych plików z 301 dodań i 66 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TS140 description
* Copyright (c) 2000-2003 by Stephane Fillod
*
* $Id: ts140.c,v 1.2 2005-01-19 22:23:21 pa4tu Exp $
* $Id: ts140.c,v 1.3 2005-01-31 16:15:55 pa4tu 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
@ -25,48 +25,173 @@
#endif
#include <stdlib.h>
#include <stdio.h>
#include <hamlib/rig.h>
#include <bandplan.h>
#include "hamlib/rig.h"
#include "bandplan.h"
#include "kenwood.h"
#define TS140_ALL_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM)
#define TS140_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM)
#define TS140_ALL_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_CWR)
#define TS140_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_CWR)
#define TS140_AM_TX_MODES RIG_MODE_AM
#define TS140_VFO (RIG_VFO_A|RIG_VFO_B)
#define TS140_ANTS (RIG_ANT_1)
#define TS140_VFO (RIG_VFO_A|RIG_VFO_B|RIG_VFO_MEM)
#define TS140_ANTS (0)
/*
* mode defines
*/
#define MD_NONE '0'
#define MD_LSB '1'
#define MD_USB '2'
#define MD_CW '3'
#define MD_FM '4'
#define MD_AM '5'
#define MD_CWR '7'
/*
* vfo defines
*/
#define VFO_A '0'
#define VFO_B '1'
#define VFO_MEM '2'
static const struct kenwood_priv_caps ts140_priv_caps = {
.cmdtrm = EOM_KEN,
};
int ts140_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
unsigned char modebuf[50];
int mode_len, retval;
mode_len = 50;
retval = kenwood_transaction (rig, "IF;", 3, modebuf, &mode_len);
if (retval != RIG_OK)
return retval;
if (mode_len != 38 || modebuf[1] != 'F') {
rig_debug(RIG_DEBUG_ERR,"ts140_get_mode: unexpected answer len=%d\n",
mode_len);
return -RIG_ERJCTED;
}
switch (modebuf[29]) {
case MD_CW: *mode = RIG_MODE_CW; break;
case MD_CWR: *mode = RIG_MODE_CWR; break; /* Not actually reverse CW. It's narrow where the optional filter is fitted */
case MD_USB: *mode = RIG_MODE_USB; break;
case MD_LSB: *mode = RIG_MODE_LSB; break;
case MD_FM: *mode = RIG_MODE_FM; break;
case MD_AM: *mode = RIG_MODE_AM; break;
case MD_NONE: *mode = RIG_MODE_NONE; break;
default:
rig_debug(RIG_DEBUG_ERR,"ts140_get_mode: "
"unsupported mode '%c'\n", modebuf[29]);
return -RIG_EINVAL;
}
*width = rig_passband_normal(rig, *mode);
return RIG_OK;
}
int ts140_set_vfo(RIG *rig, vfo_t vfo)
{
unsigned char cmdbuf[16], ackbuf[16];
int cmd_len, ack_len, retval;
char vfo_function;
switch (vfo) {
case RIG_VFO_VFO:
case RIG_VFO_A: vfo_function = VFO_A; break;
case RIG_VFO_B: vfo_function = VFO_B; break;
case RIG_VFO_MEM: vfo_function = VFO_MEM; break;
case RIG_VFO_CURR: return RIG_OK;
default:
rig_debug(RIG_DEBUG_ERR,"ts140_set_vfo: unsupported VFO %d\n",
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;
}
int ts140_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
unsigned char freqbuf[50];
int freq_len, retval;
long long f;
/* We're using IF; here because the TS-140S is incapable of supplying
* frequency information in MEM mode with the kenwood_get_freq method. It may
* entail more data over the serial port, but for fewer errors and unexplained
* silence from rpc.rigd it is a small price to pay. */
freq_len = 50;
retval = kenwood_transaction (rig, "IF;", 3, freqbuf, &freq_len);
if (retval != RIG_OK)
return retval;
if (freq_len != 38 || freqbuf[1] != 'F') {
rig_debug(RIG_DEBUG_ERR,"ts140_get_freq: wrong answer len=%d\n",
freq_len);
return -RIG_ERJCTED;
}
freqbuf[14] = '\0';
sscanf(freqbuf+2, "%lld", &f);
*freq = (freq_t)f;
return RIG_OK;
}
int ts140_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
unsigned char fctbuf[16], ackbuf[16];
int fct_len, ack_len;
ack_len = 0;
switch (func) {
case RIG_FUNC_LOCK:
if (status > 1) status = 1;
fct_len = sprintf(fctbuf,"LK%d;", status); /* The only way I could get the rig to drop the lock once asserted */
return kenwood_transaction (rig, fctbuf, fct_len, ackbuf, &ack_len);
default:
rig_debug(RIG_DEBUG_ERR,"Unsupported set_func %#x", func);
return -RIG_EINVAL;
}
return RIG_OK;
}
/*
* ts140 rig capabilities.
* extrapolated from TS680, which is more or less the same radio
* MattD.. 2005-01-14
*
* MattD.. 2005-01-29
*/
const struct rig_caps ts140_caps = {
.rig_model = RIG_MODEL_TS140S,
.model_name = "TS-140S",
.mfg_name = "Kenwood",
.version = "0.2.1",
.version = "0.3",
.copyright = "LGPL",
.status = RIG_STATUS_ALPHA,
.status = RIG_STATUS_BETA,
.rig_type = RIG_TYPE_TRANSCEIVER,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_RIG,
.port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800,
.serial_rate_max = 9600,
.serial_rate_max = 9600, /* Rig only capable of 4800 baud from factory and 9k6 with jumper change */
.serial_data_bits = 8,
.serial_stop_bits = 2,
.serial_stop_bits = 2, /* TWO stop bits. This is correct. */
.serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0,
.post_write_delay = 0,
.timeout = 200,
.timeout = 300,
.retry = 3,
.has_get_func = RIG_FUNC_LOCK,
@ -74,13 +199,11 @@ const struct rig_caps ts140_caps = {
.has_get_level = RIG_LEVEL_NONE,
.has_set_level = RIG_LEVEL_NONE,
.has_get_parm = RIG_PARM_NONE,
.has_set_parm = RIG_PARM_NONE, /* FIXME: parms */
.has_set_parm = RIG_PARM_NONE, /* No PARAMS controllable */
.level_gran = {}, /* FIXME: granularity */
.parm_gran = {},
.ctcss_list = NULL,
.dcs_list = NULL,
.preamp = { RIG_DBLST_END, }, /* Not controllable */
.attenuator = { RIG_DBLST_END, }, /* Not Controllable */
.attenuator = { RIG_DBLST_END, }, /* Not controllable */
.max_rit = kHz(1.2),
.max_xit = kHz(1.2),
.max_ifshift = Hz(0), /* Not controllable */
@ -91,7 +214,7 @@ const struct rig_caps ts140_caps = {
.chan_list = {
{ 0, 19, RIG_MTYPE_MEM }, /* TBC */
{ 0, 19, RIG_MTYPE_MEM },
{ 20, 30, RIG_MTYPE_EDGE },
RIG_CHAN_END,
},
@ -100,11 +223,10 @@ const struct rig_caps ts140_caps = {
{kHz(50),kHz(34999),TS140_ALL_MODES,-1,-1,TS140_VFO},
RIG_FRNG_END,
}, /* rx range */
.tx_range_list1 = {
FRQ_RNG_HF(1,TS140_OTHER_TX_MODES, W(5),W(100),TS140_VFO,TS140_ANTS), /* SSB actually 110W */
FRQ_RNG_HF(1,TS140_AM_TX_MODES, W(4),W(40),TS140_VFO,TS140_ANTS), /* AM class */
RIG_FRNG_END,
.tx_range_list1 = {
FRQ_RNG_HF(1,TS140_OTHER_TX_MODES,W(5),W(100),TS140_VFO,TS140_ANTS),
FRQ_RNG_HF(1,TS140_AM_TX_MODES,W(2),W(40),TS140_VFO,TS140_ANTS),
RIG_FRNG_END,
},
.rx_range_list2 = {
@ -112,13 +234,11 @@ const struct rig_caps ts140_caps = {
RIG_FRNG_END,
}, /* rx range */
.tx_range_list2 = {
FRQ_RNG_HF(2,TS140_OTHER_TX_MODES, W(5),W(100),TS140_VFO,TS140_ANTS), /* SSB actually 110W */
FRQ_RNG_HF(2,TS140_AM_TX_MODES, W(4),W(40),TS140_VFO,TS140_ANTS), /* AM class */
RIG_FRNG_END,
FRQ_RNG_HF(2,TS140_OTHER_TX_MODES,W(5),W(100),TS140_VFO,TS140_ANTS),
FRQ_RNG_HF(2,TS140_AM_TX_MODES,W(2),W(40),TS140_VFO,TS140_ANTS),
RIG_FRNG_END,
}, /* tx range */
.tuning_steps = {
.tuning_steps = { /* FIXME: Done */
{TS140_ALL_MODES,10},
{TS140_ALL_MODES,100},
{TS140_ALL_MODES,kHz(1)},
@ -134,27 +254,24 @@ const struct rig_caps ts140_caps = {
},
/* mode/filter list, remember: order matters! */
.filters = {
{RIG_MODE_SSB|RIG_MODE_CW, kHz(2.2)},
{RIG_MODE_CW, 600},
{RIG_MODE_AM, kHz(6)},
{RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_AM, kHz(2.2)},
{RIG_MODE_CWR, 600},
{RIG_MODE_FM, kHz(12)},
RIG_FLT_END,
},
.priv = (void *)&ts140_priv_caps,
.set_freq = kenwood_set_freq,
.get_freq = kenwood_get_freq,
.get_freq = ts140_get_freq,
.set_rit = kenwood_set_rit,
.get_rit = kenwood_get_rit,
.set_xit = kenwood_set_xit,
.get_xit = kenwood_get_xit,
.set_mode = kenwood_set_mode, /* With the IF-10C, these can only set, not get mode */
.set_vfo = kenwood_set_vfo,
.set_mode = kenwood_set_mode,
.get_mode = ts140_get_mode,
.set_vfo = ts140_set_vfo,
.get_vfo = kenwood_get_vfo,
.get_ptt = kenwood_get_ptt,
.set_ptt = kenwood_set_ptt,
.get_dcd = kenwood_get_dcd,
.set_func = kenwood_set_func,
.set_func = ts140_set_func,
.get_func = kenwood_get_func,
.vfo_op = kenwood_vfo_op,
.set_mem = kenwood_set_mem,
@ -167,4 +284,3 @@ const struct rig_caps ts140_caps = {
* Function definitions below
*/

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TS680 description
* Copyright (c) 2000-2003 by Stephane Fillod
*
* $Id: ts680.c,v 1.2 2005-01-19 22:23:21 pa4tu Exp $
* $Id: ts680.c,v 1.3 2005-01-31 16:15:56 pa4tu 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
@ -25,42 +25,163 @@
#endif
#include <stdlib.h>
#include <stdio.h>
#include <hamlib/rig.h>
#include <bandplan.h>
#include "hamlib/rig.h"
#include "bandplan.h"
#include "kenwood.h"
#define TS680_ALL_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_CW|RIG_MODE_SSB)
#define TS680_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM)
#define TS680_ALL_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_CWR)
#define TS680_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_CWR)
#define TS680_AM_TX_MODES RIG_MODE_AM
/* BUG: set VFO only sets the VFO hamlib operates on. Does not change on radio */
#define TS680_VFO (RIG_VFO_A|RIG_VFO_B)
#define TS680_VFO (RIG_VFO_A|RIG_VFO_B|RIG_VFO_MEM)
#define TS680_ANTS (0)
/*
* mode defines
*/
#define MD_NONE '0'
#define MD_LSB '1'
#define MD_USB '2'
#define MD_CW '3'
#define MD_FM '4'
#define MD_AM '5'
#define MD_CWR '7'
/*
* vfo defines
*/
#define VFO_A '0'
#define VFO_B '1'
#define VFO_MEM '2'
static const struct kenwood_priv_caps ts680_priv_caps = {
.cmdtrm = EOM_KEN,
};
int ts680_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
unsigned char modebuf[50];
int mode_len, retval;
mode_len = 50;
retval = kenwood_transaction (rig, "IF;", 3, modebuf, &mode_len);
if (retval != RIG_OK)
return retval;
if (mode_len != 38 || modebuf[1] != 'F') {
rig_debug(RIG_DEBUG_ERR,"ts680_get_mode: unexpected answer len=%d\n",
mode_len);
return -RIG_ERJCTED;
}
switch (modebuf[29]) {
case MD_CW: *mode = RIG_MODE_CW; break;
case MD_CWR: *mode = RIG_MODE_CWR; break; /* Not actually reverse CW. It's narrow where the optional filter is fitted */
case MD_USB: *mode = RIG_MODE_USB; break;
case MD_LSB: *mode = RIG_MODE_LSB; break;
case MD_FM: *mode = RIG_MODE_FM; break;
case MD_AM: *mode = RIG_MODE_AM; break;
case MD_NONE: *mode = RIG_MODE_NONE; break;
default:
rig_debug(RIG_DEBUG_ERR,"ts680_get_mode: "
"unsupported mode '%c'\n", modebuf[29]);
return -RIG_EINVAL;
}
*width = rig_passband_normal(rig, *mode);
return RIG_OK;
}
int ts680_set_vfo(RIG *rig, vfo_t vfo)
{
unsigned char cmdbuf[16], ackbuf[16];
int cmd_len, ack_len, retval;
char vfo_function;
switch (vfo) {
case RIG_VFO_VFO:
case RIG_VFO_A: vfo_function = VFO_A; break;
case RIG_VFO_B: vfo_function = VFO_B; break;
case RIG_VFO_MEM: vfo_function = VFO_MEM; break;
case RIG_VFO_CURR: return RIG_OK;
default:
rig_debug(RIG_DEBUG_ERR,"ts680_set_vfo: unsupported VFO %d\n",
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;
}
int ts680_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{
unsigned char freqbuf[50];
int freq_len, retval;
long long f;
/* We're using IF; here because the TS-680S is incapable of supplying
* frequency information in MEM mode with the kenwood_get_freq method. It may
* entail more data over the serial port, but for fewer errors and unexplained
* silence from rpc.rigd it is a small price to pay. */
freq_len = 50;
retval = kenwood_transaction (rig, "IF;", 3, freqbuf, &freq_len);
if (retval != RIG_OK)
return retval;
if (freq_len != 38 || freqbuf[1] != 'F') {
rig_debug(RIG_DEBUG_ERR,"ts680_get_freq: wrong answer len=%d\n",
freq_len);
return -RIG_ERJCTED;
}
freqbuf[14] = '\0';
sscanf(freqbuf+2, "%lld", &f);
*freq = (freq_t)f;
return RIG_OK;
}
int ts680_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
unsigned char fctbuf[16], ackbuf[16];
int fct_len, ack_len;
ack_len = 0;
switch (func) {
case RIG_FUNC_LOCK:
if (status > 1) status = 1;
fct_len = sprintf(fctbuf,"LK%d;", status); /* The only way I could get the rig to drop the lock once asserted */
return kenwood_transaction (rig, fctbuf, fct_len, ackbuf, &ack_len);
default:
rig_debug(RIG_DEBUG_ERR,"Unsupported set_func %#x", func);
return -RIG_EINVAL;
}
return RIG_OK;
}
/*
* ts680 rig capabilities.
* written by experimentation from an actual radio:
* MattD.. 2005-01-12
* These changes probably apply to the TS-140 as well.
* TODO: Might be an idea to verify this on all variants.
* MattD.. 2005-01-29
*/
const struct rig_caps ts680s_caps = {
.rig_model = RIG_MODEL_TS680S,
.rig_model = RIG_MODEL_TS680S, /* Returns ID of 006. Suggest this is added to kenwood.c */
.model_name = "TS-680S",
.mfg_name = "Kenwood",
.version = "0.2.1",
.version = "0.3",
.copyright = "LGPL",
.status = RIG_STATUS_ALPHA,
.status = RIG_STATUS_BETA,
.rig_type = RIG_TYPE_TRANSCEIVER,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_RIG,
.port_type = RIG_PORT_SERIAL,
.serial_rate_min = 4800,
.serial_rate_max = 9600, /* Rig only capable of 4800 baud from factory and 9k6 with jumper change */
@ -141,24 +262,22 @@ const struct rig_caps ts680s_caps = {
.filters = {
{RIG_MODE_AM, kHz(6)},
{RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_AM, kHz(2.2)},
{RIG_MODE_CW, 600}, /* TODO: Can't get this to work. the CW narrow filter is 600Hz */
{RIG_MODE_CWR, 600},
{RIG_MODE_FM, kHz(12)},
RIG_FLT_END,
},
.priv = (void *)&ts680_priv_caps,
.set_freq = kenwood_set_freq,
.get_freq = kenwood_get_freq,
.get_freq = ts680_get_freq,
.set_rit = kenwood_set_rit,
.get_rit = kenwood_get_rit,
.set_xit = kenwood_set_xit,
.get_xit = kenwood_get_xit,
.set_mode = kenwood_set_mode,
.set_vfo = kenwood_set_vfo, /* TODO: Why does this not change the radio? */
.get_mode = ts680_get_mode,
.set_vfo = ts680_set_vfo,
.get_vfo = kenwood_get_vfo,
.set_ptt = kenwood_set_ptt,
.get_dcd = kenwood_get_dcd,
.set_func = kenwood_set_func,
.set_func = ts680_set_func,
.get_func = kenwood_get_func,
.vfo_op = kenwood_vfo_op,
.set_mem = kenwood_set_mem,