[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 2b448d28154491a628ca6
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2020-12-31 05:19:03
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 2b448d28154491a628ca607c6c1c0aed73382b36 (commit) via 7a9e909b619376f8dc029b8cb0336de614ab1e89 (commit) from d425c8af709994248f0eb5d85bbcbcd9c16bf66c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 2b448d28154491a628ca607c6c1c0aed73382b36 Author: Michael Black W9MDB <mdb...@ya...> Date: Wed Dec 30 23:18:18 2020 -0600 Add 950.c https://github.com/Hamlib/Hamlib/issues/483 diff --git a/rigs/barrett/950.c b/rigs/barrett/950.c new file mode 100644 index 00000000..2ca93178 --- /dev/null +++ b/rigs/barrett/950.c @@ -0,0 +1,212 @@ +/* + * Hamlib Barrett 950 backend - main file + * Copyright (c) 2017-2020 by Michael Black W9MDB + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <math.h> + +#include <hamlib/rig.h> +#include "serial.h" +#include "misc.h" +#include "cal.h" +#include "token.h" +#include "register.h" + +#include "barrett.h" + +#define MAXCMDLEN 32 + +#define BARRETT950_VFOS (RIG_VFO_A|RIG_VFO_MEM) + +#define BARRETT950_MODES (RIG_MODE_AM | RIG_MODE_CW | RIG_MODE_RTTY | RIG_MODE_SSB) + +#define BARRETT950_LEVELS (RIG_LEVEL_NONE) + + +static int barrett950_set_freq(RIG *rig, vfo_t vfo, freq_t freq); + +static int barrett950_get_level(RIG *rig, vfo_t vfo, setting_t level, + value_t *val); + +static const char *barrett950_get_info(RIG *rig); + + +const struct rig_caps barrett950_caps = +{ + RIG_MODEL(RIG_MODEL_BARRETT_950), + .model_name = "950", + .mfg_name = "Barrett", + .version = BACKEND_VER ".0", + .copyright = "LGPL", + .status = RIG_STATUS_ALPHA, + .rig_type = RIG_TYPE_TRANSCEIVER, + .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, + .ptt_type = RIG_PTT_RIG, + .dcd_type = RIG_DCD_NONE, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 9600, + .serial_rate_max = 9600, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_XONXOFF, + .write_delay = 0, + .post_write_delay = 50, + .timeout = 1000, + .retry = 3, + + .has_get_func = RIG_FUNC_NONE, + .has_set_func = RIG_FUNC_NONE, + .has_get_level = BARRETT950_LEVELS, + .has_set_level = RIG_LEVEL_NONE, + .has_get_parm = RIG_PARM_NONE, + .has_set_parm = RIG_PARM_NONE, + .transceive = RIG_TRN_RIG, + .rx_range_list1 = {{ + .startf = kHz(1600), .endf = MHz(30), .modes = BARRETT950_MODES, + .low_power = -1, .high_power = -1, BARRETT950_VFOS, RIG_ANT_1 + }, + RIG_FRNG_END, + }, + .rx_range_list2 = {RIG_FRNG_END,}, + .tx_range_list1 = {RIG_FRNG_END,}, + .tx_range_list2 = {RIG_FRNG_END,}, + .tuning_steps = { {BARRETT950_MODES, 1}, {BARRETT950_MODES, RIG_TS_ANY}, RIG_TS_END, }, + .filters = { + {RIG_MODE_SSB | RIG_MODE_CW | RIG_MODE_RTTY, kHz(2.4)}, + {RIG_MODE_CW, Hz(500)}, + {RIG_MODE_AM, kHz(8)}, + {RIG_MODE_AM, kHz(2.4)}, + RIG_FLT_END, + }, + .priv = NULL, + + .rig_init = barrett_init, + .rig_cleanup = barrett_cleanup, + + .set_freq = barrett950_set_freq, + .get_freq = barrett_get_freq, + .set_mode = barrett_set_mode, + .get_mode = barrett_get_mode, + + .get_level = barrett950_get_level, + + .get_info = barrett950_get_info, + .set_ptt = barrett_set_ptt, + .get_ptt = NULL, + .set_split_freq = barrett_set_split_freq, + .set_split_vfo = barrett_set_split_vfo, + .get_split_vfo = barrett_get_split_vfo, +}; + +/* + * barrett950_set_freq + * assumes rig!=NULL, rig->state.priv!=NULL + */ +int barrett950_set_freq(RIG *rig, vfo_t vfo, freq_t freq) +{ + char cmd_buf[MAXCMDLEN]; + int retval; + struct barrett_priv_data *priv = rig->state.priv; + + rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s freq=%.0f\n", __func__, + rig_strvfo(vfo), freq); + + // If we are not explicitly asking for VFO_B then we'll set the receive side also + if (vfo != RIG_VFO_B) + { + char *response = NULL; + sprintf((char *) cmd_buf, "OR%08.0f", freq); + retval = barrett_transaction(rig, cmd_buf, 0, &response); + + if (retval < 0) + { + return retval; + } + + //dump_hex((unsigned char *)response, strlen(response)); + + if (strncmp(response, "OK", 2) != 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: Expected OK, got '%s'\n", __func__, response); + return -RIG_EINVAL; + } + } + + if (priv->split == 0 + || vfo == RIG_VFO_B) // if we aren't in split mode we have to set the TX VFO too + { + + char *response = NULL; + sprintf((char *) cmd_buf, "PT%08.0f", freq); + retval = barrett_transaction(rig, cmd_buf, 0, &response); + + if (retval < 0) + { + return retval; + } + + if (strncmp(response, "OK", 2) != 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: Expected OK, got '%s'\n", __func__, response); + return -RIG_EINVAL; + } + } + + return RIG_OK; +} + +/* + * barrett950_get_level + */ +int barrett950_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) +{ + return -RIG_ENIMPL; +} + +/* + * barrett950_get_info + */ +const char *barrett950_get_info(RIG *rig) +{ + char *response = NULL; + int retval; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + retval = barrett_transaction(rig, "IV", 0, &response); + + if (retval == RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: result=%s\n", __func__, response); + } + else + { + rig_debug(RIG_DEBUG_VERBOSE, "Software Version %s\n", response); + } + + return response; +} commit 7a9e909b619376f8dc029b8cb0336de614ab1e89 Author: Michael Black W9MDB <mdb...@ya...> Date: Wed Dec 30 23:15:42 2020 -0600 Add Barrett 950 https://github.com/Hamlib/Hamlib/issues/483 diff --git a/include/hamlib/riglist.h b/include/hamlib/riglist.h index 75f121e2..97de42c9 100644 --- a/include/hamlib/riglist.h +++ b/include/hamlib/riglist.h @@ -619,6 +619,7 @@ #define RIG_BARRETT 32 #define RIG_BACKEND_BARRETT "barrett" #define RIG_MODEL_BARRETT_2050 RIG_MAKE_MODEL(RIG_BARRETT, 1) +#define RIG_MODEL_BARRETT_950 RIG_MAKE_MODEL(RIG_BARRETT, 2) /* * Elad diff --git a/rigs/barrett/Makefile.am b/rigs/barrett/Makefile.am index d170a3cf..71953213 100644 --- a/rigs/barrett/Makefile.am +++ b/rigs/barrett/Makefile.am @@ -1,4 +1,4 @@ -BARRETTSRC = barrett.c barrett.h +BARRETTSRC = barrett.c barrett.h 950.c noinst_LTLIBRARIES = libhamlib-barrett.la libhamlib_barrett_la_SOURCES = $(BARRETTSRC) diff --git a/rigs/barrett/barrett.c b/rigs/barrett/barrett.c index cf4c8d3b..739825c9 100644 --- a/rigs/barrett/barrett.c +++ b/rigs/barrett/barrett.c @@ -46,21 +46,21 @@ #define BARRETT_LEVELS (RIG_LEVEL_STRENGTH) -static int barrett_init(RIG *rig); -static int barrett_cleanup(RIG *rig); +int barrett_init(RIG *rig); +int barrett_cleanup(RIG *rig); static int barrett_set_freq(RIG *rig, vfo_t vfo, freq_t freq); -static int barrett_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); -static int barrett_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); +int barrett_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); +int barrett_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int barrett_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); -static int barrett_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); -static int barrett_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, +int barrett_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); +int barrett_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); -static int barrett_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq); -static int barrett_set_split_vfo(RIG *rig, vfo_t rxvfo, split_t split, +int barrett_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq); +int barrett_set_split_vfo(RIG *rig, vfo_t rxvfo, split_t split, vfo_t txvfo); -static int barrett_get_split_vfo(RIG *rig, vfo_t rxvfo, split_t *split, +int barrett_get_split_vfo(RIG *rig, vfo_t rxvfo, split_t *split, vfo_t *txvfo); static int barrett_get_level(RIG *rig, vfo_t vfo, setting_t level, @@ -211,6 +211,7 @@ DECLARE_INITRIG_BACKEND(barrett) rig_debug(RIG_DEBUG_VERBOSE, "%s: _init called\n", __func__); rig_register(&barrett_caps); + rig_register(&barrett950_caps); rig_debug(RIG_DEBUG_VERBOSE, "%s: _init back from rig_register\n", __func__); return RIG_OK; diff --git a/rigs/barrett/barrett.h b/rigs/barrett/barrett.h index 33e5da2a..9395d72b 100644 --- a/rigs/barrett/barrett.h +++ b/rigs/barrett/barrett.h @@ -39,6 +39,7 @@ #define BARRETT_DATA_LEN 64 extern const struct rig_caps barrett_caps; +extern const struct rig_caps barrett950_caps; struct barrett_priv_data { char cmd_str[BARRETT_DATA_LEN]; /* command string buffer */ @@ -46,4 +47,23 @@ struct barrett_priv_data { char split; /* split on/off */ }; +extern int barrett_transaction(RIG *rig, char *cmd, int expected, char **result); + +extern int barrett_init(RIG *rig); +extern int barrett_cleanup(RIG *rig); +extern int barrett_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); +extern int barrett_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); +extern int barrett_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); +extern int barrett_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); +extern int barrett_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq); +extern int barrett_set_split_vfo(RIG *rig, vfo_t rxvfo, split_t split, + vfo_t txvfo); + +extern int barrett_get_split_vfo(RIG *rig, vfo_t rxvfo, split_t *split, + vfo_t *txvfo); + + + + #endif /* _BARRETT_H */ diff --git a/tests/testrig.c b/tests/testrig.c index b7b9ab97..a2a8e890 100644 --- a/tests/testrig.c +++ b/tests/testrig.c @@ -83,6 +83,7 @@ int main(int argc, char *argv[]) printf("Port %s opened ok\n", SERIAL_PORT); + printf("Offset of vfo_list=%p\n", &my_rig->state.vfo_list); /* * Below are examples of set/get routines. * Must add checking of functionality map prior to command execution -- FS ----------------------------------------------------------------------- Summary of changes: include/hamlib/riglist.h | 1 + rigs/barrett/950.c | 212 +++++++++++++++++++++++++++++++++++++++++++++++ rigs/barrett/Makefile.am | 2 +- rigs/barrett/barrett.c | 19 +++-- rigs/barrett/barrett.h | 20 +++++ tests/testrig.c | 1 + 6 files changed, 245 insertions(+), 10 deletions(-) create mode 100644 rigs/barrett/950.c hooks/post-receive -- Hamlib -- Ham radio control libraries |