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

int HAMLIB_API port_close ( hamlib_port_t p,
rig_port_t  port_type 
)

Close a hamlib_port.

Parameters:
p rig port descriptor
port_type equivalent rig port type
Returns:
status
This function may also be used with ptt and dcd ports.

Definition at line 144 of file iofunc.c.

References hamlib_port_t::fd, par_close(), rig_debug(), RIG_DEBUG_ERR, RIG_OK, RIG_PORT_DEVICE, RIG_PORT_NETWORK, RIG_PORT_PARALLEL, RIG_PORT_SERIAL, RIG_PORT_USB, and ser_close().

Referenced by rig_close().

{
    int ret = RIG_OK;

      if (p->fd != -1) {
            switch (port_type) {
            case RIG_PORT_SERIAL:
                  ret = ser_close(p);
                  break;
            case RIG_PORT_PARALLEL:
                  ret = par_close(p);
                  break;
            case RIG_PORT_USB:
                  ret = usb_port_close(p);
                  break;
            case RIG_PORT_NETWORK:
                  ret = network_close(p);
                  break;

            default:
                rig_debug(RIG_DEBUG_ERR, "%s: Unknown port type %d\n",
                                    __func__, port_type);
            /* fall through */
            case RIG_PORT_DEVICE:
                  ret = close(p->fd);
            }
            p->fd = -1;
      }

      return ret;
}


Generated by  Doxygen 1.6.0   Back to index