Logo Search packages:      
Sourcecode: hamlib version File versions

static int tt565_get_level ( RIG rig,
vfo_t  vfo,
setting_t  level,
value_t val 
)

Get the current value of an Orion "level".

Parameters:
rig must be != NULL
vfo 
level identifier for level of interest
val Receives level's value, must != NULL
See also:
tt565_get_level Supported rx levels:
-RIG_LEVEL_SWR
-RIG_LEVEL_RAWSTR, int raw rx signal strength (rig units)
-RIG_LEVEL_RFPOWER
-RIG_LEVEL_AGC
-RIG_LEVEL_AF
-RIG_LEVEL_IF
-RIG_LEVEL_RF
-RIG_LEVEL_ATT
-RIG_LEVEL_PREAMP
-RIG_LEVEL_SQL
-RIG_LEVEL_MICGAIN
-RIG_LEVEL_COMP
-RIG_LEVEL_CWPITCH
-RIG_LEVEL_KEYSPED
-RIG_LEVEL_NR
-RIG_LEVEL_VOX
-RIG_LEVEL_VOXGAIN
-RIG_LEVEL_ANTIVOX
(RIG_LEVEL_STRENGTH, int calibrated signal strength (dB, S9 = 0) is handled in settings.c)

Definition at line 1107 of file orion.c.

References rig_caps::attenuator, rig::caps, EOM, value_t::f, value_t::i, rig_caps::preamp, RIG_AGC_USER, rig_debug(), RIG_DEBUG_ERR, RIG_EINVAL, RIG_EPROTO, RIG_LEVEL_AF, RIG_LEVEL_AGC, RIG_LEVEL_ANTIVOX, RIG_LEVEL_ATT, RIG_LEVEL_COMP, RIG_LEVEL_CWPITCH, RIG_LEVEL_IF, RIG_LEVEL_KEYSPD, RIG_LEVEL_MICGAIN, RIG_LEVEL_NR, RIG_LEVEL_PREAMP, RIG_LEVEL_RAWSTR, RIG_LEVEL_RF, RIG_LEVEL_RFPOWER, RIG_LEVEL_SQL, RIG_LEVEL_SWR, RIG_LEVEL_VOX, RIG_LEVEL_VOXGAIN, RIG_OK, RIG_VFO_SUB, tt565_transaction(), and which_receiver().

