From d9ab62445cd790acdfaafdb54183421a063a655d Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 1 Jun 2020 12:21:48 +0100 Subject: [PATCH] Deal with remote PTT type at the client end Remote PTT must always be either RIG_PTT_RIG_MICDATA or RIG_PTT_NONE. Also take care not to override any locally set PTT type as it is feasible to use a local hardware PTT at the client end with remote CAT control. Maybe an odd arrangement but Hamlib does not preclude it. This is all done while preserving the accuracy of the ptt_type value in dump_state requests. --- dummy/netrigctl.c | 14 +++++++++++--- tests/rigctl_parse.c | 3 +-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/dummy/netrigctl.c b/dummy/netrigctl.c index 4acb59786..52df37c68 100644 --- a/dummy/netrigctl.c +++ b/dummy/netrigctl.c @@ -539,9 +539,17 @@ static int netrigctl_open(RIG *rig) } else if (strcmp(setting, "ptt_type") == 0) { - rig->caps->ptt_type = strtol(value, NULL, 0); - rig->state.pttport.type.ptt = rig->caps->ptt_type; - rig_debug(RIG_DEBUG_TRACE, "%s: %s set to %d\n", __func__, setting, rig->caps->ptt_type); + ptt_type_t temp = (ptt_type_t)strtol(value, NULL, 0); + if (RIG_PTT_RIG_MICDATA == rig->state.pttport.type.ptt && RIG_PTT_NONE == temp) + { + /* + * remote PTT must always be RIG_PTT_RIG_MICDATA + * if there is any PTT capability and we have not + * locally overridden it + */ + rig->state.pttport.type.ptt = temp; + rig_debug(RIG_DEBUG_TRACE, "%s: %s set to %d\n", __func__, setting, rig->state.pttport.type.ptt); + } } else { diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 5b90a4681..d89985aa8 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -4080,8 +4080,7 @@ declare_proto_rig(dump_state) // protocol 1 fields can be multi-line -- just write the thing to allow for it // backward compatible as new values will just generate warnings fprintf(fout, "vfo_ops=0x%x\n", rig->caps->vfo_ops); - fprintf(fout, "ptt_type=0x%x\n", - rig->caps->ptt_type == RIG_PTT_NONE ? RIG_PTT_NONE : RIG_PTT_RIG_MICDATA); + fprintf(fout, "ptt_type=0x%x\n", rig->state.pttport.type.ptt); fprintf(fout, "done\n"); #if 0 // why isn't this implemented? Does anybody care?