kopia lustrzana https://github.com/Hamlib/Hamlib
extract set_dtr/set_rts to serve multiple purposes
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1377 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.4
rodzic
f78e4e655c
commit
36ce8141ca
52
src/serial.c
52
src/serial.c
|
@ -1,10 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* Hamlib Interface - serial communication low-level support
|
* Hamlib Interface - serial communication low-level support
|
||||||
* Copyright (c) 2000-2002 by Stephane Fillod and Frank Singleton
|
* Copyright (c) 2000-2003 by Stephane Fillod and Frank Singleton
|
||||||
* Parts of the PTT handling are derived from soundmodem, an excellent
|
* Parts of the PTT handling are derived from soundmodem, an excellent
|
||||||
* ham packet softmodem written by Thomas Sailer, HB9JNX.
|
* ham packet softmodem written by Thomas Sailer, HB9JNX.
|
||||||
*
|
*
|
||||||
* $Id: serial.c,v 1.28 2002-11-28 22:33:48 fillods Exp $
|
* $Id: serial.c,v 1.29 2003-02-23 22:36:30 fillods Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -424,37 +424,39 @@ int ser_close(port_t *p)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ser_set_rts(const port_t *p, int state)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
/*
|
||||||
|
* TODO: log error with 0x%lx GetLastError()
|
||||||
|
*/
|
||||||
|
return !EscapeCommFunction(p->handle, state ? SETRTS : CLRRTS);
|
||||||
|
#else
|
||||||
|
unsigned char y = TIOCM_RTS;
|
||||||
|
return ioctl(p->fd, state ? TIOCMBIS : TIOCMBIC, &y);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int ser_set_dtr(const port_t *p, int state)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
return !EscapeCommFunction(p->handle, state ? SETDTR : CLRDTR);
|
||||||
|
#else
|
||||||
|
unsigned char y = TIOCM_DTR;
|
||||||
|
return ioctl(p->fd, state ? TIOCMBIS : TIOCMBIC, &y);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* p is supposed to be &rig->state.pttport
|
* p is supposed to be &rig->state.pttport
|
||||||
*/
|
*/
|
||||||
int ser_ptt_set(port_t *p, ptt_t pttx)
|
int ser_ptt_set(port_t *p, ptt_t pttx)
|
||||||
{
|
{
|
||||||
switch(p->type.ptt) {
|
switch(p->type.ptt) {
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
|
||||||
/*
|
|
||||||
* TODO: log error with 0x%lx GetLastError()
|
|
||||||
*/
|
|
||||||
case RIG_PTT_SERIAL_RTS:
|
case RIG_PTT_SERIAL_RTS:
|
||||||
return !EscapeCommFunction(p->handle, pttx==RIG_PTT_ON ?
|
return ser_set_rts(p, pttx==RIG_PTT_ON);
|
||||||
SETRTS : CLRRTS);
|
|
||||||
|
|
||||||
case RIG_PTT_SERIAL_DTR:
|
case RIG_PTT_SERIAL_DTR:
|
||||||
return !EscapeCommFunction(p->handle, pttx==RIG_PTT_ON ?
|
return ser_set_dtr(p, pttx==RIG_PTT_ON);
|
||||||
SETDTR : CLRDTR);
|
|
||||||
#else
|
|
||||||
case RIG_PTT_SERIAL_RTS:
|
|
||||||
{
|
|
||||||
unsigned char y = TIOCM_RTS;
|
|
||||||
return ioctl(p->fd, pttx==RIG_PTT_ON ? TIOCMBIS : TIOCMBIC, &y);
|
|
||||||
}
|
|
||||||
|
|
||||||
case RIG_PTT_SERIAL_DTR:
|
|
||||||
{
|
|
||||||
unsigned char y = TIOCM_DTR;
|
|
||||||
return ioctl(p->fd, pttx==RIG_PTT_ON ? TIOCMBIS : TIOCMBIC, &y);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
rig_debug(RIG_DEBUG_ERR,"Unsupported PTT type %d\n",
|
rig_debug(RIG_DEBUG_ERR,"Unsupported PTT type %d\n",
|
||||||
p->type.ptt);
|
p->type.ptt);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Hamlib Interface - serial communication header
|
* Hamlib Interface - serial communication header
|
||||||
* Copyright (c) 2000-2002 by Stephane Fillod and Frank Singleton
|
* Copyright (c) 2000-2002 by Stephane Fillod and Frank Singleton
|
||||||
*
|
*
|
||||||
* $Id: serial.h,v 1.17 2002-03-07 22:49:00 fillods Exp $
|
* $Id: serial.h,v 1.18 2003-02-23 22:36:30 fillods Exp $
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify
|
* This library is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Library General Public License as
|
* it under the terms of the GNU Library General Public License as
|
||||||
|
@ -37,6 +37,8 @@ int ser_close(port_t *p);
|
||||||
int ser_ptt_set(port_t *p, ptt_t pttx);
|
int ser_ptt_set(port_t *p, ptt_t pttx);
|
||||||
int ser_ptt_get(port_t *p, ptt_t *pttx);
|
int ser_ptt_get(port_t *p, ptt_t *pttx);
|
||||||
int ser_dcd_get(port_t *p, dcd_t *dcdx);
|
int ser_dcd_get(port_t *p, dcd_t *dcdx);
|
||||||
|
int ser_set_rts(const port_t *p, int state);
|
||||||
|
int ser_set_dtr(const port_t *p, int state);
|
||||||
int par_open(port_t *p);
|
int par_open(port_t *p);
|
||||||
int par_close(port_t *p);
|
int par_close(port_t *p);
|
||||||
int par_ptt_set(port_t *p, ptt_t pttx);
|
int par_ptt_set(port_t *p, ptt_t pttx);
|
||||||
|
|
Ładowanie…
Reference in New Issue