Merge branch 'k2-afsk-modes'

of git://git.code.sf.net/u/bsomervi/hamlib

Many changes to Kenwood backend rigs.
Hamlib-3.0
Nate Bargmann 2015-01-25 06:39:54 -06:00
commit 16ea41d260
10 zmienionych plików z 1924 dodań i 1841 usunięć

Wyświetl plik

@ -185,10 +185,13 @@ int elecraft_open(RIG *rig)
return -RIG_EINVAL;
}
/* Currently we cannot cope with AI mode so turn it off in case last
client left it on */
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case it's not
supported */
if (RIG_MODEL_XG3 != rig->caps->rig_model)
{
/* currently we cannot cope with AI mode so turn it off in case
last client left it on */
kenwood_set_trn(rig, RIG_TRN_OFF); /* ignore status in case it's
not supported */
}
return RIG_OK;
}

Wyświetl plik

@ -34,7 +34,7 @@
#include "elecraft.h"
#define K2_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR)
#define K2_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB)
#define K2_FUNC_ALL (RIG_FUNC_NB|RIG_FUNC_LOCK)
@ -46,6 +46,18 @@
#define K2_ANTS (RIG_ANT_1|RIG_ANT_2)
static rmode_t k2_mode_table[KENWOOD_MODE_TABLE_MAX] = {
[0] = RIG_MODE_NONE,
[1] = RIG_MODE_LSB,
[2] = RIG_MODE_USB,
[3] = RIG_MODE_CW,
[4] = RIG_MODE_NONE,
[5] = RIG_MODE_NONE,
[6] = RIG_MODE_PKTLSB, /* AFSK */
[7] = RIG_MODE_CWR,
[8] = RIG_MODE_NONE, /* TUNE mode */
[9] = RIG_MODE_PKTUSB /* AFSK */
};
/* kenwood_transaction() will add this to command strings
* sent to the rig and remove it from strings returned from
@ -53,6 +65,7 @@
*/
static struct kenwood_priv_caps k2_priv_caps = {
.cmdtrm = EOM_KEN,
.mode_table = k2_mode_table,
};
@ -119,8 +132,8 @@ const struct rig_caps k2_caps = {
.serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0, /* Timing between bytes */
.post_write_delay = 100, /* Timing between command strings */
.timeout = 600, /* FA and FB make take up to 500 ms on band change */
.retry = 3,
.timeout = 2000, /* FA and FB make take up to 500 ms on band change */
.retry = 10,
.has_get_func = K2_FUNC_ALL,
.has_set_func = K2_FUNC_ALL,
@ -187,7 +200,7 @@ const struct rig_caps k2_caps = {
.filters = {
{RIG_MODE_SSB, kHz(2.5)},
{RIG_MODE_CW|RIG_MODE_CWR, Hz(500)},
{RIG_MODE_RTTY|RIG_MODE_RTTYR, Hz(500)},
{RIG_MODE_PKTLSB|RIG_MODE_PKTUSB, kHz(2.5)},
RIG_FLT_END,
},
.priv = (void *)&k2_priv_caps,
@ -287,8 +300,8 @@ int k2_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
case RIG_MODE_CWR:
flt = &k2_fwmd_cw;
break;
case RIG_MODE_RTTY:
case RIG_MODE_RTTYR:
case RIG_MODE_PKTLSB:
case RIG_MODE_PKTUSB:
if (priv->k2_md_rtty == 0)
return -RIG_EINVAL; /* RTTY module not installed */
else
@ -489,19 +502,20 @@ int k2_probe_mdfw(RIG *rig, struct kenwood_priv_data *priv)
/* Now begin the process of querying the available modes and filters. */
/* First try to put the K2 into RTTY mode and check if it's available. */
priv->k2_md_rtty = 0; /* Assume RTTY module not installed */
err = kenwood_simple_cmd(rig, "MD6");
if (err != RIG_OK)
if (err != RIG_OK && err != -RIG_ERJCTED)
return err;
if (RIG_OK == err)
{
/* Read back mode and test to see if K2 reports RTTY. */
err = kenwood_safe_transaction(rig, "MD", buf, KENWOOD_MAX_BUF_LEN, 4);
if (err != RIG_OK)
return err;
/* Check for mode and test to see if K2 reports RTTY. */
err = kenwood_safe_transaction(rig, "MD", buf, KENWOOD_MAX_BUF_LEN, 4);
if (err != RIG_OK)
return err;
if (strcmp("MD6", buf) == 0)
priv->k2_md_rtty = 1; /* set flag for RTTY mode installed */
else
priv->k2_md_rtty = 0; /* RTTY module not installed */
if (!strcmp("MD6", buf))
priv->k2_md_rtty = 1; /* set flag for RTTY mode enabled */
}
rig_debug(RIG_DEBUG_VERBOSE, "%s: RTTY flag is: %d\n", __func__, priv->k2_md_rtty);
i = (priv->k2_md_rtty == 1) ? 2 : 1;

Wyświetl plik

@ -103,7 +103,7 @@ const struct rig_caps k3_caps = {
.serial_rate_min = 4800,
.serial_rate_max = 38400,
.serial_data_bits = 8,
.serial_stop_bits = 2,
.serial_stop_bits = 1,
.serial_parity = RIG_PARITY_NONE,
.serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0, /* Timing between bytes */

Plik diff jest za duży Load Diff

Wyświetl plik

@ -27,23 +27,23 @@
#include <string.h>
#include "token.h"
#define BACKEND_VER "0.8"
#define BACKEND_VER "0.9"
#define EOM_KEN ';'
#define EOM_TH '\r'
#define KENWOOD_MODE_TABLE_MAX 10
#define KENWOOD_MAX_BUF_LEN 50 /* max answer len, arbitrary */
#define KENWOOD_MODE_TABLE_MAX 10
#define KENWOOD_MAX_BUF_LEN 50 /* max answer len, arbitrary */
/* Tokens for Parameters common to multiple rigs.
* Use token # >= 1 or <= 100. Defined here so they will be
* available in Kenwood name space.
*/
#define TOK_VOICE TOKEN_BACKEND(1)
#define TOK_FINE TOKEN_BACKEND(2)
#define TOK_XIT TOKEN_BACKEND(3)
#define TOK_RIT TOKEN_BACKEND(4)
#define TOK_VOICE TOKEN_BACKEND(1)
#define TOK_FINE TOKEN_BACKEND(2)
#define TOK_XIT TOKEN_BACKEND(3)
#define TOK_RIT TOKEN_BACKEND(4)
/* Token structure assigned to .cfgparams in rig_caps */
extern const struct confparams kenwood_cfg_params[];
@ -63,19 +63,20 @@ extern const struct confparams kenwood_cfg_params[];
#define MD_FSKR '9'
struct kenwood_priv_caps {
char cmdtrm; /* Command termination chars (ken=';' or th='\r') */
int if_len; /* length of IF; anwser */
char cmdtrm; /* Command termination chars (ken=';' or th='\r') */
int if_len; /* length of IF; anwser */
rmode_t *mode_table;
};
struct kenwood_priv_data {
char info[KENWOOD_MAX_BUF_LEN];
split_t split; /* current split state */
int k2_ext_lvl; /* Initial K2 extension level */
int k3_ext_lvl; /* Initial K3 extension level */
int k2_md_rtty; /* K2 RTTY mode available flag, 1 = RTTY, 0 = N/A */
char *fw_rev; /* firmware revision level */
unsigned fw_rev_uint; /* firmware revison as a number 1.07 -> 107 */
split_t split; /* current split state */
int k2_ext_lvl; /* Initial K2 extension level */
int k3_ext_lvl; /* Initial K3 extension level */
int k2_md_rtty; /* K2 RTTY mode available flag, 1 = RTTY, 0 = N/A */
char *fw_rev; /* firmware revision level */
unsigned fw_rev_uint; /* firmware revison as a number 1.07 -> 107 */
void * data; /* model specific data */
};
@ -88,9 +89,9 @@ extern const tone_t kenwood38_ctcss_list[];
extern const tone_t kenwood42_ctcss_list[];
int kenwood_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
size_t *data_len);
size_t *data_len);
int kenwood_safe_transaction(RIG *rig, const char *cmd, char *buf,
size_t buf_size, size_t expected);
size_t buf_size, size_t expected);
rmode_t kenwood2rmode(unsigned char mode, const rmode_t mode_table[]);
char rmode2kenwood(rmode_t mode, const rmode_t mode_table[]);
@ -199,27 +200,14 @@ extern const struct rig_caps f6k_caps;
/* use when not interested in the answer, but want to check its len */
static int inline kenwood_simple_transaction(RIG *rig, const char *cmd, size_t expected)
{
char buf[20];
return kenwood_safe_transaction(rig, cmd, buf, sizeof(buf), expected);
struct kenwood_priv_data *priv = rig->state.priv;
return kenwood_safe_transaction(rig, cmd, priv->info, KENWOOD_MAX_BUF_LEN, expected);
}
/* no answer needed at all */
static int inline kenwood_simple_cmd(RIG *rig, const char *cmd)
{
char buf[20];
return kenwood_safe_transaction(rig, cmd, buf, sizeof(buf), 0);
}
/* answer is the same as the command */
static int inline kenwood_cmd(RIG *rig, const char *cmd)
{
char buf[20];
int lenz = strlen(cmd)+1;
if (lenz > sizeof(buf))
return -RIG_ENOMEM;
else
return kenwood_safe_transaction(rig, cmd, buf, sizeof(buf), lenz);
return kenwood_safe_transaction(rig, cmd, NULL, 0, 0);
}
#endif /* _KENWOOD_H */

