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

int HAMLIB_API rig_mW2power ( RIG rig,
float *  power,
unsigned int  mwpower,
freq_t  freq,
rmode_t  mode 

conversion utility from absolute in mW to relative range

rigThe rig handle
powerThe location where to store the converted relative power
mwpowerThe power in mW
freqThe frequency where the conversion should take place
modeThe mode where the conversion should take place

Converts a power value expressed in the real transmit power in milli Watts the radio would emit to a range on a [0.0 .. 1.0] relative scale. The freq and mode where the conversion should take place must be also provided since the relative power is peculiar to a specific freq and mode range of the radio.

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:

Definition at line 2335 of file rig.c.

References caps, freq_range_list::high_power, RIG_ECONF, RIG_EINVAL, RIG_ETRUNC, rig_get_range(), RIG_OK, state, and rig_state::tx_range_list.

      const freq_range_t *txrange;

      if (!rig || !rig->caps || !power || mwpower<=0)
            return -RIG_EINVAL;

      if (rig->caps->mW2power != NULL)
            return rig->caps->mW2power(rig, power, mwpower, freq, mode);

      txrange = rig_get_range(rig->state.tx_range_list, freq, mode);
      if (!txrange) {
             * freq is not on the tx range!
            return -RIG_ECONF; /* could be RIG_EINVAL ? */
      if (txrange->high_power == 0) {
            *power = 0.0;
            return RIG_OK;
      *power = (float)mwpower / txrange->high_power;
      if (*power > 1.0)
            *power = 1.0;
      return (mwpower>txrange->high_power? RIG_OK : -RIG_ETRUNC);

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index