From caed2d73a18bcff88792c3e4340bc0c87f477b0b Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 26 Jan 2020 14:53:04 +0000 Subject: [PATCH] Improved get PTT state handling in dummy backend --- dummy/dummy.c | 52 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/dummy/dummy.c b/dummy/dummy.c index cb3d479f1..5e5b9b52e 100644 --- a/dummy/dummy.c +++ b/dummy/dummy.c @@ -33,6 +33,8 @@ #include "hamlib/rig.h" #include "serial.h" #include "parallel.h" +#include "cm108.h" +#include "gpio.h" #include "misc.h" #include "tones.h" #include "idx_builtin.h" @@ -496,29 +498,57 @@ static int dummy_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) static int dummy_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; + int rc; int status = 0; - ptt_t par_status = RIG_PTT_OFF; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - *ptt = priv->ptt; // sneak a look at the hardware PTT and OR that in with our result // as if it had keyed us switch (rig->state.pttport.type.ptt) { - case RIG_PTT_SERIAL_DTR: if (rig->state.pttport.fd >= 0) ser_get_dtr( - &rig->state.pttport, &status); break; + case RIG_PTT_SERIAL_DTR: + if (rig->state.pttport.fd >= 0) + { + if (RIG_OK != (rc = ser_get_dtr(&rig->state.pttport, &status))) return rc; + *ptt = status ? RIG_PTT_ON : RIG_PTT_OFF; + } + break; - case RIG_PTT_SERIAL_RTS: if (rig->state.pttport.fd >= 0) ser_get_rts( - &rig->state.pttport, &status); break; + case RIG_PTT_SERIAL_RTS: + if (rig->state.pttport.fd >= 0) + { + if (RIG_OK != (rc = ser_get_rts(&rig->state.pttport, &status))) return rc; + *ptt = status ? RIG_PTT_ON : RIG_PTT_OFF; + } + break; - case RIG_PTT_PARALLEL: if (rig->state.pttport.fd >= 0) par_ptt_get( - &rig->state.pttport, &par_status); break; + case RIG_PTT_PARALLEL: + if (rig->state.pttport.fd >= 0) + { + if (RIG_OK != (rc = par_ptt_get(&rig->state.pttport, ptt))) return rc; + } + break; - default: break; + case RIG_PTT_CM108: + if (rig->state.pttport.fd >= 0) + { + if (RIG_OK != (rc = cm108_ptt_get(&rig->state.pttport, ptt))) return rc; + } + break; + + case RIG_PTT_GPIO: + case RIG_PTT_GPION: + if (rig->state.pttport.fd >= 0) + { + if (RIG_OK != (rc = gpio_ptt_get(&rig->state.pttport, ptt))) return rc; + } + break; + + default: + *ptt = priv->ptt; + break; } - - *ptt = *ptt || status || RIG_PTT_ON == par_status; return RIG_OK; }