kopia lustrzana https://github.com/Hamlib/Hamlib
Move serial line control error checks to lower level routines
Moved in preference to introducing errno.h into rig.c.Hamlib-3.0
rodzic
0e0779877d
commit
4e2a6adf12
|
@ -537,10 +537,6 @@ int HAMLIB_API rig_open(RIG *rig)
|
||||||
status = ser_set_dtr(&rs->pttport, RIG_PTT_OFF);
|
status = ser_set_dtr(&rs->pttport, RIG_PTT_OFF);
|
||||||
else if (rs->pttport.type.ptt == RIG_PTT_SERIAL_RTS)
|
else if (rs->pttport.type.ptt == RIG_PTT_SERIAL_RTS)
|
||||||
status = ser_set_rts(&rs->pttport, RIG_PTT_OFF);
|
status = ser_set_rts(&rs->pttport, RIG_PTT_OFF);
|
||||||
if (status != RIG_OK)
|
|
||||||
{
|
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: Cannot set serial control line - %s\n", __func__, strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RIG_PTT_PARALLEL:
|
case RIG_PTT_PARALLEL:
|
||||||
|
|
54
src/serial.c
54
src/serial.c
|
@ -430,22 +430,29 @@ int ser_close(hamlib_port_t *p)
|
||||||
int HAMLIB_API ser_set_rts(hamlib_port_t *p, int state)
|
int HAMLIB_API ser_set_rts(hamlib_port_t *p, int state)
|
||||||
{
|
{
|
||||||
unsigned int y = TIOCM_RTS;
|
unsigned int y = TIOCM_RTS;
|
||||||
|
int rc;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: RTS=%d\n", __func__, state);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: RTS=%d\n", __func__, state);
|
||||||
|
|
||||||
#if defined(TIOCMBIS) && defined(TIOCMBIC)
|
#if defined(TIOCMBIS) && defined(TIOCMBIC)
|
||||||
return IOCTL(p->fd, state ? TIOCMBIS : TIOCMBIC, &y) < 0 ?
|
rc = IOCTL(p->fd, state ? TIOCMBIS : TIOCMBIC, &y);
|
||||||
-RIG_EIO : RIG_OK;
|
|
||||||
#else
|
#else
|
||||||
if (IOCTL(p->fd, TIOCMGET, &y) < 0) {
|
rc = IOCTL(p->fd, TIOCMGET, &y);
|
||||||
return -RIG_EIO;
|
if (rc >= 0)
|
||||||
}
|
{
|
||||||
if (state)
|
if (state)
|
||||||
y |= TIOCM_RTS;
|
y |= TIOCM_RTS;
|
||||||
else
|
else
|
||||||
y &= ~TIOCM_RTS;
|
y &= ~TIOCM_RTS;
|
||||||
return IOCTL(p->fd, TIOCMSET, &y) < 0 ? -RIG_EIO : RIG_OK;
|
rc = IOCTL(p->fd, TIOCMSET, &y);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (rc < 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: Cannot change RTS - %s\n", __func__, strerror(errno));
|
||||||
|
return -RIG_EIO;
|
||||||
|
}
|
||||||
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -473,22 +480,29 @@ int HAMLIB_API ser_get_rts(hamlib_port_t *p, int *state)
|
||||||
int HAMLIB_API ser_set_dtr(hamlib_port_t *p, int state)
|
int HAMLIB_API ser_set_dtr(hamlib_port_t *p, int state)
|
||||||
{
|
{
|
||||||
unsigned int y = TIOCM_DTR;
|
unsigned int y = TIOCM_DTR;
|
||||||
|
int rc;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: DTR=%d\n", __func__, state);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: DTR=%d\n", __func__, state);
|
||||||
|
|
||||||
#if defined(TIOCMBIS) && defined(TIOCMBIC)
|
#if defined(TIOCMBIS) && defined(TIOCMBIC)
|
||||||
return IOCTL(p->fd, state ? TIOCMBIS : TIOCMBIC, &y) < 0 ?
|
rc = IOCTL(p->fd, state ? TIOCMBIS : TIOCMBIC, &y);
|
||||||
-RIG_EIO : RIG_OK;
|
|
||||||
#else
|
#else
|
||||||
if (IOCTL(p->fd, TIOCMGET, &y) < 0) {
|
rc = IOCTL(p->fd, TIOCMGET, &y);
|
||||||
return -RIG_EIO;
|
if (rc >= 0)
|
||||||
}
|
{
|
||||||
if (state)
|
if (state)
|
||||||
y |= TIOCM_DTR;
|
y |= TIOCM_DTR;
|
||||||
else
|
else
|
||||||
y &= ~TIOCM_DTR;
|
y &= ~TIOCM_DTR;
|
||||||
return IOCTL(p->fd, TIOCMSET, &y) < 0 ? -RIG_EIO : RIG_OK;
|
rc = IOCTL(p->fd, TIOCMSET, &y);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (rc < 0)
|
||||||
|
{
|
||||||
|
rig_debug(RIG_DEBUG_ERR, "%s: Cannot change DTR - %s\n", __func__, strerror(errno));
|
||||||
|
return -RIG_EIO;
|
||||||
|
}
|
||||||
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Ładowanie…
Reference in New Issue