kopia lustrzana https://github.com/Hamlib/Hamlib
generalize th_set_channel and th_get_channel to all th tm rigs
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1707 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.1
rodzic
7260fba70d
commit
f0c75ca8fb
222
kenwood/th.c
222
kenwood/th.c
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Kenwood backend - TH handheld primitives
|
* Hamlib Kenwood backend - TH handheld primitives
|
||||||
* Copyright (c) 2001-2003 by Stephane Fillod
|
* Copyright (c) 2001-2003 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: th.c,v 1.17 2004-01-15 22:03:18 fillods Exp $
|
* $Id: th.c,v 1.18 2004-03-20 16:48:34 f4dwv Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -944,3 +944,223 @@ int th_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
||||||
return retval;
|
return retval;
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* get and set channel tested on thg71 and tmv7 */
|
||||||
|
/* must work on other th and tm kenwood rigs */
|
||||||
|
/* Beware : special numbering scheme : */
|
||||||
|
/* 0-199 : normal memories */
|
||||||
|
/* 200-209 : scan lower limit memories L */
|
||||||
|
/* 210-219 : scan upper limit memories U */
|
||||||
|
/* 220 : Priority channel */
|
||||||
|
/* 221-222 : Call channel */
|
||||||
|
/* 223-231 : Band vfo mem */
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int th_get_channel(RIG *rig, channel_t *chan)
|
||||||
|
{
|
||||||
|
char membuf[64],ackbuf[ACKBUF_LEN];
|
||||||
|
int retval,ack_len;
|
||||||
|
long long freq,offset;
|
||||||
|
char req[16],scf[128];
|
||||||
|
int step, shift, rev, tone, ctcss, tonefq, ctcssfq;
|
||||||
|
|
||||||
|
if(chan->channel_num<200)
|
||||||
|
sprintf(req,"MR 0,0,%03d",chan->channel_num);
|
||||||
|
else
|
||||||
|
if(chan->channel_num<210) {
|
||||||
|
sprintf(req,"MR 0,0,L%01d",chan->channel_num-200);
|
||||||
|
sprintf(chan->channel_desc,"L%01d",chan->channel_num-200);
|
||||||
|
} else
|
||||||
|
if(chan->channel_num<220) {
|
||||||
|
sprintf(req,"MR 0,0,U%01d",chan->channel_num-210);
|
||||||
|
sprintf(chan->channel_desc,"U%01d",chan->channel_num-210);
|
||||||
|
} else
|
||||||
|
if(chan->channel_num==220) {
|
||||||
|
sprintf(req,"MR 0,0,PR");
|
||||||
|
sprintf(chan->channel_desc,"Pr");
|
||||||
|
} else
|
||||||
|
if(chan->channel_num<223) {
|
||||||
|
sprintf(req,"CR 0,%01d",chan->channel_num-221);
|
||||||
|
if(chan->channel_num==221) sprintf(chan->channel_desc,"Call V");
|
||||||
|
if(chan->channel_num==222) sprintf(chan->channel_desc,"Call U");
|
||||||
|
} else
|
||||||
|
if(chan->channel_num<232) {
|
||||||
|
sprintf(req,"VR %01d",chan->channel_num-222);
|
||||||
|
sprintf(chan->channel_desc,"BAND %01d",chan->channel_num-222);
|
||||||
|
} else
|
||||||
|
return -RIG_EINVAL;
|
||||||
|
|
||||||
|
sprintf(membuf,"%s"EOM,req);
|
||||||
|
ack_len=ACKBUF_LEN;
|
||||||
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
strcpy(scf,req);
|
||||||
|
strcat(scf,",%"FREQFMT",%d,%d,%d,%d,%d,,%d,,%d,%"FREQFMT);
|
||||||
|
retval = sscanf(ackbuf, scf,
|
||||||
|
&freq, &step, &shift, &rev, &tone,
|
||||||
|
&ctcss, &tonefq, &ctcssfq, &offset);
|
||||||
|
|
||||||
|
chan->freq=(freq_t)freq;
|
||||||
|
chan->vfo=RIG_VFO_MEM;
|
||||||
|
chan->tuning_step=rig->state.tuning_steps[step].ts;
|
||||||
|
if(freq <MHz(136) ) {
|
||||||
|
chan->mode=RIG_MODE_AM;
|
||||||
|
chan->width=kHz(9);
|
||||||
|
} else {
|
||||||
|
chan->mode=RIG_MODE_FM;
|
||||||
|
chan->width=kHz(12);
|
||||||
|
}
|
||||||
|
switch(shift) {
|
||||||
|
case 0 :
|
||||||
|
chan->rptr_shift=RIG_RPT_SHIFT_NONE;
|
||||||
|
break;
|
||||||
|
case 1 :
|
||||||
|
chan->rptr_shift=RIG_RPT_SHIFT_PLUS;
|
||||||
|
break;
|
||||||
|
case 2 :
|
||||||
|
chan->rptr_shift=RIG_RPT_SHIFT_MINUS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
chan->rptr_offs=offset;
|
||||||
|
|
||||||
|
if(tone)
|
||||||
|
chan->ctcss_tone=rig->caps->ctcss_list[tonefq==1?0:tonefq-2];
|
||||||
|
else
|
||||||
|
chan->ctcss_tone=0;
|
||||||
|
if(ctcss)
|
||||||
|
chan->ctcss_sql=rig->caps->ctcss_list[ctcssfq==1?0:ctcssfq-2];
|
||||||
|
else
|
||||||
|
chan->ctcss_sql=0;
|
||||||
|
|
||||||
|
chan->tx_freq=RIG_FREQ_NONE;
|
||||||
|
if(chan->channel_num<223 && offset==0) {
|
||||||
|
req[5]='1';
|
||||||
|
sprintf(membuf,"%s"EOM,req);
|
||||||
|
ack_len=ACKBUF_LEN;
|
||||||
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
||||||
|
if (retval == RIG_OK) {
|
||||||
|
strcat(req,",%"FREQFMT",%d");
|
||||||
|
retval = sscanf(ackbuf, req, &freq, &step);
|
||||||
|
chan->tx_freq=freq;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(chan->channel_num<200) {
|
||||||
|
sprintf(membuf,"MNA 0,%03d"EOM,chan->channel_num);
|
||||||
|
ack_len=ACKBUF_LEN;
|
||||||
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
return retval;
|
||||||
|
memcpy(chan->channel_desc,&ackbuf[10],7);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------- */
|
||||||
|
int th_set_channel(RIG *rig, const channel_t *chan)
|
||||||
|
{
|
||||||
|
char membuf[ACKBUF_LEN],ackbuf[ACKBUF_LEN];
|
||||||
|
int retval,ack_len;
|
||||||
|
char req[64];
|
||||||
|
long long freq,offset;
|
||||||
|
int chn, step, shift, tone, ctcss, tonefq, ctcssfq;
|
||||||
|
|
||||||
|
chn=chan->channel_num;
|
||||||
|
freq=(long long)chan->freq;
|
||||||
|
|
||||||
|
for(step=0; rig->state.tuning_steps[step].ts!=0;step++)
|
||||||
|
if(chan->tuning_step==rig->state.tuning_steps[step].ts) break;
|
||||||
|
|
||||||
|
switch(chan->rptr_shift) {
|
||||||
|
case RIG_RPT_SHIFT_NONE :
|
||||||
|
shift=0;
|
||||||
|
break;
|
||||||
|
case RIG_RPT_SHIFT_PLUS:
|
||||||
|
shift=1;
|
||||||
|
break;
|
||||||
|
case RIG_RPT_SHIFT_MINUS:
|
||||||
|
shift=2;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: not supported shift\n", __FUNCTION__);
|
||||||
|
return -RIG_EINVAL;
|
||||||
|
}
|
||||||
|
offset=chan->rptr_offs;
|
||||||
|
|
||||||
|
if(chan->ctcss_tone==0) {
|
||||||
|
tone=0;tonefq=9;
|
||||||
|
} else {
|
||||||
|
tone=1;
|
||||||
|
for (tonefq = 0; rig->caps->ctcss_list[tonefq] != 0 && tonefq < RIG_TONEMAX; tonefq++) {
|
||||||
|
if (rig->caps->ctcss_list[tonefq] == chan->ctcss_tone)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tonefq=tonefq==0?1:tonefq+2;
|
||||||
|
}
|
||||||
|
if(chan->ctcss_sql==0) {
|
||||||
|
ctcss=0;ctcssfq=9;
|
||||||
|
} else {
|
||||||
|
ctcss=1;
|
||||||
|
for (ctcssfq = 0; rig->caps->ctcss_list[ctcssfq] != 0 && ctcssfq < RIG_TONEMAX; ctcssfq++) {
|
||||||
|
if (rig->caps->ctcss_list[ctcssfq] == chan->ctcss_sql)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ctcssfq=ctcssfq==0?1:ctcssfq+2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(chan->channel_num<200)
|
||||||
|
sprintf(req,"MW 0,0,%03d",chan->channel_num);
|
||||||
|
else
|
||||||
|
if(chan->channel_num<210) {
|
||||||
|
sprintf(req,"MW 0,0,L%01d",chan->channel_num-200);
|
||||||
|
} else
|
||||||
|
if(chan->channel_num<220) {
|
||||||
|
sprintf(req,"MW 0,0,U%01d",chan->channel_num-210);
|
||||||
|
} else
|
||||||
|
if(chan->channel_num==220) {
|
||||||
|
sprintf(req,"MW 0,0,PR");
|
||||||
|
} else
|
||||||
|
if(chan->channel_num<223) {
|
||||||
|
sprintf(req,"CW 0,%01d",chan->channel_num-221);
|
||||||
|
} else
|
||||||
|
if(chan->channel_num<232) {
|
||||||
|
sprintf(req,"VW %01d",chan->channel_num-222);
|
||||||
|
} else
|
||||||
|
return -RIG_EINVAL;
|
||||||
|
|
||||||
|
if(chan->channel_num<=220)
|
||||||
|
sprintf(membuf, "%s,%011lld,%01d,%01d,0,%01d,%01d,,%02d,,%02d,%09lld,0"EOM,
|
||||||
|
req,(long long)freq, step, shift, tone,
|
||||||
|
ctcss, tonefq, ctcssfq, (long long)offset);
|
||||||
|
else
|
||||||
|
sprintf(membuf, "%s,%011lld,%01d,%01d,0,%01d,%01d,,%02d,,%02d,%09lld"EOM,
|
||||||
|
req, (long long)freq, step, shift, tone,
|
||||||
|
ctcss, tonefq, ctcssfq, (long long)offset);
|
||||||
|
|
||||||
|
ack_len=ACKBUF_LEN;
|
||||||
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
if(chan->channel_num<223 && chan->tx_freq!=RIG_FREQ_NONE) {
|
||||||
|
req[5]='1';
|
||||||
|
sprintf(membuf, "%s,%011lld,%01d"EOM, req,(long long)chan->tx_freq, step);
|
||||||
|
ack_len=ACKBUF_LEN;
|
||||||
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(chan->channel_num<200) {
|
||||||
|
ack_len=ACKBUF_LEN;
|
||||||
|
sprintf(membuf,"MNA 0,%03d,%s"EOM,chan->channel_num,chan->channel_desc);
|
||||||
|
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
||||||
|
if (retval != RIG_OK)
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RIG_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
16
kenwood/th.h
16
kenwood/th.h
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Kenwood backend - TH handheld header
|
* Hamlib Kenwood backend - TH handheld header
|
||||||
* Copyright (c) 2001-2003 by Stephane Fillod
|
* Copyright (c) 2001-2003 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: th.h,v 1.5 2003-11-30 20:43:32 f4dwv Exp $
|
* $Id: th.h,v 1.6 2004-03-20 16:48:34 f4dwv Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -44,6 +44,20 @@ extern int th_get_mem(RIG *rig, vfo_t vfo, int *ch);
|
||||||
extern int th_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
|
extern int th_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
|
||||||
extern int th_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
|
extern int th_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op);
|
||||||
extern int th_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd);
|
extern int th_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd);
|
||||||
|
extern int th_get_channel(RIG *rig, channel_t *chan);
|
||||||
|
extern int th_set_channel(RIG *rig, const channel_t *chan);
|
||||||
|
|
||||||
|
#define TH_CHANNEL_CAPS \
|
||||||
|
.freq=1,\
|
||||||
|
.tx_freq=1,\
|
||||||
|
.mode=1,\
|
||||||
|
.width=1,\
|
||||||
|
.tuning_step=1,\
|
||||||
|
.rptr_shift=1,\
|
||||||
|
.rptr_offs=1,\
|
||||||
|
.ctcss_tone=1,\
|
||||||
|
.ctcss_sql=1,\
|
||||||
|
.channel_desc=1
|
||||||
|
|
||||||
|
|
||||||
#endif /* __TH_H__ */
|
#endif /* __TH_H__ */
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Kenwood backend - TH-D7 description
|
* Hamlib Kenwood backend - TH-D7 description
|
||||||
* Copyright (c) 2000-2003 by Stephane Fillod
|
* Copyright (c) 2000-2003 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: thd7.c,v 1.10 2003-10-01 19:31:58 fillods Exp $
|
* $Id: thd7.c,v 1.11 2004-03-20 16:48:34 f4dwv Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -116,10 +116,12 @@ const struct rig_caps thd7a_caps = {
|
||||||
.bank_qty = 0,
|
.bank_qty = 0,
|
||||||
.chan_desc_sz = 0,
|
.chan_desc_sz = 0,
|
||||||
|
|
||||||
|
.chan_list = {
|
||||||
.chan_list = { { 1, 200, RIG_MTYPE_MEM },
|
{ 1, 199, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* normal MEM */
|
||||||
RIG_CHAN_END,
|
{ 200,219, RIG_MTYPE_EDGE , {TH_CHANNEL_CAPS}}, /* U/L MEM */
|
||||||
}, /* FIXME: memory channel list: 200 memories */
|
{ 221,222, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* Call 0/1 */
|
||||||
|
RIG_CHAN_END,
|
||||||
|
},
|
||||||
|
|
||||||
.rx_range_list1 = { RIG_FRNG_END, }, /* FIXME: enter region 1 setting */
|
.rx_range_list1 = { RIG_FRNG_END, }, /* FIXME: enter region 1 setting */
|
||||||
.tx_range_list1 = { RIG_FRNG_END, },
|
.tx_range_list1 = { RIG_FRNG_END, },
|
||||||
|
@ -168,6 +170,8 @@ const struct rig_caps thd7a_caps = {
|
||||||
.get_ctcss_tone = th_get_ctcss_tone,
|
.get_ctcss_tone = th_get_ctcss_tone,
|
||||||
.set_mem = th_set_mem,
|
.set_mem = th_set_mem,
|
||||||
.get_mem = th_get_mem,
|
.get_mem = th_get_mem,
|
||||||
|
.set_channel = th_set_channel,
|
||||||
|
.get_channel = th_get_channel,
|
||||||
.set_trn = th_set_trn,
|
.set_trn = th_set_trn,
|
||||||
.get_trn = th_get_trn,
|
.get_trn = th_get_trn,
|
||||||
|
|
||||||
|
|
241
kenwood/thg71.c
241
kenwood/thg71.c
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Kenwood backend - TH-G71 description
|
* Hamlib Kenwood backend - TH-G71 description
|
||||||
* Copyright (c) 2003 by Stephane Fillod
|
* Copyright (c) 2003 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: thg71.c,v 1.10 2004-01-15 22:43:59 fillods Exp $
|
* $Id: thg71.c,v 1.11 2004-03-20 16:48:34 f4dwv Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -54,19 +54,6 @@
|
||||||
#define RIG_TONEMAX 38
|
#define RIG_TONEMAX 38
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define THG71_CHANNEL_CAPS \
|
|
||||||
.freq=1,\
|
|
||||||
.tx_freq=1,\
|
|
||||||
.mode=1,\
|
|
||||||
.width=1,\
|
|
||||||
.tuning_step=1,\
|
|
||||||
.rptr_shift=1,\
|
|
||||||
.rptr_offs=1,\
|
|
||||||
.ctcss_tone=1,\
|
|
||||||
.ctcss_sql=1,\
|
|
||||||
.channel_desc=1
|
|
||||||
|
|
||||||
|
|
||||||
#define RIG_VFO_A_OP (RIG_OP_UP|RIG_OP_DOWN)
|
#define RIG_VFO_A_OP (RIG_OP_UP|RIG_OP_DOWN)
|
||||||
|
|
||||||
#define ACKBUF_LEN 128
|
#define ACKBUF_LEN 128
|
||||||
|
@ -85,8 +72,6 @@ int thg71_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
|
||||||
int thg71_set_vfo (RIG *rig, vfo_t vfo);
|
int thg71_set_vfo (RIG *rig, vfo_t vfo);
|
||||||
int thg71_get_vfo (RIG *rig, vfo_t *vfo);
|
int thg71_get_vfo (RIG *rig, vfo_t *vfo);
|
||||||
int thg71_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
|
int thg71_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
|
||||||
int thg71_get_channel(RIG *rig, channel_t *chan);
|
|
||||||
int thg71_set_channel(RIG *rig, const channel_t *chan);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* th-g71 rig capabilities.
|
* th-g71 rig capabilities.
|
||||||
|
@ -136,11 +121,11 @@ const struct rig_caps thg71_caps = {
|
||||||
|
|
||||||
|
|
||||||
.chan_list = {
|
.chan_list = {
|
||||||
{ 1, 199, RIG_MTYPE_MEM , {THG71_CHANNEL_CAPS}}, /* normal MEM */
|
{ 1, 199, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* normal MEM */
|
||||||
{ 200,219, RIG_MTYPE_EDGE , {THG71_CHANNEL_CAPS}}, /* U/L MEM */
|
{ 200,219, RIG_MTYPE_EDGE , {TH_CHANNEL_CAPS}}, /* U/L MEM */
|
||||||
{ 220,220, RIG_MTYPE_MEM , {THG71_CHANNEL_CAPS}}, /* Priority */
|
{ 220,220, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* Priority */
|
||||||
{ 221,222, RIG_MTYPE_MEM , {THG71_CHANNEL_CAPS}}, /* Call 0/1 */
|
{ 221,222, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* Call 0/1 */
|
||||||
{ 223,231, RIG_MTYPE_MEM , {THG71_CHANNEL_CAPS}}, /* Band VFO */
|
{ 223,231, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* Band VFO */
|
||||||
RIG_CHAN_END,
|
RIG_CHAN_END,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -182,8 +167,8 @@ const struct rig_caps thg71_caps = {
|
||||||
.get_vfo = thg71_get_vfo,
|
.get_vfo = thg71_get_vfo,
|
||||||
.set_mem = th_set_mem,
|
.set_mem = th_set_mem,
|
||||||
.get_mem = th_get_mem,
|
.get_mem = th_get_mem,
|
||||||
.set_channel = thg71_set_channel,
|
.set_channel = th_set_channel,
|
||||||
.get_channel = thg71_get_channel,
|
.get_channel = th_get_channel,
|
||||||
.set_trn = th_set_trn,
|
.set_trn = th_set_trn,
|
||||||
.get_trn = th_get_trn,
|
.get_trn = th_get_trn,
|
||||||
|
|
||||||
|
@ -418,216 +403,6 @@ int thg71_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
int thg71_get_channel(RIG *rig, channel_t *chan)
|
|
||||||
{
|
|
||||||
char membuf[64],ackbuf[ACKBUF_LEN];
|
|
||||||
int retval,ack_len;
|
|
||||||
long long freq,offset;
|
|
||||||
char req[16],scf[128];
|
|
||||||
int step, shift, rev, tone, ctcss, tonefq, ctcssfq;
|
|
||||||
|
|
||||||
if(chan->channel_num<200)
|
|
||||||
sprintf(req,"MR 0,0,%03d",chan->channel_num);
|
|
||||||
else
|
|
||||||
if(chan->channel_num<210) {
|
|
||||||
sprintf(req,"MR 0,0,L%01d",chan->channel_num-200);
|
|
||||||
sprintf(chan->channel_desc,"L%01d",chan->channel_num-200);
|
|
||||||
} else
|
|
||||||
if(chan->channel_num<220) {
|
|
||||||
sprintf(req,"MR 0,0,U%01d",chan->channel_num-210);
|
|
||||||
sprintf(chan->channel_desc,"U%01d",chan->channel_num-210);
|
|
||||||
} else
|
|
||||||
if(chan->channel_num==220) {
|
|
||||||
sprintf(req,"MR 0,0,PR");
|
|
||||||
sprintf(chan->channel_desc,"Pr");
|
|
||||||
} else
|
|
||||||
if(chan->channel_num<223) {
|
|
||||||
sprintf(req,"CR 0,%01d",chan->channel_num-221);
|
|
||||||
if(chan->channel_num==221) sprintf(chan->channel_desc,"Call V");
|
|
||||||
if(chan->channel_num==222) sprintf(chan->channel_desc,"Call U");
|
|
||||||
} else
|
|
||||||
if(chan->channel_num<232) {
|
|
||||||
sprintf(req,"VR %01d",chan->channel_num-222);
|
|
||||||
sprintf(chan->channel_desc,"BAND %01d",chan->channel_num-222);
|
|
||||||
} else
|
|
||||||
return -RIG_EINVAL;
|
|
||||||
|
|
||||||
sprintf(membuf,"%s"EOM,req);
|
|
||||||
ack_len=ACKBUF_LEN;
|
|
||||||
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
||||||
if (retval != RIG_OK)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
strcpy(scf,req);
|
|
||||||
strcat(scf,",%"FREQFMT",%d,%d,%d,%d,%d,,%d,,%d,%"FREQFMT);
|
|
||||||
retval = sscanf(ackbuf, scf,
|
|
||||||
&freq, &step, &shift, &rev, &tone,
|
|
||||||
&ctcss, &tonefq, &ctcssfq, &offset);
|
|
||||||
|
|
||||||
chan->freq=(freq_t)freq;
|
|
||||||
chan->vfo=RIG_VFO_MEM;
|
|
||||||
chan->tuning_step=rig->state.tuning_steps[step].ts;
|
|
||||||
if(freq <MHz(136) ) {
|
|
||||||
chan->mode=RIG_MODE_AM;
|
|
||||||
chan->width=kHz(9);
|
|
||||||
} else {
|
|
||||||
chan->mode=RIG_MODE_FM;
|
|
||||||
chan->width=kHz(12);
|
|
||||||
}
|
|
||||||
switch(shift) {
|
|
||||||
case 0 :
|
|
||||||
chan->rptr_shift=RIG_RPT_SHIFT_NONE;
|
|
||||||
break;
|
|
||||||
case 1 :
|
|
||||||
chan->rptr_shift=RIG_RPT_SHIFT_PLUS;
|
|
||||||
break;
|
|
||||||
case 2 :
|
|
||||||
chan->rptr_shift=RIG_RPT_SHIFT_MINUS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
chan->rptr_offs=offset;
|
|
||||||
|
|
||||||
if(tone)
|
|
||||||
chan->ctcss_tone=rig->caps->ctcss_list[tonefq==1?0:tonefq-2];
|
|
||||||
else
|
|
||||||
chan->ctcss_tone=0;
|
|
||||||
if(ctcss)
|
|
||||||
chan->ctcss_sql=rig->caps->ctcss_list[ctcssfq==1?0:ctcssfq-2];
|
|
||||||
else
|
|
||||||
chan->ctcss_sql=0;
|
|
||||||
|
|
||||||
chan->tx_freq=RIG_FREQ_NONE;
|
|
||||||
if(chan->channel_num<223 && offset==0) {
|
|
||||||
req[5]='1';
|
|
||||||
sprintf(membuf,"%s"EOM,req);
|
|
||||||
ack_len=ACKBUF_LEN;
|
|
||||||
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
||||||
if (retval == RIG_OK) {
|
|
||||||
strcat(req,",%"FREQFMT",%d");
|
|
||||||
retval = sscanf(ackbuf, req, &freq, &step);
|
|
||||||
chan->tx_freq=freq;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(chan->channel_num<200) {
|
|
||||||
sprintf(membuf,"MNA 0,%03d"EOM,chan->channel_num);
|
|
||||||
ack_len=ACKBUF_LEN;
|
|
||||||
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
||||||
if (retval != RIG_OK)
|
|
||||||
return retval;
|
|
||||||
memcpy(chan->channel_desc,&ackbuf[10],7);
|
|
||||||
}
|
|
||||||
|
|
||||||
return RIG_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
|
||||||
int thg71_set_channel(RIG *rig, const channel_t *chan)
|
|
||||||
{
|
|
||||||
char membuf[ACKBUF_LEN],ackbuf[ACKBUF_LEN];
|
|
||||||
int retval,ack_len;
|
|
||||||
char req[64];
|
|
||||||
long long freq,offset;
|
|
||||||
int chn, step, shift, tone, ctcss, tonefq, ctcssfq;
|
|
||||||
|
|
||||||
chn=chan->channel_num;
|
|
||||||
freq=(long long)chan->freq;
|
|
||||||
|
|
||||||
for(step=0; rig->state.tuning_steps[step].ts!=0;step++)
|
|
||||||
if(chan->tuning_step==rig->state.tuning_steps[step].ts) break;
|
|
||||||
|
|
||||||
switch(chan->rptr_shift) {
|
|
||||||
case RIG_RPT_SHIFT_NONE :
|
|
||||||
shift=0;
|
|
||||||
break;
|
|
||||||
case RIG_RPT_SHIFT_PLUS:
|
|
||||||
shift=1;
|
|
||||||
break;
|
|
||||||
case RIG_RPT_SHIFT_MINUS:
|
|
||||||
shift=2;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: not supported shift\n", __FUNCTION__);
|
|
||||||
return -RIG_EINVAL;
|
|
||||||
}
|
|
||||||
offset=chan->rptr_offs;
|
|
||||||
|
|
||||||
if(chan->ctcss_tone==0) {
|
|
||||||
tone=0;tonefq=9;
|
|
||||||
} else {
|
|
||||||
tone=1;
|
|
||||||
for (tonefq = 0; rig->caps->ctcss_list[tonefq] != 0 && tonefq < RIG_TONEMAX; tonefq++) {
|
|
||||||
if (rig->caps->ctcss_list[tonefq] == chan->ctcss_tone)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tonefq=tonefq==0?1:tonefq+2;
|
|
||||||
}
|
|
||||||
if(chan->ctcss_sql==0) {
|
|
||||||
ctcss=0;ctcssfq=9;
|
|
||||||
} else {
|
|
||||||
ctcss=1;
|
|
||||||
for (ctcssfq = 0; rig->caps->ctcss_list[ctcssfq] != 0 && ctcssfq < RIG_TONEMAX; ctcssfq++) {
|
|
||||||
if (rig->caps->ctcss_list[ctcssfq] == chan->ctcss_sql)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ctcssfq=ctcssfq==0?1:ctcssfq+2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(chan->channel_num<200)
|
|
||||||
sprintf(req,"MW 0,0,%03d",chan->channel_num);
|
|
||||||
else
|
|
||||||
if(chan->channel_num<210) {
|
|
||||||
sprintf(req,"MW 0,0,L%01d",chan->channel_num-200);
|
|
||||||
} else
|
|
||||||
if(chan->channel_num<220) {
|
|
||||||
sprintf(req,"MW 0,0,U%01d",chan->channel_num-210);
|
|
||||||
} else
|
|
||||||
if(chan->channel_num==220) {
|
|
||||||
sprintf(req,"MW 0,0,PR");
|
|
||||||
} else
|
|
||||||
if(chan->channel_num<223) {
|
|
||||||
sprintf(req,"CW 0,%01d",chan->channel_num-221);
|
|
||||||
} else
|
|
||||||
if(chan->channel_num<232) {
|
|
||||||
sprintf(req,"VW %01d",chan->channel_num-222);
|
|
||||||
} else
|
|
||||||
return -RIG_EINVAL;
|
|
||||||
|
|
||||||
if(chan->channel_num<=220)
|
|
||||||
sprintf(membuf, "%s,%011lld,%01d,%01d,0,%01d,%01d,,%02d,,%02d,%09lld,0"EOM,
|
|
||||||
req,(long long)freq, step, shift, tone,
|
|
||||||
ctcss, tonefq, ctcssfq, (long long)offset);
|
|
||||||
else
|
|
||||||
sprintf(membuf, "%s,%011lld,%01d,%01d,0,%01d,%01d,,%02d,,%02d,%09lld"EOM,
|
|
||||||
req, (long long)freq, step, shift, tone,
|
|
||||||
ctcss, tonefq, ctcssfq, (long long)offset);
|
|
||||||
|
|
||||||
ack_len=ACKBUF_LEN;
|
|
||||||
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
||||||
if (retval != RIG_OK)
|
|
||||||
return retval;
|
|
||||||
|
|
||||||
if(chan->channel_num<223 && chan->tx_freq!=RIG_FREQ_NONE) {
|
|
||||||
req[5]='1';
|
|
||||||
sprintf(membuf, "%s,%011lld,%01d"EOM, req,(long long)chan->tx_freq, step);
|
|
||||||
ack_len=ACKBUF_LEN;
|
|
||||||
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
||||||
if (retval != RIG_OK)
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(chan->channel_num<200) {
|
|
||||||
ack_len=ACKBUF_LEN;
|
|
||||||
sprintf(membuf,"MNA 0,%03d,%s"EOM,chan->channel_num,chan->channel_desc);
|
|
||||||
retval = kenwood_transaction(rig, membuf, strlen(membuf), ackbuf, &ack_len);
|
|
||||||
if (retval != RIG_OK)
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
return RIG_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------- */
|
||||||
int thg71_open(RIG *rig)
|
int thg71_open(RIG *rig)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Kenwood backend - TM-D700 description
|
* Hamlib Kenwood backend - TM-D700 description
|
||||||
* Copyright (c) 2000-2004 by Stephane Fillod
|
* Copyright (c) 2000-2004 by Stephane Fillod
|
||||||
*
|
*
|
||||||
* $Id: tmd700.c,v 1.1 2004-02-08 17:05:55 fillods Exp $
|
* $Id: tmd700.c,v 1.2 2004-03-20 16:48:34 f4dwv Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -113,11 +113,12 @@ const struct rig_caps tmd700_caps = {
|
||||||
.bank_qty = 0,
|
.bank_qty = 0,
|
||||||
.chan_desc_sz = 0,
|
.chan_desc_sz = 0,
|
||||||
|
|
||||||
|
.chan_list = {
|
||||||
.chan_list = { { 1, 200, RIG_MTYPE_MEM },
|
{ 1, 199, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* normal MEM */
|
||||||
RIG_CHAN_END,
|
{ 200,219, RIG_MTYPE_EDGE , {TH_CHANNEL_CAPS}}, /* U/L MEM */
|
||||||
}, /* FIXME: memory channel list: 200 memories */
|
{ 221,222, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* Call 0/1 */
|
||||||
|
RIG_CHAN_END,
|
||||||
|
},
|
||||||
/*
|
/*
|
||||||
* TODO: Japan & TM-D700S, and Taiwan models
|
* TODO: Japan & TM-D700S, and Taiwan models
|
||||||
*/
|
*/
|
||||||
|
@ -183,6 +184,8 @@ const struct rig_caps tmd700_caps = {
|
||||||
.get_ctcss_tone = th_get_ctcss_tone,
|
.get_ctcss_tone = th_get_ctcss_tone,
|
||||||
.set_mem = th_set_mem,
|
.set_mem = th_set_mem,
|
||||||
.get_mem = th_get_mem,
|
.get_mem = th_get_mem,
|
||||||
|
.set_channel = th_set_channel,
|
||||||
|
.get_channel = th_get_channel,
|
||||||
.set_trn = th_set_trn,
|
.set_trn = th_set_trn,
|
||||||
.get_trn = th_get_trn,
|
.get_trn = th_get_trn,
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue