kopia lustrzana https://github.com/Hamlib/Hamlib
fixes to allow new RIG_PORT_PARALLEL
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1300 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.4
rodzic
aeb4d70336
commit
2bb4e81d09
|
@ -1,18 +1,8 @@
|
|||
/**
|
||||
* \file src/rotator.c
|
||||
* \ingroup rot
|
||||
* \brief Rotator interface
|
||||
* \author Stephane Fillod
|
||||
* \date 2000-2001
|
||||
*
|
||||
* Hamlib interface is a frontend implementing rotator wrapper functions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Hamlib Interface - main file
|
||||
* Copyright (c) 2000,2001 by Stephane Fillod and Frank Singleton
|
||||
* Copyright (c) 2000-2002 by Stephane Fillod and Frank Singleton
|
||||
*
|
||||
* $Id: rotator.c,v 1.8 2002-11-04 22:37:53 fillods Exp $
|
||||
* $Id: rotator.c,v 1.9 2002-11-28 22:33:48 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -30,6 +20,17 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file src/rotator.c
|
||||
* \ingroup rot
|
||||
* \brief Rotator interface
|
||||
* \author Stephane Fillod
|
||||
* \date 2000-2002
|
||||
*
|
||||
* Hamlib interface is a frontend implementing rotator wrapper functions.
|
||||
*/
|
||||
|
||||
|
||||
/*! \page rot Rotator interface
|
||||
*
|
||||
* Rotator can be any kind of azimuth or azimuth and elevation controlled
|
||||
|
@ -58,6 +59,7 @@
|
|||
#ifndef DOC_HIDDEN
|
||||
|
||||
#define DEFAULT_SERIAL_PORT "/dev/rotator"
|
||||
#define DEFAULT_PARALLEL_PORT "/dev/parport0"
|
||||
|
||||
#define CHECK_ROT_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state)
|
||||
|
||||
|
@ -189,17 +191,29 @@ ROT *rot_init(rot_model_t rot_model)
|
|||
|
||||
rs->comm_state = 0;
|
||||
rs->rotport.type.rig = caps->port_type; /* default from caps */
|
||||
|
||||
rs->rotport.write_delay = caps->write_delay;
|
||||
rs->rotport.post_write_delay = caps->post_write_delay;
|
||||
rs->rotport.timeout = caps->timeout;
|
||||
rs->rotport.retry = caps->retry;
|
||||
|
||||
switch (caps->port_type) {
|
||||
case RIG_PORT_SERIAL:
|
||||
strncpy(rs->rotport.pathname, DEFAULT_SERIAL_PORT, FILPATHLEN);
|
||||
rs->rotport.parm.serial.rate = caps->serial_rate_max; /* fastest ! */
|
||||
rs->rotport.parm.serial.data_bits = caps->serial_data_bits;
|
||||
rs->rotport.parm.serial.stop_bits = caps->serial_stop_bits;
|
||||
rs->rotport.parm.serial.parity = caps->serial_parity;
|
||||
rs->rotport.parm.serial.handshake = caps->serial_handshake;
|
||||
rs->rotport.write_delay = caps->write_delay;
|
||||
rs->rotport.post_write_delay = caps->post_write_delay;
|
||||
break;
|
||||
|
||||
rs->rotport.timeout = caps->timeout;
|
||||
rs->rotport.retry = caps->retry;
|
||||
case RIG_PORT_PARALLEL:
|
||||
strncpy(rs->rotport.pathname, DEFAULT_PARALLEL_PORT, FILPATHLEN);
|
||||
break;
|
||||
|
||||
default:
|
||||
strncpy(rs->rotport.pathname, "", FILPATHLEN);
|
||||
}
|
||||
|
||||
rs->min_el = caps->min_el;
|
||||
rs->max_el = caps->max_el;
|
||||
|
@ -271,6 +285,13 @@ int rot_open(ROT *rot)
|
|||
return status;
|
||||
break;
|
||||
|
||||
case RIG_PORT_PARALLEL:
|
||||
rs->rotport.stream = NULL;
|
||||
status = par_open(&rs->rotport);
|
||||
if (status < 0)
|
||||
return status;
|
||||
break;
|
||||
|
||||
case RIG_PORT_DEVICE:
|
||||
status = open(rs->rotport.pathname, O_RDWR, 0);
|
||||
if (status < 0)
|
||||
|
@ -352,10 +373,20 @@ int rot_close(ROT *rot)
|
|||
|
||||
|
||||
if (rs->rotport.fd != -1) {
|
||||
if (!rs->rotport.stream)
|
||||
fclose(rs->rotport.stream); /* this closes also fd */
|
||||
else
|
||||
close(rs->rotport.fd);
|
||||
if (rs->rotport.stream != NULL) {
|
||||
fclose(rs->rotport.stream); /* this closes also fd */
|
||||
} else {
|
||||
switch(rs->rotport.type.rig) {
|
||||
case RIG_PORT_SERIAL:
|
||||
ser_close(&rs->rotport);
|
||||
break;
|
||||
case RIG_PORT_PARALLEL:
|
||||
par_close(&rs->rotport);
|
||||
break;
|
||||
default:
|
||||
close(rs->rotport.fd);
|
||||
}
|
||||
}
|
||||
rs->rotport.fd = -1;
|
||||
rs->rotport.stream = NULL;
|
||||
}
|
||||
|
|
12
src/serial.c
12
src/serial.c
|
@ -4,7 +4,7 @@
|
|||
* Parts of the PTT handling are derived from soundmodem, an excellent
|
||||
* ham packet softmodem written by Thomas Sailer, HB9JNX.
|
||||
*
|
||||
* $Id: serial.c,v 1.27 2002-09-08 22:45:16 fillods Exp $
|
||||
* $Id: serial.c,v 1.28 2002-11-28 22:33:48 fillods Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -552,8 +552,16 @@ int par_open(port_t *p)
|
|||
int fd;
|
||||
|
||||
fd = open(p->pathname, O_RDWR);
|
||||
if (fd < 0) {
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "Opening device \"%s\": %s\n", p->pathname, strerror(errno));
|
||||
return -RIG_EIO;
|
||||
}
|
||||
#ifdef HAVE_LINUX_PPDEV_H
|
||||
ioctl(fd, PPCLAIM);
|
||||
if (ioctl(fd, PPCLAIM) < 0) {
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "Claiming device \"%s\": %s\n", p->pathname, strerror(errno));
|
||||
close(fd);
|
||||
return -RIG_EIO;
|
||||
}
|
||||
#endif
|
||||
p->fd = fd;
|
||||
return fd;
|
||||
|
|
Ładowanie…
Reference in New Issue