kopia lustrzana https://github.com/Hamlib/Hamlib
factorized th_transaction with kenwood_transaction, killed thd7_* functions and share with th breed rigs
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1026 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.3
rodzic
ad7310335b
commit
9ed48795a2
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hamlib Kenwood backend - main file
|
||||
* Copyright (c) 2000,2001,2002 by Stephane Fillod
|
||||
* Copyright (c) 2000-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: kenwood.c,v 1.33 2002-03-05 20:23:44 fillods Exp $
|
||||
* $Id: kenwood.c,v 1.34 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -40,10 +40,6 @@
|
|||
|
||||
#include "kenwood.h"
|
||||
|
||||
|
||||
#define EOM ';'
|
||||
#define EOM_TH '\r'
|
||||
|
||||
/*
|
||||
* modes in use by the "MD" command
|
||||
*/
|
||||
|
@ -106,70 +102,121 @@ const int kenwood38_ctcss_list[] = {
|
|||
0,
|
||||
};
|
||||
|
||||
/*
|
||||
* port_transaction
|
||||
* called by kenwood_transaction and probe_kenwood
|
||||
* We assume that port!=NULL, data!=NULL, data_len!=NULL
|
||||
* Otherwise, you'll get a nice seg fault. You've been warned!
|
||||
* return value: RIG_OK if everything's fine, negative value otherwise
|
||||
* TODO: error case handling, error codes from the rig, ..
|
||||
*/
|
||||
static int port_transaction(port_t *port, const char *cmd, int cmd_len, char *data, int *data_len)
|
||||
{
|
||||
int i, retval;
|
||||
#define cmd_trm(rig) ((struct kenwood_priv_caps *)(rig)->caps->priv)->cmdtrm
|
||||
|
||||
retval = write_block(port, cmd, cmd_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
/*
|
||||
* buffered read are quite helpful here!
|
||||
* However, an automate with a state model would be more efficient..
|
||||
*/
|
||||
i = 0;
|
||||
do {
|
||||
retval = fread_block(port, data+i, 1);
|
||||
if (retval == 0)
|
||||
continue; /* huh!? */
|
||||
if (retval < 0)
|
||||
return retval;
|
||||
i++;
|
||||
} while (data[i-1] != EOM && data[i-1] != EOM_TH);
|
||||
|
||||
*data_len = i;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* kenwood_transaction
|
||||
* We assume that rig!=NULL, rig->state!= NULL, data!=NULL, data_len!=NULL
|
||||
* Otherwise, you'll get a nice seg fault. You've been warned!
|
||||
* return value: RIG_OK if everything's fine, negative value otherwise
|
||||
* TODO: error case handling, error codes from the rig, ..
|
||||
* Assumes rig!=NULL rig->state!=NULL rig->caps!=NULL
|
||||
*
|
||||
* Note: right now, kenwood_transaction is a simple call to port_transaction.
|
||||
* kenwood_transaction could have been written to accept a port_t instead
|
||||
* of RIG, but who knows if we will need some priv stuff in the future?
|
||||
* cmdstr - Command to be sent to the rig. Cmdstr can also be NULL, indicating
|
||||
* that only a reply is needed (nothing will be send).
|
||||
* data - Buffer for reply string. Can be NULL, indicating that no reply is
|
||||
* is needed and will return with RIG_OK after command was sent.
|
||||
* datasize - in: Size of buffer. It is the caller's responsibily to provide
|
||||
* a large enough buffer for all possible replies for a command.
|
||||
* out: location where to store number of bytes read.
|
||||
*
|
||||
* It is possible to tell kenwood_transaction no data are expected back,
|
||||
* so it won't return -RIG_ETIMEOUT. To do so, pass *data_len set to 0.
|
||||
* Note: kenwood_transaction cannot just sent the cmd and return
|
||||
* immediately because the rig can return an error code.
|
||||
* FIXME: handle correctly error codes: "?;", "E;", "O;"
|
||||
* returns:
|
||||
* RIG_OK - if no error occured.
|
||||
* RIG_EIO - if an I/O error occured while sending/receiving data.
|
||||
* RIG_ETIMEOUT - if timeout expires without any characters received.
|
||||
* RIG_REJECTED - if a negative acknowledge was received or command not
|
||||
* recognized by rig.
|
||||
*/
|
||||
int kenwood_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int *data_len)
|
||||
int
|
||||
kenwood_transaction (RIG *rig, const char *cmdstr, int cmd_len,
|
||||
char *data, size_t *datasize)
|
||||
{
|
||||
int ret, wanted_data_len;
|
||||
struct rig_state *rs;
|
||||
int retval;
|
||||
const char *cmdtrm = EOM_KEN; /* Default Command/Reply termination char */
|
||||
int retry_read = 0;
|
||||
#define MAX_RETRY_READ 32
|
||||
|
||||
wanted_data_len = *data_len;
|
||||
rs = &rig->state;
|
||||
rs->hold_decode = 1;
|
||||
|
||||
ret = port_transaction(&rig->state.rigport, cmd, cmd_len, data, data_len);
|
||||
if (wanted_data_len == 0 && ret == -RIG_ETIMEOUT)
|
||||
ret = RIG_OK;
|
||||
return ret;
|
||||
serial_flush(&rs->rigport);
|
||||
|
||||
cmdtrm = cmd_trm(rig);
|
||||
|
||||
if (cmdstr) {
|
||||
retval = write_block(&rs->rigport, cmdstr, strlen(cmdstr));
|
||||
if (retval != RIG_OK)
|
||||
goto transaction_quit;
|
||||
#ifdef TH_ADD_CMDTRM
|
||||
retval = write_block(&rs->rigport, cmdtrm, strlen(cmdtrm));
|
||||
if (retval != RIG_OK)
|
||||
goto transaction_quit;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (data == NULL || *datasize <= 0) {
|
||||
rig->state.hold_decode = 0;
|
||||
return RIG_OK; /* don't want a reply */
|
||||
}
|
||||
|
||||
transaction_read:
|
||||
retval = read_string(&rs->rigport, data, *datasize, cmdtrm, strlen(cmdtrm));
|
||||
if (retval < 0)
|
||||
goto transaction_quit;
|
||||
else
|
||||
*datasize = retval;
|
||||
|
||||
/* Check that command termination is correct */
|
||||
if (!strchr(cmdtrm, data[strlen(data)])) {
|
||||
if (retry_read++ < MAX_RETRY_READ)
|
||||
goto transaction_read;
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": Command is not correctly terminated '%s'\n", data);
|
||||
retval = -RIG_EPROTO;
|
||||
goto transaction_quit;
|
||||
}
|
||||
|
||||
/* Command recognised by rig but invalid data entered. */
|
||||
if (strlen(data) == 2 && data[0] == 'N') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": NegAck for '%s'\n", cmdstr);
|
||||
retval = -RIG_ERJCTED;
|
||||
goto transaction_quit;
|
||||
}
|
||||
|
||||
/* Command not understood by rig */
|
||||
if (strlen(data) == 2 && data[0] == '?') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": Unknown command '%s'\n", cmdstr);
|
||||
retval = -RIG_ERJCTED;
|
||||
goto transaction_quit;
|
||||
}
|
||||
|
||||
#define CONFIG_STRIP_CMDTRM 1
|
||||
#ifdef CONFIG_STRIP_CMDTRM
|
||||
if (strlen(data) > 0)
|
||||
data[strlen(data)-1] = '\0'; /* not very elegant, but should work. */
|
||||
else
|
||||
data[0] = '\0';
|
||||
#endif
|
||||
/*
|
||||
* Check that received the correct reply. The first two characters
|
||||
* should be the same as command.
|
||||
*/
|
||||
if (cmdstr && (data[0] != cmdstr[0] || data[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.
|
||||
*/
|
||||
if (retry_read++ < MAX_RETRY_READ)
|
||||
goto transaction_read;
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": Unexpected reply '%s'\n", data);
|
||||
retval = -RIG_EPROTO;
|
||||
goto transaction_quit;
|
||||
}
|
||||
|
||||
retval = RIG_OK;
|
||||
transaction_quit:
|
||||
rs->hold_decode = 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* kenwood_set_vfo
|
||||
* Assumes rig!=NULL
|
||||
|
@ -177,7 +224,7 @@ int kenwood_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, int
|
|||
int kenwood_set_vfo(RIG *rig, vfo_t vfo)
|
||||
{
|
||||
unsigned char cmdbuf[16], ackbuf[16];
|
||||
int ack_len = 0, retval;
|
||||
int cmd_len, ack_len = 0, retval;
|
||||
char vfo_function;
|
||||
|
||||
/*
|
||||
|
@ -195,13 +242,11 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo)
|
|||
vfo);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
cmdbuf[0] = 'F';
|
||||
cmdbuf[1] = 'R';
|
||||
cmdbuf[2] = vfo_function;
|
||||
cmdbuf[3] = EOM;
|
||||
|
||||
cmd_len = sprintf(cmdbuf, "FR%c%s", vfo_function, cmd_trm(rig));
|
||||
|
||||
/* set RX VFO */
|
||||
retval = kenwood_transaction (rig, cmdbuf, 4, ackbuf, &ack_len);
|
||||
retval = kenwood_transaction (rig, cmdbuf, cmd_len, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -290,7 +335,7 @@ int kenwood_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
{
|
||||
unsigned char freqbuf[50];
|
||||
unsigned char cmdbuf[4];
|
||||
int freq_len, retval;
|
||||
int cmd_len, freq_len, retval;
|
||||
char vfo_letter;
|
||||
|
||||
/*
|
||||
|
@ -311,11 +356,10 @@ int kenwood_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
vfo);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
cmdbuf[0] = 'F';
|
||||
cmdbuf[1] = vfo_letter;
|
||||
cmdbuf[2] = EOM;
|
||||
|
||||
retval = kenwood_transaction (rig, cmdbuf, 3, freqbuf, &freq_len);
|
||||
cmd_len = sprintf(cmdbuf, "F%c%s", vfo_letter, cmd_trm(rig));
|
||||
|
||||
retval = kenwood_transaction (rig, cmdbuf, cmd_len, freqbuf, &freq_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
|
@ -1089,13 +1133,14 @@ const char* kenwood_get_info(RIG *rig)
|
|||
}
|
||||
}
|
||||
|
||||
#define IDBUFSZ 16
|
||||
|
||||
/*
|
||||
* probe_kenwood
|
||||
*/
|
||||
rig_model_t probe_kenwood(port_t *port)
|
||||
{
|
||||
unsigned char idbuf[16];
|
||||
unsigned char idbuf[IDBUFSZ];
|
||||
int id_len, i, k_id;
|
||||
int retval;
|
||||
|
||||
|
@ -1110,7 +1155,8 @@ rig_model_t probe_kenwood(port_t *port)
|
|||
if (retval != RIG_OK)
|
||||
return RIG_MODEL_NONE;
|
||||
|
||||
retval = port_transaction(port, "ID;", 3, idbuf, &id_len);
|
||||
retval = write_block(port, "ID;", 3);
|
||||
id_len = read_string(port, idbuf, IDBUFSZ, EOM_KEN EOM_TH, 2);
|
||||
|
||||
close(port->fd);
|
||||
|
||||
|
@ -1170,7 +1216,6 @@ int kenwood_init(RIG *rig)
|
|||
{
|
||||
const struct rig_caps *caps;
|
||||
const struct kenwood_priv_caps *priv_caps;
|
||||
struct kenwood_priv_data *priv;
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
|
||||
if (!rig || !rig->caps)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Hamlib Kenwood backend - main header
|
||||
* Copyright (c) 2000-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: kenwood.h,v 1.20 2002-03-05 20:23:44 fillods Exp $
|
||||
* $Id: kenwood.h,v 1.21 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -23,6 +23,9 @@
|
|||
#ifndef _KENWOOD_H
|
||||
#define _KENWOOD_H 1
|
||||
|
||||
#define EOM_KEN ";"
|
||||
#define EOM_TH "\r"
|
||||
|
||||
struct kenwood_priv_caps {
|
||||
/* read-only values */
|
||||
const char *cmdtrm; /* Command termination chars (ken=';' or th='\r') */
|
||||
|
@ -43,7 +46,7 @@ extern int kenwood_cleanup(RIG *rig);
|
|||
extern const int kenwood38_ctcss_list[];
|
||||
|
||||
int kenwood_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||
int *data_len);
|
||||
size_t *data_len);
|
||||
int kenwood_set_vfo(RIG *rig, vfo_t vfo);
|
||||
int kenwood_get_vfo(RIG *rig, vfo_t *vfo);
|
||||
int kenwood_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
|
||||
|
|
141
kenwood/th.c
141
kenwood/th.c
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hamlib Kenwood backend - TH handheld primitives
|
||||
* Copyright (c) 2001 by Stephane Fillod
|
||||
* Copyright (c) 2001-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: th.c,v 1.6 2002-03-10 23:41:39 fillods Exp $
|
||||
* $Id: th.c,v 1.7 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -40,7 +40,7 @@
|
|||
#include <serial.h>
|
||||
|
||||
const struct kenwood_priv_caps th_priv_caps = {
|
||||
cmdtrm: "\r",
|
||||
cmdtrm: EOM_TH,
|
||||
};
|
||||
/* Note: Currently the code assumes the command termination is a
|
||||
* single character.
|
||||
|
@ -50,7 +50,7 @@ const struct kenwood_priv_caps th_priv_caps = {
|
|||
#ifdef TH_ADD_CMDTRM
|
||||
#define EOM
|
||||
#else
|
||||
#define EOM "\r"
|
||||
#define EOM EOM_TH
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -65,6 +65,7 @@ const struct kenwood_priv_caps th_priv_caps = {
|
|||
|
||||
#define ACKBUF_LEN 64
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* th_transaction
|
||||
* Assumes rig!=NULL rig->state!=NULL rig->caps!=NULL
|
||||
|
@ -171,6 +172,16 @@ transaction_quit:
|
|||
return retval;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int th_transaction (RIG *rig, const char *cmdstr, char *data, size_t datasize)
|
||||
{
|
||||
size_t ds = datasize;
|
||||
return kenwood_transaction(rig, cmdstr, strlen(cmdstr),
|
||||
data, &ds);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* th_decode_event is called by sa_sigio, when some asynchronous
|
||||
* data has been received from the rig.
|
||||
|
@ -796,4 +807,126 @@ th_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
const char *
|
||||
th_get_info(RIG *rig) /* I hope this is the correct function for this command. */
|
||||
{
|
||||
static unsigned char firmbuf[16];
|
||||
int retval, firm_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
|
||||
memset(firmbuf, 0, sizeof(firmbuf));
|
||||
retval = kenwood_transaction (rig, "ID" EOM, 3, firmbuf, &firm_len);
|
||||
if (retval != RIG_OK)
|
||||
return NULL;
|
||||
#if 1
|
||||
if (firm_len != 6) {
|
||||
rig_debug(RIG_DEBUG_ERR,__FUNCTION__": wrong answer len=%d\n",
|
||||
firm_len);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
if (firmbuf[0] != 'I' || firmbuf[1] != 'D') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", firmbuf, firm_len);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &firmbuf[2];
|
||||
}
|
||||
|
||||
/*
|
||||
* th_set_mem
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
int
|
||||
th_set_mem(RIG *rig, vfo_t vfo, int ch)
|
||||
{
|
||||
unsigned char vsel, membuf[16], ackbuf[16];
|
||||
int retval, mem_len, ack_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
memset(ackbuf, 0, sizeof(ackbuf));
|
||||
|
||||
if (ch < 0 || ch > 200) {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": channel num out of range: %d\n", ch);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
switch (vfo) {
|
||||
case RIG_VFO_A: vsel = '0'; break;
|
||||
case RIG_VFO_B: vsel = '1'; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unsupported VFO %d\n", vfo);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
mem_len = sprintf(membuf, "MC %c,%i" EOM, vsel, ch);
|
||||
retval = kenwood_transaction(rig, membuf, mem_len, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (ackbuf[0] == 'N' && ackbuf[1] == '\n') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": negative acknowledgment\n");
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
if (ackbuf[0] != 'M' || ackbuf[1] != 'C') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", ackbuf, ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int
|
||||
th_get_mem(RIG *rig, vfo_t vfo, int *ch)
|
||||
{
|
||||
unsigned char *membuf, ackbuf[16];
|
||||
int retval, mem_len, ack_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
memset(ackbuf, 0, sizeof(ackbuf));
|
||||
|
||||
switch (vfo) {
|
||||
case RIG_VFO_A:
|
||||
membuf = "MC 0" EOM;
|
||||
break;
|
||||
case RIG_VFO_B:
|
||||
membuf = "MC 1" EOM;
|
||||
break;
|
||||
case RIG_VFO_CURR:
|
||||
membuf = "MC" EOM;
|
||||
break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unsupported VFO %d\n", vfo);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
mem_len = strlen(membuf);
|
||||
retval = kenwood_transaction(rig, membuf, mem_len, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (ackbuf[0] == 'N' && ackbuf[1] == '\n') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": negative acknowledgment\n");
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
if (ackbuf[0] != 'M' || ackbuf[1] != 'C') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", ackbuf, ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
*ch = atoi(&membuf[3]);
|
||||
#if 0
|
||||
if (*ch < 0 || *ch > 200) {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": channel num out of range: %d\n", ch);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
#endif
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hamlib Kenwood backend - TH handheld header
|
||||
* Copyright (c) 2001 by Stephane Fillod
|
||||
* Copyright (c) 2001-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: th.h,v 1.2 2002-01-07 17:48:36 fgretief Exp $
|
||||
* $Id: th.h,v 1.3 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -36,6 +36,9 @@ extern int th_get_func (RIG *rig, vfo_t vfo, setting_t func, int *status);
|
|||
extern int th_get_level (RIG *rig, vfo_t vfo, setting_t level, value_t *val);
|
||||
extern int th_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone);
|
||||
extern int th_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone);
|
||||
extern const char *th_get_info(RIG *rig);
|
||||
extern int th_set_mem(RIG *rig, vfo_t vfo, int ch);
|
||||
extern int th_get_mem(RIG *rig, vfo_t vfo, int *ch);
|
||||
|
||||
#endif /* __TH_H__ */
|
||||
/* end of file */
|
||||
|
|
519
kenwood/thd7.c
519
kenwood/thd7.c
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hamlib Kenwood backend - TH-D7 description
|
||||
* Copyright (c) 2000,2001 by Stephane Fillod
|
||||
* Copyright (c) 2000-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: thd7.c,v 1.5 2002-01-07 17:46:28 fgretief Exp $
|
||||
* $Id: thd7.c,v 1.6 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -44,18 +44,6 @@
|
|||
#define RIG_ASSERT(x)
|
||||
#endif
|
||||
|
||||
static int thd7_set_vfo(RIG *rig, vfo_t vfo);
|
||||
static int thd7_get_vfo(RIG *rig, vfo_t *vfo);
|
||||
static int thd7_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
|
||||
static int thd7_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
|
||||
static int thd7_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone);
|
||||
static int thd7_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone);
|
||||
static int thd7_set_trn(RIG *rig, int trn);
|
||||
static int thd7_get_trn(RIG *rig, int *trn);
|
||||
static const char *thd7_get_info(RIG *rig);
|
||||
static int thd7_set_mem(RIG *rig, vfo_t vfo, int ch);
|
||||
static int thd7_get_mem(RIG *rig, vfo_t vfo, int *ch);
|
||||
static int thd7_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
|
||||
|
||||
#define THD7_MODES (RIG_MODE_FM|RIG_MODE_AM)
|
||||
#define THD7_MODES_TX (RIG_MODE_FM)
|
||||
|
@ -85,7 +73,7 @@ static int thd7_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
|
|||
#define THD7_VFO (RIG_VFO_A|RIG_VFO_B)
|
||||
|
||||
const struct kenwood_priv_caps thd7_priv_caps = {
|
||||
cmdtrm: "\r", /* Command termination character */
|
||||
cmdtrm: EOM_TH, /* Command termination character */
|
||||
};
|
||||
|
||||
|
||||
|
@ -183,511 +171,20 @@ set_mode: th_set_mode,
|
|||
get_mode: th_get_mode,
|
||||
set_vfo: th_set_vfo,
|
||||
get_vfo: th_get_vfo,
|
||||
set_ctcss_tone: thd7_set_ctcss_tone,
|
||||
get_ctcss_tone: thd7_get_ctcss_tone,
|
||||
set_mem: thd7_set_mem,
|
||||
get_mem: thd7_get_mem,
|
||||
set_ctcss_tone: th_set_ctcss_tone,
|
||||
get_ctcss_tone: th_get_ctcss_tone,
|
||||
set_mem: th_set_mem,
|
||||
get_mem: th_get_mem,
|
||||
set_trn: th_set_trn,
|
||||
get_trn: th_get_trn,
|
||||
|
||||
get_func: th_get_func,
|
||||
get_level: th_get_level,
|
||||
get_info: thd7_get_info,
|
||||
get_info: th_get_info,
|
||||
|
||||
decode_event: th_decode_event,
|
||||
};
|
||||
|
||||
#define EOM "\r"
|
||||
|
||||
|
||||
/*
|
||||
* thd7_set_vfo
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
static int
|
||||
thd7_set_vfo(RIG *rig, vfo_t vfo)
|
||||
{
|
||||
unsigned char vsel, vfobuf[16], ackbuf[24];
|
||||
int retval, vfo_len, ack_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__" called\n");
|
||||
RIG_ASSERT(rig != NULL);
|
||||
|
||||
switch (vfo) {
|
||||
case RIG_VFO_A: vsel = '0'; break;
|
||||
case RIG_VFO_B: vsel = '1'; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unsupported VFO %d\n", vfo);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
vfo_len = sprintf(vfobuf, "BC %c" EOM, vsel);
|
||||
retval = kenwood_transaction (rig, vfobuf, vfo_len, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (ackbuf[0] == 'N' && ackbuf[1] == '\n') {
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* thd7_get_vfo
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
static int
|
||||
thd7_get_vfo(RIG *rig, vfo_t *vfo)
|
||||
{
|
||||
unsigned char ackbuf[16];
|
||||
int retval, ack_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__" called\n");
|
||||
RIG_ASSERT(rig != NULL);
|
||||
|
||||
retval = kenwood_transaction (rig, "BC" EOM, 3, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
// if (ack_len != 5) { /* for some reason ack_len is zero */
|
||||
if (ackbuf[0] != 'B' || ackbuf[1] != 'C' || ackbuf[2] != ' ') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", ackbuf, ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
switch (ackbuf[3]) {
|
||||
case '0': *vfo = RIG_VFO_A; break;
|
||||
case '1': *vfo = RIG_VFO_B; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected VFO value %c\n",
|
||||
ackbuf[3]);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* thd7_set_mode
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
static int
|
||||
thd7_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
{
|
||||
unsigned char mdbuf[24], ackbuf[24];
|
||||
int retval, kmode, mdbuf_len, ack_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__" called\n");
|
||||
RIG_ASSERT(rig != NULL);
|
||||
|
||||
switch (mode) {
|
||||
case RIG_MODE_FM: kmode = '0'; break;
|
||||
case RIG_MODE_AM: kmode = '1'; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,__FUNCTION__": unsupported mode %d\n", mode);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
mdbuf_len = sprintf(mdbuf, "MD %c" EOM, kmode);
|
||||
retval = kenwood_transaction (rig, mdbuf, mdbuf_len, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (ackbuf[0] == 'N' && ackbuf[1] == '\n') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": ack NG, len=%d\n", ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* thd7_get_mode
|
||||
* Assumes rig!=NULL, mode!=NULL
|
||||
*/
|
||||
static int
|
||||
thd7_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
||||
{
|
||||
int retval, ack_len = 0;
|
||||
unsigned char ackbuf[24];
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
RIG_ASSERT(rig != NULL);
|
||||
RIG_ASSERT(mode != NULL);
|
||||
memset(ackbuf, 0, sizeof(ackbuf)); /* for terminating zero of string */
|
||||
|
||||
retval = kenwood_transaction (rig, "MD" EOM, 3, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
/*if (ack_len != 5) { */ /* ack_len does not work. */
|
||||
if (ackbuf[0] == 'N' && ackbuf[1] == '\n') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": ack NG, len=%d\n", ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
if (ackbuf[0] != 'M' || ackbuf[1] != 'D' || ackbuf[2] != ' ') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unknown replay (%i) %s\n",
|
||||
ack_len, ackbuf);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
if (width)
|
||||
*width = RIG_PASSBAND_NORMAL;
|
||||
|
||||
switch (ackbuf[3]) {
|
||||
case '0': *mode = RIG_MODE_FM; break;
|
||||
case '1': *mode = RIG_MODE_AM; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unsupported mode %c\n", ackbuf[3]);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
#ifndef RIG_TONEMAX
|
||||
#define RIG_TONEMAX 38
|
||||
#endif
|
||||
|
||||
/*
|
||||
* thd7_set_ctcss_tone
|
||||
* Assumes rig!=NULL, rig->caps->ctcss_list != NULL
|
||||
*/
|
||||
static int
|
||||
thd7_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
|
||||
{
|
||||
const struct rig_caps *caps;
|
||||
unsigned char tonebuf[24], ackbuf[24];
|
||||
int retval, tone_len, ack_len = 0;
|
||||
int i;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
RIG_ASSERT(rig != NULL);
|
||||
RIG_ASSERT(rig->caps != NULL && rig->caps->ctcss_list != NULL);
|
||||
memset(ackbuf, 0, sizeof(ackbuf));
|
||||
|
||||
caps = rig->caps;
|
||||
|
||||
for (i = 0; caps->ctcss_list[i] != 0 && i < RIG_TONEMAX; i++) {
|
||||
if (caps->ctcss_list[i] == tone)
|
||||
break;
|
||||
}
|
||||
if (caps->ctcss_list[i] != tone)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
i += (i == 0) ? 1 : 2; /* Correct for TH-7D anomally */
|
||||
tone_len = sprintf(tonebuf, "CTN %02d" EOM, i);
|
||||
retval = kenwood_transaction (rig, tonebuf, tone_len, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
/* error/result checking */
|
||||
if (ackbuf[0] == 'N' && ackbuf[1] == '\n') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": negative acknowledgment\n");
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
if (ackbuf[0] != 'C' || ackbuf[1] != 'T' || ackbuf[2] != 'N') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", tonebuf, tone_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* thd7_get_ctcss_tone
|
||||
* Assumes rig!=NULL, rig->caps!=NULL
|
||||
*/
|
||||
static int
|
||||
thd7_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
|
||||
{
|
||||
const struct rig_caps *caps;
|
||||
unsigned char tonebuf[24];
|
||||
int retval, tone_len = 0;
|
||||
unsigned int tone_idx;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
RIG_ASSERT(rig != NULL);
|
||||
RIG_ASSERT(rig->caps != NULL && rig->caps->ctcss_list != NULL);
|
||||
memset(tonebuf, 0, sizeof(tonebuf)); /* for terminating zero of string */
|
||||
|
||||
caps = rig->caps;
|
||||
|
||||
retval = kenwood_transaction (rig, "CTN" EOM, 4, tonebuf, &tone_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (tonebuf[0] != 'C' || tonebuf[1] != 'T' || tonebuf[2] != 'N') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", tonebuf, tone_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
sscanf(tonebuf+3, "%u", (int*)&tone_idx);
|
||||
|
||||
/* verify tone index for TH-7D rig */
|
||||
if (tone_idx <= 0 || tone_idx == 2 || tone_idx > 39) {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__
|
||||
": Unexpected CTCSS no (%04d)\n", tone_idx);
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
tone_idx -= (tone_idx == 1) ? 1 : 2; /* Correct for TH-7D anomaly */
|
||||
*tone = caps->ctcss_list[tone_idx];
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
#ifdef USE_TRN_FUNCS
|
||||
/*
|
||||
* th7d_set_trn
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
static int
|
||||
thd7_set_trn(RIG *rig, int trn)
|
||||
{
|
||||
unsigned char trnbuf[16], ackbuf[16];
|
||||
int retval, trn_len, ack_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
memset(ackbuf, 0, sizeof(ackbuf));
|
||||
|
||||
trn_len = sprintf(trnbuf, "AI %c" EOM,
|
||||
(trn == RIG_TRN_RIG) ? '1' : '0');
|
||||
|
||||
retval = kenwood_transaction (rig, trnbuf, trn_len, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (ackbuf[0] != 'A' || ackbuf[1] != 'I') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", ackbuf, ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* th7d_get_trn
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
static int
|
||||
thd7_get_trn(RIG *rig, int *trn)
|
||||
{
|
||||
unsigned char trnbuf[16];
|
||||
int retval, trn_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
memset(trnbuf, 0, sizeof(trnbuf));
|
||||
|
||||
retval = kenwood_transaction(rig, "AI" EOM, 3, trnbuf, &trn_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (trnbuf[0] == 'N' && trnbuf[1] == '\n') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": ack NG, len=%d\n", trn_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
if (trnbuf[0] != 'A' || trnbuf[1] != 'I') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", trnbuf, trn_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
*trn = (trnbuf[4] != '0') ? RIG_TRN_RIG : RIG_TRN_OFF;
|
||||
return RIG_OK;
|
||||
}
|
||||
#endif /* USE_TRN_FUNCS */
|
||||
|
||||
static const char *
|
||||
thd7_get_info(RIG *rig) /* I hope this is the correct function for this command. */
|
||||
{
|
||||
static unsigned char firmbuf[16];
|
||||
int retval, firm_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
|
||||
memset(firmbuf, 0, sizeof(firmbuf));
|
||||
retval = kenwood_transaction (rig, "ID" EOM, 3, firmbuf, &firm_len);
|
||||
if (retval != RIG_OK)
|
||||
return NULL;
|
||||
#if 1
|
||||
if (firm_len != 6) {
|
||||
rig_debug(RIG_DEBUG_ERR,__FUNCTION__": wrong answer len=%d\n",
|
||||
firm_len);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
if (firmbuf[0] != 'I' || firmbuf[1] != 'D') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", firmbuf, firm_len);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &firmbuf[2];
|
||||
}
|
||||
|
||||
/*
|
||||
* thd7_set_mem
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
static int
|
||||
thd7_set_mem(RIG *rig, vfo_t vfo, int ch)
|
||||
{
|
||||
unsigned char vsel, membuf[16], ackbuf[16];
|
||||
int retval, mem_len, ack_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
memset(ackbuf, 0, sizeof(ackbuf));
|
||||
|
||||
if (ch < 0 || ch > 200) {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": channel num out of range: %d\n", ch);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
switch (vfo) {
|
||||
case RIG_VFO_A: vsel = '0'; break;
|
||||
case RIG_VFO_B: vsel = '1'; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unsupported VFO %d\n", vfo);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
mem_len = sprintf(membuf, "MC %c,%i" EOM, vsel, ch);
|
||||
retval = kenwood_transaction(rig, membuf, mem_len, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (ackbuf[0] == 'N' && ackbuf[1] == '\n') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": negative acknowledgment\n");
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
if (ackbuf[0] != 'M' || ackbuf[1] != 'C') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", ackbuf, ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
thd7_get_mem(RIG *rig, vfo_t vfo, int *ch)
|
||||
{
|
||||
unsigned char *membuf, ackbuf[16];
|
||||
int retval, mem_len, ack_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
memset(ackbuf, 0, sizeof(ackbuf));
|
||||
|
||||
switch (vfo) {
|
||||
case RIG_VFO_A:
|
||||
membuf = "MC 0" EOM;
|
||||
break;
|
||||
case RIG_VFO_B:
|
||||
membuf = "MC 1" EOM;
|
||||
break;
|
||||
case RIG_VFO_CURR:
|
||||
membuf = "MC" EOM;
|
||||
break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unsupported VFO %d\n", vfo);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
mem_len = strlen(membuf);
|
||||
retval = kenwood_transaction(rig, membuf, mem_len, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
if (ackbuf[0] == 'N' && ackbuf[1] == '\n') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": negative acknowledgment\n");
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
if (ackbuf[0] != 'M' || ackbuf[1] != 'C') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", ackbuf, ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
*ch = atoi(&membuf[3]);
|
||||
#if 0
|
||||
if (*ch < 0 || *ch > 200) {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": channel num out of range: %d\n", ch);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
#endif
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* thd7_get_level
|
||||
* Assumes rig!=NULL
|
||||
*/
|
||||
static int
|
||||
thd7_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
||||
{
|
||||
unsigned char vsel, lvlbuf[16], ackbuf[16];
|
||||
int retval, lvl_len, ack_len = 0;
|
||||
|
||||
rig_debug(RIG_DEBUG_TRACE, __FUNCTION__": called\n");
|
||||
memset(ackbuf, 0, sizeof(ackbuf));
|
||||
|
||||
switch (vfo) {
|
||||
case RIG_VFO_A: vsel = '0'; break;
|
||||
case RIG_VFO_B: vsel = '1'; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unsupported VFO %d\n", vfo);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
|
||||
switch (level) {
|
||||
case RIG_LEVEL_STRENGTH:
|
||||
lvl_len = sprintf(lvlbuf, "SM %c" EOM, vsel);
|
||||
retval = kenwood_transaction(rig, lvlbuf, lvl_len, ackbuf, &ack_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
if (ackbuf[0] == 'N' && ackbuf[1] == '\n') {
|
||||
rig_debug(RIG_DEBUG_ERR,__FUNCTION__": negative acknowledgment\n");
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
if (ackbuf[0] != 'S' || ackbuf[1] != 'M') {
|
||||
rig_debug(RIG_DEBUG_ERR, __FUNCTION__": unexpected reply "
|
||||
"'%s', len=%d\n", ackbuf, ack_len);
|
||||
return -RIG_ERJCTED;
|
||||
}
|
||||
|
||||
val->i = atoi(&ackbuf[3]);
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_SQLSTAT:
|
||||
case RIG_LEVEL_PREAMP:
|
||||
case RIG_LEVEL_ATT:
|
||||
case RIG_LEVEL_AF:
|
||||
case RIG_LEVEL_RF:
|
||||
case RIG_LEVEL_SQL:
|
||||
case RIG_LEVEL_MICGAIN:
|
||||
case RIG_LEVEL_IF:
|
||||
case RIG_LEVEL_APF:
|
||||
case RIG_LEVEL_NR:
|
||||
case RIG_LEVEL_PBT_IN:
|
||||
case RIG_LEVEL_PBT_OUT:
|
||||
case RIG_LEVEL_CWPITCH:
|
||||
case RIG_LEVEL_KEYSPD:
|
||||
case RIG_LEVEL_NOTCHF:
|
||||
case RIG_LEVEL_COMP:
|
||||
case RIG_LEVEL_AGC:
|
||||
case RIG_LEVEL_BKINDL:
|
||||
case RIG_LEVEL_BALANCE:
|
||||
return -RIG_ENIMPL;
|
||||
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"Unsupported get_level %d", level);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/* end of file */
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hamlib Kenwood backend - TH-F7 description
|
||||
* Copyright (c) 2001 by Stephane Fillod
|
||||
* Copyright (c) 2001-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: thf7.c,v 1.3 2002-01-07 17:43:21 fgretief Exp $
|
||||
* $Id: thf7.c,v 1.4 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -24,15 +24,6 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h> /* Standard input/output definitions */
|
||||
#include <string.h> /* String function definitions */
|
||||
#include <unistd.h> /* UNIX standard function definitions */
|
||||
#include <fcntl.h> /* File control definitions */
|
||||
#include <errno.h> /* Error number definitions */
|
||||
#include <termios.h> /* POSIX terminal control definitions */
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include <hamlib/riglist.h>
|
||||
#include "kenwood.h"
|
||||
|
@ -53,7 +44,7 @@
|
|||
#define THF7_VFO (RIG_VFO_A|RIG_VFO_C)
|
||||
|
||||
const struct kenwood_priv_caps thf7_priv_caps = {
|
||||
cmdtrm: "\r", /* Command termination character */
|
||||
cmdtrm: EOM_TH, /* Command termination character */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -65,7 +56,7 @@ model_name:"TH-F7E",
|
|||
mfg_name: "Kenwood",
|
||||
version: "0.1",
|
||||
copyright: "LGPL",
|
||||
status: RIG_STATUS_NEW,
|
||||
status: RIG_STATUS_ALPHA,
|
||||
rig_type: RIG_TYPE_HANDHELD,
|
||||
ptt_type: RIG_PTT_RIG,
|
||||
dcd_type: RIG_DCD_RIG,
|
||||
|
@ -152,8 +143,15 @@ get_ctcss_tone: th_get_ctcss_tone,
|
|||
set_ptt: kenwood_set_ptt,
|
||||
get_dcd: kenwood_get_dcd,
|
||||
vfo_op: kenwood_vfo_op,
|
||||
set_mem: kenwood_set_mem,
|
||||
get_mem: kenwood_get_mem,
|
||||
set_mem: th_set_mem,
|
||||
get_mem: th_get_mem,
|
||||
set_trn: th_set_trn,
|
||||
get_trn: th_get_trn,
|
||||
|
||||
get_func: th_get_func,
|
||||
get_level: th_get_level,
|
||||
get_info: th_get_info,
|
||||
|
||||
decode_event: th_decode_event,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hamlib Kenwood backend - TS2000 description
|
||||
* Copyright (c) 2000,2001,2002 by Stephane Fillod
|
||||
* Copyright (c) 2000-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: ts2000.c,v 1.4 2002-02-19 08:30:49 pa4tu Exp $
|
||||
* $Id: ts2000.c,v 1.5 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -57,6 +57,10 @@ static const tone_t ts2000_dcs_list[] = {
|
|||
0,
|
||||
};
|
||||
|
||||
const struct kenwood_priv_caps ts2000_priv_caps = {
|
||||
cmdtrm: EOM_KEN,
|
||||
};
|
||||
|
||||
/*
|
||||
* ts2000 rig capabilities.
|
||||
*
|
||||
|
@ -205,7 +209,7 @@ filters: {
|
|||
{RIG_MODE_FM|RIG_MODE_AM, kHz(12)},
|
||||
RIG_FLT_END,
|
||||
},
|
||||
priv: NULL,
|
||||
priv: (void *)&ts2000_priv_caps,
|
||||
|
||||
set_freq: kenwood_set_freq,
|
||||
get_freq: kenwood_get_freq,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hamlib Kenwood backend - TS450S description
|
||||
* Copyright (c) 2000,2001,2002 by Stephane Fillod
|
||||
* Copyright (c) 2000-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: ts450s.c,v 1.3 2002-01-03 21:45:03 fillods Exp $
|
||||
* $Id: ts450s.c,v 1.4 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -38,6 +38,10 @@
|
|||
|
||||
#define TS450S_VFO (RIG_VFO_A|RIG_VFO_B)
|
||||
|
||||
static const struct kenwood_priv_caps ts450_priv_caps = {
|
||||
cmdtrm: EOM_KEN,
|
||||
};
|
||||
|
||||
/*
|
||||
* ts450s rig capabilities.
|
||||
* Notice that some rigs share the same functions.
|
||||
|
@ -142,7 +146,7 @@ filters: {
|
|||
{RIG_MODE_FM, kHz(14)},
|
||||
RIG_FLT_END,
|
||||
},
|
||||
priv: NULL,
|
||||
priv: (void *)&ts450_priv_caps,
|
||||
|
||||
set_freq: kenwood_set_freq,
|
||||
get_freq: kenwood_get_freq,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Hamlib Kenwood backend - TS50 description
|
||||
* Copyright (c) 2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: ts50s.c,v 1.2 2002-02-19 08:34:56 pa4tu Exp $
|
||||
* $Id: ts50s.c,v 1.3 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -42,6 +42,10 @@
|
|||
#define TS50_VFO (RIG_VFO_A|RIG_VFO_B)
|
||||
#define TS50_VFO_OP (RIG_OP_UP|RIG_OP_DOWN)
|
||||
|
||||
static const struct kenwood_priv_caps ts50_priv_caps = {
|
||||
cmdtrm: EOM_KEN,
|
||||
};
|
||||
|
||||
/*
|
||||
* ts50 rig capabilities.
|
||||
*
|
||||
|
@ -169,7 +173,7 @@ filters: {
|
|||
{RIG_MODE_FM, kHz(12)},
|
||||
RIG_FLT_END,
|
||||
},
|
||||
priv: NULL,
|
||||
priv: (void *)&ts50_priv_caps,
|
||||
|
||||
set_freq: kenwood_set_freq,
|
||||
get_freq: kenwood_get_freq,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Hamlib Kenwood backend - TS570 description
|
||||
* Copyright (c) 2001,2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: ts570.c,v 1.6 2002-02-19 08:32:05 pa4tu Exp $
|
||||
* $Id: ts570.c,v 1.7 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -41,6 +41,10 @@
|
|||
#define TS570_VFO (RIG_VFO_A|RIG_VFO_B)
|
||||
#define TS570_VFO_OP (RIG_OP_UP|RIG_OP_DOWN)
|
||||
|
||||
static const struct kenwood_priv_caps ts570_priv_caps = {
|
||||
cmdtrm: EOM_KEN,
|
||||
};
|
||||
|
||||
/*
|
||||
* ts570 rig capabilities.
|
||||
* Notice that some rigs share the same functions.
|
||||
|
@ -177,7 +181,7 @@ filters: {
|
|||
{RIG_MODE_FM, kHz(14)},
|
||||
RIG_FLT_END,
|
||||
},
|
||||
priv: NULL,
|
||||
priv: (void *)&ts570_priv_caps,
|
||||
|
||||
set_freq: kenwood_set_freq,
|
||||
get_freq: kenwood_get_freq,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hamlib Kenwood backend - TS-790 description
|
||||
* Copyright (c) 2000,2001,2002 by Stephane Fillod
|
||||
* Copyright (c) 2000-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: ts790.c,v 1.2 2002-02-19 08:33:08 pa4tu Exp $
|
||||
* $Id: ts790.c,v 1.3 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -41,6 +41,10 @@
|
|||
|
||||
#define TS790_VFO_OP (RIG_OP_UP|RIG_OP_DOWN)
|
||||
|
||||
static const struct kenwood_priv_caps ts790_priv_caps = {
|
||||
cmdtrm: EOM_KEN,
|
||||
};
|
||||
|
||||
/*
|
||||
* ts790 rig capabilities.
|
||||
*
|
||||
|
@ -157,7 +161,7 @@ filters: {
|
|||
{RIG_MODE_FM, kHz(12)},
|
||||
RIG_FLT_END,
|
||||
},
|
||||
priv: NULL,
|
||||
priv: (void *)&ts790_priv_caps,
|
||||
|
||||
set_freq: kenwood_set_freq,
|
||||
get_freq: kenwood_get_freq,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Hamlib Kenwood backend - TS850 description
|
||||
* Copyright (c) 2000-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: ts850.c,v 1.1 2002-03-05 20:23:34 fillods Exp $
|
||||
* $Id: ts850.c,v 1.2 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -38,6 +38,10 @@
|
|||
|
||||
#define TS850_VFO (RIG_VFO_A|RIG_VFO_B)
|
||||
|
||||
static const struct kenwood_priv_caps ts850_priv_caps = {
|
||||
cmdtrm: EOM_KEN,
|
||||
};
|
||||
|
||||
/*
|
||||
* ts850 rig capabilities.
|
||||
* Notice that some rigs share the same functions.
|
||||
|
@ -167,7 +171,7 @@ filters: {
|
|||
{RIG_MODE_FM, kHz(12)},
|
||||
RIG_FLT_END,
|
||||
},
|
||||
priv: NULL,
|
||||
priv: (void *)&ts850_priv_caps,
|
||||
|
||||
set_freq: kenwood_set_freq,
|
||||
get_freq: kenwood_get_freq,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Hamlib Kenwood backend - TS870S description
|
||||
* Copyright (c) 2000,2001,2002 by Stephane Fillod
|
||||
* Copyright (c) 2000-2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: ts870s.c,v 1.21 2002-02-18 18:27:03 pa4tu Exp $
|
||||
* $Id: ts870s.c,v 1.22 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -38,6 +38,10 @@
|
|||
|
||||
#define TS870S_VFO (RIG_VFO_A|RIG_VFO_B)
|
||||
|
||||
static const struct kenwood_priv_caps ts870s_priv_caps = {
|
||||
cmdtrm: EOM_KEN,
|
||||
};
|
||||
|
||||
/*
|
||||
* ts870s rig capabilities.
|
||||
* Notice that some rigs share the same functions.
|
||||
|
@ -170,7 +174,7 @@ filters: {
|
|||
{RIG_MODE_FM, kHz(14)},
|
||||
RIG_FLT_END,
|
||||
},
|
||||
priv: NULL,
|
||||
priv: (void *)&ts870s_priv_caps,
|
||||
|
||||
set_freq: kenwood_set_freq,
|
||||
get_freq: kenwood_get_freq,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Hamlib Kenwood backend - TS950 description
|
||||
* Copyright (c) 2002 by Stephane Fillod
|
||||
*
|
||||
* $Id: ts950.c,v 1.2 2002-02-19 08:34:01 pa4tu Exp $
|
||||
* $Id: ts950.c,v 1.3 2002-03-13 23:42:43 fillods 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
|
||||
|
@ -38,6 +38,10 @@
|
|||
|
||||
#define TS950_VFO (RIG_VFO_A|RIG_VFO_B)
|
||||
|
||||
const struct kenwood_priv_caps ts950_priv_caps = {
|
||||
cmdtrm: EOM_KEN,
|
||||
};
|
||||
|
||||
/*
|
||||
* ts950sdx rig capabilities.
|
||||
*
|
||||
|
@ -142,7 +146,7 @@ filters: {
|
|||
{RIG_MODE_FM, kHz(14)},
|
||||
RIG_FLT_END,
|
||||
},
|
||||
priv: NULL,
|
||||
priv: (void *)&ts950_priv_caps,
|
||||
|
||||
set_freq: kenwood_set_freq,
|
||||
get_freq: kenwood_get_freq,
|
||||
|
|
Ładowanie…
Reference in New Issue