{
      int retval, cmd_len, lvl_len;
      char cmdbuf[TT565_BUFSIZE],lvlbuf[TT565_BUFSIZE];

      /* Optimize: sort the switch cases with the most frequent first */
      switch (level) {
      case RIG_LEVEL_SWR:
            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, "?S" EOM, 3, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            /* in Xmit, response is @STFuuuRvvvSwww (or ...Swwww)
                  uuu = 000-100 (apx) fwd watts
                        vvv = 000-100       rev watts
                        www = 256-999  256 * VSWR
               in Rcv,  response is @SRMuuuSvvv
                  uuu = 000-100 (apx) Main S meter
                        vvv = 000-100 (apx) Sub  S meter
            */

            if (lvlbuf[1] != 'S' || lvl_len < 5 ) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }
            if (lvlbuf[2]=='T') {
                  val->f = atof(strchr(lvlbuf+5,'S')+1)/256.0;
                  if (val->f < 1.0) val->f = 9.99;    /* high VSWR */
            }
                  else val->f = 0.0;      /* SWR in Receive = 0.0 */
            break;

      case RIG_LEVEL_RAWSTR:
            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, "?S" EOM, 3, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'S' || lvl_len < 5) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }

            if (lvlbuf[2] == 'R') {
                  val->i = atoi(strchr(lvlbuf+3,
                        vfo == RIG_VFO_SUB ? 'S' : 'M')+1);  /* check main/sub logic */
            }
                  else val->i = 0;  /* S-meter in xmit = 0 */
            break;

      case RIG_LEVEL_RFPOWER:
            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, "?TP" EOM, 4, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'T' || lvlbuf[2] != 'P' || lvl_len < 4) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }

            val->f = atof(lvlbuf+3)/100.0;
            break;

      case RIG_LEVEL_AGC:
            cmd_len = sprintf(cmdbuf, "?R%cA" EOM,
                        which_receiver(rig, vfo));

            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, cmdbuf, cmd_len, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'R' || lvlbuf[3] != 'A' || lvl_len < 5) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
                  }

            switch(lvlbuf[4]) {
                  case 'O': val->i=RIG_AGC_OFF; break;
                  case 'F': val->i=RIG_AGC_FAST; break;
                  case 'M': val->i=RIG_AGC_MEDIUM; break;
                  case 'S': val->i=RIG_AGC_SLOW; break;
                  case 'P': val->i=RIG_AGC_USER; break;
                  default:
                        return -RIG_EPROTO;
                  }
            break;

      case RIG_LEVEL_AF:
            cmd_len = sprintf(cmdbuf, "?U%c" EOM,
                        which_receiver(rig, vfo));

            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, cmdbuf, cmd_len, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'U' || lvl_len < 4) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }

            val->f = atof(lvlbuf+3)/255.0;
            break;

      case RIG_LEVEL_IF:
            cmd_len = sprintf(cmdbuf, "?R%cP" EOM,    /* passband tuning */
                        which_receiver(rig, vfo));

            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, cmdbuf, cmd_len, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'R' || lvlbuf[3] != 'P' || lvl_len < 5) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }

            val->i = atoi(lvlbuf+4);
            break;

      case RIG_LEVEL_RF:
            cmd_len = sprintf(cmdbuf, "?R%cG" EOM,
                        which_receiver(rig, vfo));

            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, cmdbuf, cmd_len, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'R' || lvlbuf[3] != 'G' || lvl_len < 5) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }

            val->f = atof(lvlbuf+4)/100.0;
            break;

      case RIG_LEVEL_ATT:
            cmd_len = sprintf(cmdbuf, "?R%cT" EOM,
                        which_receiver(rig, vfo));

            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, cmdbuf, cmd_len, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'R' || lvlbuf[3] != 'T' || lvl_len < 5) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }

            if (lvlbuf[4] == '0')
                  val->i = 0;
            else
                  val->i = rig->caps->attenuator[lvlbuf[4]-'1'];
            break;

      case RIG_LEVEL_PREAMP:
            /* Sub receiver does not contain a Preamp */
            if (which_receiver(rig, vfo) == 'S') {
                  val->i=0;
                  break;
            }
            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, "?RME" EOM, 5, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'R' || lvlbuf[3] != 'E' || lvl_len < 5) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }

            val->i = lvlbuf[4] == '0' ? 0 : rig->caps->preamp[0];
            break;

      case RIG_LEVEL_SQL:
            cmd_len = sprintf(cmdbuf, "?R%cS" EOM,
                        which_receiver(rig, vfo));

            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, cmdbuf, cmd_len, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'R' || lvlbuf[3] != 'S' || lvl_len < 5) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }

            val->f = (atof(lvlbuf+4)+127.0)/127.0;
            break;

      case RIG_LEVEL_MICGAIN:
            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, "?TM" EOM, 4, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'T' || lvlbuf[2] != 'M' || lvl_len < 4) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }

            val->f = atof(lvlbuf+3)/100.0;
            break;

      case RIG_LEVEL_COMP:
            lvl_len = sizeof(lvlbuf);     
            retval = tt565_transaction (rig, "?TS" EOM, 4, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'T' || lvlbuf[2] != 'S' || lvl_len < 4) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }

            val->f = atof(lvlbuf+3)/9.0;
            break;

      case RIG_LEVEL_CWPITCH:
            lvl_len = sizeof(lvlbuf);
            retval = tt565_transaction (rig, "?CT" EOM, 4, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'C' || lvlbuf[2] != 'T' || lvl_len < 4) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }
            val->i = atoi(lvlbuf+3);
            break;

      case RIG_LEVEL_KEYSPD:
            lvl_len = sizeof(lvlbuf);
            retval = tt565_transaction (rig, "?CS" EOM, 4, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;

            if (lvlbuf[1] != 'C' || lvlbuf[2] != 'S' || lvl_len < 4) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }
            val->i = atoi(lvlbuf+3);
            break;

      case RIG_LEVEL_NR:
            /* RIG_LEVEL_NR controls Orion NB setting - TEMP */
            cmd_len = sprintf(cmdbuf, "?R%cNB" EOM,
                                which_receiver(rig, vfo));
      
            lvl_len = sizeof(lvlbuf);
            retval = tt565_transaction (rig, cmdbuf, cmd_len, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;
            if (lvlbuf[1] != 'R' || lvlbuf[3] != 'N' || lvlbuf[4] != 'B' ||
                  lvl_len < 6 ) {
                        rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                              __FUNCTION__, lvlbuf);
                        return -RIG_EPROTO;
                  }
            val->f = atof(lvlbuf+5)/9.0;  /* Note 0-9 -> 0.0 - 1.0 */
            break;

      case RIG_LEVEL_VOX:     /* =VOXDELAY, tenths of secs. */
            lvl_len = sizeof(lvlbuf);
            retval = tt565_transaction (rig, "?TH" EOM, 4, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;
            if (lvlbuf[1] != 'T' || lvlbuf[2] != 'H' || lvl_len < 4) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                        __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }
            val->f = 10.0*atof(lvlbuf+3);
            break;

      case RIG_LEVEL_VOXGAIN: /* Float, 0.0 - 1.0 */
            lvl_len = sizeof(lvlbuf);
            retval = tt565_transaction (rig, "?TG" EOM, 4, lvlbuf, &lvl_len);
            if (retval != RIG_OK)
                  return retval;
            if (lvlbuf[1] != 'T' || lvlbuf[2] != 'G' || lvl_len < 4) {
                  rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                        __FUNCTION__, lvlbuf);
                  return -RIG_EPROTO;
            }
            val->f = 0.01 * atof(lvlbuf+3);
      break;

      case RIG_LEVEL_ANTIVOX: /* Float, 0.0 - 1.0 */
                lvl_len = sizeof(lvlbuf);
                retval = tt565_transaction (rig, "?TA" EOM, 4, lvlbuf, &lvl_len);
                if (retval != RIG_OK)
                        return retval;
                if (lvlbuf[1] != 'T' || lvlbuf[2] != 'A' || lvl_len < 4) {
                        rig_debug(RIG_DEBUG_ERR,"%s: unexpected answer '%s'\n",
                                __FUNCTION__, lvlbuf);
                        return -RIG_EPROTO;
                }
                val->f = 0.01 * atof(lvlbuf+3);
      break;

      default:
            rig_debug(RIG_DEBUG_ERR,"%s: unsupported level %d\n", 
                        __FUNCTION__, level);
            return -RIG_EINVAL;
      }

      return RIG_OK;
}


Generated by  Doxygen 1.6.0   Back to index