kopia lustrzana https://github.com/Hamlib/Hamlib
new pp_write data/control helpers
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1485 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.2.0
rodzic
73655ad83b
commit
20efdcce8d
62
src/serial.c
62
src/serial.c
|
@ -4,7 +4,7 @@
|
||||||
* 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.31 2003-04-19 11:49:43 fillods Exp $
|
* $Id: serial.c,v 1.32 2003-06-22 19:50:36 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
|
||||||
|
@ -581,24 +581,68 @@ int par_close(port_t *p)
|
||||||
return close(p->fd);
|
return close(p->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int par_write_data(port_t *p, unsigned char data)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
#ifdef HAVE_LINUX_PPDEV_H
|
||||||
|
status = ioctl(p->fd, PPWDATA, &data);
|
||||||
|
return status == 0 ? RIG_OK : -RIG_EIO;
|
||||||
|
#endif
|
||||||
|
return -RIG_ENIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int par_read_data(port_t *p, unsigned char *data)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
#ifdef HAVE_LINUX_PPDEV_H
|
||||||
|
status = ioctl(p->fd, PPRDATA, data);
|
||||||
|
return status == 0 ? RIG_OK : -RIG_EIO;
|
||||||
|
#endif
|
||||||
|
return -RIG_ENIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int par_write_control(port_t *p, unsigned char control)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
#ifdef HAVE_LINUX_PPDEV_H
|
||||||
|
status = ioctl(p->fd, PPWCONTROL, &control);
|
||||||
|
return status == 0 ? RIG_OK : -RIG_EIO;
|
||||||
|
#endif
|
||||||
|
return -RIG_ENIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int par_read_control(port_t *p, unsigned char *control)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
#ifdef HAVE_LINUX_PPDEV_H
|
||||||
|
status = ioctl(p->fd, PPRCONTROL, control);
|
||||||
|
return status == 0 ? RIG_OK : -RIG_EIO;
|
||||||
|
#endif
|
||||||
|
return -RIG_ENIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int par_ptt_set(port_t *p, ptt_t pttx)
|
int par_ptt_set(port_t *p, ptt_t pttx)
|
||||||
{
|
{
|
||||||
switch(p->type.ptt) {
|
switch(p->type.ptt) {
|
||||||
#ifdef HAVE_LINUX_PPDEV_H
|
|
||||||
case RIG_PTT_PARALLEL:
|
case RIG_PTT_PARALLEL:
|
||||||
{
|
{
|
||||||
unsigned char reg;
|
unsigned char reg;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = ioctl(p->fd, PPRDATA, ®);
|
status = par_read_data(p, ®);
|
||||||
|
if (status != RIG_OK)
|
||||||
|
return status;
|
||||||
if (pttx == RIG_PTT_ON)
|
if (pttx == RIG_PTT_ON)
|
||||||
reg |= 1 << p->parm.parallel.pin;
|
reg |= 1 << p->parm.parallel.pin;
|
||||||
else
|
else
|
||||||
reg &= ~(1 << p->parm.parallel.pin);
|
reg &= ~(1 << p->parm.parallel.pin);
|
||||||
|
|
||||||
return ioctl(p->fd, PPWDATA, ®);
|
return par_write_data(p, reg);
|
||||||
}
|
}
|
||||||
#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);
|
||||||
|
@ -613,18 +657,16 @@ int par_ptt_set(port_t *p, ptt_t pttx)
|
||||||
int par_ptt_get(port_t *p, ptt_t *pttx)
|
int par_ptt_get(port_t *p, ptt_t *pttx)
|
||||||
{
|
{
|
||||||
switch(p->type.ptt) {
|
switch(p->type.ptt) {
|
||||||
#ifdef HAVE_LINUX_PPDEV_H
|
|
||||||
case RIG_PTT_PARALLEL:
|
case RIG_PTT_PARALLEL:
|
||||||
{
|
{
|
||||||
unsigned char reg;
|
unsigned char reg;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = ioctl(p->fd, PPRDATA, ®);
|
status = par_read_data(p, ®);
|
||||||
*pttx = reg & (1<<p->parm.parallel.pin) ?
|
*pttx = reg & (1<<p->parm.parallel.pin) ?
|
||||||
RIG_PTT_ON:RIG_PTT_OFF;
|
RIG_PTT_ON:RIG_PTT_OFF;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
#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);
|
||||||
|
@ -639,18 +681,16 @@ int par_ptt_get(port_t *p, ptt_t *pttx)
|
||||||
int par_dcd_get(port_t *p, dcd_t *dcdx)
|
int par_dcd_get(port_t *p, dcd_t *dcdx)
|
||||||
{
|
{
|
||||||
switch(p->type.dcd) {
|
switch(p->type.dcd) {
|
||||||
#ifdef HAVE_LINUX_PPDEV_H
|
|
||||||
case RIG_DCD_PARALLEL:
|
case RIG_DCD_PARALLEL:
|
||||||
{
|
{
|
||||||
unsigned char reg;
|
unsigned char reg;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = ioctl(p->fd, PPRDATA, ®);
|
status = par_read_data(p, ®);
|
||||||
*dcdx = reg & (1<<p->parm.parallel.pin) ?
|
*dcdx = reg & (1<<p->parm.parallel.pin) ?
|
||||||
RIG_DCD_ON:RIG_DCD_OFF;
|
RIG_DCD_ON:RIG_DCD_OFF;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
rig_debug(RIG_DEBUG_ERR,"Unsupported DCD type %d\n",
|
rig_debug(RIG_DEBUG_ERR,"Unsupported DCD type %d\n",
|
||||||
p->type.dcd);
|
p->type.dcd);
|
||||||
|
|
|
@ -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.18 2003-02-23 22:36:30 fillods Exp $
|
* $Id: serial.h,v 1.19 2003-06-22 19:50:36 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
|
||||||
|
@ -45,5 +45,10 @@ int par_ptt_set(port_t *p, ptt_t pttx);
|
||||||
int par_ptt_get(port_t *p, ptt_t *pttx);
|
int par_ptt_get(port_t *p, ptt_t *pttx);
|
||||||
int par_dcd_get(port_t *p, dcd_t *dcdx);
|
int par_dcd_get(port_t *p, dcd_t *dcdx);
|
||||||
|
|
||||||
|
extern HAMLIB_EXPORT(int) par_write_data(port_t *p, unsigned char data);
|
||||||
|
extern HAMLIB_EXPORT(int) par_write_control(port_t *p, unsigned char control);
|
||||||
|
extern HAMLIB_EXPORT(int) par_read_data(port_t *p, unsigned char *data);
|
||||||
|
extern HAMLIB_EXPORT(int) par_read_control(port_t *p, unsigned char *control);
|
||||||
|
|
||||||
#endif /* _SERIAL_H */
|
#endif /* _SERIAL_H */
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue