thg71,tmv7,ts450s,ts690: verify rig id at rig_open

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2613 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.9
Alessandro Zummo, IZ1PRB 2009-02-03 22:42:44 +00:00
rodzic 80d96e2bbb
commit b8da433c98
6 zmienionych plików z 113 dodań i 56 usunięć

Wyświetl plik

@ -3,7 +3,7 @@
* Copyright (c) 2000-2009 by Stephane Fillod
* Copyright (C) 2009 Alessandro Zummo <a.zummo@towertech.it>
*
* $Id: kenwood.c,v 1.106 2009-02-03 22:33:00 azummo Exp $
* $Id: kenwood.c,v 1.107 2009-02-03 22:42:44 azummo 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
@ -78,15 +78,31 @@ static const struct kenwood_id kenwood_id_list[] = {
{ RIG_MODEL_NONE, UNKNOWN_ID }, /* end marker */
};
/* XXX numeric ids have been tested only with the TS-450 */
static const struct kenwood_id_string kenwood_id_string_list[] = {
{ RIG_MODEL_THD7A, "TH-D7" },
{ RIG_MODEL_THD7AG, "TH-D7G" },
{ RIG_MODEL_TMD700, "TM-D700" },
{ RIG_MODEL_TMV7, "TM-V7" },
{ RIG_MODEL_THF6A, "TH-F6" },
{ RIG_MODEL_THF7E, "TH-F7" },
{ RIG_MODEL_THG71, "TH-G71" },
{ RIG_MODEL_NONE, NULL }, /* end marker */
{ RIG_MODEL_TS940, "001" },
{ RIG_MODEL_TS811, "002" },
{ RIG_MODEL_TS711, "003" },
{ RIG_MODEL_TS440, "004" },
{ RIG_MODEL_R5000, "005" },
{ RIG_MODEL_TS790, "007" },
{ RIG_MODEL_TS950SDX, "008" }, /* reported as RIG_MODEL_TS950SD originally */
{ RIG_MODEL_TS850, "009" },
{ RIG_MODEL_TS450S, "010" },
{ RIG_MODEL_TS690S, "011" },
{ RIG_MODEL_TS870S, "015" },
{ RIG_MODEL_TS570D, "017" }, /* Elecraft K2 also returns 17 */
{ RIG_MODEL_TS570S, "018" },
{ RIG_MODEL_TS2000, "019" },
{ RIG_MODEL_TS480, "020" },
{ RIG_MODEL_THD7A, "TH-D7" },
{ RIG_MODEL_THD7AG, "TH-D7G" },
{ RIG_MODEL_TMD700, "TM-D700" },
{ RIG_MODEL_TMV7, "TM-V7" },
{ RIG_MODEL_THF6A, "TH-F6" },
{ RIG_MODEL_THF7E, "TH-F7" },
{ RIG_MODEL_THG71, "TH-G71" },
{ RIG_MODEL_NONE, NULL }, /* end marker */
};
rmode_t kenwood_mode_table[KENWOOD_MODE_TABLE_MAX] = {
@ -296,7 +312,7 @@ int kenwood_init(RIG *rig)
struct kenwood_priv_data *priv;
struct kenwood_priv_caps *caps = kenwood_caps(rig);
rig_debug(RIG_DEBUG_ERR, "%s\n", __func__);
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
priv = malloc(sizeof(struct kenwood_priv_data));
if (priv == NULL)
@ -330,6 +346,67 @@ int kenwood_cleanup(RIG *rig)
return RIG_OK;
}
int kenwood_open(RIG *rig)
{
int err, i;
char *idptr;
char id[KENWOOD_MAX_BUF_LEN];
rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__);
/* get id in buffer, will be null terminated */
err = kenwood_get_id(rig, id);
if (err != RIG_OK) {
rig_debug(RIG_DEBUG_ERR, "%s: cannot get identification\n",
__func__);
return err;
}
/* id is something like 'IDXXX' or 'ID XXX' */
if (strlen(id) < 5) {
rig_debug(RIG_DEBUG_ERR, "%s: unknown id type (%s)\n", id);
return -RIG_EPROTO;
}
/* check for a white space and skip it */
idptr = &id[2];
if (*idptr == ' ')
idptr++;
/* compare id string */
for (i = 0; kenwood_id_string_list[i].model != RIG_MODEL_NONE; i++) {
if (strcmp(kenwood_id_string_list[i].id, idptr) != 0)
continue;
/* found matching id, verify driver */
rig_debug(RIG_DEBUG_TRACE, "%s: found match %s\n",
__func__, kenwood_id_string_list[i].id);
if (kenwood_id_string_list[i].model == rig->caps->rig_model)
return RIG_OK;
/* driver mismatch */
rig_debug(RIG_DEBUG_ERR,
"%s: wrong driver selected (%d instead of %d)\n",
__func__, rig->caps->rig_model,
kenwood_id_string_list[i].model);
return -RIG_EINVAL;
}
rig_debug(RIG_DEBUG_ERR, "%s: your rig (%s) is unknown\n",
__func__, id);
return -RIG_EPROTO;
}
/* caller must give a buffer of KENWOOD_MAX_BUF_LEN size */
int kenwood_get_id(RIG *rig, char *buf)
{
size_t size = KENWOOD_MAX_BUF_LEN;
return kenwood_transaction(rig, "ID", 2, buf, &size);
}
static int kenwood_get_if(RIG *rig)
{
struct kenwood_priv_data *priv = rig->state.priv;
@ -338,7 +415,7 @@ static int kenwood_get_if(RIG *rig)
cmdbuf[2] = caps->cmdtrm;
return kenwood_safe_transaction (rig, cmdbuf, priv->info,
KENWOOD_MAX_IF_LEN, caps->if_len);
KENWOOD_MAX_BUF_LEN, caps->if_len);
}
/*
@ -1608,12 +1685,12 @@ int kenwood_get_channel(RIG *rig, channel_t *chan)
/* XXX filter cannot be read there. strange. maybe another command? */
if (buf[19] == '0' || buf[19] == ' ')
chan->ctcss_tone = 0;
else {
buf[22]='\0';
chan->ctcss_tone = 0;
else {
buf[22]='\0';
if (rig->caps->ctcss_list)
chan->ctcss_tone = rig->caps->ctcss_list[atoi(&buf[20])];
}
chan->ctcss_tone = rig->caps->ctcss_list[atoi(&buf[20])];
}
/* memory lockout */
if (buf[18] == '1')

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - main header
* Copyright (c) 2000-2009 by Stephane Fillod
*
* $Id: kenwood.h,v 1.48 2009-02-02 07:30:35 azummo Exp $
* $Id: kenwood.h,v 1.49 2009-02-03 22:42:44 azummo 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
@ -28,8 +28,8 @@
#define EOM_KEN ';'
#define EOM_TH '\r'
#define KENWOOD_MODE_TABLE_MAX 10
#define KENWOOD_MAX_IF_LEN 50
#define KENWOOD_MODE_TABLE_MAX 10
#define KENWOOD_MAX_BUF_LEN 50 /* max answer len, arbitrary */
/*
* modes in use by the "MD" command
@ -51,7 +51,7 @@ struct kenwood_priv_caps {
};
struct kenwood_priv_data {
char info[KENWOOD_MAX_IF_LEN];
char info[KENWOOD_MAX_BUF_LEN];
};
#define kenwood_caps(rig) ((struct kenwood_priv_caps *)(rig)->caps->priv)
@ -71,6 +71,7 @@ char rmode2kenwood(rmode_t mode, const rmode_t mode_table[]);
int kenwood_init(RIG *rig);
int kenwood_cleanup(RIG *rig);
int kenwood_open(RIG *rig);
int kenwood_set_vfo(RIG *rig, vfo_t vfo);
int kenwood_get_vfo_if(RIG *rig, vfo_t *vfo);
@ -110,6 +111,7 @@ int kenwood_get_mem_if(RIG *rig, vfo_t vfo, int *ch);
int kenwood_get_channel(RIG *rig, channel_t *chan);
int kenwood_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch);
const char * kenwood_get_info(RIG *rig);
int kenwood_get_id(RIG *rig, char *buf);
int kenwood_set_trn(RIG *rig, int trn);
int kenwood_get_trn(RIG *rig, int *trn);

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TH-G71 description
* Copyright (c) 2003-2008 by Stephane Fillod
*
* $Id: thg71.c,v 1.23 2009-01-28 23:30:53 azummo Exp $
* $Id: thg71.c,v 1.24 2009-02-03 22:42:44 azummo 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
@ -418,15 +418,10 @@ int thg71_open(RIG *rig)
size_t ack_len=ACKBUF_LEN;
const freq_range_t frend=RIG_FRNG_END;
/* just to be sure it's a THG-71 */
retval = kenwood_transaction(rig, "ID"EOM, 3, ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
if (ack_len<9 || strncmp(ackbuf,"ID TH-G71",9)) {
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __FUNCTION__, ackbuf);
return -RIG_ERJCTED;
}
/* this will check the model id */
retval = kenwood_open(rig);
if (retval != RIG_OK)
return retval;
/* fill state.rx/tx range_list */
ack_len=ACKBUF_LEN;

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TM-V7 description
* Copyright (c) 2004-2008 by Stephane Fillod
*
* $Id: tmv7.c,v 1.18 2009-01-28 23:30:54 azummo Exp $
* $Id: tmv7.c,v 1.19 2009-02-03 22:42:44 azummo 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
@ -76,7 +76,6 @@ static struct kenwood_priv_caps tmv7_priv_caps = {
/* tmv7 procs */
static int tmv7_open(RIG *rig);
static int tmv7_decode_event (RIG *rig);
static int tmv7_set_vfo (RIG *rig, vfo_t vfo);
static int tmv7_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
@ -186,7 +185,7 @@ const struct rig_caps tmv7_caps = {
.priv = (void *)&tmv7_priv_caps,
.rig_init = kenwood_init,
.rig_cleanup = kenwood_cleanup,
.rig_open = tmv7_open,
.rig_open = kenwood_open,
.rig_close = NULL,
.set_freq = th_set_freq,
@ -658,24 +657,3 @@ int tmv7_set_channel(RIG *rig, const channel_t *chan)
return RIG_OK;
}
/*-------------------------------------------------------------------- */
int tmv7_open(RIG *rig)
{
char ackbuf[ACKBUF_LEN];
int retval;
size_t ack_len=ACKBUF_LEN;
/* just to be sure it's a TM-V7 */
retval = kenwood_transaction(rig, "ID"EOM, 3, ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
if (ack_len<9 || strncmp(ackbuf,"ID TM-V7",8)) {
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected reply '%s'\n", __FUNCTION__, ackbuf);
return -RIG_ERJCTED;
}
return RIG_OK;
}

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TS450S description
* Copyright (c) 2000-2004 by Stephane Fillod
*
* $Id: ts450s.c,v 1.27 2009-02-02 20:33:05 azummo Exp $
* $Id: ts450s.c,v 1.28 2009-02-03 22:42:44 azummo 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
@ -63,6 +63,10 @@ static int ts450_open(RIG *rig)
{
int err;
err = kenwood_open(rig);
if (err != RIG_OK)
return err;
err = kenwood_simple_transaction(rig, "TO", 3);
if (err != RIG_OK) {
rig_debug(RIG_DEBUG_TRACE, "%s: tone unit not detected\n", __func__);

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TS690 description
* Copyright (c) 2000-2004 by Stephane Fillod
*
* $Id: ts690.c,v 1.6 2009-01-28 23:31:42 azummo Exp $
* $Id: ts690.c,v 1.7 2009-02-03 22:42:44 azummo 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
@ -166,6 +166,7 @@ const struct rig_caps ts690s_caps = {
.rig_init = kenwood_init,
.rig_cleanup = kenwood_cleanup,
.rig_open = kenwood_open,
.set_freq = kenwood_set_freq,
.get_freq = kenwood_get_freq,
.set_rit = kenwood_set_rit,