Logo Search packages:      
Sourcecode: hamlib version File versions

int HAMLIB_API rig_get_ptt ( RIG rig,
vfo_t  vfo,
ptt_t ptt 
)

get the status of the PTT

Parameters:
rig The rig handle
vfo The target VFO
ptt The location where to store the status of the PTT
Retrieves the status of PTT (are we on the air?).

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_set_ptt()

Definition at line 1224 of file rig.c.

References caps, rig_state::current_vfo, rig_caps::get_ptt, par_ptt_get(), hamlib_port_t::ptt, rig_state::pttport, RIG_EINVAL, RIG_ENAVAIL, RIG_ENIMPL, RIG_ENTARGET, RIG_OK, RIG_PTT_NONE, RIG_PTT_OFF, RIG_PTT_ON, RIG_PTT_PARALLEL, RIG_PTT_RIG, RIG_PTT_SERIAL_DTR, RIG_PTT_SERIAL_RTS, RIG_VFO_CURR, ser_get_dtr(), ser_get_rts(), rig_caps::set_vfo, state, rig_caps::status, rig_caps::targetable_vfo, and hamlib_port_t::type.

{     
      const struct rig_caps *caps;
      int retcode, status;
      vfo_t curr_vfo;

      if (CHECK_RIG_ARG(rig) || !ptt)
            return -RIG_EINVAL;

      caps = rig->caps;

      switch (rig->state.pttport.type.ptt) {
      case RIG_PTT_RIG:
            if (caps->get_ptt == NULL)
                  return -RIG_ENIMPL;

            if ((caps->targetable_vfo&RIG_TARGETABLE_PURE) || 
                        vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
                  return caps->get_ptt(rig, vfo, ptt);
      
            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_ptt(rig, vfo, ptt);
            caps->set_vfo(rig, curr_vfo);
            return retcode;

            break;

      case RIG_PTT_SERIAL_RTS:
            if (caps->get_ptt)
                  return caps->get_ptt(rig, vfo, ptt);

            retcode = ser_get_rts(&rig->state.pttport, &status);
            *ptt = status ? RIG_PTT_ON : RIG_PTT_OFF;
            return retcode;

      case RIG_PTT_SERIAL_DTR:
            if (caps->get_ptt)
                  return caps->get_ptt(rig, vfo, ptt);

            retcode = ser_get_dtr(&rig->state.pttport, &status);
            *ptt = status ? RIG_PTT_ON : RIG_PTT_OFF;
            return retcode;

      case RIG_PTT_PARALLEL:
            if (caps->get_ptt)
                  return caps->get_ptt(rig, vfo, ptt);

            return par_ptt_get(&rig->state.pttport, ptt);

      case RIG_PTT_NONE:
            return -RIG_ENAVAIL;    /* not available */

      default:
            return -RIG_EINVAL;
      }

      return RIG_OK;
}


Generated by  Doxygen 1.6.0   Back to index