kopia lustrzana https://github.com/Hamlib/Hamlib
Merge branch 'k2-afsk-modes'
of git://git.code.sf.net/u/bsomervi/hamlib Many changes to Kenwood backend rigs.Hamlib-3.0
commit
16ea41d260
|
@ -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;
|
||||
}
|
||||
|
|
40
kenwood/k2.c
40
kenwood/k2.c
|
@ -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;
|
||||
|
||||
/* Check for mode and test to see if K2 reports RTTY. */
|
||||
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;
|
||||
|
||||
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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -193,14 +193,25 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, int cmd_len,
|
|||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig || !datasize)
|
||||
if (!rig || !datasize || !cmdstr)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
struct kenwood_priv_data *priv = rig->state.priv;
|
||||
struct kenwood_priv_caps *caps = kenwood_caps(rig);
|
||||
struct rig_state *rs;
|
||||
int retval;
|
||||
char cmdtrm[2]; /* Default Command/Reply termination char */
|
||||
char *cmd;
|
||||
int len;
|
||||
int retry_read = 0;
|
||||
int reply_expected = data && *datasize > 0;
|
||||
size_t length = *datasize;
|
||||
static char const std_verify[] = "ID;"; /* command we can always
|
||||
send to any rig even when
|
||||
the rig is busy */
|
||||
static char const shrt_verify[] = ";"; /* alternate short verify
|
||||
command XG3 etc. */
|
||||
char const * verify = ',' == cmdstr[1] ? shrt_verify : std_verify;
|
||||
|
||||
rs = &rig->state;
|
||||
rs->hold_decode = 1;
|
||||
|
@ -212,12 +223,7 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, int cmd_len,
|
|||
|
||||
transaction_write:
|
||||
|
||||
serial_flush(&rs->rigport);
|
||||
|
||||
if (cmdstr) {
|
||||
|
||||
char *cmd;
|
||||
int len = strlen(cmdstr);
|
||||
len = strlen(cmdstr);
|
||||
|
||||
cmd = malloc(len + 2);
|
||||
if (cmd == NULL) {
|
||||
|
@ -233,38 +239,45 @@ transaction_write:
|
|||
len++;
|
||||
}
|
||||
|
||||
*datasize = length; /* reset as may be a retry */
|
||||
|
||||
serial_flush(&rs->rigport);
|
||||
retval = write_block(&rs->rigport, cmd, len);
|
||||
|
||||
free(cmd);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
goto transaction_quit;
|
||||
}
|
||||
|
||||
if (data == NULL || *datasize <= 0) {
|
||||
if (!reply_expected) {
|
||||
rig->state.hold_decode = 0;
|
||||
return RIG_OK; /* don't want a reply */
|
||||
|
||||
/* no reply expected so we need to write a command that always
|
||||
gives a reply so we can read any error replies from the actual
|
||||
command being sent without blocking */
|
||||
if (RIG_OK != (retval = write_block (&rs->rigport, verify, strlen (verify)))) {
|
||||
goto transaction_quit;
|
||||
}
|
||||
}
|
||||
|
||||
memset(data,0,*datasize);
|
||||
retval = read_string(&rs->rigport, data, *datasize, cmdtrm, strlen(cmdtrm));
|
||||
retval = read_string(&rs->rigport, priv->info, reply_expected ? *datasize : strlen (verify) + 5, cmdtrm, strlen(cmdtrm));
|
||||
if (retval < 0) {
|
||||
if (retry_read++ < rig->state.rigport.retry)
|
||||
if (retry_read++ < rig->caps->retry)
|
||||
goto transaction_write;
|
||||
goto transaction_quit;
|
||||
}
|
||||
|
||||
/* Check that command termination is correct */
|
||||
if (strchr(cmdtrm, data[strlen(data)-1])==NULL) {
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n", __func__, data);
|
||||
if (retry_read++ < rig->state.rigport.retry)
|
||||
if (strchr(cmdtrm, priv->info[strlen(priv->info)-1])==NULL) {
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n", __func__, priv->info);
|
||||
if (retry_read++ < rig->caps->retry)
|
||||
goto transaction_write;
|
||||
retval = -RIG_EPROTO;
|
||||
goto transaction_quit;
|
||||
}
|
||||
|
||||
if (strlen(data) == 2) {
|
||||
switch (data[0]) {
|
||||
if (strlen(priv->info) == 2) {
|
||||
switch (priv->info[0]) {
|
||||
case 'N':
|
||||
/* Command recognised by rig but invalid data entered. */
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: NegAck for '%s'\n", __func__, cmdstr);
|
||||
|
@ -273,60 +286,86 @@ transaction_write:
|
|||
case 'O':
|
||||
/* Too many characters sent without a carriage return */
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Overflow for '%s'\n", __func__, cmdstr);
|
||||
if (retry_read++ < rig->state.rigport.retry)
|
||||
if (retry_read++ < rig->caps->retry)
|
||||
goto transaction_write;
|
||||
retval = -RIG_EPROTO;
|
||||
goto transaction_quit;
|
||||
case 'E':
|
||||
/* Communication error */
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: Communication error for '%s'\n", __func__, cmdstr);
|
||||
if (retry_read++ < rig->state.rigport.retry)
|
||||
if (retry_read++ < rig->caps->retry)
|
||||
goto transaction_write;
|
||||
retval = -RIG_EIO;
|
||||
goto transaction_quit;
|
||||
case '?':
|
||||
/* Command not understood by rig */
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Unknown command '%s'\n", __func__, cmdstr);
|
||||
if (retry_read++ < rig->state.rigport.retry)
|
||||
/* Command not understood by rig or rig busy */
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Unknown command or rig busy '%s'\n", __func__, cmdstr);
|
||||
if (retry_read++ < rig->caps->retry)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: Retrying shortly\n", __func__);
|
||||
usleep (rig->caps->timeout * 1000);
|
||||
goto transaction_write;
|
||||
}
|
||||
retval = -RIG_ERJCTED;
|
||||
goto transaction_quit;
|
||||
}
|
||||
}
|
||||
|
||||
*datasize = retval; /* this is retval from successful
|
||||
read_string above, don't assign
|
||||
until here because IN value is
|
||||
needed for retries */
|
||||
|
||||
/* always give back a null terminated string without
|
||||
* the command terminator.
|
||||
*/
|
||||
if (strlen(data) > 0)
|
||||
data[strlen(data) - 1] = '\0'; /* not elegant, but works */
|
||||
else
|
||||
data[0] = '\0';
|
||||
|
||||
/*
|
||||
* Check that we received the correct reply. The first two characters
|
||||
* should be the same as command.
|
||||
* should be the same as command. Because the Elecraft XG3 uses
|
||||
* single character commands we only check the first character in
|
||||
* that case.
|
||||
*/
|
||||
if (cmdstr && (data[0] != cmdstr[0] || (cmdstr[1] != '\0' && data[1] != cmdstr[1]))) {
|
||||
if (reply_expected)
|
||||
{
|
||||
if (priv->info[0] != cmdstr[0] || (cmdstr[1] && priv->info[1] != cmdstr[1]))
|
||||
{
|
||||
/*
|
||||
* TODO: When RIG_TRN is enabled, we can pass the string
|
||||
* to the decoder for callback. That way we don't ignore
|
||||
* any commands.
|
||||
* TODO: When RIG_TRN is enabled, we can pass the string to
|
||||
* the decoder for callback. That way we don't ignore any
|
||||
* commands.
|
||||
*/
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply %c%c for command %c%c\n",
|
||||
__func__, data[0], data[1], cmdstr[0], cmdstr[1]);
|
||||
__func__, priv->info[0], priv->info[1], cmdstr[0], cmdstr[1]);
|
||||
|
||||
if (retry_read++ < rig->state.rigport.retry)
|
||||
if (retry_read++ < rig->caps->retry)
|
||||
goto transaction_write;
|
||||
|
||||
retval = -RIG_EPROTO;
|
||||
goto transaction_quit;
|
||||
}
|
||||
|
||||
/* always give back a null terminated string without the command
|
||||
* terminator.
|
||||
*/
|
||||
int len = (*datasize < retval ? *datasize : retval) - 1;
|
||||
strncpy (data, priv->info, len);
|
||||
data[len] = '\0';
|
||||
*datasize = retval; /* this is retval from successful
|
||||
read_string above, don't assign until
|
||||
here because IN value is needed for
|
||||
retries */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (verify[0] != priv->info[0] || (verify[1] && verify[1] != priv->info[1]))
|
||||
{
|
||||
/*
|
||||
* TODO: When RIG_TRN is enabled, we can pass the string to
|
||||
* the decoder for callback. That way we don't ignore any
|
||||
* commands.
|
||||
*/
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong reply %c%c for command verification %c%c\n",
|
||||
__func__, priv->info[0], priv->info[1], verify[0], verify[1]);
|
||||
|
||||
if (retry_read++ < rig->caps->retry)
|
||||
goto transaction_write;
|
||||
|
||||
retval = -RIG_EPROTO;
|
||||
goto transaction_quit;
|
||||
}
|
||||
}
|
||||
retval = RIG_OK;
|
||||
|
||||
transaction_quit:
|
||||
|
@ -358,26 +397,35 @@ int kenwood_safe_transaction(RIG *rig, const char *cmd, char *buf,
|
|||
{
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (!rig || !buf)
|
||||
if (!rig || !cmd)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
int err;
|
||||
int retry = 0;
|
||||
|
||||
if (expected == 0)
|
||||
buf_size = 0;
|
||||
|
||||
err = kenwood_transaction(rig, cmd, strlen(cmd), buf, &buf_size);
|
||||
if (err != RIG_OK)
|
||||
do
|
||||
{
|
||||
size_t length = buf_size;
|
||||
err = kenwood_transaction(rig, cmd, strlen(cmd), buf, &length);
|
||||
if (err != RIG_OK) /* return immediately on error as any
|
||||
retries handled at lower level */
|
||||
return err;
|
||||
|
||||
if (buf_size != expected) {
|
||||
if (length != expected) /* worth retrying as some rigs
|
||||
occasionally send short results */
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: wrong answer; len for cmd %s: "
|
||||
"expected = %d, got %d\n",
|
||||
__func__, cmd, expected, buf_size);
|
||||
return -RIG_EPROTO;
|
||||
__func__, cmd, expected, length);
|
||||
err = -RIG_EPROTO;
|
||||
usleep (rig->caps->timeout * 1000);
|
||||
}
|
||||
} while (err != RIG_OK && ++retry < rig->caps->retry);
|
||||
|
||||
return RIG_OK;
|
||||
return err;
|
||||
}
|
||||
|
||||
rmode_t kenwood2rmode(unsigned char mode, const rmode_t mode_table[])
|
||||
|
@ -395,10 +443,13 @@ char rmode2kenwood(rmode_t mode, const rmode_t mode_table[])
|
|||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
|
||||
|
||||
if (mode != RIG_MODE_NONE)
|
||||
{
|
||||
for(i = 0; i < KENWOOD_MODE_TABLE_MAX; i++) {
|
||||
if (mode_table[i] == mode)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -623,7 +674,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';
|
||||
}
|
||||
|
@ -774,14 +826,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':
|
||||
|
@ -2368,7 +2421,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)
|
||||
|
@ -2379,7 +2437,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 */
|
||||
|
@ -2412,6 +2470,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';
|
||||
|
@ -2477,9 +2539,17 @@ 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 */
|
||||
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,
|
||||
(int) chan->freq,
|
||||
(int64_t)chan->freq,
|
||||
'0' + mode,
|
||||
(chan->flags & RIG_CHFLAG_SKIP) ? '1' : '0',
|
||||
chan->ctcss_tone ? '1' : '0',
|
||||
|
@ -2489,9 +2559,10 @@ int kenwood_set_channel(RIG *rig, const channel_t *chan)
|
|||
if (err != RIG_OK)
|
||||
return err;
|
||||
|
||||
sprintf(buf, "MW1 %02d%011d%c%c%c%02d ",
|
||||
sprintf(buf, "MW1%c%02d%011"PRIll"%c%c%c%02d ",
|
||||
bank,
|
||||
chan->channel_num,
|
||||
(chan->split == RIG_SPLIT_ON) ? ((int) chan->tx_freq) : 0,
|
||||
(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',
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <string.h>
|
||||
#include "token.h"
|
||||
|
||||
#define BACKEND_VER "0.8"
|
||||
#define BACKEND_VER "0.9"
|
||||
|
||||
#define EOM_KEN ';'
|
||||
#define EOM_TH '\r'
|
||||
|
@ -76,6 +76,7 @@ struct kenwood_priv_data {
|
|||
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 */
|
||||
};
|
||||
|
||||
|
||||
|
@ -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 */
|
||||
|
|
48
kenwood/th.c
48
kenwood/th.c
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,10 +106,11 @@ 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} },
|
||||
{ 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,
|
||||
},
|
||||
|
||||
|
@ -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, */
|
||||
|
||||
};
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue