Add more diagnostics and error checks to serial line control

Hamlib-3.0
Bill Somerville 2014-11-24 00:18:48 +00:00
rodzic e1a0e9121c
commit 0e0779877d
2 zmienionych plików z 13 dodań i 4 usunięć

Wyświetl plik

@ -480,7 +480,8 @@ int HAMLIB_API rig_open(RIG *rig)
rs->rigport.pathname);
return -RIG_ECONF;
}
if (!strcmp(rs->pttport.pathname, rs->rigport.pathname))
if ('\0' == rs->pttport.pathname[0]
|| !strcmp(rs->pttport.pathname, rs->rigport.pathname))
{
/* check for control line conflicts */
if (rs->rigport.parm.serial.rts_state != RIG_SIGNAL_UNSET &&
@ -529,13 +530,17 @@ int HAMLIB_API rig_open(RIG *rig)
status = -RIG_EIO;
}
}
if (RIG_OK == status)
if (RIG_OK == status)
{
/* Needed on Linux because the kernel forces RTS/DTR at open */
if (rs->pttport.type.ptt == RIG_PTT_SERIAL_DTR)
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)
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;
case RIG_PTT_PARALLEL:

Wyświetl plik

@ -431,6 +431,8 @@ int HAMLIB_API ser_set_rts(hamlib_port_t *p, int state)
{
unsigned int y = TIOCM_RTS;
rig_debug(RIG_DEBUG_VERBOSE, "%s: RTS=%d\n", __func__, state);
#if defined(TIOCMBIS) && defined(TIOCMBIC)
return IOCTL(p->fd, state ? TIOCMBIS : TIOCMBIC, &y) < 0 ?
-RIG_EIO : RIG_OK;
@ -472,6 +474,8 @@ int HAMLIB_API ser_set_dtr(hamlib_port_t *p, int state)
{
unsigned int y = TIOCM_DTR;
rig_debug(RIG_DEBUG_VERBOSE, "%s: DTR=%d\n", __func__, state);
#if defined(TIOCMBIS) && defined(TIOCMBIC)
return IOCTL(p->fd, state ? TIOCMBIS : TIOCMBIC, &y) < 0 ?
-RIG_EIO : RIG_OK;