git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1242 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.1.4
Stéphane Fillod, F8CFE 2002-11-04 22:22:30 +00:00
rodzic 52e9a15924
commit e2f54e9d10
6 zmienionych plików z 1649 dodań i 1513 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
## $Id: hamlib.cfg,v 1.6 2002-09-24 21:42:56 fillods Exp $
## $Id: hamlib.cfg,v 1.7 2002-11-04 22:22:30 fillods Exp $
PROJECT_NAME = "Hamlib - the C library reference"
@ -18,6 +18,9 @@ MAN_EXTENSION = .3
CASE_SENSE_NAMES = NO
INPUT = index.doxygen \
../src/rig.c \
../src/conf.c \
../src/mem.c \
../src/settings.c \
../src/rotator.c \
../src/tones.c \
../src/locator.c

Wyświetl plik

@ -1,8 +1,15 @@
/**
* \file src/conf.c
* \ingroup rig
* \brief Rig configuration interface
* \author Stephane Fillod
* \date 2000-2002
*/
/*
* Hamlib Interface - configuration interface
* Copyright (c) 2000,2001,2002 by Stephane Fillod and Frank Singleton
* Copyright (c) 2000,2002 by Stephane Fillod
*
* $Id: conf.c,v 1.7 2002-08-16 17:43:02 fillods Exp $
* $Id: conf.c,v 1.8 2002-11-04 22:21:42 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
@ -31,11 +38,8 @@
#include <unistd.h> /* UNIX standard function definitions */
#include <hamlib/rig.h>
#include "conf.h"
#include "token.h"
/*
* Place holder for now. Here will be defined all the configuration
* options available in the rig->state struct.
@ -97,7 +101,7 @@ static const struct confparams frontend_cfg_params[] = {
* assumes rig!=NULL, val!=NULL
* TODO: check format of val before doing atoi().
*/
int frontend_set_conf(RIG *rig, token_t token, const char *val)
static int frontend_set_conf(RIG *rig, token_t token, const char *val)
{
const struct rig_caps *caps;
struct rig_state *rs;
@ -186,7 +190,7 @@ int frontend_set_conf(RIG *rig, token_t token, const char *val)
* frontend_get_conf
* assumes rig!=NULL, val!=NULL
*/
int frontend_get_conf(RIG *rig, token_t token, char *val)
static int frontend_get_conf(RIG *rig, token_t token, char *val)
{
const struct rig_caps *caps;
struct rig_state *rs;
@ -254,10 +258,19 @@ int frontend_get_conf(RIG *rig, token_t token, char *val)
return RIG_OK;
}
/*
* rig_token_foreach
* executes cfunc on all the elements stored in the conf table
* start first with backend conf table, then finish with frontend table
/**
* \brief call a function against each configuration token of a rig
* \param rig The rig handle
* \param cfunc The function to perform on each token
* \param data Any data to be passed to cfunc
*
* Executes \a cfunc on all the elements stored in the conf table.
* rig_token_foreach starts first with backend conf table, then finish
* with frontend table.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*/
int rig_token_foreach(RIG *rig, int (*cfunc)(const struct confparams *, rig_ptr_t), rig_ptr_t data)
{
@ -276,11 +289,14 @@ int rig_token_foreach(RIG *rig, int (*cfunc)(const struct confparams *, rig_ptr_
}
/*
* lookup conf token by its name, return pointer to confparams struct.
/**
* \brief lookup a confparam struct
* \param rig The rig handle
* \param name The name of the configuration parameter
*
* lookup backend config table first, then fall back to frontend.
* TODO: should use Lex to speed it up, strcmp hurts!
* Lookup conf token by its name.
*
* \return a pointer to the confparams struct if found, otherwise NULL.
*/
const struct confparams *rig_confparam_lookup(RIG *rig, const char *name)
{
@ -297,8 +313,14 @@ const struct confparams *rig_confparam_lookup(RIG *rig, const char *name)
return NULL;
}
/*
* Simple lookup returning token id assicated with name
/**
* \brief lookup a token id
* \param rig The rig handle
* \param name The name of the configuration parameter
*
* Simple lookup returning token id assicated with name.
*
* \return the token id if found, otherwise RIG_CONF_END
*/
token_t rig_token_lookup(RIG *rig, const char *name)
{
@ -311,4 +333,60 @@ token_t rig_token_lookup(RIG *rig, const char *name)
return cfp->token;
}
/**
* \brief set a radio configuration parameter
* \param rig The rig handle
* \param token The parameter
* \param val The value to set the parameter to
*
* Sets a configuration parameter.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_get_conf()
*/
int rig_set_conf(RIG *rig, token_t token, const char *val)
{
if (!rig || !rig->caps)
return -RIG_EINVAL;
if (IS_TOKEN_FRONTEND(token))
return frontend_set_conf(rig, token, val);
if (rig->caps->set_conf == NULL)
return -RIG_ENAVAIL;
return rig->caps->set_conf(rig, token, val);
}
/**
* \brief get the value of a configuration parameter
* \param rig The rig handle
* \param token The parameter
* \param val The location where to store the value of config \a token
*
* Retrieves the value of a configuration paramter associated with \a token.
* The location pointed to by val must be large enough to hold the value of the config.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_conf()
*/
int rig_get_conf(RIG *rig, token_t token, char *val)
{
if (!rig || !rig->caps || !val)
return -RIG_EINVAL;
if (IS_TOKEN_FRONTEND(token))
return frontend_get_conf(rig, token, val);
if (rig->caps->get_conf == NULL)
return -RIG_ENAVAIL;
return rig->caps->get_conf(rig, token, val);
}

525
src/mem.c 100644
Wyświetl plik

@ -0,0 +1,525 @@
/**
* \file src/mem.c
* \ingroup rig
* \brief Memory and channel interface
* \author Stephane Fillod
* \date 2000-2002
*
* Hamlib interface is a frontend implementing wrapper functions.
*/
/*
* Hamlib Interface - mem/channel calls
* Copyright (c) 2000-2002 by Stephane Fillod
*
* $Id: mem.c,v 1.1 2002-11-04 22:21:42 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
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <hamlib/rig.h>
#ifndef DOC_HIDDEN
#define CHECK_RIG_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state)
#endif /* !DOC_HIDDEN */
/**
* \brief set the current memory channel number
* \param rig The rig handle
* \param vfo The target VFO
* \param ch The memory channel number
*
* Sets the current memory channel number.
* It is not mandatory for the radio to be in memory mode. Actually
* it depends on rigs. YMMV.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_get_mem()
*/
int rig_set_mem(RIG *rig, vfo_t vfo, int ch)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
caps = rig->caps;
if (caps->set_mem == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->set_mem(rig, vfo, ch);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->set_mem(rig, vfo, ch);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief get the current memory channel number
* \param rig The rig handle
* \param vfo The target VFO
* \param ch The location where to store the current memory channel number
*
* Retrieves the current memory channel number.
* It is not mandatory for the radio to be in memory mode. Actually
* it depends on rigs. YMMV.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_mem()
*/
int rig_get_mem(RIG *rig, vfo_t vfo, int *ch)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig) || !ch)
return -RIG_EINVAL;
caps = rig->caps;
if (caps->get_mem == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->get_mem(rig, vfo, ch);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->get_mem(rig, vfo, ch);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief set the current memory bank
* \param rig The rig handle
* \param vfo The target VFO
* \param bank The memory bank
*
* Sets the current memory bank number.
* It is not mandatory for the radio to be in memory mode. Actually
* it depends on rigs. YMMV.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_mem()
*/
int rig_set_bank(RIG *rig, vfo_t vfo, int bank)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
caps = rig->caps;
if (caps->set_bank == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->set_bank(rig, vfo, bank);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->set_bank(rig, vfo, bank);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
#ifndef DOC_HIDDEN
/*
* call on every ext_levels of a rig
*/
static int generic_retr_extl(RIG *rig, const struct confparams *cfp, rig_ptr_t ptr)
{
channel_t *chan = (channel_t *)ptr;
struct ext_list *p;
unsigned el_size = 0;
if (chan->ext_levels == NULL)
p = chan->ext_levels = malloc(2*sizeof(struct ext_list));
else {
for (p = chan->ext_levels; !RIG_IS_EXT_END(*p); p++)
el_size += sizeof(struct ext_list);
chan->ext_levels = realloc(chan->ext_levels,
el_size+sizeof(struct ext_list));
}
p->token = cfp->token;
rig_get_ext_level(rig, RIG_VFO_CURR, p->token, &p->val);
p++;
p->token = 0; /* RIG_EXT_END */
return 1; /* process them all */
}
/*
* stores current VFO state into chan by emulating rig_get_channel
*/
int generic_save_channel(RIG *rig, channel_t *chan)
{
int i;
int chan_num;
vfo_t vfo;
if (CHECK_RIG_ARG(rig) || !chan)
return -RIG_EINVAL;
chan_num = chan->channel_num;
vfo = chan->vfo;
memset(chan, 0, sizeof(channel_t));
chan->channel_num = chan_num;
chan->vfo = vfo;
rig_get_vfo(rig, &chan->vfo);
rig_get_freq(rig, RIG_VFO_CURR, &chan->freq);
rig_get_mode(rig, RIG_VFO_CURR, &chan->mode, &chan->width);
chan->split = RIG_SPLIT_OFF;
rig_get_split(rig, RIG_VFO_CURR, &chan->split);
if (chan->split != RIG_SPLIT_OFF) {
rig_get_split_freq(rig, RIG_VFO_CURR, &chan->tx_freq);
rig_get_split_mode(rig, RIG_VFO_CURR, &chan->tx_mode, &chan->tx_width);
} else {
chan->tx_freq = chan->freq;
chan->tx_mode = chan->mode;
chan->tx_width = chan->width;
}
rig_get_rptr_shift(rig, RIG_VFO_CURR, &chan->rptr_shift);
rig_get_rptr_offs(rig, RIG_VFO_CURR, &chan->rptr_offs);
rig_get_ant(rig, RIG_VFO_CURR, &chan->ant);
rig_get_ts(rig, RIG_VFO_CURR, &chan->tuning_step);
rig_get_rit(rig, RIG_VFO_CURR, &chan->rit);
rig_get_xit(rig, RIG_VFO_CURR, &chan->xit);
for (i=0; i<RIG_SETTING_MAX; i++)
if (RIG_LEVEL_SET(rig_idx2setting(i)))
rig_get_level(rig, RIG_VFO_CURR, rig_idx2setting(i), &chan->levels[i]);
chan->funcs = 0;
for (i=0; i<RIG_SETTING_MAX; i++) {
int fstatus;
if (rig_get_func(rig, RIG_VFO_CURR, rig_idx2setting(i), &fstatus) == RIG_OK)
chan->funcs |= fstatus ? rig_idx2setting(i) : 0;
}
rig_get_ctcss_tone(rig, RIG_VFO_CURR, &chan->ctcss_tone);
rig_get_ctcss_sql(rig, RIG_VFO_CURR, &chan->ctcss_sql);
rig_get_dcs_code(rig, RIG_VFO_CURR, &chan->dcs_code);
rig_get_dcs_sql(rig, RIG_VFO_CURR, &chan->dcs_sql);
/* rig_get_mem_name(rig, RIG_VFO_CURR, chan->channel_desc); */
rig_ext_level_foreach(rig, generic_retr_extl, (rig_ptr_t)chan);
return RIG_OK;
}
/*
* Restores chan into current VFO state by emulating rig_set_channel
*/
int generic_restore_channel(RIG *rig, const channel_t *chan)
{
int i;
struct ext_list *p;
if (CHECK_RIG_ARG(rig) || !chan)
return -RIG_EINVAL;
rig_set_vfo(rig, chan->vfo);
rig_set_freq(rig, RIG_VFO_CURR, chan->freq);
rig_set_mode(rig, RIG_VFO_CURR, chan->mode, chan->width);
rig_set_split(rig, RIG_VFO_CURR, chan->split);
if (chan->split != RIG_SPLIT_OFF) {
rig_set_split_freq(rig, RIG_VFO_CURR, chan->tx_freq);
rig_set_split_mode(rig, RIG_VFO_CURR, chan->tx_mode, chan->tx_width);
}
rig_set_rptr_shift(rig, RIG_VFO_CURR, chan->rptr_shift);
rig_set_rptr_offs(rig, RIG_VFO_CURR, chan->rptr_offs);
for (i=0; i<RIG_SETTING_MAX; i++)
rig_set_level(rig, RIG_VFO_CURR, rig_idx2setting(i), chan->levels[i]);
rig_set_ant(rig, RIG_VFO_CURR, chan->ant);
rig_set_ts(rig, RIG_VFO_CURR, chan->tuning_step);
rig_set_rit(rig, RIG_VFO_CURR, chan->rit);
rig_set_xit(rig, RIG_VFO_CURR, chan->xit);
for (i=0; i<RIG_SETTING_MAX; i++)
rig_set_func(rig, RIG_VFO_CURR, rig_idx2setting(i),
chan->funcs & rig_idx2setting(i));
rig_set_ctcss_tone(rig, RIG_VFO_CURR, chan->ctcss_tone);
rig_set_ctcss_sql(rig, RIG_VFO_CURR, chan->ctcss_sql);
rig_set_dcs_code(rig, RIG_VFO_CURR, chan->dcs_code);
rig_set_dcs_sql(rig, RIG_VFO_CURR, chan->dcs_sql);
/* rig_set_mem_name(rig, RIG_VFO_CURR, chan->channel_desc); */
for (p = chan->ext_levels; !RIG_IS_EXT_END(*p); p++)
rig_set_ext_level(rig, RIG_VFO_CURR, p->token, p->val);
return RIG_OK;
}
#endif /* !DOC_HIDDEN */
/**
* \brief set channel data
* \param rig The rig handle
* \param chan The location of data to set for this channel
*
* Sets the data associated with a channel. This channel can either
* be the state of a VFO specified by \a chan->vfo, or a memory channel
* specified with \a chan->vfo = RIG_VFO_MEM and \a chan->channel_num.
* See #channel_t for more information.
*
* The rig_set_channel is supposed to have no impact on the current VFO
* and memory number selected. Depending on backend and rig capabilities,
* the chan struct may not be set completely.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_get_channel()
*/
int rig_set_channel(RIG *rig, const channel_t *chan)
{
struct rig_caps *rc;
int curr_chan_num, get_mem_status = RIG_OK;
vfo_t curr_vfo;
vfo_t vfo; /* requested vfo */
int retcode;
#ifdef PARANOID_CHANNEL_HANDLING
channel_t curr_chan;
#endif
if (CHECK_RIG_ARG(rig) || !chan)
return -RIG_EINVAL;
/*
* TODO: check chan->channel_num is valid
*/
rc = rig->caps;
if (rc->set_channel)
return rc->set_channel(rig, chan);
/*
* if not available, emulate it
* Optional: get_vfo, set_vfo,
* TODO: check return codes
*/
vfo = chan->vfo;
if (vfo == RIG_VFO_MEM && !rc->set_mem)
return -RIG_ENAVAIL;
if (vfo == RIG_VFO_CURR)
return generic_restore_channel(rig, chan);
if (!rc->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
/* may be needed if the restore_channel has some side effects */
#ifdef PARANOID_CHANNEL_HANDLING
generic_save_channel(rig, &curr_chan);
#endif
if (vfo == RIG_VFO_MEM)
get_mem_status = rig_get_mem(rig, RIG_VFO_CURR, &curr_chan_num);
retcode = rig_set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
if (vfo == RIG_VFO_MEM)
rig_set_mem(rig, RIG_VFO_CURR, chan->channel_num);
retcode = generic_restore_channel(rig, chan);
/* restore current memory number */
if (vfo == RIG_VFO_MEM && get_mem_status == RIG_OK)
rig_set_mem(rig, RIG_VFO_CURR, curr_chan_num);
rig_set_vfo(rig, curr_vfo);
#ifdef PARANOID_CHANNEL_HANDLING
generic_restore_channel(rig, &curr_chan);
#endif
return retcode;
}
/**
* \brief get channel data
* \param rig The rig handle
* \param chan The location where to store the channel data
*
* Retrieves the data associated with a channel. This channel can either
* be the state of a VFO specified by \a chan->vfo, or a memory channel
* specified with \a chan->vfo = RIG_VFO_MEM and \a chan->channel_num.
* See #channel_t for more information.
*
* Example:
\code
channel_t chan;
int err;
chan->vfo = RIG_VFO_MEM;
chan->channel_num = 10;
err = rig_get_channel(rig, &chan);
if (err != RIG_OK)
error("get_channel failed: %s", rigerror(err));
\endcode
*
* The rig_get_channel is supposed to have no impact on the current VFO
* and memory number selected. Depending on backend and rig capabilities,
* the chan struct may not be filled in completely.
*
* Note: chan->ext_levels is a pointer to a newly mallocated memory.
* This is the responsability of the caller to manage and eventually
* free it.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_channel()
*/
int rig_get_channel(RIG *rig, channel_t *chan)
{
struct rig_caps *rc;
int curr_chan_num, get_mem_status = RIG_OK;
vfo_t curr_vfo;
vfo_t vfo; /* requested vfo */
int retcode;
#ifdef PARANOID_CHANNEL_HANDLING
channel_t curr_chan;
#endif
if (CHECK_RIG_ARG(rig) || !chan)
return -RIG_EINVAL;
/*
* TODO: check chan->channel_num is valid
*/
rc = rig->caps;
if (rc->get_channel)
return rc->get_channel(rig, chan);
/*
* if not available, emulate it
* Optional: get_vfo, set_vfo
* TODO: check return codes
*/
vfo = chan->vfo;
if (vfo == RIG_VFO_MEM && !rc->set_mem)
return -RIG_ENAVAIL;
if (vfo == RIG_VFO_CURR)
return generic_save_channel(rig, chan);
if (!rc->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
/* may be needed if the restore_channel has some side effects */
#ifdef PARANOID_CHANNEL_HANDLING
generic_save_channel(rig, &curr_chan);
#endif
if (vfo == RIG_VFO_MEM)
get_mem_status = rig_get_mem(rig, RIG_VFO_CURR, &curr_chan_num);
retcode = rig_set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
if (vfo == RIG_VFO_MEM)
rig_set_mem(rig, RIG_VFO_CURR, chan->channel_num);
retcode = generic_save_channel(rig, chan);
/* restore current memory number */
if (vfo == RIG_VFO_MEM && get_mem_status == RIG_OK)
rig_set_mem(rig, RIG_VFO_CURR, curr_chan_num);
rig_set_vfo(rig, curr_vfo);
#ifdef PARANOID_CHANNEL_HANDLING
generic_restore_channel(rig, &curr_chan);
#endif
return retcode;
}

1470
src/rig.c

Plik diff jest za duży Load Diff

612
src/settings.c 100644
Wyświetl plik

@ -0,0 +1,612 @@
/**
* \file src/settings.c
* \ingroup rig
* \brief func/level/parm interface
* \author Stephane Fillod
* \date 2000-2002
*
* Hamlib interface is a frontend implementing wrapper functions.
*/
/*
* Hamlib Interface - func/level/parm
* Copyright (c) 2000-2002 by Stephane Fillod
*
* $Id: settings.c,v 1.1 2002-11-04 22:21:42 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
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <hamlib/rig.h>
#ifndef DOC_HIDDEN
#define CHECK_RIG_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state)
#endif /* !DOC_HIDDEN */
/**
* \brief set a radio level setting
* \param rig The rig handle
* \param vfo The target VFO
* \param level The level setting
* \param val The value to set the level setting to
*
* Sets the level of a setting.
* The level value \a val can be a float or an integer. See #value_t
* for more information.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_has_set_level(), rig_get_level()
*/
int rig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
caps = rig->caps;
if (caps->set_level == NULL || !rig_has_set_level(rig,level))
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->set_level(rig, vfo, level, val);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->set_level(rig, vfo, level, val);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief get the value of a level
* \param rig The rig handle
* \param vfo The target VFO
* \param level The level setting
* \param val The location where to store the value of \a level
*
* Retrieves the value of a \a level.
* The level value \a val can be a float or an integer. See #value_t
* for more information.
*
* RIG_LEVEL_STRENGTH: \a val is an integer, representing the S Meter
* level in dB, according to the ideal S Meter scale. The ideal
* S Meter scale is as follow: S0=-54, S1=-48, S2=-42, S3=-36,
* S4=-30, S5=-24, S6=-18, S7=-12, S8=-6, S9=0, +10=10, +20=20,
* +30=30, +40=40, +50=50 and +60=60. This is the responsability
* of the backend to return values calibrated for this scale.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_has_get_level(), rig_set_level()
*/
int rig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig) || !val)
return -RIG_EINVAL;
caps = rig->caps;
if (caps->get_level == NULL || !rig_has_get_level(rig,level))
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->get_level(rig, vfo, level, val);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->get_level(rig, vfo, level, val);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief set a radio parameter
* \param rig The rig handle
* \param parm The parameter
* \param val The value to set the parameter to
*
* Sets a parameter.
* The parameter value \a val can be a float or an integer. See #value_t
* for more information.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_has_set_parm(), rig_get_parm()
*/
int rig_set_parm(RIG *rig, setting_t parm, value_t val)
{
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
if (rig->caps->set_parm == NULL || !rig_has_set_parm(rig,parm))
return -RIG_ENAVAIL;
return rig->caps->set_parm(rig, parm, val);
}
/**
* \brief get the value of a parameter
* \param rig The rig handle
* \param parm The parameter
* \param val The location where to store the value of \a parm
*
* Retrieves the value of a \a parm.
* The parameter value \a val can be a float or an integer. See #value_t
* for more information.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_has_get_parm(), rig_set_parm()
*/
int rig_get_parm(RIG *rig, setting_t parm, value_t *val)
{
if (CHECK_RIG_ARG(rig) || !val)
return -RIG_EINVAL;
if (rig->caps->get_parm == NULL || !rig_has_get_parm(rig,parm))
return -RIG_ENAVAIL;
return rig->caps->get_parm(rig, parm, val);
}
/**
* \brief check retrieval ability of level settings
* \param rig The rig handle
* \param level The level settings
*
* Checks if a rig is capable of *getting* a level setting.
* Since the \a level is an OR'ed bitwise argument, more than
* one level can be checked at the same time.
*
* EXAMPLE: if (rig_has_get_level(my_rig, RIG_LVL_STRENGTH)) disp_Smeter();
*
* \return a bit map of supported level settings that can be retrieved,
* otherwise 0 if none supported.
*
* \sa rig_has_set_level(), rig_get_level()
*/
setting_t rig_has_get_level(RIG *rig, setting_t level)
{
if (!rig || !rig->caps)
return 0;
return (rig->state.has_get_level & level);
}
/**
* \brief check settable ability of level settings
* \param rig The rig handle
* \param level The level settings
*
* Checks if a rig can *set* a level setting.
* Since the \a level is an OR'ed bitwise argument, more than
* one level can be check at the same time.
*
* EXAMPLE: if (rig_has_set_level(my_rig, RIG_LVL_RFPOWER)) crank_tx();
*
* \return a bit map of supported level settings that can be set,
* otherwise 0 if none supported.
*
* \sa rig_has_get_level(), rig_set_level()
*/
setting_t rig_has_set_level(RIG *rig, setting_t level)
{
if (!rig || !rig->caps)
return 0;
return (rig->state.has_set_level & level);
}
/**
* \brief check retrieval ability of parameter settings
* \param rig The rig handle
* \param parm The parameter settings
*
* Checks if a rig is capable of *getting* a parm setting.
* Since the \a parm is an OR'ed bitwise argument, more than
* one parameter can be checked at the same time.
*
* EXAMPLE: if (rig_has_get_parm(my_rig, RIG_PARM_ANN)) good4you();
*
* \return a bit map of supported parameter settings that can be retrieved,
* otherwise 0 if none supported.
*
* \sa rig_has_set_parm(), rig_get_parm()
*/
setting_t rig_has_get_parm(RIG *rig, setting_t parm)
{
if (!rig || !rig->caps)
return 0;
return (rig->state.has_get_parm & parm);
}
/**
* \brief check settable ability of parameter settings
* \param rig The rig handle
* \param parm The parameter settings
*
* Checks if a rig can *set* a parameter setting.
* Since the \a parm is an OR'ed bitwise argument, more than
* one parameter can be check at the same time.
*
* EXAMPLE: if (rig_has_set_parm(my_rig, RIG_PARM_ANN)) announce_all();
*
* \return a bit map of supported parameter settings that can be set,
* otherwise 0 if none supported.
*
* \sa rig_has_get_parm(), rig_set_parm()
*/
setting_t rig_has_set_parm(RIG *rig, setting_t parm)
{
if (!rig || !rig->caps)
return 0;
return (rig->state.has_set_parm & parm);
}
/**
* \brief check ability of radio functions
* \param rig The rig handle
* \param func The functions
*
* Checks if a rig supports a set of functions.
* Since the \a func is an OR'ed bitwise argument, more than
* one function can be checked at the same time.
*
* EXAMPLE: if (rig_has_get_func(my_rig,RIG_FUNC_FAGC)) disp_fagc_button();
*
* \return a bit map of supported functions,
* otherwise 0 if none supported.
*
* \sa rig_has_set_func(), rig_get_func()
*/
setting_t rig_has_get_func(RIG *rig, setting_t func)
{
if (!rig || !rig->caps)
return 0;
return (rig->state.has_get_func & func);
}
/**
* \brief check ability of radio functions
* \param rig The rig handle
* \param func The functions
*
* Checks if a rig supports a set of functions.
* Since the \a func is an OR'ed bitwise argument, more than
* one function can be checked at the same time.
*
* EXAMPLE: if (rig_has_set_func(my_rig,RIG_FUNC_FAGC)) disp_fagc_button();
*
* \return a bit map of supported functions,
* otherwise 0 if none supported.
*
* \sa rig_set_func(), rig_has_get_func()
*/
setting_t rig_has_set_func(RIG *rig, setting_t func)
{
if (!rig || !rig->caps)
return 0;
return (rig->state.has_set_func & func);
}
/**
* \brief activate/desactivate functions of radio
* \param rig The rig handle
* \param vfo The target VFO
* \param func The functions to activate
* \param status The status (on or off) to set to
*
* Activate/desactivate functions of the radio.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_get_func()
*/
int rig_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
caps = rig->caps;
if (caps->set_func == NULL || !rig_has_set_func(rig,func))
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->set_func(rig, vfo, func, status);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->set_func(rig, vfo, func, status);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief get the status of functions of the radio
* \param rig The rig handle
* \param vfo The target VFO
* \param func The functions to get the status
* \param status The location where to store the function status
*
* Retrieves the status of functions of the radio. Only the function bits
* set to 1 will be queried.
* On return, \a func will hold the status of functions (bit set to 1 =
* activated, bit set to 0 = desactivated).
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_func()
*/
int rig_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig) || !func)
return -RIG_EINVAL;
caps = rig->caps;
if (caps->get_func == NULL || !rig_has_get_func(rig,func))
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->get_func(rig, vfo, func, status);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->get_func(rig, vfo, func, status);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief set a radio level extra parameter
* \param rig The rig handle
* \param vfo The target VFO
* \param token The parameter
* \param val The value to set the parameter to
*
* Sets an level extra parameter.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_get_ext_level()
*/
int rig_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
caps = rig->caps;
if (caps->set_ext_level == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->set_ext_level(rig, vfo, token, val);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->set_ext_level(rig, vfo, token, val);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief get the value of a level extra parameter
* \param rig The rig handle
* \param vfo The target VFO
* \param token The parameter
* \param val The location where to store the value of \a token
*
* Retrieves the value of a level extra paramter associated with \a token.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_ext_level()
*/
int rig_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig) || !val)
return -RIG_EINVAL;
caps = rig->caps;
if (caps->get_ext_level == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->get_ext_level(rig, vfo, token, val);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->get_ext_level(rig, vfo, token, val);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief set a radio parm extra parameter
* \param rig The rig handle
* \param token The parameter
* \param val The value to set the parameter to
*
* Sets an parm extra parameter.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_get_ext_parm()
*/
int rig_set_ext_parm(RIG *rig, token_t token, value_t val)
{
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
if (rig->caps->set_ext_parm == NULL)
return -RIG_ENAVAIL;
return rig->caps->set_ext_parm(rig, token, val);
}
/**
* \brief get the value of a parm extra parameter
* \param rig The rig handle
* \param token The parameter
* \param val The location where to store the value of \a token
*
* Retrieves the value of a parm extra paramter associated with \a token.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_ext_parm()
*/
int rig_get_ext_parm(RIG *rig, token_t token, value_t *val)
{
if (CHECK_RIG_ARG(rig) || !val)
return -RIG_EINVAL;
if (rig->caps->get_ext_parm == NULL)
return -RIG_ENAVAIL;
return rig->caps->get_ext_parm(rig, token, val);
}
/**
* \brief basically convert setting_t expressed 2^n to n
* \param s The setting to convert to
*
* Converts a setting_t value expressed by 2^n to the value of n.
*
* \return the index such that 2^n is the setting, otherwise 0
* if the setting was not found.
*/
int rig_setting2idx(setting_t s)
{
int i;
for (i = 0; i<RIG_SETTING_MAX; i++) {
if (s & rig_idx2setting(i))
return i;
}
return 0;
}

Wyświetl plik

@ -1,15 +1,15 @@
/**
* \file src/tones.c
* \ingroup hamlib
* \brief CTCSS and DCS tables
* \ingroup rig
* \brief CTCSS and DCS interface and tables
* \author Stephane Fillod
* \date 2000-2002
*/
/*
* Hamlib Interface - CTCSS and DCS tables
* Copyright (c) 2000-2002 by Stephane Fillod and Frank Singleton
* Hamlib Interface - CTCSS and DCS interface and tables
* Copyright (c) 2000-2002 by Stephane Fillod
*
* $Id: tones.c,v 1.2 2002-02-12 22:15:27 fillods Exp $
* $Id: tones.c,v 1.3 2002-11-04 22:21:42 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
@ -37,12 +37,12 @@
* 52 CTCSS sub-audible tones
*/
const tone_t full_ctcss_list[] = {
600, 670, 693, 719, 744, 770, 797, 825, 854, 885, 915,
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1200, 1230, 1273,
1318, 1365, 1413, 1462, 1514, 1567, 1598, 1622, 1655, 1679,
1713, 1738, 1773, 1799, 1835, 1862, 1899, 1928, 1966, 1995,
2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541,
0,
600, 670, 693, 719, 744, 770, 797, 825, 854, 885, 915,
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1200, 1230, 1273,
1318, 1365, 1413, 1462, 1514, 1567, 1598, 1622, 1655, 1679,
1713, 1738, 1773, 1799, 1835, 1862, 1899, 1928, 1966, 1995,
2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541,
0,
};
/**
@ -53,27 +53,411 @@ const tone_t full_ctcss_list[] = {
* own caps. --SF
*/
const tone_t common_ctcss_list[] = {
670, 693, 719, 744, 770, 797, 825, 854, 885, 915,
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273,
1318, 1365, 1413, 1462, 1514, 1567, 1598, 1622, 1655, 1679,
1713, 1738, 1773, 1799, 1835, 1862, 1899, 1928, 1966, 1995,
2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541,
0,
670, 693, 719, 744, 770, 797, 825, 854, 885, 915,
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273,
1318, 1365, 1413, 1462, 1514, 1567, 1598, 1622, 1655, 1679,
1713, 1738, 1773, 1799, 1835, 1862, 1899, 1928, 1966, 1995,
2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541,
0,
};
/**
* 106 DCS codes
*/
const tone_t full_dcs_list[] = {
17, 23, 25, 26, 31, 32, 36, 43, 47, 50, 51, 53,
54, 65, 71, 72, 73, 74, 114, 115, 116, 122, 125, 131,
132, 134, 143, 145, 152, 155, 156, 162, 165, 172, 174, 205,
212, 223, 225, 226, 243, 244, 245, 246, 251, 252, 255, 261,
263, 265, 266, 271, 274, 306, 311, 315, 325, 331, 332, 343,
346, 351, 356, 364, 365, 371, 411, 412, 413, 423, 431, 432,
445, 446, 452, 454, 455, 462, 464, 465, 466, 503, 506, 516,
523, 526, 532, 546, 565, 606, 612, 624, 627, 631, 632, 654,
662, 664, 703, 712, 723, 731, 732, 734, 743, 754,
0,
17, 23, 25, 26, 31, 32, 36, 43, 47, 50, 51, 53,
54, 65, 71, 72, 73, 74, 114, 115, 116, 122, 125, 131,
132, 134, 143, 145, 152, 155, 156, 162, 165, 172, 174, 205,
212, 223, 225, 226, 243, 244, 245, 246, 251, 252, 255, 261,
263, 265, 266, 271, 274, 306, 311, 315, 325, 331, 332, 343,
346, 351, 356, 364, 365, 371, 411, 412, 413, 423, 431, 432,
445, 446, 452, 454, 455, 462, 464, 465, 466, 503, 506, 516,
523, 526, 532, 546, 565, 606, 612, 624, 627, 631, 632, 654,
662, 664, 703, 712, 723, 731, 732, 734, 743, 754,
0,
};
#ifndef DOC_HIDDEN
#define CHECK_RIG_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state)
#endif /* !DOC_HIDDEN */
/**
* \brief set CTCSS sub-tone frequency
* \param rig The rig handle
* \param vfo The target VFO
* \param tone The tone to set to
*
* Sets the current Continuous Tone Controlled Squelch System (CTCSS)
* sub-audible tone frequency.
* \note the \a tone integer is NOT in Hz, but in tenth of Hz! This way,
* if you want to set a subaudible tone of 88.5 Hz for example,
* then pass 885 to this function.
* Also, to disable Tone encoding, set \a tone to 0 (FIXME: not clear in API).
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_get_ctcss_tone(), rig_set_ctcss_sql()
*/
int rig_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
caps = rig->caps;
if (caps->set_ctcss_tone == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->set_ctcss_tone(rig, vfo, tone);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->set_ctcss_tone(rig, vfo, tone);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief get the current CTCSS sub-tone frequency
* \param rig The rig handle
* \param vfo The target VFO
* \param tone The location where to store the current tone
*
* Retrieves the current Continuous Tone Controlled Squelch System (CTCSS)
* sub-audible tone frequency.
* \note the \a *tone integer is NOT in Hz, but in tenth of Hz! This way,
* if the function rig_get_ctcss_tone() returns a subaudible tone of 885
* for example, then the real tone is 88.5 Hz.
* Also, a value of 0 for \a *tone means the Tone encoding is disabled.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_ctcss_tone(), rig_get_ctcss_sql()
*/
int rig_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig) || !tone)
return -RIG_EINVAL;
caps = rig->caps;
if (caps->get_ctcss_tone == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->get_ctcss_tone(rig, vfo, tone);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->get_ctcss_tone(rig, vfo, tone);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief set the current encoding DCS code
* \param rig The rig handle
* \param vfo The target VFO
* \param code The tone to set to
*
* Sets the current encoding Digitally-Coded Squelch code.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_get_dcs_code(), rig_set_dcs_sql()
*/
int rig_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
caps = rig->caps;
if (caps->set_dcs_code == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->set_dcs_code(rig, vfo, code);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->set_dcs_code(rig, vfo, code);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief get the current encoding DCS code
* \param rig The rig handle
* \param vfo The target VFO
* \param code The location where to store the current tone
*
* Retrieves the current encoding Digitally-Coded Squelch code.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_dcs_code(), rig_get_dcs_sql()
*/
int rig_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig) || !code)
return -RIG_EINVAL;
caps = rig->caps;
if (caps->get_dcs_code == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->get_dcs_code(rig, vfo, code);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->get_dcs_code(rig, vfo, code);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief set CTCSS squelch
* \param rig The rig handle
* \param vfo The target VFO
* \param tone The PL tone to set the squelch to
*
* Sets the current Continuous Tone Controlled Squelch System (CTCSS)
* sub-audible *squelch* tone.
* \note \a tone is NOT in Hz, but in tenth of Hz! This way,
* if you want to set subaudible squelch tone of 88.5 Hz for example,
* then pass 885 to this function.
* Also, to disable Tone squelch, set \a tone to 0 (FIXME: not clear in API).
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_get_ctcss_sql(), rig_set_ctcss_tone()
*/
int rig_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
caps = rig->caps;
if (caps->set_ctcss_sql == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->set_ctcss_sql(rig, vfo, tone);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->set_ctcss_sql(rig, vfo, tone);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief get the current CTCSS squelch
* \param rig The rig handle
* \param vfo The target VFO
* \param tone The location where to store the current tone
*
* Retrieves the current Continuous Tone Controlled Squelch System (CTCSS)
* sub-audible *squelch* tone.
* \note \a *tone is NOT in Hz, but in tenth of Hz! This way,
* if the function rig_get_ctcss_sql() returns a subaudible tone of 885
* for example, then the real tone is 88.5 Hz.
* Also, a value of 0 for \a tone means the Tone squelch is disabled.
*
* \return RIG_OK if the operation has been sucessful, otherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_ctcss_sql(), rig_get_ctcss_tone()
*/
int rig_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig) || !tone)
return -RIG_EINVAL;
caps = rig->caps;
if (caps->get_ctcss_sql == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->get_ctcss_sql(rig, vfo, tone);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->get_ctcss_sql(rig, vfo, tone);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief set the current DCS code
* \param rig The rig handle
* \param vfo The target VFO
* \param code The tone to set to
*
* Sets the current Digitally-Coded *Squelch* code.
*
* \return returns RIG_OK if the operation has been sucessful, ortherwise
* a negative value if an error occured (in which case, cause is set
* appropriately).
*
* \sa rig_get_dcs_sql(), rig_set_dcs_code()
*/
int rig_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig))
return -RIG_EINVAL;
caps = rig->caps;
if (caps->set_dcs_sql == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->set_dcs_sql(rig, vfo, code);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->set_dcs_sql(rig, vfo, code);
caps->set_vfo(rig, curr_vfo);
return retcode;
}
/**
* \brief get the current DCS code
* \param rig The rig handle
* \param vfo The target VFO
* \param code The location where to store the current tone
*
* Retrieves the current Digitally-Coded *Squelch* code.
*
* \return RIG_OK if the operation has been sucessful, ortherwise
* a negative value if an error occured (in which case, cause is
* set appropriately).
*
* \sa rig_set_dcs_sql(), rig_get_dcs_code()
*/
int rig_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *code)
{
const struct rig_caps *caps;
int retcode;
vfo_t curr_vfo;
if (CHECK_RIG_ARG(rig) || !code)
return -RIG_EINVAL;
caps = rig->caps;
if (caps->get_dcs_sql == NULL)
return -RIG_ENAVAIL;
if ((caps->targetable_vfo&RIG_TARGETABLE_ALL) ||
vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
return caps->get_dcs_sql(rig, vfo, code);
if (!caps->set_vfo)
return -RIG_ENTARGET;
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
if (retcode != RIG_OK)
return retcode;
retcode = caps->get_dcs_sql(rig, vfo, code);
caps->set_vfo(rig, curr_vfo);
return retcode;
}