Wyświetl plik

@ -197,7 +197,7 @@ th_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
freq_sent = freq_sent >= MHz(470) ? (round(freq_sent/10000)*10000) : freq_sent;
sprintf(buf, "FQ %011"PRIll",%X", (int64_t) freq_sent, step);
return kenwood_cmd(rig, buf);
return kenwood_simple_cmd(rig, buf);
}
/*
@ -270,7 +270,7 @@ th_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
sprintf(mdbuf, "MD %c", kmode);
retval = kenwood_cmd(rig, mdbuf);
retval = kenwood_simple_cmd(rig, mdbuf);
if (retval != RIG_OK)
return retval;
@ -403,7 +403,7 @@ th_set_vfo(RIG *rig, vfo_t vfo)
return kenwood_wrong_vfo(__func__, vfo);
}
return kenwood_cmd(rig, cmd);
return kenwood_simple_cmd(rig, cmd);
}
int
@ -548,7 +548,7 @@ int tm_set_vfo_bc2 (RIG *rig, vfo_t vfo)
}
sprintf(vfobuf, "VMC %d,%d", vfonum, vfomode);
retval = kenwood_cmd(rig, vfobuf);
retval = kenwood_simple_cmd(rig, vfobuf);
if (retval != RIG_OK)
return retval;
@ -556,7 +556,7 @@ int tm_set_vfo_bc2 (RIG *rig, vfo_t vfo)
return RIG_OK;
sprintf(vfobuf, "BC %d,%d", vfonum, txvfonum);
retval = kenwood_cmd(rig, vfobuf);
retval = kenwood_simple_cmd(rig, vfobuf);
if (retval != RIG_OK)
return retval;
@ -599,12 +599,12 @@ int th_set_split_vfo (RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
/* Set VFO mode. To be done for TX vfo also? */
sprintf(vfobuf, "VMC %d,0", vfonum);
retval = kenwood_cmd(rig, vfobuf);
retval = kenwood_simple_cmd(rig, vfobuf);
if (retval != RIG_OK)
return retval;
sprintf(vfobuf, "BC %d,%d", vfonum, txvfonum);
retval = kenwood_cmd(rig, vfobuf);
retval = kenwood_simple_cmd(rig, vfobuf);
if (retval != RIG_OK)
return retval;
@ -652,7 +652,7 @@ int th_get_split_vfo (RIG *rig, vfo_t vfo, split_t *split, vfo_t *txvfo)
int
th_set_trn(RIG *rig, int trn)
{
return kenwood_cmd(rig, (trn == RIG_TRN_RIG) ? "AI 1" : "AI 0");
return kenwood_simple_cmd(rig, (trn == RIG_TRN_RIG) ? "AI 1" : "AI 0");
}
/*
@ -747,7 +747,7 @@ th_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
static int th_tburst(RIG *rig, vfo_t vfo, int status)
{
return kenwood_cmd(rig, (status == 1) ? "TT" : "RX");
return kenwood_simple_cmd(rig, (status == 1) ? "TT" : "RX");
}
/*
@ -766,7 +766,7 @@ static int th_set_kenwood_func(RIG *rig, const char *cmd, int status)
buf[BUFSZ-1] = '\0';
strncat(buf, status ? " 1" : " 0", BUFSZ-1);
return kenwood_cmd(rig, buf);
return kenwood_simple_cmd(rig, buf);
}
@ -901,11 +901,11 @@ th_set_parm(RIG *rig, setting_t parm, value_t val)
case RIG_PARM_APO:
if (val.i > 30)
return kenwood_cmd(rig, "APO 2");
return kenwood_simple_cmd(rig, "APO 2");
else if (val.i > 0)
return kenwood_cmd(rig, "APO 1");
return kenwood_simple_cmd(rig, "APO 1");
else
return kenwood_cmd(rig, "APO 0");
return kenwood_simple_cmd(rig, "APO 0");
default:
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported parm %#x\n", __func__, parm);
@ -1089,29 +1089,29 @@ int th_set_level (RIG *rig, vfo_t vfo, setting_t level, value_t val)
(int)(val.f*(rig->caps->level_gran[LVL_RFPOWER].max.i - rig->caps->level_gran[LVL_RFPOWER].min.i))
+ rig->caps->level_gran[LVL_RFPOWER].min.i);
return kenwood_cmd(rig, buf);
return kenwood_simple_cmd(rig, buf);
case RIG_LEVEL_SQL :
sprintf(buf, "SQ %c,%02x", vch,
(int)(val.f*(rig->caps->level_gran[LVL_SQL].max.i-rig->caps->level_gran[LVL_SQL].min.i))
+ rig->caps->level_gran[LVL_SQL].min.i);
return kenwood_cmd(rig, buf);
return kenwood_simple_cmd(rig, buf);
case RIG_LEVEL_AF :
sprintf(buf, "AG %c,%02x", vch, (int)(val.f * 32.0));
return kenwood_cmd(rig, buf);
return kenwood_simple_cmd(rig, buf);
case RIG_LEVEL_ATT :
sprintf(buf, "ATT %c", val.i ? '1' : '0');
return kenwood_cmd(rig, buf);
return kenwood_simple_cmd(rig, buf);
case RIG_LEVEL_BALANCE :
sprintf(buf, "BAL %c", '4' - (int) (val.f * ('4'-'0')));
return kenwood_cmd(rig, buf);
return kenwood_simple_cmd(rig, buf);
case RIG_LEVEL_VOXGAIN:
sprintf(buf, "VXG %d", (int) (val.f * 9));
return kenwood_cmd(rig, buf);
return kenwood_simple_cmd(rig, buf);
case RIG_LEVEL_VOXDELAY: /* "VXD" */
return -RIG_ENIMPL;
@ -1501,7 +1501,7 @@ th_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
{
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__);
return kenwood_cmd(rig, (ptt == RIG_PTT_ON) ? "TX" : "RX");
return kenwood_simple_cmd(rig, (ptt == RIG_PTT_ON) ? "TX" : "RX");
}
int th_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd)
@ -1558,13 +1558,13 @@ int th_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
switch (op) {
case RIG_OP_UP:
return kenwood_cmd(rig, "UP");
return kenwood_simple_cmd(rig, "UP");
case RIG_OP_DOWN:
return kenwood_cmd(rig, "DW");
return kenwood_simple_cmd(rig, "DW");
case RIG_OP_TO_VFO:
return kenwood_cmd(rig, "MSH");
return kenwood_simple_cmd(rig, "MSH");
default:
return -RIG_EINVAL;
@ -2037,7 +2037,7 @@ int th_set_ant(RIG * rig, vfo_t vfo, ant_t ant)
return -RIG_EINVAL;
}
return kenwood_cmd(rig, cmd);
return kenwood_simple_cmd(rig, cmd);
}

