Logo Search packages:      
Sourcecode: hamlib version File versions  Download package

int HAMLIB_API rig_get_level ( RIG rig,
vfo_t  vfo,
setting_t  level,
value_t val 
)

get the value of a level

Parameters:
rig The rig handle
vfo The target VFO
level The level setting
val The location where to store the value of level
Retrieves the value of a level. The level value val can be a float or an integer. See value_t for more information.

RIG_LEVEL_STRENGTH: 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.

Returns:
RIG_OK if the operation has been sucessful, otherwise a negative value if an error occured (in which case, cause is set appropriately).
See also:
rig_has_get_level(), rig_set_level()

Definition at line 131 of file settings.c.

References caps, rig_state::current_vfo, rig_caps::get_level, rig_caps::has_get_level, value_t::i, RIG_EINVAL, RIG_ENAVAIL, RIG_ENTARGET, rig_has_get_level(), RIG_LEVEL_RAWSTR, RIG_LEVEL_STRENGTH, RIG_OK, rig_raw2val(), RIG_VFO_CURR, rig_caps::set_vfo, state, rig_state::str_cal, and rig_caps::targetable_vfo.

{
      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;

      /*
       * Special case(frontend emulation): calibrated S-meter reading
       */
      if (level == RIG_LEVEL_STRENGTH && 
                  (caps->has_get_level & RIG_LEVEL_STRENGTH) == 0 &&
                  rig_has_get_level(rig,RIG_LEVEL_RAWSTR)) {

            value_t rawstr;
            retcode = rig_get_level(rig, vfo, RIG_LEVEL_RAWSTR, &rawstr);
            if (retcode != RIG_OK)
                  return retcode;
            val->i = (int)rig_raw2val(rawstr.i, &rig->state.str_cal);
            return RIG_OK;
      }


      if ((caps->targetable_vfo&RIG_TARGETABLE_PURE) ||
                  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;
}


Generated by  Doxygen 1.6.0   Back to index