split serial_open in open and serial_setup

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1012 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.1.3
Stéphane Fillod, F8CFE 2002-03-07 22:49:00 +00:00
rodzic cdb57dbaf4
commit d5ef4f01b5
2 zmienionych plików z 45 dodań i 25 usunięć

Wyświetl plik

@ -1,10 +1,10 @@
/*
* Hamlib Interface - serial communication low-level support
* Copyright (c) 2000,2001,2002 by Stephane Fillod and Frank Singleton
* Copyright (c) 2000-2002 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.
*
* $Id: serial.c,v 1.24 2002-01-22 21:17:54 fillods Exp $
* $Id: serial.c,v 1.25 2002-03-07 22:49:00 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
@ -86,17 +86,7 @@
int serial_open(port_t *rp) {
int fd; /* File descriptor for the port */
speed_t speed; /* serial comm speed */
#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
int err;
if (!rp)
return -RIG_EINVAL;
@ -115,6 +105,45 @@ int serial_open(port_t *rp) {
return -RIG_EIO;
}
rp->fd = fd;
err = serial_setup(rp);
if (err != RIG_OK) {
close(fd);
return err;
}
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! */
}
return RIG_OK;
}
int serial_setup(port_t *rp)
{
speed_t speed; /* serial comm speed */
int fd;
#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
if (!rp)
return -RIG_EINVAL;
fd = rp->fd;
/*
* Get the current options for the port...
*/
@ -328,16 +357,6 @@ int serial_open(port_t *rp) {
}
#endif
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! */
}
rp->fd = fd;
return RIG_OK;
}

Wyświetl plik

@ -1,8 +1,8 @@
/*
* Hamlib Interface - serial communication header
* Copyright (c) 2000,2001 by Stephane Fillod and Frank Singleton
* Copyright (c) 2000-2002 by Stephane Fillod and Frank Singleton
*
* $Id: serial.h,v 1.16 2002-01-16 22:58:50 fillods Exp $
* $Id: serial.h,v 1.17 2002-03-07 22:49:00 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
@ -28,6 +28,7 @@
extern HAMLIB_EXPORT(int) serial_open(port_t *rs);
extern HAMLIB_EXPORT(int) serial_setup(port_t *rs);
extern HAMLIB_EXPORT(int) serial_flush(port_t *p);
/* Hamlib internal use, see rig.c */