Wyświetl plik

@ -943,7 +943,7 @@ int tmd710_set_vfo (RIG *rig, vfo_t vfo)
}
snprintf(vfobuf,9, "VM %d,%d", vfonum, vfomode);
retval = kenwood_cmd(rig, vfobuf);
retval = kenwood_simple_cmd(rig, vfobuf);
if (retval != RIG_OK)
return retval;
@ -951,7 +951,7 @@ int tmd710_set_vfo (RIG *rig, vfo_t vfo)
return RIG_OK;
snprintf(vfobuf, 15, "BC %d,%d", vfonum, txvfonum);
retval = kenwood_cmd(rig, vfobuf);
retval = kenwood_simple_cmd(rig, vfobuf);
if (retval != RIG_OK)
return retval;

Wyświetl plik

@ -30,8 +30,6 @@
#include <hamlib/rig.h>
#include "kenwood.h"
#include "ic10.h"
#define TS570_ALL_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY)
#define TS570_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY)
@ -710,8 +708,8 @@ const struct rig_caps ts570s_caps = {
.serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0,
.post_write_delay = 30,
.timeout = 1000,
.retry = 3,
.timeout = 400,
.retry = 5,
.has_get_func = TS570_FUNC_ALL,
.has_set_func = TS570_FUNC_ALL,
@ -825,7 +823,7 @@ const struct rig_caps ts570s_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 = ts570_set_rit,
.get_rit = kenwood_get_rit,
.set_xit = ts570_set_xit,
@ -889,8 +887,8 @@ const struct rig_caps ts570d_caps = {
.serial_handshake = RIG_HANDSHAKE_NONE,
.write_delay = 0,
.post_write_delay = 30,
.timeout = 1000,
.retry = 3,
.timeout = 400,
.retry = 5,
.has_get_func = TS570_FUNC_ALL,
.has_set_func = TS570_FUNC_ALL,
@ -1009,7 +1007,7 @@ const struct rig_caps ts570d_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 = ts570_set_rit,
.get_rit = kenwood_get_rit,
.set_xit = ts570_set_xit,

Wyświetl plik

@ -532,6 +532,7 @@ const struct rig_caps ts870s_caps = {
.priv = (void *)&ts870s_priv_caps,
.rig_init = kenwood_init,
.rig_open = kenwood_open,
.rig_cleanup = kenwood_cleanup,
.set_freq = kenwood_set_freq,
.get_freq = kenwood_get_freq,

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, */
};