2000-10-01 14:24:47 +00:00
|
|
|
/*
|
2001-07-13 19:08:15 +00:00
|
|
|
* Hamlib Interface - serial communication low-level support
|
|
|
|
* Copyright (c) 2000,2001 by Stephane Fillod and Frank Singleton
|
|
|
|
* Parts of the PTT handling are derived from soundmodem, an excellent
|
|
|
|
* ham packet softmodem written by Thomas Sailer, HB9JNX.
|
2000-10-01 14:24:47 +00:00
|
|
|
*
|
2001-07-13 19:08:15 +00:00
|
|
|
* $Id: serial.c,v 1.16 2001-07-13 19:08:15 f4cfe Exp $
|
2000-10-01 14:24:47 +00:00
|
|
|
*
|
2001-07-13 19:08:15 +00:00
|
|
|
* This library is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of
|
|
|
|
* the License, or (at your option) any later version.
|
2001-02-11 23:16:07 +00:00
|
|
|
*
|
2001-07-13 19:08:15 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Library General Public License for more details.
|
2001-02-11 23:16:07 +00:00
|
|
|
*
|
2001-07-13 19:08:15 +00:00
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2000-10-01 14:24:47 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-02-09 23:08:20 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2000-10-01 14:24:47 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h> /* Standard input/output definitions */
|
|
|
|
#include <string.h> /* String function definitions */
|
|
|
|
#include <unistd.h> /* UNIX standard function definitions */
|
|
|
|
#include <fcntl.h> /* File control definitions */
|
|
|
|
#include <errno.h> /* Error number definitions */
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
2001-02-14 01:09:57 +00:00
|
|
|
#ifdef HAVE_TERMIOS_H
|
|
|
|
#include <termios.h> /* POSIX terminal control definitions */
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_TERMIO_H
|
|
|
|
#include <termio.h>
|
|
|
|
#else /* sgtty */
|
|
|
|
#include <sgtty.h>
|
|
|
|
#endif
|
|
|
|
|
2001-06-12 23:59:21 +00:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
2001-06-02 17:56:37 +00:00
|
|
|
/* for CTS/RTS and DTR/DSR control --SF */
|
|
|
|
#include <windows.h>
|
|
|
|
#include <winioctl.h>
|
2001-06-12 23:59:21 +00:00
|
|
|
#include <winbase.h>
|
2001-02-14 01:09:57 +00:00
|
|
|
#endif
|
|
|
|
|
2001-06-15 07:08:37 +00:00
|
|
|
#define HAMLIB_DLL
|
2000-10-08 21:46:09 +00:00
|
|
|
#include <hamlib/rig.h>
|
2000-10-01 14:24:47 +00:00
|
|
|
#include "serial.h"
|
|
|
|
#include "misc.h"
|
|
|
|
|
2001-02-09 23:08:20 +00:00
|
|
|
#ifdef HAVE_SYS_IOCCOM_H
|
|
|
|
#include <sys/ioccom.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
|
|
|
#include <linux/ppdev.h>
|
|
|
|
#endif
|
|
|
|
|
2000-10-01 14:24:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Open serial port using rig.state data
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* input: ptr to rig.state structure, with serial port
|
|
|
|
* populated. (eg: "/dev/ttyS1").
|
|
|
|
*
|
|
|
|
* returns:
|
|
|
|
*
|
|
|
|
* 0 if OK or negative value on error.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-06-05 18:08:30 +00:00
|
|
|
int serial_open(port_t *rp) {
|
2000-10-01 14:24:47 +00:00
|
|
|
|
|
|
|
int fd; /* File descriptor for the port */
|
|
|
|
speed_t speed; /* serial comm speed */
|
|
|
|
|
2001-02-14 01:09:57 +00:00
|
|
|
#ifdef HAVE_TERMIOS_H
|
|
|
|
struct termios options;
|
|
|
|
#elif defined(HAVE_TERMIO_H)
|
|
|
|
struct termio options;
|
|
|
|
#elif defined(HAVE_SGTTY_H)
|
|
|
|
struct sgttyb sg;
|
|
|
|
#else
|
|
|
|
#error "No term control supported!"
|
|
|
|
#endif
|
|
|
|
|
2001-06-05 18:08:30 +00:00
|
|
|
if (!rp)
|
2000-10-01 14:24:47 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open in Non-blocking mode. Watch for EAGAIN errors!
|
|
|
|
*/
|
2001-06-04 17:01:21 +00:00
|
|
|
fd = open(rp->path, O_RDWR | O_NOCTTY | O_NDELAY);
|
2000-10-01 14:24:47 +00:00
|
|
|
|
|
|
|
if (fd == -1) {
|
|
|
|
|
|
|
|
/* Could not open the port. */
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "serial_open: Unable to open %s - %s\n",
|
2001-06-04 17:01:21 +00:00
|
|
|
rp->path, strerror(errno));
|
2000-10-01 14:24:47 +00:00
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the current options for the port...
|
|
|
|
*/
|
|
|
|
|
2001-02-14 01:09:57 +00:00
|
|
|
#ifdef HAVE_TERMIOS_H
|
2000-10-01 14:24:47 +00:00
|
|
|
tcgetattr(fd, &options);
|
2001-02-14 01:09:57 +00:00
|
|
|
#elif defined(HAVE_TERMIO_H)
|
|
|
|
ioctl (fd, TCGETA, &options);
|
|
|
|
#else /* sgtty */
|
|
|
|
ioctl (fd, TIOCGETP, &sg);
|
|
|
|
#endif
|
2000-10-01 14:24:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the baud rates to requested values
|
|
|
|
*/
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
switch(rp->parm.serial.rate) {
|
2000-10-01 14:24:47 +00:00
|
|
|
case 300:
|
|
|
|
speed = B300; /* yikes... */
|
|
|
|
break;
|
|
|
|
case 1200:
|
|
|
|
speed = B1200;
|
|
|
|
break;
|
|
|
|
case 2400:
|
|
|
|
speed = B2400;
|
|
|
|
break;
|
|
|
|
case 4800:
|
|
|
|
speed = B4800;
|
|
|
|
break;
|
|
|
|
case 9600:
|
|
|
|
speed = B9600;
|
|
|
|
break;
|
|
|
|
case 19200:
|
|
|
|
speed = B19200;
|
|
|
|
break;
|
|
|
|
case 38400:
|
|
|
|
speed = B38400;
|
|
|
|
break;
|
|
|
|
case 57600:
|
|
|
|
speed = B57600; /* cool.. */
|
|
|
|
break;
|
2001-06-02 17:56:37 +00:00
|
|
|
case 115200:
|
|
|
|
speed = B115200; /* awsome! */
|
|
|
|
break;
|
2000-10-01 14:24:47 +00:00
|
|
|
default:
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "open_serial: unsupported rate specified: %d\n",
|
2001-06-04 17:01:21 +00:00
|
|
|
rp->parm.serial.rate);
|
2000-10-01 14:24:47 +00:00
|
|
|
close(fd);
|
|
|
|
return -RIG_ECONF;
|
|
|
|
}
|
2001-02-14 01:09:57 +00:00
|
|
|
/* TODO */
|
2000-10-01 14:24:47 +00:00
|
|
|
cfsetispeed(&options, speed);
|
|
|
|
cfsetospeed(&options, speed);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable the receiver and set local mode...
|
|
|
|
*/
|
|
|
|
|
|
|
|
options.c_cflag |= (CLOCAL | CREAD);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set data to requested values.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
switch(rp->parm.serial.data_bits) {
|
2000-10-01 14:24:47 +00:00
|
|
|
case 7:
|
|
|
|
options.c_cflag &= ~CSIZE;
|
|
|
|
options.c_cflag |= CS7;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
options.c_cflag &= ~CSIZE;
|
|
|
|
options.c_cflag |= CS8;
|
|
|
|
break;
|
|
|
|
default:
|
2001-06-04 17:01:21 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR,"open_serial: unsupported serial_data_bits "
|
|
|
|
"specified: %d\n", rp->parm.serial.data_bits);
|
2000-10-01 14:24:47 +00:00
|
|
|
close(fd);
|
|
|
|
return -RIG_ECONF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set stop bits to requested values.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
switch(rp->parm.serial.stop_bits) {
|
2000-10-01 14:24:47 +00:00
|
|
|
case 1:
|
|
|
|
options.c_cflag &= ~CSTOPB;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
options.c_cflag |= CSTOPB;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2001-06-04 17:01:21 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "open_serial: unsupported serial_stop_bits "
|
|
|
|
"specified: %d\n",
|
|
|
|
rp->parm.serial.stop_bits);
|
2000-10-01 14:24:47 +00:00
|
|
|
close(fd);
|
|
|
|
return -RIG_ECONF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set parity to requested values.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
switch(rp->parm.serial.parity) {
|
2000-10-01 14:24:47 +00:00
|
|
|
case RIG_PARITY_NONE:
|
|
|
|
options.c_cflag &= ~PARENB;
|
|
|
|
break;
|
|
|
|
case RIG_PARITY_EVEN:
|
|
|
|
options.c_cflag |= PARENB;
|
|
|
|
options.c_cflag &= ~PARODD;
|
|
|
|
break;
|
|
|
|
case RIG_PARITY_ODD:
|
|
|
|
options.c_cflag |= PARENB;
|
|
|
|
options.c_cflag |= PARODD;
|
|
|
|
break;
|
|
|
|
default:
|
2001-06-04 17:01:21 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "open_serial: unsupported serial_parity "
|
|
|
|
"specified: %d\n",
|
|
|
|
rp->parm.serial.parity);
|
2000-10-01 14:24:47 +00:00
|
|
|
close(fd);
|
|
|
|
return -RIG_ECONF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set flow control to requested mode
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
switch(rp->parm.serial.handshake) {
|
2000-10-01 14:24:47 +00:00
|
|
|
case RIG_HANDSHAKE_NONE:
|
|
|
|
options.c_cflag &= ~CRTSCTS;
|
|
|
|
options.c_iflag &= ~IXON;
|
|
|
|
break;
|
|
|
|
case RIG_HANDSHAKE_XONXOFF:
|
|
|
|
options.c_cflag &= ~CRTSCTS;
|
|
|
|
options.c_iflag |= IXON; /* Enable Xon/Xoff software handshaking */
|
|
|
|
break;
|
|
|
|
case RIG_HANDSHAKE_HARDWARE:
|
|
|
|
options.c_cflag |= CRTSCTS; /* Enable Hardware handshaking */
|
|
|
|
options.c_iflag &= ~IXON;
|
|
|
|
break;
|
|
|
|
default:
|
2001-06-04 17:01:21 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR, "open_serial: unsupported flow_control "
|
|
|
|
"specified: %d\n",
|
|
|
|
rp->parm.serial.handshake);
|
2000-10-01 14:24:47 +00:00
|
|
|
close(fd);
|
|
|
|
return -RIG_ECONF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Choose raw input, no preprocessing please ..
|
|
|
|
*/
|
|
|
|
|
2001-02-14 01:09:57 +00:00
|
|
|
#if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H)
|
2000-10-01 14:24:47 +00:00
|
|
|
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Choose raw output, no preprocessing please ..
|
|
|
|
*/
|
|
|
|
|
|
|
|
options.c_oflag &= ~OPOST;
|
|
|
|
|
2001-02-14 01:09:57 +00:00
|
|
|
#else /* sgtty */
|
|
|
|
sg.sg_flags = RAW;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-10-01 14:24:47 +00:00
|
|
|
/*
|
|
|
|
* Flush serial port
|
|
|
|
*/
|
|
|
|
|
|
|
|
tcflush(fd, TCIFLUSH);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finally, set the new options for the port...
|
|
|
|
*/
|
|
|
|
|
2001-02-14 01:09:57 +00:00
|
|
|
#ifdef HAVE_TERMIOS_H
|
2000-10-01 14:24:47 +00:00
|
|
|
if (tcsetattr(fd, TCSANOW, &options) == -1) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "open_serial: tcsetattr failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
close(fd);
|
|
|
|
return -RIG_ECONF; /* arg, so close! */
|
|
|
|
}
|
2001-02-14 01:09:57 +00:00
|
|
|
#elif defined(HAVE_TERMIO_H)
|
|
|
|
if (ioctl(fd, TCSETA, &options) == -1) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "open_serial: ioctl(TCSETA) failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
close(fd);
|
|
|
|
return -RIG_ECONF; /* arg, so close! */
|
|
|
|
}
|
|
|
|
#else /* sgtty */
|
|
|
|
if (ioctl(fd, TIOCSETP, &sg) == -1) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "open_serial: ioctl(TIOCSETP) failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
close(fd);
|
|
|
|
return -RIG_ECONF; /* arg, so close! */
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-10 22:19:08 +00:00
|
|
|
rp->stream = fdopen(fd, "r+b");
|
|
|
|
if (rp->stream == NULL) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "open_serial: fdopen failed: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
close(fd);
|
|
|
|
return -RIG_EIO; /* arg, so close! */
|
|
|
|
}
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
rp->fd = fd;
|
2000-10-01 14:24:47 +00:00
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read "num" bytes from "fd" and put results into
|
|
|
|
* an array of unsigned char pointed to by "rxbuffer"
|
|
|
|
*
|
|
|
|
* Sleeps read_delay milliseconds until number of bytes to read
|
|
|
|
* is the amount requested.
|
|
|
|
*
|
|
|
|
* It then reads "num" bytes into rxbuffer.
|
|
|
|
*
|
|
|
|
* input:
|
|
|
|
* fd - file descriptor
|
|
|
|
* rxbuffer - ptr to rx buffer
|
|
|
|
* num - number of bytes to read
|
|
|
|
* read_delay - number of msec between read attempts
|
|
|
|
*
|
|
|
|
* returns:
|
|
|
|
*
|
|
|
|
* n - numbers of bytes read
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-06-02 17:56:37 +00:00
|
|
|
/* please, use read_block instead, and forget about non-portable FIONREAD */
|
|
|
|
#ifdef WANT_DEPRECATED_READSLEEP
|
2000-10-01 14:24:47 +00:00
|
|
|
|
|
|
|
int read_sleep(int fd, unsigned char *rxbuffer, int num , int read_delay) {
|
|
|
|
int bytes = 0;
|
|
|
|
int n = 0;
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_ERR,"serial:read_sleep called with num = %i \n",num);
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
ioctl(fd, FIONREAD, &bytes); /* get bytes in buffer */
|
|
|
|
rig_debug(RIG_DEBUG_TRACE,"bytes = %i\n", bytes);
|
|
|
|
if (bytes == num)
|
|
|
|
break;
|
|
|
|
usleep(read_delay*1000); /* sleep read_delay msecs */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this should not block now */
|
|
|
|
|
|
|
|
n = read(fd,rxbuffer,num); /* grab num bytes from rig */
|
|
|
|
|
|
|
|
dump_hex(rxbuffer,num);
|
|
|
|
return n; /* return bytes read */
|
|
|
|
}
|
|
|
|
|
2001-06-02 17:56:37 +00:00
|
|
|
#endif /* WANT_DEPRECATED_READSLEEP */
|
|
|
|
|
2000-10-01 14:24:47 +00:00
|
|
|
/*
|
|
|
|
* Write a block of count characters to file descriptor,
|
|
|
|
* with a pause between each character if write_delay is > 0
|
|
|
|
*
|
2000-10-09 01:17:20 +00:00
|
|
|
* The write_delay is for Yaesu type rigs..require 5 character
|
2000-10-01 14:24:47 +00:00
|
|
|
* sequence to be sent with 50-200msec between each char.
|
|
|
|
*
|
2000-10-09 01:17:20 +00:00
|
|
|
* Also, post_write_delay is for some Yaesu rigs (eg: FT747) that
|
|
|
|
* get confused with sequential fast writes between cmd sequences.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
2000-10-01 14:24:47 +00:00
|
|
|
* input:
|
|
|
|
*
|
|
|
|
* fd - file descriptor to write to
|
|
|
|
* txbuffer - pointer to a command sequence array
|
|
|
|
* count - count of byte to send from the txbuffer
|
|
|
|
* write_delay - write delay in ms between 2 chars
|
2000-10-23 19:58:14 +00:00
|
|
|
* post_write_delay - minimum delay between two writes
|
|
|
|
* post_write_date - timeval of last write
|
2000-10-01 14:24:47 +00:00
|
|
|
*
|
|
|
|
* returns:
|
|
|
|
*
|
|
|
|
* 0 = OK
|
|
|
|
* <0 = NOT OK
|
|
|
|
*
|
|
|
|
* Actually, this function has nothing specific to serial comm,
|
|
|
|
* it could work very well also with any file handle, like a socket.
|
|
|
|
*/
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
int write_block(port_t *p, const char *txbuffer, size_t count)
|
2000-10-01 14:24:47 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2000-10-23 19:58:14 +00:00
|
|
|
#ifdef WANT_NON_ACTIVE_POST_WRITE_DELAY
|
2001-06-04 17:01:21 +00:00
|
|
|
if (p->post_write_date.tv_sec != 0) {
|
2000-10-23 19:58:14 +00:00
|
|
|
signed int date_delay; /* in us */
|
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
/* FIXME in Y2038 ... */
|
|
|
|
gettimeofday(tv, NULL);
|
2001-06-04 17:01:21 +00:00
|
|
|
date_delay = p->post_write_delay*1000 -
|
|
|
|
((tv.tv_sec - p->post_write_date->tv_sec)*1000000 +
|
|
|
|
(tv.tv_usec - p->post_write_date->tv_usec));
|
2000-10-23 19:58:14 +00:00
|
|
|
if (date_delay > 0) {
|
|
|
|
/*
|
|
|
|
* optional delay after last write
|
|
|
|
*/
|
|
|
|
usleep(date_delay);
|
|
|
|
}
|
2001-06-04 17:01:21 +00:00
|
|
|
p->post_write_date.tv_sec = 0;
|
2000-10-23 19:58:14 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
if (p->write_delay > 0) {
|
2000-10-01 14:24:47 +00:00
|
|
|
for (i=0; i < count; i++) {
|
2001-06-04 17:01:21 +00:00
|
|
|
if (write(p->fd, txbuffer+i, 1) < 0) {
|
2000-10-23 19:58:14 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR,"write_block() failed - %s\n",
|
|
|
|
strerror(errno));
|
2000-10-01 14:24:47 +00:00
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
2001-06-04 17:01:21 +00:00
|
|
|
usleep(p->write_delay*1000);
|
2000-10-01 14:24:47 +00:00
|
|
|
}
|
|
|
|
} else {
|
2001-06-04 17:01:21 +00:00
|
|
|
write(p->fd, txbuffer, count);
|
2000-10-01 14:24:47 +00:00
|
|
|
}
|
2000-10-09 01:17:20 +00:00
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
if (p->post_write_delay > 0) {
|
2000-10-23 19:58:14 +00:00
|
|
|
#ifdef WANT_NON_ACTIVE_POST_WRITE_DELAY
|
|
|
|
#define POST_WRITE_DELAY_TRSHLD 10
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
if (p->post_write_delay > POST_WRITE_DELAY_TRSHLD)
|
|
|
|
gettimeofday(p->post_write_date, NULL);
|
2000-10-23 19:58:14 +00:00
|
|
|
else
|
2001-06-04 17:01:21 +00:00
|
|
|
#else
|
|
|
|
usleep(p->post_write_delay*1000); /* optional delay after last write */
|
2000-10-09 01:17:20 +00:00
|
|
|
/* otherwise some yaesu rigs get confused */
|
|
|
|
/* with sequential fast writes*/
|
2001-06-04 17:01:21 +00:00
|
|
|
#endif
|
2000-10-23 19:58:14 +00:00
|
|
|
}
|
2000-10-01 14:24:47 +00:00
|
|
|
rig_debug(RIG_DEBUG_TRACE,"TX %d bytes\n",count);
|
|
|
|
dump_hex(txbuffer,count);
|
|
|
|
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read "num" bytes from "fd" and put results into
|
|
|
|
* an array of unsigned char pointed to by "rxbuffer"
|
|
|
|
*
|
|
|
|
* Blocks on read until timeout hits.
|
|
|
|
*
|
|
|
|
* It then reads "num" bytes into rxbuffer.
|
|
|
|
*
|
|
|
|
* Actually, this function has nothing specific to serial comm,
|
|
|
|
* it could work very well also with any file handle, like a socket.
|
|
|
|
*/
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
int read_block(port_t *p, char *rxbuffer, size_t count)
|
2000-10-01 14:24:47 +00:00
|
|
|
{
|
|
|
|
fd_set rfds;
|
|
|
|
struct timeval tv, tv_timeout;
|
|
|
|
int rd_count, total_count = 0;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
FD_ZERO(&rfds);
|
2001-06-04 17:01:21 +00:00
|
|
|
FD_SET(p->fd, &rfds);
|
2000-10-01 14:24:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait up to timeout ms.
|
|
|
|
*/
|
2001-06-04 17:01:21 +00:00
|
|
|
tv_timeout.tv_sec = p->timeout/1000;
|
|
|
|
tv_timeout.tv_usec = (p->timeout%1000)*1000;
|
2000-10-01 14:24:47 +00:00
|
|
|
|
|
|
|
while (count > 0) {
|
|
|
|
tv = tv_timeout; /* select may have updated it */
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
retval = select(p->fd+1, &rfds, NULL, NULL, &tv);
|
2001-06-10 22:19:08 +00:00
|
|
|
if (retval == 0) {
|
|
|
|
rig_debug(RIG_DEBUG_WARN, "read_block: timedout after %d chars\n",
|
|
|
|
total_count);
|
2000-10-01 14:24:47 +00:00
|
|
|
return -RIG_ETIMEOUT;
|
|
|
|
}
|
2001-06-10 22:19:08 +00:00
|
|
|
if (retval < 0) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR,"read_block: select error after %d chars: "
|
|
|
|
"%s\n", total_count, strerror(errno));
|
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
2000-10-01 14:24:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* grab bytes from the rig
|
|
|
|
* The file descriptor must have been set up non blocking.
|
|
|
|
*/
|
2001-06-04 17:01:21 +00:00
|
|
|
rd_count = read(p->fd, rxbuffer+total_count, count);
|
2000-10-01 14:24:47 +00:00
|
|
|
if (rd_count < 0) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "read_block: read failed - %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
|
|
|
total_count += rd_count;
|
|
|
|
count -= rd_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_TRACE,"RX %d bytes\n",total_count);
|
|
|
|
dump_hex(rxbuffer, total_count);
|
|
|
|
return total_count; /* return bytes count read */
|
|
|
|
}
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
int fread_block(port_t *p, char *rxbuffer, size_t count)
|
2000-10-08 21:46:09 +00:00
|
|
|
{
|
|
|
|
fd_set rfds;
|
|
|
|
struct timeval tv, tv_timeout;
|
|
|
|
int rd_count, total_count = 0;
|
|
|
|
int retval;
|
|
|
|
int fd;
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
fd = fileno(p->stream);
|
2000-10-08 21:46:09 +00:00
|
|
|
|
|
|
|
FD_ZERO(&rfds);
|
|
|
|
FD_SET(fd, &rfds);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait up to timeout ms.
|
|
|
|
*/
|
2001-06-04 17:01:21 +00:00
|
|
|
tv_timeout.tv_sec = p->timeout/1000;
|
|
|
|
tv_timeout.tv_usec = (p->timeout%1000)*1000;
|
2000-10-08 21:46:09 +00:00
|
|
|
|
|
|
|
|
2001-06-10 22:19:08 +00:00
|
|
|
/*
|
|
|
|
* grab bytes from the rig
|
|
|
|
* The file descriptor must have been set up non blocking.
|
|
|
|
*/
|
|
|
|
rd_count = fread(rxbuffer, 1, count, p->stream);
|
|
|
|
if (rd_count < 0) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "read_block: read failed - %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
|
|
|
total_count += rd_count;
|
|
|
|
count -= rd_count;
|
2000-10-08 21:46:09 +00:00
|
|
|
|
|
|
|
while (count > 0) {
|
|
|
|
tv = tv_timeout; /* select may have updated it */
|
|
|
|
|
|
|
|
retval = select(fd+1, &rfds, NULL, NULL, &tv);
|
2001-06-10 22:19:08 +00:00
|
|
|
if (retval == 0) {
|
|
|
|
rig_debug(RIG_DEBUG_WARN, "fread_block: timedout after %d chars\n",
|
|
|
|
total_count);
|
2000-10-08 21:46:09 +00:00
|
|
|
return -RIG_ETIMEOUT;
|
|
|
|
}
|
2001-06-10 22:19:08 +00:00
|
|
|
if (retval < 0) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR,"fread_block: select error after %d chars: "
|
|
|
|
"%s\n", total_count, strerror(errno));
|
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
2000-10-08 21:46:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* grab bytes from the rig
|
|
|
|
* The file descriptor must have been set up non blocking.
|
|
|
|
*/
|
2001-06-04 17:01:21 +00:00
|
|
|
rd_count = fread(rxbuffer+total_count, 1, count, p->stream);
|
2000-10-08 21:46:09 +00:00
|
|
|
if (rd_count < 0) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "read_block: read failed - %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return -RIG_EIO;
|
|
|
|
}
|
|
|
|
total_count += rd_count;
|
|
|
|
count -= rd_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
rig_debug(RIG_DEBUG_TRACE,"RX %d bytes\n",total_count);
|
|
|
|
dump_hex(rxbuffer, total_count);
|
|
|
|
return total_count; /* return bytes count read */
|
|
|
|
}
|
|
|
|
|
2001-01-28 22:18:09 +00:00
|
|
|
/*
|
2001-02-09 23:08:20 +00:00
|
|
|
* ser_ptt_set and par_ptt_set
|
|
|
|
* ser_ptt_open/ser_ptt_close & par_ptt_open/par_ptt_close
|
|
|
|
*
|
2001-06-04 17:01:21 +00:00
|
|
|
* ser_open/ser_close,par_open/par_close to be used for PTT and DCD
|
|
|
|
*
|
|
|
|
* assumes: p is not NULL
|
2001-02-09 23:08:20 +00:00
|
|
|
*/
|
|
|
|
|
2001-06-15 07:08:37 +00:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
2001-06-04 17:01:21 +00:00
|
|
|
int ser_open(port_t *p)
|
2001-06-02 17:56:37 +00:00
|
|
|
{
|
2001-06-04 17:01:21 +00:00
|
|
|
const char *path = p->path;
|
2001-06-02 17:56:37 +00:00
|
|
|
HANDLE h;
|
|
|
|
DCB dcb;
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
h = CreateFile(path, GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
|
|
|
OPEN_EXISTING, 0, NULL);
|
2001-06-02 17:56:37 +00:00
|
|
|
if (h == INVALID_HANDLE_VALUE) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "Cannot open PTT device \"%s\"\n", path);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Check if it is a comm device */
|
|
|
|
if (!GetCommState(h, &dcb)) {
|
|
|
|
rig_debug(RIG_DEBUG_ERR, "Device \"%s\" not a COM device\n", path);
|
|
|
|
CloseHandle(h);
|
|
|
|
return -1;
|
|
|
|
}
|
2001-06-04 17:01:21 +00:00
|
|
|
p->handle = h;
|
|
|
|
return 0;
|
2001-06-02 17:56:37 +00:00
|
|
|
}
|
|
|
|
#else
|
2001-06-04 17:01:21 +00:00
|
|
|
int ser_open(port_t *p)
|
2001-02-09 23:08:20 +00:00
|
|
|
{
|
2001-06-04 17:01:21 +00:00
|
|
|
return (p->fd = open(p->path, O_RDWR | O_NOCTTY));
|
2001-02-09 23:08:20 +00:00
|
|
|
}
|
2001-06-02 17:56:37 +00:00
|
|
|
#endif
|
2001-02-09 23:08:20 +00:00
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
int ser_close(port_t *p)
|
2001-02-09 23:08:20 +00:00
|
|
|
{
|
2001-06-15 07:08:37 +00:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
2001-06-04 17:01:21 +00:00
|
|
|
return CloseHandle(p->handle);
|
|
|
|
#else
|
|
|
|
return close(p->fd);
|
2001-02-09 23:08:20 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
/*
|
|
|
|
* p is supposed to be &rig->state.pttport
|
|
|
|
*/
|
|
|
|
int ser_ptt_set(port_t *p, ptt_t pttx)
|
2001-01-28 22:18:09 +00:00
|
|
|
{
|
2001-06-04 17:01:21 +00:00
|
|
|
switch(p->type.ptt) {
|
2001-06-15 07:08:37 +00:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
2001-06-04 17:01:21 +00:00
|
|
|
/*
|
|
|
|
* TODO: log error with 0x%lx GetLastError()
|
|
|
|
*/
|
2001-06-02 17:56:37 +00:00
|
|
|
case RIG_PTT_SERIAL_RTS:
|
2001-06-04 17:01:21 +00:00
|
|
|
return !EscapeCommFunction(p->handle, pttx==RIG_PTT_ON ?
|
|
|
|
SETRTS : CLRRTS);
|
2001-06-02 17:56:37 +00:00
|
|
|
|
|
|
|
case RIG_PTT_SERIAL_DTR:
|
2001-06-04 17:01:21 +00:00
|
|
|
return !EscapeCommFunction(p->handle, pttx==RIG_PTT_ON ?
|
|
|
|
SETDTR : CLRDTR);
|
2001-06-02 17:56:37 +00:00
|
|
|
#else
|
2001-01-28 22:18:09 +00:00
|
|
|
case RIG_PTT_SERIAL_RTS:
|
2001-06-04 17:01:21 +00:00
|
|
|
{
|
|
|
|
unsigned char y = TIOCM_RTS;
|
|
|
|
return ioctl(p->fd, pttx==RIG_PTT_ON ? TIOCMBIS : TIOCMBIC, &y);
|
|
|
|
}
|
2001-01-28 22:18:09 +00:00
|
|
|
|
|
|
|
case RIG_PTT_SERIAL_DTR:
|
2001-06-04 17:01:21 +00:00
|
|
|
{
|
|
|
|
unsigned char y = TIOCM_DTR;
|
|
|
|
return ioctl(p->fd, pttx==RIG_PTT_ON ? TIOCMBIS : TIOCMBIC, &y);
|
|
|
|
}
|
2001-06-02 17:56:37 +00:00
|
|
|
#endif
|
2001-02-09 23:08:20 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
rig_debug(RIG_DEBUG_ERR,"Unsupported PTT type %d\n",
|
2001-06-04 17:01:21 +00:00
|
|
|
p->type.ptt);
|
2001-02-09 23:08:20 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
/*
|
|
|
|
* assumes pttx not NULL
|
|
|
|
*/
|
|
|
|
int ser_ptt_get(port_t *p, ptt_t *pttx)
|
2001-02-09 23:08:20 +00:00
|
|
|
{
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
switch(p->type.ptt) {
|
2001-06-15 07:08:37 +00:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
2001-06-04 17:01:21 +00:00
|
|
|
/* TODO... */
|
|
|
|
#else
|
|
|
|
case RIG_PTT_SERIAL_RTS:
|
2001-06-12 23:59:21 +00:00
|
|
|
{
|
|
|
|
unsigned char y;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status = ioctl(p->fd, TIOCMGET, &y);
|
|
|
|
*pttx = y & TIOCM_RTS ? RIG_PTT_ON:RIG_PTT_OFF;
|
|
|
|
return status;
|
|
|
|
}
|
2001-06-04 17:01:21 +00:00
|
|
|
|
|
|
|
case RIG_PTT_SERIAL_DTR:
|
2001-06-12 23:59:21 +00:00
|
|
|
{
|
|
|
|
unsigned char y;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status = ioctl(p->fd, TIOCMGET, &y);
|
|
|
|
*pttx = y & TIOCM_DTR ? RIG_PTT_ON:RIG_PTT_OFF;
|
|
|
|
return status;
|
|
|
|
}
|
2001-02-09 23:08:20 +00:00
|
|
|
#endif
|
|
|
|
default:
|
2001-06-04 17:01:21 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR,"Unsupported PTT type %d\n",
|
|
|
|
p->type.ptt);
|
2001-02-09 23:08:20 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-06-04 17:01:21 +00:00
|
|
|
* assumes dcdx not NULL
|
|
|
|
* p is supposed to be &rig->state.dcdport
|
2001-02-09 23:08:20 +00:00
|
|
|
*/
|
2001-06-04 17:01:21 +00:00
|
|
|
int ser_dcd_get(port_t *p, dcd_t *dcdx)
|
2001-02-09 23:08:20 +00:00
|
|
|
{
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
switch(p->type.dcd) {
|
2001-06-15 07:08:37 +00:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
2001-06-04 17:01:21 +00:00
|
|
|
/* TODO... */
|
2001-06-02 17:56:37 +00:00
|
|
|
#else
|
2001-06-04 17:01:21 +00:00
|
|
|
case RIG_DCD_SERIAL_CTS:
|
2001-06-12 23:59:21 +00:00
|
|
|
{
|
|
|
|
unsigned char y;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status = ioctl(p->fd, TIOCMGET, &y);
|
|
|
|
*dcdx = y & TIOCM_CTS ? RIG_DCD_ON:RIG_DCD_OFF;
|
|
|
|
return status;
|
|
|
|
}
|
2001-02-09 23:08:20 +00:00
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
case RIG_DCD_SERIAL_DSR:
|
2001-06-12 23:59:21 +00:00
|
|
|
{
|
|
|
|
unsigned char y;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status = ioctl(p->fd, TIOCMGET, &y);
|
|
|
|
*dcdx = y & TIOCM_DSR ? RIG_DCD_ON:RIG_DCD_OFF;
|
|
|
|
return status;
|
|
|
|
}
|
2001-06-02 17:56:37 +00:00
|
|
|
#endif
|
2001-02-09 23:08:20 +00:00
|
|
|
default:
|
2001-06-04 17:01:21 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR,"Unsupported DCD type %d\n",
|
|
|
|
p->type.dcd);
|
2001-02-09 23:08:20 +00:00
|
|
|
return -RIG_EINVAL;
|
|
|
|
}
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
|
|
|
|
|
2001-02-09 23:08:20 +00:00
|
|
|
/*
|
2001-06-04 17:01:21 +00:00
|
|
|
* TODO: to be called before exiting: atexit(parport_cleanup)
|
|
|
|
* void parport_cleanup() { ioctl(fd, PPRELEASE); }
|
2001-02-09 23:08:20 +00:00
|
|
|
*/
|
2001-06-04 17:01:21 +00:00
|
|
|
|
|
|
|
int par_open(port_t *p)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
fd = open(p->path, O_RDWR);
|
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
|
|
|
ioctl(fd, PPCLAIM);
|
|
|
|
#endif
|
|
|
|
p->fd = fd;
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
int par_close(port_t *p)
|
2001-02-09 23:08:20 +00:00
|
|
|
{
|
2001-06-04 17:01:21 +00:00
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
|
|
|
ioctl(p->fd, PPRELEASE);
|
|
|
|
#endif
|
|
|
|
return close(p->fd);
|
|
|
|
}
|
2001-01-28 22:18:09 +00:00
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
int par_ptt_set(port_t *p, ptt_t pttx)
|
|
|
|
{
|
|
|
|
switch(p->type.ptt) {
|
2001-02-09 23:08:20 +00:00
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
2001-01-28 22:18:09 +00:00
|
|
|
case RIG_PTT_PARALLEL:
|
|
|
|
{
|
|
|
|
unsigned char reg;
|
2001-02-14 01:09:57 +00:00
|
|
|
int status;
|
2001-01-28 22:18:09 +00:00
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
status = ioctl(p->fd, PPRDATA, ®);
|
|
|
|
if (pttx == RIG_PTT_ON)
|
|
|
|
reg |= 1 << p->parm.parallel.pin;
|
|
|
|
else
|
|
|
|
reg &= ~(1 << p->parm.parallel.pin);
|
|
|
|
|
|
|
|
return ioctl(p->fd, PPWDATA, ®);
|
2001-01-28 22:18:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
default:
|
2001-02-09 23:08:20 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR,"Unsupported PTT type %d\n",
|
2001-06-04 17:01:21 +00:00
|
|
|
p->type.ptt);
|
|
|
|
return -RIG_EINVAL;
|
2001-01-28 22:18:09 +00:00
|
|
|
}
|
2001-02-09 23:08:20 +00:00
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-14 01:09:57 +00:00
|
|
|
/*
|
2001-06-04 17:01:21 +00:00
|
|
|
* assumes pttx not NULL
|
2001-02-14 01:09:57 +00:00
|
|
|
*/
|
2001-06-04 17:01:21 +00:00
|
|
|
int par_ptt_get(port_t *p, ptt_t *pttx)
|
2001-02-14 01:09:57 +00:00
|
|
|
{
|
2001-06-04 17:01:21 +00:00
|
|
|
switch(p->type.ptt) {
|
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
|
|
|
case RIG_PTT_PARALLEL:
|
|
|
|
{
|
|
|
|
unsigned char reg;
|
|
|
|
int status;
|
2001-02-14 01:09:57 +00:00
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
status = ioctl(p->fd, PPRDATA, ®);
|
|
|
|
*pttx = reg & (1<<p->parm.parallel.pin) ?
|
|
|
|
RIG_PTT_ON:RIG_PTT_OFF;
|
|
|
|
return status;
|
|
|
|
}
|
2001-06-02 17:56:37 +00:00
|
|
|
#endif
|
2001-02-14 01:09:57 +00:00
|
|
|
default:
|
2001-06-04 17:01:21 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR,"Unsupported PTT type %d\n",
|
|
|
|
p->type.ptt);
|
|
|
|
return -RIG_ENAVAIL;
|
2001-02-14 01:09:57 +00:00
|
|
|
}
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* assumes dcdx not NULL
|
|
|
|
*/
|
2001-06-04 17:01:21 +00:00
|
|
|
int par_dcd_get(port_t *p, dcd_t *dcdx)
|
2001-02-14 01:09:57 +00:00
|
|
|
{
|
2001-06-04 17:01:21 +00:00
|
|
|
switch(p->type.dcd) {
|
2001-02-14 01:09:57 +00:00
|
|
|
#ifdef HAVE_LINUX_PPDEV_H
|
2001-02-15 00:00:11 +00:00
|
|
|
case RIG_DCD_PARALLEL:
|
2001-02-14 01:09:57 +00:00
|
|
|
{
|
|
|
|
unsigned char reg;
|
|
|
|
int status;
|
|
|
|
|
2001-06-04 17:01:21 +00:00
|
|
|
status = ioctl(p->fd, PPRDATA, ®);
|
|
|
|
*dcdx = reg & (1<<p->parm.parallel.pin) ?
|
|
|
|
RIG_DCD_ON:RIG_DCD_OFF;
|
2001-02-14 01:09:57 +00:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
default:
|
2001-02-15 00:00:11 +00:00
|
|
|
rig_debug(RIG_DEBUG_ERR,"Unsupported DCD type %d\n",
|
2001-06-04 17:01:21 +00:00
|
|
|
p->type.dcd);
|
2001-02-14 01:09:57 +00:00
|
|
|
return -RIG_ENAVAIL;
|
|
|
|
}
|
|
|
|
return RIG_OK;
|
|
|
|
}
|
2001-02-09 23:08:20 +00:00
|
|
|
|