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

int frontrot_set_conf ( ROT rot,
token_t  token,
const char *  val 
)

Set rotator state info from alpha input.

Parameters:
rot
tokenTOK_... specifying which info to set
valinput
Returns:
RIG_OK or < 0 error

assumes rot!=NULL, val!=NULL

Definition at line 125 of file rot_conf.c.

References rot::caps, rot_state::max_az, rot_state::max_el, rot_state::min_az, rot_state::min_el, hamlib_port_t::parm, hamlib_port_t::pathname, hamlib_port_t::post_write_delay, hamlib_port_t::retry, hamlib_port_t::rig, RIG_EINVAL, RIG_HANDSHAKE_HARDWARE, RIG_HANDSHAKE_NONE, RIG_HANDSHAKE_XONXOFF, RIG_OK, RIG_PARITY_EVEN, RIG_PARITY_MARK, RIG_PARITY_NONE, RIG_PARITY_ODD, RIG_PARITY_SPACE, RIG_PORT_SERIAL, rot_state::rotport, hamlib_port_t::serial, rot::state, hamlib_port_t::timeout, TOK_DATA_BITS, TOK_HANDSHAKE, TOK_MAX_AZ, TOK_MAX_EL, TOK_MIN_AZ, TOK_MIN_EL, TOK_PARITY, TOK_PATHNAME, TOK_POST_WRITE_DELAY, TOK_RETRY, TOK_SERIAL_SPEED, TOK_STOP_BITS, TOK_TIMEOUT, TOK_WRITE_DELAY, and hamlib_port_t::write_delay.

Referenced by rot_set_conf().

{
      const struct rot_caps *caps;
      struct rot_state *rs;
      int val_i;

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

      switch(token) {
      case TOK_PATHNAME:
            strncpy(rs->rotport.pathname, val, FILPATHLEN-1);
            break;
      case TOK_WRITE_DELAY:
            if (1 != sscanf(val, "%d", &val_i))
                  return -RIG_EINVAL;
            rs->rotport.write_delay = val_i;
            break;
      case TOK_POST_WRITE_DELAY:
            if (1 != sscanf(val, "%d", &val_i))
                  return -RIG_EINVAL;
            rs->rotport.post_write_delay = val_i;
            break;
      case TOK_TIMEOUT:
            if (1 != sscanf(val, "%d", &val_i))
                  return -RIG_EINVAL;
            rs->rotport.timeout = val_i;
            break;
      case TOK_RETRY:
            if (1 != sscanf(val, "%d", &val_i))
                  return -RIG_EINVAL;
            rs->rotport.retry = val_i;
            break;

      case TOK_SERIAL_SPEED:
            if (rs->rotport.type.rig != RIG_PORT_SERIAL)
                  return -RIG_EINVAL;
            if (1 != sscanf(val, "%d", &val_i))
                  return -RIG_EINVAL;
            rs->rotport.parm.serial.rate = val_i;
            break;
      case TOK_DATA_BITS:
            if (rs->rotport.type.rig != RIG_PORT_SERIAL)
                  return -RIG_EINVAL;
            if (1 != sscanf(val, "%d", &val_i))
                  return -RIG_EINVAL;
            rs->rotport.parm.serial.data_bits = val_i;
            break;
      case TOK_STOP_BITS:
            if (rs->rotport.type.rig != RIG_PORT_SERIAL)
                  return -RIG_EINVAL;
            if (1 != sscanf(val, "%d", &val_i))
                  return -RIG_EINVAL;
            rs->rotport.parm.serial.stop_bits = val_i;
            break;
      case TOK_PARITY:
            if (rs->rotport.type.rig != RIG_PORT_SERIAL)
                  return -RIG_EINVAL;
            if (!strcmp(val, "None"))
                  rs->rotport.parm.serial.parity = RIG_PARITY_NONE;
            else if (!strcmp(val, "Odd"))
                  rs->rotport.parm.serial.parity = RIG_PARITY_ODD;
            else if (!strcmp(val, "Even"))
                  rs->rotport.parm.serial.parity = RIG_PARITY_EVEN;
            else if (!strcmp(val, "Mark"))
                  rs->rotport.parm.serial.parity = RIG_PARITY_MARK;
            else if (!strcmp(val, "Space"))
                  rs->rotport.parm.serial.parity = RIG_PARITY_SPACE;
            else 
                  return -RIG_EINVAL;
            break;
      case TOK_HANDSHAKE:
            if (rs->rotport.type.rig != RIG_PORT_SERIAL)
                  return -RIG_EINVAL;
            if (!strcmp(val, "None"))
                  rs->rotport.parm.serial.handshake = RIG_HANDSHAKE_NONE;
            else if (!strcmp(val, "XONXOFF"))
                  rs->rotport.parm.serial.handshake = RIG_HANDSHAKE_XONXOFF;
            else if (!strcmp(val, "Hardware"))
                  rs->rotport.parm.serial.handshake = RIG_HANDSHAKE_HARDWARE;
            else 
                  return -RIG_EINVAL;
            break;

      case TOK_MIN_AZ:
            rs->min_az = atof(val);
            break;
      case TOK_MAX_AZ:
            rs->max_az = atof(val);
            break;
      case TOK_MIN_EL:
            rs->min_el = atof(val);
            break;
      case TOK_MAX_EL:
            rs->max_el = atof(val);
            break;

      default:
            return -RIG_EINVAL;
      }
      return RIG_OK;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index