From 3c5db5456fceb485532f5ba35acfdc9af44fac0c Mon Sep 17 00:00:00 2001 From: Stephane Fillod Date: Wed, 20 Jul 2011 00:09:50 +0200 Subject: [PATCH] Let set_ptt() select source, either TX mic or TX data (cherry picked from commit 421909bad2962b74cd7eddc07afec50dc6b80686) Signed-off-by: Nate Bargmann --- include/hamlib/rig.h | 9 ++++++--- kenwood/kenwood.c | 15 ++++++++++----- kenwood/ts480.c | 19 ++----------------- src/conf.c | 2 ++ src/rig.c | 22 ++++++++++++++-------- tests/dumpcaps.c | 3 +++ tests/rigctl.1 | 2 +- 7 files changed, 38 insertions(+), 34 deletions(-) diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 2b63fbc04..24be5099b 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -398,8 +398,10 @@ typedef enum { * \brief PTT status */ typedef enum { - RIG_PTT_OFF = 0, /*!< PTT activated */ - RIG_PTT_ON /*!< PTT desactivated */ + RIG_PTT_OFF = 0, /*!< PTT desactivated */ + RIG_PTT_ON, /*!< PTT activated */ + RIG_PTT_ON_MIC, /*!< PTT Mic only, fallbacks on RIG_PTT_ON if unavailable */ + RIG_PTT_ON_DATA /*!< PTT Data (Mic-muted), fallbacks on RIG_PTT_ON if unavailable */ } ptt_t; /** @@ -411,7 +413,8 @@ typedef enum { RIG_PTT_RIG, /*!< Legacy PTT */ RIG_PTT_SERIAL_DTR, /*!< PTT control through serial DTR signal */ RIG_PTT_SERIAL_RTS, /*!< PTT control through serial RTS signal */ - RIG_PTT_PARALLEL /*!< PTT control through parallel port */ + RIG_PTT_PARALLEL, /*!< PTT control through parallel port */ + RIG_PTT_RIG_MICDATA /*!< Legacy PTT, supports RIG_PTT_ON_MIC/RIG_PTT_ON_DATA */ } ptt_type_t; /** diff --git a/kenwood/kenwood.c b/kenwood/kenwood.c index f6aca38eb..6907514d8 100644 --- a/kenwood/kenwood.c +++ b/kenwood/kenwood.c @@ -1750,18 +1750,23 @@ int kenwood_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) return RIG_OK; } - -/* - * kenwood_set_ptt - */ int kenwood_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { + const char *ptt_cmd; + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); if (!rig) return -RIG_EINVAL; - return kenwood_simple_cmd(rig, (ptt == RIG_PTT_ON) ? "TX" : "RX"); + switch (ptt) { + case RIG_PTT_ON: ptt_cmd = "TX"; break; + case RIG_PTT_ON_MIC: ptt_cmd = "TX0"; break; + case RIG_PTT_ON_DATA: ptt_cmd = "TX1"; break; + case RIG_PTT_OFF: ptt_cmd = "RX"; break; + default: return -RIG_EINVAL; + } + return kenwood_simple_cmd(rig, ptt_cmd); } int kenwood_set_ptt_safe(RIG *rig, vfo_t vfo, ptt_t ptt) diff --git a/kenwood/ts480.c b/kenwood/ts480.c index 14655d74b..652207557 100644 --- a/kenwood/ts480.c +++ b/kenwood/ts480.c @@ -40,21 +40,6 @@ #define TS480_FUNC_ALL (RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_NR|RIG_FUNC_NR|RIG_FUNC_BC) -/* - * kenwood_ts480_set_ptt - * Assumes rig!=NULL - * - * set PTT with audio from data connector (NOT microphone!!!) - */ -static int -kenwood_ts480_set_ptt (RIG * rig, vfo_t vfo, ptt_t ptt) -{ - if (RIG_PTT_ON == ptt) - return kenwood_simple_cmd(rig, "TX1"); - - return kenwood_simple_cmd(rig, "RX"); -} - /* * kenwood_ts480_get_info * Assumes rig!=NULL @@ -278,7 +263,7 @@ const struct rig_caps ts480_caps = { .copyright = "LGPL", .status = RIG_STATUS_UNTESTED, .rig_type = RIG_TYPE_TRANSCEIVER, - .ptt_type = RIG_PTT_RIG, + .ptt_type = RIG_PTT_RIG_MICDATA, .dcd_type = RIG_DCD_RIG, .port_type = RIG_PORT_SERIAL, .serial_rate_min = 4800, @@ -396,7 +381,7 @@ const struct rig_caps ts480_caps = { .set_vfo = kenwood_set_vfo, .get_vfo = kenwood_get_vfo_if, .get_ptt = kenwood_get_ptt, - .set_ptt = kenwood_ts480_set_ptt, + .set_ptt = kenwood_set_ptt, .get_dcd = kenwood_get_dcd, .set_powerstat = kenwood_set_powerstat, .get_powerstat = kenwood_get_powerstat, diff --git a/src/conf.c b/src/conf.c index 0f732bcbb..7619ba560 100644 --- a/src/conf.c +++ b/src/conf.c @@ -282,6 +282,8 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) case TOK_PTT_TYPE: if (!strcmp(val, "RIG")) rs->pttport.type.ptt = RIG_PTT_RIG; + else if (!strcmp(val, "RIGMICDATA")) + rs->pttport.type.ptt = RIG_PTT_RIG_MICDATA; else if (!strcmp(val, "DTR")) rs->pttport.type.ptt = RIG_PTT_SERIAL_DTR; else if (!strcmp(val, "RTS")) diff --git a/src/rig.c b/src/rig.c index a86c1994f..f6f3b5b0c 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1,9 +1,8 @@ /* * Hamlib Interface - main file - * Copyright (c) 2000-2010 by Stephane Fillod + * Copyright (c) 2000-2011 by Stephane Fillod * Copyright (c) 2000-2003 by Frank Singleton * - * $Id: rig.c,v 1.103 2009-02-20 14:14:31 fillods Exp $ * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as @@ -31,7 +30,7 @@ * \brief Ham Radio Control Libraries interface * \author Stephane Fillod * \author Frank Singleton - * \date 2000-2010 + * \date 2000-2011 * * Hamlib provides a user-callable API, a set of "front-end" routines that * call rig-specific "back-end" routines which actually communicate with @@ -83,7 +82,7 @@ const char hamlib_version[21] = "Hamlib " PACKAGE_VERSION; * \brief Hamlib copyright notice */ const char hamlib_copyright[231] = /* hamlib 1.2 ABI specifies 231 bytes */ - "Copyright (C) 2000-2010 Stephane Fillod\n" + "Copyright (C) 2000-2011 Stephane Fillod\n" "Copyright (C) 2000-2003 Frank Singleton\n" "This is free software; see the source for copying conditions. There is NO\n" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."; @@ -471,6 +470,7 @@ int HAMLIB_API rig_open(RIG *rig) switch(rs->pttport.type.ptt) { case RIG_PTT_NONE: case RIG_PTT_RIG: + case RIG_PTT_RIG_MICDATA: break; case RIG_PTT_SERIAL_RTS: case RIG_PTT_SERIAL_DTR: @@ -611,6 +611,7 @@ int HAMLIB_API rig_close(RIG *rig) switch(rs->pttport.type.ptt) { case RIG_PTT_NONE: case RIG_PTT_RIG: + case RIG_PTT_RIG_MICDATA: break; case RIG_PTT_SERIAL_RTS: ser_set_rts(&rs->pttport, RIG_PTT_OFF); @@ -1136,12 +1137,16 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) switch (rig->state.pttport.type.ptt) { case RIG_PTT_RIG: + if (ptt == RIG_PTT_ON_MIC || ptt == RIG_PTT_ON_DATA) + ptt = RIG_PTT_ON; + /* fall through */ + case RIG_PTT_RIG_MICDATA: if (caps->set_ptt == NULL) - return -RIG_ENIMPL; + return -RIG_ENIMPL; if ((caps->targetable_vfo&RIG_TARGETABLE_PURE) || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) - return caps->set_ptt(rig, vfo, ptt); + return caps->set_ptt(rig, vfo, ptt); if (!caps->set_vfo) return -RIG_ENTARGET; @@ -1157,10 +1162,10 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) break; case RIG_PTT_SERIAL_DTR: - return ser_set_dtr(&rig->state.pttport, ptt==RIG_PTT_ON); + return ser_set_dtr(&rig->state.pttport, ptt!=RIG_PTT_OFF); case RIG_PTT_SERIAL_RTS: - return ser_set_rts(&rig->state.pttport, ptt==RIG_PTT_ON); + return ser_set_rts(&rig->state.pttport, ptt!=RIG_PTT_OFF); case RIG_PTT_PARALLEL: return par_ptt_set(&rig->state.pttport, ptt); @@ -1201,6 +1206,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) switch (rig->state.pttport.type.ptt) { case RIG_PTT_RIG: + case RIG_PTT_RIG_MICDATA: if (caps->get_ptt == NULL) return -RIG_ENIMPL; diff --git a/tests/dumpcaps.c b/tests/dumpcaps.c index 851dccf82..4d3a73d11 100644 --- a/tests/dumpcaps.c +++ b/tests/dumpcaps.c @@ -103,6 +103,9 @@ int dumpcaps (RIG* rig, FILE *fout) case RIG_PTT_RIG: fprintf(fout, "Rig capable\n"); break; + case RIG_PTT_RIG_MICDATA: + fprintf(fout, "Rig capable (Mic/Data)\n"); + break; case RIG_PTT_PARALLEL: fprintf(fout, "Parallel port (DATA0)\n"); break; diff --git a/tests/rigctl.1 b/tests/rigctl.1 index 53f4095bd..1a4d6f0b8 100644 --- a/tests/rigctl.1 +++ b/tests/rigctl.1 @@ -203,7 +203,7 @@ against the Hamlib backend. Get 'XIT', in Hz. .TP .B T, set_ptt 'PTT' -Set 'PTT', 0 (RX) or 1 (TX). +Set 'PTT', 0 (RX), 1 (TX), 2 (TX mic), 3 (TX data). .TP .B t, get_ptt Get 'PTT' status.