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

int HAMLIB_API serial_open ( hamlib_port_t rp  ) 

Open serial port using rig.state data.

Parameters:
rp port data structure (must spec port id eg /dev/ttyS1)
Returns:
RIG_OK or < 0 if error

Definition at line 91 of file serial.c.

References hamlib_port_t::fd, hamlib_port_t::pathname, rig_debug(), RIG_DEBUG_ERR, RIG_EINVAL, RIG_EIO, RIG_OK, and serial_setup().

Referenced by port_open(), and rot_open().

                                              {

  int fd;                     /* File descriptor for the port */
  int err;

  if (!rp)
              return -RIG_EINVAL;

  /*
   * Open in Non-blocking mode. Watch for EAGAIN errors!
   */
  fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY);

  if (fd == -1) {
    
    /* Could not open the port. */
    
    rig_debug(RIG_DEBUG_ERR, "serial_open: Unable to open %s - %s\n", 
                                    rp->pathname, strerror(errno));
    return -RIG_EIO;
  }
 
  rp->fd = fd;

  err = serial_setup(rp);
  if (err != RIG_OK) {
              CLOSE(fd);
              return err;
  }

  return RIG_OK;
}


Generated by  Doxygen 1.6.0   Back to index