Logo Search packages:      
Sourcecode: hamlib version File versions

static int tt565_get_func ( RIG rig,
vfo_t  vfo,
setting_t  func,
int *  status 
)

get state of an Orion "function"

Parameters:
rig != NULL
vfo must == RIG_VFO_CURR
func 
status receives result of function query
Returns:
RIG_OK or < 0
See also:
tt565_set_func

Definition at line 1636 of file orion.c.

References EOM, rig_debug(), RIG_DEBUG_ERR, RIG_EINVAL, RIG_FUNC_LOCK, RIG_FUNC_NB, RIG_FUNC_TUNER, RIG_FUNC_VOX, RIG_OK, RIG_VFO_CURR, tt565_transaction(), which_receiver(), and which_vfo().

{
      char fcmdbuf[TT565_BUFSIZE], frespbuf[TT565_BUFSIZE];
      int retval, fcmdlen, fresplen;

      if (vfo != RIG_VFO_CURR)
            return -RIG_EINVAL;

      switch (func) {
      case RIG_FUNC_TUNER:
            fcmdlen = sprintf(fcmdbuf, "?TT" EOM);
            break;

      case RIG_FUNC_VOX:
            fcmdlen = sprintf(fcmdbuf, "?TV" EOM);
            break;

      case RIG_FUNC_LOCK:
            fcmdlen = sprintf(fcmdbuf, "?%cU" EOM, 
                  which_vfo(rig, vfo) );
            /* needs special treatment */
            fresplen = sizeof(frespbuf);
            retval = tt565_transaction(rig, fcmdbuf, fcmdlen, 
                  frespbuf, &fresplen);
            if (retval != RIG_OK)
                  return retval;
            /* response is @AL @AU or @BL @BU */
            *status = frespbuf[ 2 ] == 'L' ? 1:0;
            return RIG_OK;

      case RIG_FUNC_NB:
            /* Note NB should be a LEVEL for Orion. It is also
               available through LEVEL_NR
            */
            fcmdlen = sprintf(fcmdbuf, "?R%cNB" EOM,
                  which_receiver(rig, vfo) );
            /* needs special treatment */
            fresplen = sizeof(frespbuf);
            retval = tt565_transaction(rig, fcmdbuf, fcmdlen, 
                  frespbuf, &fresplen);
            if (retval != RIG_OK)
                  return retval;
            /* response is @RxNBn, n=0--9. Return 0 iff receive NB=0 */
            *status = frespbuf[ 5 ] == '0' ? 0:1;
            return RIG_OK;

      default:
            rig_debug(RIG_DEBUG_ERR,"Unsupported get_func %#x", func);
            return -RIG_EINVAL;
      }
      fresplen = sizeof(frespbuf);
      retval = tt565_transaction(rig, fcmdbuf, fcmdlen, frespbuf, &fresplen);
      if (retval != RIG_OK)
            return retval;
      *status = frespbuf[ 3 ] == '1' ? 1:0;
      return RIG_OK;
}


Generated by  Doxygen 1.6.0   Back to index