kopia lustrzana https://github.com/Hamlib/Hamlib
implemented TS570 specific get/set_memory_channel function
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2113 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.6rc1
rodzic
e710c36c6e
commit
27d434f9b8
197
kenwood/ts570.c
197
kenwood/ts570.c
|
@ -2,7 +2,7 @@
|
|||
* Hamlib Kenwood backend - TS570 description
|
||||
* Copyright (c) 2001-2005 by Stephane Fillod
|
||||
*
|
||||
* $Id: ts570.c,v 1.27 2006-03-18 10:45:16 y32kn Exp $
|
||||
* $Id: ts570.c,v 1.28 2006-08-20 13:39:47 y32kn 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
|
||||
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include "kenwood.h"
|
||||
|
@ -63,6 +64,23 @@ static const struct kenwood_priv_caps ts570_priv_caps = {
|
|||
.cmdtrm = EOM_KEN,
|
||||
};
|
||||
|
||||
|
||||
static rmode_t char_to_mode(char c)
|
||||
{
|
||||
switch (c) {
|
||||
case MD_CW: return(RIG_MODE_CW);
|
||||
case MD_CWR: return(RIG_MODE_CWR);
|
||||
case MD_USB: return(RIG_MODE_USB);
|
||||
case MD_LSB: return(RIG_MODE_LSB);
|
||||
case MD_FM: return(RIG_MODE_FM);
|
||||
case MD_AM: return(RIG_MODE_AM);
|
||||
case MD_FSK: return(RIG_MODE_RTTY);
|
||||
case MD_FSKR: return(RIG_MODE_RTTYR);
|
||||
case MD_NONE: return(RIG_MODE_NONE);
|
||||
}
|
||||
return(RIG_MODE_NONE);
|
||||
}
|
||||
|
||||
static int ts570_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
||||
{
|
||||
char buf[50];
|
||||
|
@ -144,6 +162,22 @@ static int ts570_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
static char mode_to_char(rmode_t mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case RIG_MODE_CW: return(MD_CW);
|
||||
case RIG_MODE_CWR: return(MD_CWR);
|
||||
case RIG_MODE_USB: return(MD_USB);
|
||||
case RIG_MODE_LSB: return(MD_LSB);
|
||||
case RIG_MODE_FM: return(MD_FM);
|
||||
case RIG_MODE_AM: return(MD_AM);
|
||||
case RIG_MODE_RTTY: return(MD_FSK);
|
||||
case RIG_MODE_RTTYR: return(MD_FSKR);
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_WARN,"ts570_mode_to_char %s: unsupported mode %d\n", __FUNCTION__,mode);
|
||||
}
|
||||
return(RIG_MODE_NONE);
|
||||
}
|
||||
|
||||
static int ts570_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||
{
|
||||
|
@ -151,21 +185,8 @@ static int ts570_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
int buf_len, kmode, retval;
|
||||
size_t ack_len;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case RIG_MODE_CW: kmode = MD_CW; break;
|
||||
case RIG_MODE_CWR: kmode = MD_CWR; break;
|
||||
case RIG_MODE_USB: kmode = MD_USB; break;
|
||||
case RIG_MODE_LSB: kmode = MD_LSB; break;
|
||||
case RIG_MODE_FM: kmode = MD_FM; break;
|
||||
case RIG_MODE_AM: kmode = MD_AM; break;
|
||||
case RIG_MODE_RTTY: kmode = MD_FSK; break;
|
||||
case RIG_MODE_RTTYR: kmode = MD_FSKR; break;
|
||||
default:
|
||||
rig_debug(RIG_DEBUG_ERR,"ts570_set_mode: "
|
||||
"unsupported mode %d\n", mode);
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
if ((kmode = mode_to_char(mode)) == RIG_MODE_NONE)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
buf_len = sprintf(buf, "MD%c;", kmode);
|
||||
ack_len = 0;
|
||||
|
@ -310,7 +331,6 @@ int ts570_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|||
* Assumes rig!=NULL
|
||||
*
|
||||
* set levels of most functions
|
||||
*
|
||||
*/
|
||||
int
|
||||
ts570_set_level (RIG * rig, vfo_t vfo, setting_t level, value_t val)
|
||||
|
@ -394,8 +414,143 @@ ts570_get_level (RIG * rig, vfo_t vfo, setting_t level, value_t * val)
|
|||
#define TS570_MEM_CAP { \
|
||||
.freq = 1, \
|
||||
.mode = 1, \
|
||||
.tx_freq=1, \
|
||||
.tx_mode=1, \
|
||||
.split=1, \
|
||||
.ctcss_tone=1 \
|
||||
}
|
||||
|
||||
/*
|
||||
* read memory channel
|
||||
* Assumes: rig != NULL, chan != NULL
|
||||
*
|
||||
* !!! memory channel remembers additional settings for antenna, attenuator and
|
||||
* !!! preamplifier and ctcss squelch. NOT SUPPORTED YET!
|
||||
*/
|
||||
int ts570_get_channel (RIG * rig, channel_t * chan)
|
||||
{
|
||||
char cmdbuf[16], membuf[50];
|
||||
int retval, cmd_len, num;
|
||||
size_t mem_len;
|
||||
|
||||
/*
|
||||
* first check if we shall get a memory or vfo channel
|
||||
*/
|
||||
if (chan->vfo != RIG_VFO_MEM) {
|
||||
/*
|
||||
* At the time only memory channels are supported.
|
||||
*/
|
||||
rig_debug(RIG_DEBUG_ERR,"kenwood_get_chan: "
|
||||
"ts570_get_channel not implemented"
|
||||
" for VFO channels.\n");
|
||||
return -RIG_ENIMPL;
|
||||
}
|
||||
|
||||
num=chan->channel_num;
|
||||
|
||||
cmd_len = sprintf(cmdbuf, "MR0 %02d;", num);
|
||||
mem_len = 50;
|
||||
retval = kenwood_transaction (rig, cmdbuf, cmd_len, membuf, &mem_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
memset(chan,0,sizeof(channel_t));
|
||||
chan->channel_num=num;
|
||||
|
||||
|
||||
if (membuf[19]=='0')
|
||||
chan->ctcss_tone=0;
|
||||
else {
|
||||
membuf[22]='\0';
|
||||
chan->ctcss_tone= rig->caps->ctcss_list[atoi(&membuf[20])-1];
|
||||
}
|
||||
|
||||
chan->mode=char_to_mode(membuf[17]);
|
||||
|
||||
membuf[17]='\0';
|
||||
chan->freq=atoi(&membuf[6]);
|
||||
|
||||
/* See if channel is in use */
|
||||
if (chan->freq == RIG_FREQ_NONE)
|
||||
return -RIG_ENAVAIL;
|
||||
|
||||
/* Manual says that we can read the scanning stop frequency
|
||||
* for channel 90..99 by the following command.
|
||||
* That seems not to be true. It returns the same information
|
||||
* as MR0.
|
||||
* So we use it here only for getting the split info for
|
||||
* channels 00..89.
|
||||
*/
|
||||
cmd_len = sprintf(cmdbuf, "MR1 %02d;", num);
|
||||
mem_len = 50;
|
||||
retval = kenwood_transaction (rig, cmdbuf, cmd_len, membuf, &mem_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
chan->tx_mode=char_to_mode(membuf[17]);
|
||||
membuf[17]='\0';
|
||||
chan->tx_freq=atoi(&membuf[6]);
|
||||
|
||||
if(chan->freq==chan->tx_freq &&
|
||||
chan->mode==chan->tx_mode) {
|
||||
chan->tx_freq=RIG_FREQ_NONE;
|
||||
chan->tx_mode=RIG_MODE_NONE;
|
||||
chan->split=RIG_SPLIT_OFF;
|
||||
} else
|
||||
chan->split=RIG_SPLIT_ON;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
int ts570_set_channel (RIG * rig, const channel_t * chan)
|
||||
{
|
||||
char cmdbuf[30], membuf[30];
|
||||
int retval, cmd_len;
|
||||
size_t mem_len;
|
||||
int num,freq,tx_freq,tone;
|
||||
char mode,tx_mode,split,tones;
|
||||
|
||||
num=chan->channel_num;
|
||||
freq=(int)chan->freq;
|
||||
mode=mode_to_char(chan->mode);
|
||||
if(chan->split==RIG_SPLIT_ON) {
|
||||
tx_freq=(int)chan->tx_freq;
|
||||
tx_mode=mode_to_char(chan->tx_mode);
|
||||
split='1';
|
||||
} else {
|
||||
tx_freq=0;
|
||||
tx_mode='\0';
|
||||
split='0';
|
||||
}
|
||||
|
||||
for (tone = 1; rig->caps->ctcss_list[tone-1] != 0 && tone<39; tone++) {
|
||||
if (rig->caps->ctcss_list[tone-1] == chan->ctcss_tone)
|
||||
break;
|
||||
}
|
||||
if(chan->ctcss_tone!=0) {
|
||||
tones='1';
|
||||
} else {
|
||||
tones='0';
|
||||
tone=0;
|
||||
}
|
||||
|
||||
cmd_len = sprintf(cmdbuf, "MW0 %02d%011d%c0%c%02d ;",
|
||||
num,freq,mode,tones,tone);
|
||||
mem_len = 0;
|
||||
retval = kenwood_transaction (rig, cmdbuf, cmd_len, membuf, &mem_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
cmd_len = sprintf(cmdbuf, "MW1 %02d%011d%c0%c%02d ;",
|
||||
num,tx_freq,tx_mode,tones,tone);
|
||||
mem_len = 0;
|
||||
retval = kenwood_transaction (rig, cmdbuf, cmd_len, membuf, &mem_len);
|
||||
if (retval != RIG_OK)
|
||||
return retval;
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
/*
|
||||
* ts570 rig capabilities.
|
||||
* Notice that some rigs share the same functions.
|
||||
|
@ -583,7 +738,7 @@ const struct rig_caps ts570d_caps = {
|
|||
.mfg_name = "Kenwood",
|
||||
.version = BACKEND_VER,
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_UNTESTED,
|
||||
.status = RIG_STATUS_ALPHA,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
.ptt_type = RIG_PTT_RIG,
|
||||
.dcd_type = RIG_DCD_RIG,
|
||||
|
@ -738,6 +893,8 @@ const struct rig_caps ts570d_caps = {
|
|||
.vfo_op = kenwood_vfo_op,
|
||||
.set_mem = kenwood_set_mem,
|
||||
.get_mem = kenwood_get_mem,
|
||||
.get_channel = ts570_get_channel,
|
||||
.set_channel = ts570_set_channel,
|
||||
.set_trn = kenwood_set_trn,
|
||||
.get_trn = kenwood_get_trn,
|
||||
.set_powerstat = kenwood_set_powerstat,
|
||||
|
@ -748,7 +905,3 @@ const struct rig_caps ts570d_caps = {
|
|||
};
|
||||
|
||||
|
||||
/*
|
||||
* Function definitions below
|
||||
*/
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue