Switch Kenwood TS940 to generic kenwood CAT functions

Hamlib-3.0
Bill Somerville 2015-01-04 15:41:04 +00:00
rodzic f672cc1bff
commit d92bea9538
2 zmienionych plików z 67 dodań i 39 usunięć

Wyświetl plik

@ -650,7 +650,8 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo)
sprintf(cmdbuf, "FR%c", vfo_function);
if (rig->caps->rig_model == RIG_MODEL_TS50)
if (rig->caps->rig_model == RIG_MODEL_TS50
|| rig->caps->rig_model == RIG_MODEL_TS940)
{
cmdbuf[1] = 'N';
}
@ -801,14 +802,15 @@ int kenwood_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, vfo_t *txvfo
priv->split = *split;
/* find where is the txvfo.. */
int transmitting = '1' == priv->info[28];
switch (priv->info[30])
{
case '0':
*txvfo = (*split) ? RIG_VFO_B : RIG_VFO_A;
*txvfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A;
break;
case '1':
*txvfo = (*split) ? RIG_VFO_A : RIG_VFO_B;
*txvfo = (*split && !transmitting) ? RIG_VFO_A : RIG_VFO_B;
break;
case '2':
@ -2395,7 +2397,12 @@ int kenwood_get_channel(RIG *rig, channel_t *chan)
struct kenwood_priv_caps *caps = kenwood_caps(rig);
/* put channel num in the command string */
sprintf(cmd, "MR0 %02d", chan->channel_num);
char bank = ' ';
if (rig->caps->rig_model == RIG_MODEL_TS940)
{
bank = '0' + chan->bank_num;
}
sprintf(cmd, "MR0%c%02d", bank, chan->channel_num);
err = kenwood_safe_transaction(rig, cmd, buf, 26, 24);
if (err != RIG_OK)
@ -2406,7 +2413,7 @@ int kenwood_get_channel(RIG *rig, channel_t *chan)
chan->vfo = RIG_VFO_VFO;
/* MR0 1700005890000510 ;
* MRs ccfffffffffffMLTtt ;
* MRsbccfffffffffffMLTtt ;
*/
/* parse from right to left */
@ -2439,6 +2446,10 @@ int kenwood_get_channel(RIG *rig, channel_t *chan)
buf[6] = '\0';
chan->channel_num = atoi(&buf[4]);
if (buf[3] >= '0' && buf[3] <= '9')
{
chan->bank_num = buf[3] - '0';
}
/* split freq */
cmd[2] = '1';
@ -2504,25 +2515,34 @@ int kenwood_set_channel(RIG *rig, const channel_t *chan)
tone = 0;
}
sprintf(buf, "MW0 %02d%011d%c%c%c%02d ", /* note the space at the end */
chan->channel_num,
(int) chan->freq,
'0' + mode,
(chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0',
chan->ctcss_tone ? '1' : '0',
chan->ctcss_tone ? (tone + 1) : 0);
char bank = ' ';
if (rig->caps->rig_model == RIG_MODEL_TS940)
{
bank = '0' + chan->bank_num;
}
sprintf(buf, "MW0%c%02d%011"PRIll"%c%c%c%02d ", /* note the space at
the end */
bank,
chan->channel_num,
(int64_t)chan->freq,
'0' + mode,
(chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0',
chan->ctcss_tone ? '1' : '0',
chan->ctcss_tone ? (tone + 1) : 0);
err = kenwood_simple_cmd(rig, buf);
if (err != RIG_OK)
return err;
sprintf(buf, "MW1 %02d%011d%c%c%c%02d ",
chan->channel_num,
(chan->split == RIG_SPLIT_ON) ? ((int) chan->tx_freq) : 0,
(chan->split == RIG_SPLIT_ON) ? ('0' + tx_mode) : '0',
(chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0',
chan->ctcss_tone ? '1' : '0',
chan->ctcss_tone ? (tone + 1) : 0);
sprintf(buf, "MW1%c%02d%011"PRIll"%c%c%c%02d ",
bank,
chan->channel_num,
(int64_t)(chan->split == RIG_SPLIT_ON ? chan->tx_freq : 0),
(chan->split == RIG_SPLIT_ON) ? ('0' + tx_mode) : '0',
(chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0',
chan->ctcss_tone ? '1' : '0',
chan->ctcss_tone ? (tone + 1) : 0);
return kenwood_simple_cmd(rig, buf);
}

Wyświetl plik

@ -28,7 +28,6 @@
#include <hamlib/rig.h>
#include "bandplan.h"
#include "kenwood.h"
#include "ic10.h"
#define TS940_ALL_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_CW|RIG_MODE_SSB)
@ -45,6 +44,14 @@
#define TS940_VFO_OPS (RIG_OP_UP|RIG_OP_DOWN)
#define TS940_SCAN_OPS (RIG_SCAN_VFO)
/* memory capabilities */
#define TS940_MEM_CAP { \
.freq = 1, \
.mode = 1, \
.tx_freq=1, \
.tx_mode=1, \
}
static struct kenwood_priv_caps ts940_priv_caps = {
.cmdtrm = EOM_KEN,
.if_len = 29,
@ -61,7 +68,7 @@ const struct rig_caps ts940_caps = {
.rig_model = RIG_MODEL_TS940,
.model_name = "TS-940S",
.mfg_name = "Kenwood",
.version = BACKEND_VER "." IC10_VER,
.version = BACKEND_VER ".7",
.copyright = "LGPL",
.status = RIG_STATUS_ALPHA,
.rig_type = RIG_TYPE_TRANSCEIVER,
@ -76,8 +83,8 @@ const struct rig_caps ts940_caps = {
.serial_handshake = RIG_HANDSHAKE_HARDWARE,
.write_delay = 100,
.post_write_delay = 150,
.timeout = 200,
.retry = 3,
.timeout = 600,
.retry = 5,
.has_get_func = RIG_FUNC_NONE,
.has_set_func = TS940_FUNC_ALL,
@ -99,12 +106,13 @@ const struct rig_caps ts940_caps = {
.bank_qty = 0,
.chan_desc_sz = 0,
/* four banks of 10 memories */
.chan_list = {
{ 0, 89, RIG_MTYPE_MEM, {IC10_CHANNEL_CAPS} }, /* TBC */
{ 90, 99, RIG_MTYPE_EDGE, {IC10_CHANNEL_CAPS} },
RIG_CHAN_END,
},
{ 0, 0, RIG_MTYPE_EDGE, TS940_MEM_CAP}, /* TBC */
{ 1, 8, RIG_MTYPE_MEM, TS940_MEM_CAP}, /* TBC */
{ 9, 9, RIG_MTYPE_EDGE, TS940_MEM_CAP}, /* TBC */
RIG_CHAN_END,
},
.rx_range_list1 = {
{kHz(500),MHz(30),TS940_ALL_MODES,-1,-1,TS940_VFO},
@ -146,28 +154,28 @@ const struct rig_caps ts940_caps = {
.rig_init = kenwood_init,
.rig_cleanup = kenwood_cleanup,
.set_freq = kenwood_set_freq,
.get_freq = ic10_get_freq,
.get_freq = kenwood_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,
.get_mode = ic10_get_mode,
.set_vfo = ic10_set_vfo,
.get_vfo = ic10_get_vfo,
.set_split_vfo = ic10_set_split_vfo,
.get_split_vfo = ic10_get_split_vfo,
.get_mode = kenwood_get_mode_if,
.set_vfo = kenwood_set_vfo,
.get_vfo = kenwood_get_vfo_if,
.set_split_vfo = kenwood_set_split,
.get_split_vfo = kenwood_get_split_vfo_if,
.set_ptt = kenwood_set_ptt,
.get_ptt = ic10_get_ptt,
.get_ptt = kenwood_get_ptt,
.set_func = kenwood_set_func,
.vfo_op = kenwood_vfo_op,
.set_mem = kenwood_set_mem,
.get_mem = ic10_get_mem,
.get_mem = kenwood_get_mem_if,
.set_trn = kenwood_set_trn,
.scan = kenwood_scan,
.set_channel = ic10_set_channel,
.get_channel = ic10_get_channel,
.decode_event = ic10_decode_event,
.set_channel = kenwood_set_channel,
.get_channel = kenwood_get_channel,
/* .decode_event = ic10_decode_event, */
};