From 0e0779877d38e93312763d837e05723646d33ac7 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 24 Nov 2014 00:18:48 +0000 Subject: [PATCH] Add more diagnostics and error checks to serial line control --- src/rig.c | 13 +++++++++---- src/serial.c | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/rig.c b/src/rig.c index d32a65f15..c9db373ee 100644 --- a/src/rig.c +++ b/src/rig.c @@ -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: diff --git a/src/serial.c b/src/serial.c index 26b120d73..7dcfa1e0a 100644 --- a/src/serial.c +++ b/src/serial.c @@ -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;