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

int HAMLIB_API rot_open ( ROT rot  ) 

open the communication to the rot

rot The ROT handle of the rotator to be opened
Opens communication to a rotator which ROT handle has been passed by argument.

RIG_OK if the operation has been sucessful, otherwise a negative value if an error occured (in which case, cause is set appropriately).
Return values:
RIG_EINVAL rot is NULL or unconsistent.
RIG_ENIMPL port type communication is not implemented yet.
See also:
rot_init(), rot_close()

Definition at line 287 of file rotator.c.

References rot::caps, rot_state::comm_state, hamlib_port_t::fd, network_open(), par_open(), hamlib_port_t::pathname, hamlib_port_t::rig, RIG_DEBUG_VERBOSE, RIG_EINVAL, RIG_EIO, RIG_OK, RIG_PORT_DEVICE, RIG_PORT_NETWORK, RIG_PORT_NONE, RIG_PORT_PARALLEL, RIG_PORT_RPC, RIG_PORT_SERIAL, RIG_PORT_USB, rot_debug, rot_caps::rot_open, rot_state::rotport, serial_open(), rot::state, and hamlib_port_t::type.

      const struct rot_caps *caps;
      struct rot_state *rs;
      int status;

      rot_debug(RIG_DEBUG_VERBOSE,"rot:rot_open called \n");

      if (!rot || !rot->caps)
            return -RIG_EINVAL;

      caps = rot->caps;
      rs = &rot->state;

      if (rs->comm_state)
            return -RIG_EINVAL;

      rs->rotport.fd = -1;

      switch(rs->rotport.type.rig) {
      case RIG_PORT_SERIAL:
            status = serial_open(&rs->rotport);
            if (status != 0)
                        return status;

            status = par_open(&rs->rotport);
            if (status < 0)
                  return status;

      case RIG_PORT_DEVICE:
            status = open(rs->rotport.pathname, O_RDWR, 0);
            if (status < 0)
                  return -RIG_EIO;
            rs->rotport.fd = status;

      case RIG_PORT_USB:
            status = usb_port_open(&rs->rotport);
            if (status < 0)
                  return status;

      case RIG_PORT_NONE:
      case RIG_PORT_RPC:
                  break;      /* ez :) */

      case RIG_PORT_NETWORK:
            status = network_open(&rs->rotport, 4533);
            if (status < 0)
                  return status;

            return -RIG_EINVAL;


      rs->comm_state = 1;

       * Maybe the backend has something to initialize
       * In case of failure, just close down and report error code.
      if (caps->rot_open != NULL) {
            status = caps->rot_open(rot); 
            if (status != RIG_OK) {
                  return status;

      return RIG_OK;

Generated by  Doxygen 1.6.0   Back to index