2013-04-22 20:52:51 -04:00
|
|
|
/**
|
|
|
|
* \file src/rigclass.cc
|
|
|
|
* \brief Ham Radio Control Libraries C++ interface
|
|
|
|
* \author Stephane Fillod
|
|
|
|
* \date 2001-2003
|
|
|
|
*
|
|
|
|
* Hamlib C++ interface is a frontend implementing wrapper functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-04-28 10:47:45 -04:00
|
|
|
*
|
2013-04-22 20:52:51 -04:00
|
|
|
* Hamlib C++ bindings - main file
|
|
|
|
* Copyright (c) 2001-2003 by Stephane Fillod
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <hamlib/rig.h>
|
2013-04-28 10:47:45 -04:00
|
|
|
#include "rigclass.h"
|
2013-04-22 20:52:51 -04:00
|
|
|
|
2013-04-30 14:54:11 -04:00
|
|
|
|
2013-04-22 20:52:51 -04:00
|
|
|
static int hamlibpp_freq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg);
|
|
|
|
|
|
|
|
static int hamlibpp_freq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg)
|
|
|
|
{
|
|
|
|
if (!rig || !rig->state.obj)
|
|
|
|
return -RIG_EINVAL;
|
|
|
|
|
|
|
|
/* assert rig == ((Rig*)rig->state.obj).theRig */
|
|
|
|
return ((Rig*)rig->state.obj)->FreqEvent(vfo, freq, arg);
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:21:19 -04:00
|
|
|
Rig::Rig()
|
|
|
|
{
|
2013-04-26 18:06:22 -04:00
|
|
|
rig_set_debug_level( RIG_DEBUG_WARN);
|
2013-04-22 20:52:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Rig::~Rig() {
|
|
|
|
theRig->state.obj = NULL;
|
2013-04-30 15:55:13 -04:00
|
|
|
rig_cleanup(theRig);
|
2013-04-22 20:52:51 -04:00
|
|
|
caps = NULL;
|
|
|
|
}
|
|
|
|
|
2013-05-01 08:21:19 -04:00
|
|
|
int Rig::init(rig_model_t rig_model)
|
|
|
|
{
|
|
|
|
int initOk;
|
|
|
|
|
|
|
|
theRig = rig_init(rig_model);
|
|
|
|
if (!theRig)
|
|
|
|
initOk = false;
|
|
|
|
else
|
|
|
|
initOk = true;
|
|
|
|
|
|
|
|
caps = theRig->caps;
|
|
|
|
theRig->callbacks.freq_event = &hamlibpp_freq_event;
|
|
|
|
theRig->state.obj = (rig_ptr_t)this;
|
|
|
|
|
|
|
|
return initOk;
|
|
|
|
}
|
|
|
|
|
2013-04-30 14:54:11 -04:00
|
|
|
int Rig::open(void) {
|
2013-04-30 15:55:13 -04:00
|
|
|
return rig_open(theRig);
|
2013-04-22 20:52:51 -04:00
|
|
|
}
|
|
|
|
|
2013-04-30 14:54:11 -04:00
|
|
|
int Rig::close(void) {
|
2013-04-30 15:55:13 -04:00
|
|
|
return rig_close(theRig);
|
2013-04-22 20:52:51 -04:00
|
|
|
}
|
|
|
|
|
2013-04-30 14:54:11 -04:00
|
|
|
int Rig::setConf(const char *name, const char *val)
|
2013-04-22 20:52:51 -04:00
|
|
|
{
|
2013-04-30 15:55:13 -04:00
|
|
|
return rig_set_conf(theRig, tokenLookup(name), val);
|
2013-04-30 14:54:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int Rig::setFreq(freq_t freq, vfo_t vfo) {
|
2013-04-30 15:55:13 -04:00
|
|
|
return rig_set_freq(theRig, vfo, freq);
|
2013-04-30 14:54:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
freq_t Rig::getFreq(vfo_t vfo)
|
|
|
|
{
|
|
|
|
freq_t freq;
|
2013-04-30 15:55:13 -04:00
|
|
|
rig_get_freq(theRig, vfo, &freq);
|
2013-04-30 14:54:11 -04:00
|
|
|
return freq;
|
2013-04-22 20:52:51 -04:00
|
|
|
}
|
|
|
|
|
2013-04-30 15:55:13 -04:00
|
|
|
int Rig::setMode(rmode_t mode, pbwidth_t width, vfo_t vfo) {
|
|
|
|
return rig_set_mode(theRig, vfo, mode, width);
|
2013-04-22 20:52:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
rmode_t Rig::getMode(pbwidth_t& width, vfo_t vfo) {
|
|
|
|
rmode_t mode;
|
2013-04-30 15:55:13 -04:00
|
|
|
rig_get_mode(theRig, vfo, &mode, &width);
|
2013-04-22 20:52:51 -04:00
|
|
|
return mode;
|
|
|
|
}
|
|
|
|
|
2013-04-30 15:55:13 -04:00
|
|
|
int Rig::setVFO(vfo_t vfo)
|
2013-04-22 20:52:51 -04:00
|
|
|
{
|
2013-04-30 15:55:13 -04:00
|
|
|
return rig_set_vfo(theRig, vfo);
|
2013-04-22 20:52:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
vfo_t Rig::getVFO()
|
|
|
|
{
|
|
|
|
vfo_t vfo;
|
2013-04-30 15:55:13 -04:00
|
|
|
rig_get_vfo(theRig, &vfo);
|
2013-04-22 20:52:51 -04:00
|
|
|
return vfo;
|
|
|
|
}
|
|
|
|
|
2013-04-30 15:55:13 -04:00
|
|
|
int Rig::setPTT(ptt_t ptt, vfo_t vfo)
|
|
|
|
{
|
|
|
|
return rig_set_ptt(theRig, vfo, ptt);
|
|
|
|
}
|
2013-04-22 20:52:51 -04:00
|
|
|
|
|
|
|
ptt_t Rig::getPTT(vfo_t vfo)
|
|
|
|
{
|
|
|
|
ptt_t ptt;
|
2013-04-30 15:55:13 -04:00
|
|
|
rig_get_ptt(theRig, vfo, &ptt);
|
2013-04-22 20:52:51 -04:00
|
|
|
return ptt;
|
|
|
|
}
|
|
|
|
|
2013-04-30 15:55:13 -04:00
|
|
|
token_t Rig::tokenLookup(const char *name)
|
2013-04-22 20:52:51 -04:00
|
|
|
{
|
2013-04-30 15:55:13 -04:00
|
|
|
return rig_token_lookup(theRig, name);
|
2013-04-22 20:52:51 -04:00
|
|
|
}
|