upgrade to beta level

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1709 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.1
Thierry Leconte, F4DWV 2004-03-21 16:58:07 +00:00
rodzic 70d3d7f854
commit 2fced351d7
1 zmienionych plików z 73 dodań i 328 usunięć

Wyświetl plik

@ -2,7 +2,7 @@
* Hamlib Kenwood backend - TM-V7 description
* Copyright (c) 2004 by Stephane Fillod
*
* $Id: tmv7.c,v 1.1 2004-03-20 10:23:43 fillods Exp $
* $Id: tmv7.c,v 1.2 2004-03-21 16:58:07 f4dwv 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
@ -47,6 +47,7 @@
#define TMV7_LEVEL_ALL (\
RIG_LEVEL_RAWSTR| \
RIG_LEVEL_SQL| \
RIG_LEVEL_AF| \
RIG_LEVEL_RFPOWER\
)
@ -54,19 +55,6 @@
#define RIG_TONEMAX 38
#endif
#define TMV7_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 ACKBUF_LEN 128
@ -80,13 +68,8 @@ const struct kenwood_priv_caps tmv7_priv_caps = {
/* tmv7 procs */
int tmv7_open(RIG *rig);
int tmv7_decode_event (RIG *rig);
int tmv7_set_freq (RIG *rig, vfo_t vfo, freq_t freq);
int tmv7_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
int tmv7_set_vfo (RIG *rig, vfo_t vfo);
int tmv7_get_vfo (RIG *rig, vfo_t *vfo);
int tmv7_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
int tmv7_get_channel(RIG *rig, channel_t *chan);
int tmv7_set_channel(RIG *rig, const channel_t *chan);
int tmv7_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
/*
* tm-v7 rig capabilities.
@ -97,8 +80,8 @@ const struct rig_caps tmv7_caps = {
.mfg_name = "Kenwood",
.version = "0.1",
.copyright = "LGPL",
.status = RIG_STATUS_NEW,
.rig_type = RIG_TYPE_HANDHELD,
.status = RIG_STATUS_BETA,
.rig_type = RIG_TYPE_MOBILE,
.ptt_type = RIG_PTT_RIG,
.dcd_type = RIG_DCD_RIG,
.port_type = RIG_PORT_SERIAL,
@ -136,12 +119,10 @@ const struct rig_caps tmv7_caps = {
.chan_list = {
{ 1, 199, RIG_MTYPE_MEM , {TMV7_CHANNEL_CAPS}}, /* normal MEM */
{ 200,219, RIG_MTYPE_EDGE , {TMV7_CHANNEL_CAPS}}, /* U/L MEM */
{ 220,220, RIG_MTYPE_MEM , {TMV7_CHANNEL_CAPS}}, /* Priority */
{ 221,222, RIG_MTYPE_MEM , {TMV7_CHANNEL_CAPS}}, /* Call 0/1 */
{ 223,231, RIG_MTYPE_MEM , {TMV7_CHANNEL_CAPS}}, /* Band VFO */
RIG_CHAN_END,
{ 1, 199, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* normal MEM */
{ 200,219, RIG_MTYPE_EDGE , {TH_CHANNEL_CAPS}}, /* U/L MEM */
{ 221,222, RIG_MTYPE_MEM , {TH_CHANNEL_CAPS}}, /* Call 0/1 */
RIG_CHAN_END,
},
/* no rx/tx_range_list */
@ -153,11 +134,8 @@ const struct rig_caps tmv7_caps = {
{RIG_MODE_FM,kHz(10)},
{RIG_MODE_FM,kHz(12.5)},
{RIG_MODE_FM,kHz(15)},
{RIG_MODE_FM,kHz(20)},
{RIG_MODE_FM,kHz(25)},
{RIG_MODE_FM,kHz(30)},
{RIG_MODE_FM,kHz(50)},
{RIG_MODE_FM,kHz(100)},
RIG_TS_END,
},
/* mode/filter list, remember: order matters! */
@ -167,8 +145,6 @@ const struct rig_caps tmv7_caps = {
RIG_FLT_END,
},
.str_cal ={ 2, { {0, -30 }, {5,-13}}}, /* guessed from technical manual */
.priv = (void *)&tmv7_priv_caps,
.rig_init = kenwood_init,
.rig_cleanup = kenwood_cleanup,
@ -179,18 +155,20 @@ const struct rig_caps tmv7_caps = {
.get_freq = th_get_freq,
.get_mode = tmv7_get_mode,
.set_vfo = tmv7_set_vfo,
.get_vfo = tmv7_get_vfo,
.get_vfo = th_get_vfo,
.set_mem = th_set_mem,
.get_mem = th_get_mem,
.set_channel = tmv7_set_channel,
.get_channel = tmv7_get_channel,
.set_channel = th_set_channel,
.get_channel = th_get_channel,
.set_trn = th_set_trn,
.get_trn = th_get_trn,
.set_func = tmv7_set_func,
.set_func = th_set_func,
.get_func = th_get_func,
.get_level = th_get_level,
.set_level = th_set_level,
.get_info = th_get_info,
.set_powerstat = th_set_powerstat,
.vfo_op = th_vfo_op,
.set_ptt = th_set_ptt,
.get_dcd=th_get_dcd,
@ -305,6 +283,60 @@ int tmv7_decode_event (RIG *rig)
return RIG_OK;
}
/* --------------------------------------------------------------------- */
int tmv7_set_vfo (RIG *rig, vfo_t vfo)
{
char vfobuf[16], ackbuf[ACKBUF_LEN];
int retval,ack_len;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __FUNCTION__);
switch (vfo) {
case RIG_VFO_A:
case RIG_VFO_VFO:
sprintf(vfobuf, "VMC 0,0" EOM);
break;
case RIG_VFO_B:
sprintf(vfobuf, "VMC 1,0" EOM);
break;
case RIG_VFO_MEM:
sprintf(vfobuf, "BC" EOM);
ack_len=ACKBUF_LEN;
retval = kenwood_transaction(rig, vfobuf, strlen(vfobuf), ackbuf, &ack_len);
if (retval != RIG_OK) return retval;
sprintf(vfobuf, "VMC %c,2" EOM,ackbuf[3]);
break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %d\n", __FUNCTION__, vfo);
return -RIG_EVFO;
}
ack_len=ACKBUF_LEN;
retval = kenwood_transaction(rig, vfobuf, strlen(vfobuf), ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
switch (vfo) {
case RIG_VFO_A:
sprintf(vfobuf, "BC 0,0" EOM);
break;
case RIG_VFO_B:
sprintf(vfobuf, "BC 1,1" EOM);
break;
case RIG_VFO_MEM:
return RIG_OK;
default:
return RIG_OK;
}
retval = kenwood_transaction(rig, vfobuf, strlen(vfobuf), ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
return RIG_OK;
}
/* --------------------------------------------------------------------- */
int tmv7_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
@ -330,7 +362,7 @@ int tmv7_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
sscanf(ackbuf,"FQ %"FREQFMT",%d",&freq,&step);
if(freq <MHz(136) ) {
if(freq <MHz(137) ) {
*mode=RIG_MODE_AM;
*width=kHz(9);
} else {
@ -341,301 +373,14 @@ int tmv7_get_mode (RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
return RIG_OK;
}
/* --------------------------------------------------------------------- */
int tmv7_set_vfo (RIG *rig, vfo_t vfo)
{
char vfobuf[16], ackbuf[ACKBUF_LEN];
int retval,ack_len=ACKBUF_LEN;
rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __FUNCTION__);
switch (vfo) {
case RIG_VFO_A:
case RIG_VFO_VFO:
sprintf(vfobuf, "VMC 0,0"EOM);
break;
case RIG_VFO_MEM:
sprintf(vfobuf, "VMC 0,2"EOM);
break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %d\n", __FUNCTION__, vfo);
return -RIG_EVFO;
}
retval = kenwood_transaction(rig, vfobuf, strlen(vfobuf), ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
return RIG_OK;
}
/* --------------------------------------------------------------------- */
int tmv7_get_vfo (RIG *rig, vfo_t *vfo)
{
char ackbuf[ACKBUF_LEN];
int retval,ack_len=ACKBUF_LEN;
int vch;
retval = kenwood_transaction(rig, "VMC 0"EOM , 6, ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
sscanf(ackbuf,"VMC 0,%d"EOM,&vch);
switch(vch) {
case 0:
*vfo=RIG_VFO_A;
break;
case 1:
case 2:
*vfo=RIG_VFO_MEM;
break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %d\n", __FUNCTION__, vfo);
return -RIG_EVFO;
}
return RIG_OK;
}
/* --------------------------------------------------------------------- */
int tmv7_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
char ackbuf[ACKBUF_LEN];
int retval,ack_len=ACKBUF_LEN;
if(func != RIG_FUNC_TBURST)
return -RIG_EINVAL;
if(status==1) {
retval = kenwood_transaction(rig, "TT"EOM, 3, ackbuf, &ack_len);
if (retval != RIG_OK)
return retval;
return RIG_OK;
}
if(status==0) {
return rig_set_ptt(rig,vfo,RIG_PTT_OFF);
}
return -RIG_EINVAL;
}
/* --------------------------------------------------------------------- */
int tmv7_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 tmv7_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 tmv7_open(RIG *rig)
{
char ackbuf[ACKBUF_LEN],*strl,*stru;
int retval,i,ack_len=ACKBUF_LEN;
const freq_range_t frend=RIG_FRNG_END;
/* just to be sure it's a THG-71 */
/* 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;
@ -663,7 +408,7 @@ int tmv7_open(RIG *rig)
frng.end=MHz(atoi(stru));
frng.vfo=RIG_VFO_A;
frng.ant=0;
if(frng.end<=MHz(135))
if(frng.end<=MHz(136))
frng.modes=RIG_MODE_AM;
else
frng.modes=RIG_MODE_FM;