Open Parallel Port.
Definition at line 101 of file parallel.c. References hamlib_port_t::fd, hamlib_port_t::pathname, rig_debug(), RIG_DEBUG_ERR, RIG_EINVAL, RIG_EIO, and RIG_ENIMPL. Referenced by port_open(), rig_open(), and rot_open(). { int fd; int mode; if (!port->pathname) return -RIG_EINVAL; #ifdef HAVE_LINUX_PPDEV_H /* TODO: open with O_NONBLOCK ? */ fd = open(port->pathname, O_RDWR); if (fd < 0) { rig_debug(RIG_DEBUG_ERR, "Opening device \"%s\": %s\n", port->pathname, strerror(errno)); return -RIG_EIO; } mode = IEEE1284_MODE_COMPAT; if (ioctl (fd, PPSETMODE, &mode) != 0) { rig_debug(RIG_DEBUG_ERR, "PPSETMODE \"%s\": %s\n", port->pathname, strerror(errno)); close(fd); return -RIG_EIO; } #elif defined(HAVE_DEV_PPBUS_PPI_H) fd = open(port->pathname, O_RDWR); if (fd < 0) { rig_debug(RIG_DEBUG_ERR, "Opening device \"%s\": %s\n", port->pathname, strerror(errno)); return -RIG_EIO; } #elif defined(WIN32) fd = (int)CreateFile(port->pathname, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (fd == (int)INVALID_HANDLE_VALUE) { rig_debug(RIG_DEBUG_ERR, "Opening device \"%s\"\n", port->pathname); CloseHandle((HANDLE)fd); return -RIG_EIO; } #else return -RIG_ENIMPL; #endif port->fd = fd; return fd; }
|