* Added methods to test for get_freq, set_freq, get_mode,
      set_mode, get_ppt and set_ptt capability.
    * Interface allows use of a device that can set frequency but
      cannot get frequency, mode or ptt state such as the
      Elektor 3/04 receiver, a drm implementation.  getFreq method
      simply returns the last setFreq.
pull/2/head
David Freese 2009-11-07 07:10:10 -06:00
rodzic 2d95d82047
commit d85b974e3f
3 zmienionych plików z 72 dodań i 10 usunięć

Wyświetl plik

@ -35,6 +35,7 @@ protected:
class Rig {
protected:
RIG *rig; // Global ref. to the rig
freq_t fnull;
public:
Rig();
Rig(rig_model_t rig_model);
@ -52,12 +53,18 @@ public:
void setFreq(freq_t freq, vfo_t vfo = RIG_VFO_CURR);
freq_t getFreq(vfo_t vfo = RIG_VFO_CURR);
bool canSetFreq();
bool canGetFreq();
void setMode(rmode_t, pbwidth_t width = RIG_PASSBAND_NORMAL, vfo_t vfo = RIG_VFO_CURR);
rmode_t getMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
bool canSetMode();
bool canGetMode();
void setPTT (ptt_t ptt, vfo_t vfo = RIG_VFO_CURR);
ptt_t getPTT (vfo_t vfo = RIG_VFO_CURR);
bool canSetPTT();
bool canGetPTT();
void setVFO(vfo_t);
vfo_t getVFO();

Wyświetl plik

@ -217,12 +217,15 @@ bool hamlib_init(bool bPtt)
LOG_INFO("trying frequency request");
try {
need_freq = true;
freq = xcvr->getFreq();
if (freq == 0) {
xcvr->close();
show_error(__func__, "Rig not responding");
return false;
if ( !xcvr->canGetFreq() ) need_freq = true; // getFreq will return setFreq value
else {
need_freq = true;
freq = xcvr->getFreq();
if (freq == 0) {
xcvr->close();
show_error(__func__, "Rig not responding");
return false;
}
}
}
catch (const RigException& Ex) {
@ -231,8 +234,11 @@ bool hamlib_init(bool bPtt)
}
try {
need_mode = true;
mode = xcvr->getMode(width);
if ( !xcvr->canGetMode() ) need_mode = false;
else {
need_mode = true;
mode = xcvr->getMode(width);
}
}
catch (const RigException& Ex) {
show_error("Get Mode", Ex.what());
@ -242,7 +248,10 @@ bool hamlib_init(bool bPtt)
try {
if (hamlib_ptt == true) {
LOG_INFO("trying PTT");
xcvr->setPTT(RIG_PTT_OFF);
if (!xcvr->canSetPTT())
hamlib_ptt = false;
else
xcvr->setPTT(RIG_PTT_OFF);
}
}
catch (const RigException& Ex) {

Wyświetl plik

@ -21,6 +21,7 @@ Rig::Rig() : rig(0) { }
Rig::Rig(rig_model_t rig_model)
{
rig = rig_init(rig_model);
fnull = 3580.0;
if (!rig)
throw RigException ("Could not initialize rig");
}
@ -64,8 +65,42 @@ void Rig::close(void)
}
}
bool Rig::canSetFreq()
{
return (rig->caps->set_freq != NULL);
}
bool Rig::canGetFreq()
{
return (rig->caps->get_freq != NULL);
}
bool Rig::canSetMode()
{
return (rig->caps->set_mode != NULL);
}
bool Rig::canGetMode()
{
return (rig->caps->get_mode != NULL);
}
bool Rig::canSetPTT()
{
return (rig->caps->set_ptt != NULL);
}
bool Rig::canGetPTT()
{
return (rig->caps->get_ptt != NULL);
}
void Rig::setFreq(freq_t freq, vfo_t vfo)
{
fnull = freq;
if (!canSetFreq()) { // rig does not support set_freq
return;
}
int err;
for (int i = 0; i < NUMTRIES; i++) {
err = rig_set_freq(rig, vfo, freq);
@ -77,7 +112,10 @@ void Rig::setFreq(freq_t freq, vfo_t vfo)
freq_t Rig::getFreq(vfo_t vfo)
{
freq_t freq = 0;
if (!canGetFreq()) { // rig does not support get_freq
return fnull;
}
freq_t freq = fnull;
int i;
for (i = 0; i < NUMTRIES; i++)
if (rig_get_freq(rig, vfo, &freq) == RIG_OK)
@ -87,6 +125,8 @@ freq_t Rig::getFreq(vfo_t vfo)
void Rig::setMode(rmode_t mode, pbwidth_t width, vfo_t vfo)
{
if (!canSetMode())
throw RigException(RIG_ENAVAIL);
int err;
for (int i = 0; i < NUMTRIES; i++) {
if ((err = rig_set_mode(rig, vfo, mode, width)) == RIG_OK)
@ -97,6 +137,8 @@ void Rig::setMode(rmode_t mode, pbwidth_t width, vfo_t vfo)
rmode_t Rig::getMode(pbwidth_t& width, vfo_t vfo)
{
if (!canGetMode())
throw RigException(RIG_ENAVAIL);
int err;
rmode_t mode;
for (int i = 0; i < NUMTRIES; i++) {
@ -108,6 +150,8 @@ rmode_t Rig::getMode(pbwidth_t& width, vfo_t vfo)
void Rig::setPTT(ptt_t ptt, vfo_t vfo)
{
if (!canSetPTT())
throw RigException(RIG_ENAVAIL);
int err;
for (int i = 0; i < NUMTRIES; i++) {
if ((err = rig_set_ptt(rig, vfo, ptt)) == RIG_OK)
@ -118,6 +162,8 @@ void Rig::setPTT(ptt_t ptt, vfo_t vfo)
ptt_t Rig::getPTT(vfo_t vfo)
{
if (!canGetPTT())
throw RigException(RIG_ENAVAIL);
int err;
ptt_t ptt;
for (int i = 0; i < NUMTRIES; i++) {