From 453995e7c06b8566b05c251c4bfccd090cea3987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Mon, 5 Apr 2010 10:01:09 +0000 Subject: [PATCH] fix segfault and allow mode listing in rigctl git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2865 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- Segfault-award | 6 ++++++ include/hamlib/rig.h | 1 + src/rig.c | 9 ++++++--- tests/rigctl_parse.c | 10 ++++------ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Segfault-award b/Segfault-award index 584e6cf59..de7647ff6 100644 --- a/Segfault-award +++ b/Segfault-award @@ -13,3 +13,9 @@ Here is the list of the brave fellows: * Chuck Hemker N2POR, v1.1.3, 09/2002, src/event.c when using rig_set_trn() and receiving a SIGIO, and having a second non serial rig open. + +* Roeland Th. Jansen PA3MET, v1.2.10, 03/2010, tests/rigctl_parse.c + $ rigctl + Rig command: M + Mode: ? + diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 0add58527..dd51a7188 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -1431,6 +1431,7 @@ struct rig_state { rmode_t current_mode; /*!< Mode currently set */ pbwidth_t current_width; /*!< Passband width currently set */ vfo_t tx_vfo; /*!< Tx VFO currently set */ + int mode_list; /*!< Complete list of modes for this rig */ }; diff --git a/src/rig.c b/src/rig.c index 6a758d5d1..421c0083e 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1,6 +1,6 @@ /* * Hamlib Interface - main file - * Copyright (c) 2000-2009 by Stephane Fillod + * Copyright (c) 2000-2010 by Stephane Fillod * Copyright (c) 2000-2003 by Frank Singleton * * $Id: rig.c,v 1.103 2009-02-20 14:14:31 fillods Exp $ @@ -31,7 +31,7 @@ * \brief Ham Radio Control Libraries interface * \author Stephane Fillod * \author Frank Singleton - * \date 2000-2009 + * \date 2000-2010 * * 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 +83,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-2009 Stephane Fillod\n" + "Copyright (C) 2000-2010 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."; @@ -344,11 +344,14 @@ RIG * HAMLIB_API rig_init(rig_model_t rig_model) } rs->vfo_list = 0; + rs->mode_list = 0; for (i=0; irx_range_list[i]); i++) { rs->vfo_list |= rs->rx_range_list[i].vfo; + rs->mode_list |= rs->rx_range_list[i].modes; } for (i=0; itx_range_list[i]); i++) { rs->vfo_list |= rs->tx_range_list[i].vfo; + rs->mode_list |= rs->tx_range_list[i].modes; } memcpy(rs->preamp, caps->preamp, sizeof(int)*MAXDBLSTSIZ); diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 4888aeacc..464bb2c71 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -752,14 +752,13 @@ declare_proto_rig(set_mode) rmode_t mode; pbwidth_t width; -#if 0 if (!strcmp(arg1, "?")) { char s[SPRINTF_MAX_SIZE]; - sprintf_mode(s, rig->state.modes); + sprintf_mode(s, rig->state.mode_list); fprintf(fout, "%s\n", s); return RIG_OK; } -#endif + mode = rig_parse_mode(arg1); sscanf(arg2, "%ld", &width); return rig_set_mode(rig, vfo, mode, width); @@ -1031,14 +1030,13 @@ declare_proto_rig(set_split_mode) int width; vfo_t txvfo = RIG_VFO_TX; -#if 0 if (!strcmp(arg1, "?")) { char s[SPRINTF_MAX_SIZE]; - sprintf_mode(s, rig->state.modes); + sprintf_mode(s, rig->state.mode_list); fprintf(fout, "%s\n", s); return RIG_OK; } -#endif + mode = rig_parse_mode(arg1); sscanf(arg2, "%d", &width); return rig_set_split_mode(rig, txvfo, mode, (pbwidth_t) width);