diff --git a/NEWS b/NEWS index 595ce892f..262862a19 100644 --- a/NEWS +++ b/NEWS @@ -6,14 +6,20 @@ Copyright (C) 2000-2021 Michael Black W9MDB, and others Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net +Version 4.5 + * 202?-??-?? + Version 4.4 - * 2021-??-?? + * 2021-12-02 * Icom rigs now default filter 2 when setting PKTUSB but user can override * Fix FTDX9000 meter readings * Add Android sensor as a rotator * Added rig_get_vfo to some Icom rigs that have XCHG or 0x25 command capability * Added ability to build hamlib with docker * Added M0NKA mcHF URP rig + * Faster serial i/o noticeable on higher baud rates + * IC7300/9700/7800/785x set_clock/get_clock routines added -- no auto set yet + * Yaesu FT1200/891/991/DX10/DX101/DX101MP set_clock/get_clock routines added Version 4.3.1 * 2021-09-14 diff --git a/amplifiers/elecraft/kpa.c b/amplifiers/elecraft/kpa.c index 8e0dd32cd..820a06780 100644 --- a/amplifiers/elecraft/kpa.c +++ b/amplifiers/elecraft/kpa.c @@ -126,7 +126,7 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len) if (err != RIG_OK) { return err; } - len = read_string(&rs->ampport, response, response_len, ";", 1, 0); + len = read_string(&rs->ampport, response, response_len, ";", 1, 0, 1); if (len < 0) { return len; } } @@ -140,7 +140,7 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len) if (response) // if response expected get it { response[0] = 0; - len = read_string(&rs->ampport, response, response_len, ";", 1, 0); + len = read_string(&rs->ampport, response, response_len, ";", 1, 0, 1); if (len < 0) { @@ -166,7 +166,7 @@ int kpa_transaction(AMP *amp, const char *cmd, char *response, int response_len) if (err != RIG_OK) { return err; } - len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1, 0); + len = read_string(&rs->ampport, responsebuf, KPABUFSZ, ";", 1, 0, 1); if (len < 0) { return len; } } @@ -369,7 +369,8 @@ int kpa_get_level(AMP *amp, setting_t level, value_t *val) // do { - retval = read_string(&rs->ampport, responsebuf, sizeof(responsebuf), ";", 1, 0); + retval = read_string(&rs->ampport, responsebuf, sizeof(responsebuf), ";", 1, 0, + 1); if (retval != RIG_OK) { return retval; } diff --git a/configure.ac b/configure.ac index 540c0baf5..0f04b931f 100644 --- a/configure.ac +++ b/configure.ac @@ -14,7 +14,7 @@ dnl Please do not use '-' in the version number, as package managers will fail, dnl however, the use of '~' should be fine as apt (others?) will treat dnl it as an earlier version than the actual release. TNX KA6MAL dnl PACKAGE_NAME + " " + PACKAGE_VERSION must not exceed 20 chars! -AC_INIT([Hamlib],[4.4~git],[hamlib-developer@lists.sourceforge.net],[hamlib],[http://www.hamlib.org]) +AC_INIT([Hamlib],[4.5~git],[hamlib-developer@lists.sourceforge.net],[hamlib],[http://www.hamlib.org]) AC_CONFIG_SRCDIR([include/hamlib/rig.h]) AC_CONFIG_MACRO_DIR([macros]) @@ -56,7 +56,7 @@ dnl See README.release on setting these values # Values given to -version-info when linking. See libtool documentation. # Set them here to keep c++/Makefile and src/Makefile in sync. ABI_VERSION=4 -ABI_REVISION=4 +ABI_REVISION=5 ABI_AGE=0 AC_DEFINE_UNQUOTED([ABI_VERSION], [$ABI_VERSION], [Frontend ABI version]) diff --git a/cppcheck.sh b/cppcheck.sh index d71b45ba9..8389b07c2 100755 --- a/cppcheck.sh +++ b/cppcheck.sh @@ -80,7 +80,7 @@ CHECK="\ if test $# -eq 0 ; then echo "See cppcheck.log when done" echo "This takes a while to run" - cppcheck --inline-suppr \ + strace -f cppcheck --inline-suppr \ -I src \ -I include \ --include=include/config.h \ diff --git a/doc/man1/rigctl.1 b/doc/man1/rigctl.1 index 71f0a8222..3aad329e7 100644 --- a/doc/man1/rigctl.1 +++ b/doc/man1/rigctl.1 @@ -1136,6 +1136,35 @@ option above, will terminate each command string sent to the radio. This character should not be a part of the input string. . .TP +.BR set_clock " \(aq" \fIDateTime\fP \(aq +Set +.RI \(aq DateTime \(aq +.IP +Sets rig clock -- note that some rigs do not handle seconds or milliseconds. +If you try to set sec/msec and rig does not support it you will get a debug warning message. +Format is ISO8601, +.EX +Formats accepted +YYYY-MM-DDTHH:MM:SS.SSS+ZZ (where +ZZ is either -/+ UTC offset) +YYYY-MM-DDTHH:MM:SS+ZZ +YYYY-MM-DDTHH:MM+ZZ +YYYY-MM-DD (sets date only) +Note: Icom rigs expect you to set local time and the hours off to UTC. +So...4PM EST example would be 2021-12-01T16:00:00+05 +But...if you want to display GMT you must set the clock for GMT with zero UTC offset. +Hopefully Icom will allow displaying either clock in the future + +.EE +. +.TP +.BR get_clock +Get +.RI \(aq RigTime \(aq +.IP +Gets rig clock -- note that some rigs do not handle seconds or milliseconds. +Format is ISO8601 YYYY-MM-DDTHH:MM:SS.sss+ZZ where +ZZ is either -/+ UTC offset +. +.TP .BR chk_vfo Get .RI \(aq Status \(aq diff --git a/doc/man1/rigctld.1 b/doc/man1/rigctld.1 index 09ba8c020..e5d4fcd94 100644 --- a/doc/man1/rigctld.1 +++ b/doc/man1/rigctld.1 @@ -1077,6 +1077,29 @@ and also need to be provided as output power may vary according to these values. .IP VFO parameter is not used in VFO mode. +.TP +.BR set_clock " \(aq" \fIDateTime\fP \(aq +Set +.RI \(aq DateTime \(aq +.IP +Sets rig clock -- note that some rigs do not handle seconds or milliseconds. +If you try to set that you will get a debug warning message. +Format is ISO8601. +.EX +Formats accepted +YYYY-MM-DDTHH:MM:SS.sss+ZZ (where +ZZ is either -/+ UTC offset) +YYYY-MM-DDTHH:MM:SS+ZZ +YYYY-MM-DDTHH:MM+ZZ +YYYY-MM-DD (sets date only) +.EE +. +.TP +.BR get_clock +Get +.RI \(aq RigTime \(aq +.IP +Gets rig clock -- note that some rigs do not handle seconds or milliseconds. +Format is ISO8601 YYYY-MM-DDTHH:MM:SS.sss+ZZ where +ZZ is either -/+ UTC offset . .TP .B chk_vfo diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 359ea3d32..e06fa8049 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -905,7 +905,7 @@ typedef uint64_t rig_level_e; #define RIG_LEVEL_AF CONSTANT_64BIT_FLAG(3) /*!< \c AF -- Volume, arg float [0.0 ... 1.0] */ #define RIG_LEVEL_RF CONSTANT_64BIT_FLAG(4) /*!< \c RF -- RF gain (not TX power) arg float [0.0 ... 1.0] */ #define RIG_LEVEL_SQL CONSTANT_64BIT_FLAG(5) /*!< \c SQL -- Squelch, arg float [0.0 ... 1.0] */ -#define RIG_LEVEL_IF CONSTANT_64BIT_FLAG(6) /*!< \c IF -- IF, arg int (Hz) */ +#define RIG_LEVEL_IF CONSTANT_64BIT_FLAG(6) /*!< \c IF shift -- IF, arg int (+/-Hz) */ #define RIG_LEVEL_APF CONSTANT_64BIT_FLAG(7) /*!< \c APF -- Audio Peak Filter, arg float [0.0 ... 1.0] */ #define RIG_LEVEL_NR CONSTANT_64BIT_FLAG(8) /*!< \c NR -- Noise Reduction, arg float [0.0 ... 1.0] */ #define RIG_LEVEL_PBT_IN CONSTANT_64BIT_FLAG(9) /*!< \c PBT_IN -- Twin PBT (inside) arg float [0.0 ... 1.0] */ @@ -1986,6 +1986,8 @@ struct rig_caps { rmode_t *mode, pbwidth_t *width, split_t *split); + int(*set_clock) (RIG *rig, int year, int month, int day, int hour, int min, int sec, double msec, int utc_offset); + int(*get_clock) (RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset); const char *clone_combo_set; /*!< String describing key combination to enter load cloning mode */ const char *clone_combo_get; /*!< String describing key combination to enter save cloning mode */ @@ -2223,6 +2225,8 @@ typedef hamlib_port_t port_t; #define HAMLIB_ELAPSED_SET 1 #define HAMLIB_ELAPSED_INVALIDATE 2 +#define HAMLIB_CACHE_ALWAYS -1 /*< value to set cache timeout to always use cache */ + typedef enum { HAMLIB_CACHE_ALL, // to set all cache timeouts at once HAMLIB_CACHE_VFO, @@ -3126,6 +3130,11 @@ extern HAMLIB_EXPORT_VAR(char) debugmsgsave3[DEBUGMSGSAVE_SIZE]; // last-2 debu #define rig_debug(debug_level,fmt,...) do { strncpy(debugmsgsave3, debugmsgsave2,sizeof(debugmsgsave3));strncpy(debugmsgsave2, debugmsgsave, sizeof(debugmsgsave2));snprintf(debugmsgsave,sizeof(debugmsgsave),fmt,__VA_ARGS__);rig_debug(debug_level,fmt,##__VA_ARGS__); } while(0); #endif #endif + +// Measuring elapsed time -- local variable inside function when macro is used +#define ELAPSED1 struct timespec __begin; elapsed_ms(&__begin, HAMLIB_ELAPSED_SET); +#define ELAPSED2 rig_debug(RIG_DEBUG_TRACE, "%s: elapsed=%.0lfms\n", __func__, elapsed_ms(&__begin, HAMLIB_ELAPSED_GET)); + extern HAMLIB_EXPORT(void) rig_debug HAMLIB_PARAMS((enum rig_debug_level_e debug_level, const char *fmt, ...)); @@ -3210,16 +3219,14 @@ extern HAMLIB_EXPORT(int) rig_get_vfo_info(RIG *rig, vfo_t vfo, freq_t *freq, rm extern HAMLIB_EXPORT(int) rig_get_rig_info(RIG *rig, char *response, int max_response_len); extern HAMLIB_EXPORT(int) rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int * cache_ms_freq, rmode_t *mode, int *cache_ms_mode, pbwidth_t *width, int *cache_ms_width); +extern HAMLIB_EXPORT(int) rig_set_clock(RIG *rig, int year, int month, int day, int hour, int min, int sec, double msec, int utc_offset); +extern HAMLIB_EXPORT(int) rig_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset); typedef unsigned long rig_useconds_t; extern HAMLIB_EXPORT(int) hl_usleep(rig_useconds_t msec); extern HAMLIB_EXPORT(int) rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie, int cookie_len); -// two functions globally accessible so rig backends can lock for an I/O transaction -void rig_lock(); -void rig_unlock(); - //! @endcond __END_DECLS diff --git a/include/hamlib/riglist.h b/include/hamlib/riglist.h index e3c16fa68..e4d63167b 100644 --- a/include/hamlib/riglist.h +++ b/include/hamlib/riglist.h @@ -70,6 +70,7 @@ #define RIG_MODEL_FLRIG RIG_MAKE_MODEL(RIG_DUMMY, 4) #define RIG_MODEL_TRXMANAGER_RIG RIG_MAKE_MODEL(RIG_DUMMY, 5) #define RIG_MODEL_DUMMY_NOVFO RIG_MAKE_MODEL(RIG_DUMMY, 6) +#define RIG_MODEL_TCI1X RIG_MAKE_MODEL(RIG_DUMMY, 7) /* diff --git a/lib/termios.c b/lib/termios.c index 2a7c85c39..29deff5b0 100644 --- a/lib/termios.c +++ b/lib/termios.c @@ -1722,6 +1722,7 @@ int win32_serial_read(int fd, void *vb, int size) return (total); #if 0 + if (size > 0) { now = GetTickCount(); @@ -1923,6 +1924,7 @@ int win32_serial_read(int fd, void *vb, int size) total += nBytes; return (total); #if 0 + if (size > 0) { now = GetTickCount(); diff --git a/macros/ax_python_devel.m4 b/macros/ax_python_devel.m4 old mode 100644 new mode 100755 index 55463ed88..1df46a9cf --- a/macros/ax_python_devel.m4 +++ b/macros/ax_python_devel.m4 @@ -67,7 +67,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 21 +#serial 23 AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL]) AC_DEFUN([AX_PYTHON_DEVEL],[ @@ -109,7 +109,6 @@ to something else than an empty string. fi else AC_MSG_RESULT([yes]) - sysconfig="distutils.sysconfig" fi # @@ -133,41 +132,28 @@ variable to configure. See ``configure --help'' for reference. fi fi - # - # - # Check for a version of Python >= 3.0.0 - # - AC_MSG_CHECKING([for a version of Python >= '3.0.0']) - ac_supports_python3_ver=`$PYTHON -c "import sys; \ - ver = sys.version.split ()[[0]]; \ - print (ver >= '3.0.0')"` - if test "$ac_supports_python3_ver" != "True"; then - if test -z "$PYTHON_NOVERSIONCHECK"; then - AC_MSG_RESULT([no]) - else - AC_MSG_RESULT([skip at user request]) - fi - else - sysconfig="sysconfig" - PYTHON_CPPFLAGS=`python3-config --includes` - PYTHON_EXTRA_LDFLAGS=`python3-config --ldflags` - AC_MSG_RESULT([yes]) - fi - - # # Check if you have distutils, else fail # - AC_MSG_CHECKING([for the distutils Python package]) - ac_distutils_result=`$PYTHON -c "import $sysconfig" 2>&1` + AC_MSG_CHECKING([for the sysconfig Python package]) + ac_sysconfig_result=`$PYTHON -c "import sysconfig" 2>&1` if test $? -eq 0; then AC_MSG_RESULT([yes]) + IMPORT_SYSCONFIG="import sysconfig" else AC_MSG_RESULT([no]) - AC_MSG_ERROR([cannot import Python module "distutils". + + AC_MSG_CHECKING([for the distutils Python package]) + ac_sysconfig_result=`$PYTHON -c "from distutils import sysconfig" 2>&1` + if test $? -eq 0; then + AC_MSG_RESULT([yes]) + IMPORT_SYSCONFIG="from distutils import sysconfig" + else + AC_MSG_ERROR([cannot import Python module "distutils". Please check your Python installation. The error was: -$ac_distutils_result]) - PYTHON_VERSION="" +$ac_sysconfig_result]) + PYTHON_VERSION="" + fi fi # @@ -175,10 +161,19 @@ $ac_distutils_result]) # AC_MSG_CHECKING([for Python include path]) if test -z "$PYTHON_CPPFLAGS"; then - python_path=`$PYTHON -c "import $sysconfig; \ - print ($sysconfig.get_python_inc ());"` - plat_python_path=`$PYTHON -c "import $sysconfig; \ - print ($sysconfig.get_python_inc (plat_specific=1));"` + if test "$IMPORT_SYSCONFIG" = "import sysconfig"; then + # sysconfig module has different functions + python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ + print (sysconfig.get_path ('include'));"` + plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ + print (sysconfig.get_path ('platinclude'));"` + else + # old distutils way + python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ + print (sysconfig.get_python_inc ());"` + plat_python_path=`$PYTHON -c "$IMPORT_SYSCONFIG; \ + print (sysconfig.get_python_inc (plat_specific=1));"` + fi if test -n "${python_path}"; then if test "${plat_python_path}" != "${python_path}"; then python_path="-I$python_path -I$plat_python_path" @@ -202,7 +197,7 @@ $ac_distutils_result]) # join all versioning strings, on some systems # major/minor numbers could be in different list elements -from $sysconfig import * +from sysconfig import * e = get_config_var('VERSION') if e is not None: print(e) @@ -225,8 +220,8 @@ EOD` ac_python_libdir=`cat<rigport, pcData, ADAT_RESPSZ, ADAT_EOL, 1, 0); + nRC = read_string(&pRigState->rigport, pcData, ADAT_RESPSZ, ADAT_EOL, 1, 0, 1); if (nRC > 0) { @@ -3726,7 +3726,7 @@ DECLARE_PROBERIG_BACKEND(adat) nRC = write_block(port, ADAT_CMD_DEF_STRING_GET_ID_CODE, strlen(ADAT_CMD_DEF_STRING_GET_ID_CODE)); - nRead = read_string(port, acBuf, ADAT_RESPSZ, ADAT_EOM, 1, 0); + nRead = read_string(port, acBuf, ADAT_RESPSZ, ADAT_EOM, 1, 0, 1); close(port->fd); if ((nRC != RIG_OK || nRead < 0)) diff --git a/rigs/alinco/dx77.c b/rigs/alinco/dx77.c index 134e6eabc..d6f8234fc 100644 --- a/rigs/alinco/dx77.c +++ b/rigs/alinco/dx77.c @@ -321,7 +321,7 @@ int dx77_transaction(RIG *rig, * Transceiver sends an echo of cmd followed by a CR/LF * TODO: check whether cmd and echobuf match (optional) */ - retval = read_string(&rs->rigport, echobuf, BUFSZ, LF, strlen(LF), 0); + retval = read_string(&rs->rigport, echobuf, BUFSZ, LF, strlen(LF), 0, 1); if (retval < 0) { @@ -337,7 +337,7 @@ int dx77_transaction(RIG *rig, /* no data expected, check for OK returned */ if (data == NULL) { - retval = read_string(&rs->rigport, echobuf, BUFSZ, LF, strlen(LF), 0); + retval = read_string(&rs->rigport, echobuf, BUFSZ, LF, strlen(LF), 0, 1); if (retval < 0) { @@ -358,7 +358,7 @@ int dx77_transaction(RIG *rig, } } - retval = read_string(&rs->rigport, data, BUFSZ, LF, strlen(LF), 0); + retval = read_string(&rs->rigport, data, BUFSZ, LF, strlen(LF), 0, 1); if (retval < 0) { diff --git a/rigs/alinco/dxsr8.c b/rigs/alinco/dxsr8.c index 02f33b9d9..030bb7193 100644 --- a/rigs/alinco/dxsr8.c +++ b/rigs/alinco/dxsr8.c @@ -264,7 +264,7 @@ int dxsr8_transaction(RIG *rig, * Transceiver sends an echo of cmd followed by a CR/LF * TODO: check whether cmd and echobuf match (optional) */ - retval = read_string(&rs->rigport, replybuf, BUFSZ, LF, strlen(LF), 0); + retval = read_string(&rs->rigport, replybuf, BUFSZ, LF, strlen(LF), 0, 1); if (retval < 0) { @@ -272,7 +272,7 @@ int dxsr8_transaction(RIG *rig, } - retval = read_string(&rs->rigport, replybuf, BUFSZ, LF, strlen(LF), 0); + retval = read_string(&rs->rigport, replybuf, BUFSZ, LF, strlen(LF), 0, 1); if (retval < 0) { diff --git a/rigs/aor/aor.c b/rigs/aor/aor.c index 799816429..df2e3e1f2 100644 --- a/rigs/aor/aor.c +++ b/rigs/aor/aor.c @@ -102,7 +102,7 @@ static int aor_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, /* * Do wait for a reply */ - retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0); + retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0, 1); if (retval < 0) { @@ -1428,7 +1428,8 @@ int aor_get_chan_all_cb(RIG *rig, vfo_t vfo, chan_cb_t chan_cb, rig_ptr_t arg) /* * get next line */ - retval = read_string(&rig->state.rigport, chanbuf, BUFSZ, EOM, strlen(EOM), 0); + retval = read_string(&rig->state.rigport, chanbuf, BUFSZ, EOM, strlen(EOM), 0, + 1); if (retval < 0) { diff --git a/rigs/aor/ar3000.c b/rigs/aor/ar3000.c index f5cb8cf02..4a52d2574 100644 --- a/rigs/aor/ar3000.c +++ b/rigs/aor/ar3000.c @@ -211,7 +211,7 @@ static int ar3k_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return RIG_OK; } - retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0); + retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0, 1); if (retval == -RIG_ETIMEOUT) { diff --git a/rigs/aor/ar3030.c b/rigs/aor/ar3030.c index 88a7c7d73..ad03b94cb 100644 --- a/rigs/aor/ar3030.c +++ b/rigs/aor/ar3030.c @@ -247,7 +247,7 @@ static int ar3030_transaction(RIG *rig, const char *cmd, int cmd_len, if (data) { /* expecting 0x0d0x0a on all commands so wait for the 0x0a */ - retval = read_string(&rs->rigport, data, BUFSZ, "\x0a", 1, 0); + retval = read_string(&rs->rigport, data, BUFSZ, "\x0a", 1, 0, 1); if (retval == -RIG_ETIMEOUT) { diff --git a/rigs/aor/sr2200.c b/rigs/aor/sr2200.c index 72519b689..7cb051837 100644 --- a/rigs/aor/sr2200.c +++ b/rigs/aor/sr2200.c @@ -307,7 +307,7 @@ static int sr2200_transaction(RIG *rig, const char *cmd, int cmd_len, /* * Do wait for a reply */ - retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0); + retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0, 1); if (retval < 0) { diff --git a/rigs/barrett/barrett.c b/rigs/barrett/barrett.c index a266f0f8b..572e5f097 100644 --- a/rigs/barrett/barrett.c +++ b/rigs/barrett/barrett.c @@ -244,7 +244,7 @@ int barrett_transaction(RIG *rig, char *cmd, int expected, char **result) { // response format is 0x11,data...,0x0d,0x0a,0x13 retval = read_string(&rs->rigport, priv->ret_data, sizeof(priv->ret_data), - "\x11", 1, 0); + "\x11", 1, 0, 1); rig_debug(RIG_DEBUG_VERBOSE, "%s: resultlen=%d\n", __func__, (int)strlen(priv->ret_data)); diff --git a/rigs/dorji/dra818.c b/rigs/dorji/dra818.c index 79d0ee783..47c05c696 100644 --- a/rigs/dorji/dra818.c +++ b/rigs/dorji/dra818.c @@ -60,7 +60,8 @@ struct dra818_priv static int dra818_response(RIG *rig, const char *expected) { char response[80]; - int r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1, 0); + int r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1, 0, + 1); if (r != strlen(expected)) { @@ -294,7 +295,7 @@ int dra818_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) (int)(priv->rx_freq / 1000000), (int)((priv->rx_freq % 1000000) / 100)); write_block(&rig->state.rigport, cmd, strlen(cmd)); - r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1, 0); + r = read_string(&rig->state.rigport, response, sizeof(response), "\n", 1, 0, 1); if (r != 5) { diff --git a/rigs/drake/drake.c b/rigs/drake/drake.c index 3cc2b0f0b..fad3265de 100644 --- a/rigs/drake/drake.c +++ b/rigs/drake/drake.c @@ -84,7 +84,7 @@ int drake_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return 0; } - retval = read_string(&rs->rigport, data, BUFSZ, LF, 1, 0); + retval = read_string(&rs->rigport, data, BUFSZ, LF, 1, 0, 1); if (retval == -RIG_ETIMEOUT) { @@ -1252,7 +1252,7 @@ DECLARE_PROBERIG_BACKEND(drake) } retval = write_block(port, "ID" EOM, 3); - id_len = read_string(port, idbuf, BUFSZ, LF, 1, 0); + id_len = read_string(port, idbuf, BUFSZ, LF, 1, 0, 1); close(port->fd); diff --git a/rigs/dummy/Makefile.am b/rigs/dummy/Makefile.am index 0b195ecb3..7a60bdcef 100644 --- a/rigs/dummy/Makefile.am +++ b/rigs/dummy/Makefile.am @@ -1,4 +1,4 @@ -DUMMYSRC = dummy_common.c dummy_common.h dummy.c dummy.h rot_dummy.c rot_dummy.h netrigctl.c netrotctl.c flrig.c flrig.h trxmanager.c trxmanager.h amp_dummy.c amp_dummy.h netampctl.c +DUMMYSRC = dummy_common.c dummy_common.h dummy.c dummy.h rot_dummy.c rot_dummy.h netrigctl.c netrotctl.c flrig.c flrig.h trxmanager.c trxmanager.h amp_dummy.c amp_dummy.h netampctl.c tci1x.c noinst_LTLIBRARIES = libhamlib-dummy.la libhamlib_dummy_la_SOURCES = $(DUMMYSRC) diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c index 5ae37a6b0..df01574d7 100644 --- a/rigs/dummy/dummy.c +++ b/rigs/dummy/dummy.c @@ -2140,6 +2140,55 @@ static int dummy_mW2power(RIG *rig, float *power, unsigned int mwpower, RETURNFUNC(RIG_OK); } +static int m_year, m_month, m_day, m_hour, m_min, m_sec, m_utc_offset; +static double m_msec; + +int dummy_set_clock(RIG *rig, int year, int month, int day, int hour, int min, + int sec, double msec, int utc_offset) +{ + int retval = RIG_OK; + + rig_debug(RIG_DEBUG_VERBOSE, "%s: %04d-%02d-%02dT%02d:%02d:%02d.%.03f%s%02d\n", + __func__, year, + month, day, hour, min, sec, msec, utc_offset >= 0 ? "+" : "-", + (unsigned)(abs(utc_offset))); + m_year = year; + m_month = month; + m_day = day; + + if (hour >= 0) + { + m_hour = hour; + m_min = min; + m_sec = sec; + m_msec = msec; + m_utc_offset = utc_offset; + } + + return retval; +} + +int dummy_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, + int *min, int *sec, double *msec, int *utc_offset) +{ + int retval = RIG_OK; + + *year = m_year; + *month = m_month; + *day = m_day; + *hour = m_hour; + *min = m_min; + *sec = m_sec; + *msec = m_msec; + *utc_offset = m_utc_offset; + + rig_debug(RIG_DEBUG_VERBOSE, + "%s: %02d-%02d-%02dT%02d:%02d:%02d:%0.3lf%s%02d\n'", + __func__, *year, *month, *day, *hour, *min, *sec, *msec, + *utc_offset >= 0 ? "+" : "-", (unsigned)abs(*utc_offset)); + return retval; +} + /* * Dummy rig capabilities. @@ -2195,7 +2244,7 @@ struct rig_caps dummy_caps = RIG_MODEL(RIG_MODEL_DUMMY), .model_name = "Dummy", .mfg_name = "Hamlib", - .version = "20210705.0", + .version = "20211130.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_OTHER, @@ -2415,6 +2464,8 @@ struct rig_caps dummy_caps = .get_trn = dummy_get_trn, .power2mW = dummy_power2mW, .mW2power = dummy_mW2power, + .set_clock = dummy_set_clock, + .get_clock = dummy_get_clock }; struct rig_caps dummy_no_vfo_caps = @@ -2580,6 +2631,8 @@ struct rig_caps dummy_no_vfo_caps = .get_trn = dummy_get_trn, .power2mW = dummy_power2mW, .mW2power = dummy_mW2power, + .set_clock = dummy_set_clock, + .get_clock = dummy_get_clock }; DECLARE_INITRIG_BACKEND(dummy) @@ -2592,6 +2645,7 @@ DECLARE_INITRIG_BACKEND(dummy) rig_register(&flrig_caps); rig_register(&trxmanager_caps); rig_register(&dummy_no_vfo_caps); + rig_register(&tci1x_caps); RETURNFUNC(RIG_OK); } diff --git a/rigs/dummy/dummy.h b/rigs/dummy/dummy.h index 61642549d..3445f1597 100644 --- a/rigs/dummy/dummy.h +++ b/rigs/dummy/dummy.h @@ -44,6 +44,7 @@ extern struct rig_caps dummy_no_vfo_caps; extern struct rig_caps netrigctl_caps; extern const struct rig_caps flrig_caps; extern const struct rig_caps trxmanager_caps; +extern const struct rig_caps tci1x_caps; int netrigctl_get_vfo_mode(RIG *); diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index 534b41951..3db71560d 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -144,7 +144,7 @@ const struct rig_caps flrig_caps = RIG_MODEL(RIG_MODEL_FLRIG), .model_name = "FLRig", .mfg_name = "FLRig", - .version = "202101014.0", + .version = "20211206.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -456,7 +456,7 @@ static int read_transaction(RIG *rig, char *xml, int xml_len) } int len = read_string(&rs->rigport, tmp_buf, sizeof(tmp_buf), delims, - strlen(delims), 0); + strlen(delims), 0, 1); rig_debug(RIG_DEBUG_TRACE, "%s: string='%s'\n", __func__, tmp_buf); // if our first response we should see the HTTP header @@ -555,9 +555,10 @@ static int flrig_transaction(RIG *rig, char *cmd, char *cmd_arg, char *value, int value_len) { char xml[MAXXMLLEN]; - int retry = 5; + int retry = 3; ENTERFUNC; + ELAPSED1; if (value) { @@ -569,7 +570,7 @@ static int flrig_transaction(RIG *rig, char *cmd, char *cmd_arg, char *value, char *pxml; int retval; - if (retry < 2) + if (retry != 3) { rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s, retry=%d\n", __func__, cmd, retry); } @@ -601,8 +602,13 @@ static int flrig_transaction(RIG *rig, char *cmd, char *cmd_arg, char *value, while (((value && strlen(value) == 0) || (strlen(xml) == 0)) && retry--); // we'll do retries if needed - if (value && strlen(value) == 0) { RETURNFUNC(RIG_EPROTO); } + if (value && strlen(value) == 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: no value returned\n", __func__); + RETURNFUNC(RIG_EPROTO); + } + ELAPSED2; RETURNFUNC(RIG_OK); } @@ -673,7 +679,8 @@ static const char *modeMapGetFLRig(rmode_t modeHamlib) for (i = 0; modeMap[i].mode_hamlib != 0; ++i) { - if (modeMap[i].mode_flrig == NULL) continue; + if (modeMap[i].mode_flrig == NULL) { continue; } + rig_debug(RIG_DEBUG_TRACE, "%s: checking modeMap[%d]=%.0f to modeHamlib=%.0f, mode_flrig='%s'\n", __func__, i, (double)modeMap[i].mode_hamlib, (double)modeHamlib, modeMap[i].mode_flrig); @@ -797,12 +804,13 @@ static int flrig_open(RIG *rig) if (retval != RIG_OK) { - rig_debug(RIG_DEBUG_ERR, "%s: get_version failed: %s\nAssuming version < 1.3.54", __func__, + rig_debug(RIG_DEBUG_ERR, + "%s: get_version failed: %s\nAssuming version < 1.3.54", __func__, rigerror(retval)); // we fall through and assume old version } - int v1=0, v2=0, v3=0, v4=0; + int v1 = 0, v2 = 0, v3 = 0, v4 = 0; sscanf(value, "%d.%d.%d.%d", &v1, &v2, &v3, &v4); if (v1 >= 1 && v2 >= 3 && v3 >= 54) diff --git a/rigs/dummy/netampctl.c b/rigs/dummy/netampctl.c index 5334b9543..91a872897 100644 --- a/rigs/dummy/netampctl.c +++ b/rigs/dummy/netampctl.c @@ -52,7 +52,7 @@ static int netampctl_transaction(AMP *amp, char *cmd, int len, char *buf) return ret; } - ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); if (ret < 0) { @@ -95,7 +95,7 @@ static int netampctl_open(AMP *amp) return -RIG_EPROTO; } - ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); if (ret <= 0) { @@ -104,7 +104,7 @@ static int netampctl_open(AMP *amp) do { - ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&->state.ampport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); if (ret > 0) { diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c index e94a907a7..c12e353ce 100644 --- a/rigs/dummy/netrigctl.c +++ b/rigs/dummy/netrigctl.c @@ -79,7 +79,7 @@ static int netrigctl_transaction(RIG *rig, char *cmd, int len, char *buf) return ret; } - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret < 0) { @@ -122,8 +122,8 @@ static int netrigctl_vfostr(RIG *rig, char *vfostr, int len, vfo_t vfo) if (vfo == RIG_VFO_NONE) { vfo = RIG_VFO_A; } } - else if (vfo == RIG_VFO_RX) vfo = priv->rx_vfo; - else if (vfo == RIG_VFO_TX) vfo = priv->tx_vfo; + else if (vfo == RIG_VFO_RX) { vfo = priv->rx_vfo; } + else if (vfo == RIG_VFO_TX) { vfo = priv->tx_vfo; } rig_debug(RIG_DEBUG_TRACE, "%s: vfo_opt=%d\n", __func__, rig->state.vfo_opt); @@ -274,6 +274,7 @@ static int netrigctl_open(RIG *rig) if (sscanf(buf, "CHKVFO %d", &priv->rigctld_vfo_mode) == 1) { + rig->state.vfo_opt = 1; rig_debug(RIG_DEBUG_TRACE, "%s: chkvfo=%d\n", __func__, priv->rigctld_vfo_mode); } else if (ret == 2) @@ -311,14 +312,14 @@ static int netrigctl_open(RIG *rig) return -RIG_EPROTO; } - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { return (ret < 0) ? ret : -RIG_EPROTO; } - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -329,7 +330,7 @@ static int netrigctl_open(RIG *rig) for (i = 0; i < HAMLIB_FRQRANGESIZ; i++) { - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -359,7 +360,7 @@ static int netrigctl_open(RIG *rig) for (i = 0; i < HAMLIB_FRQRANGESIZ; i++) { - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -401,7 +402,7 @@ static int netrigctl_open(RIG *rig) for (i = 0; i < HAMLIB_TSLSTSIZ; i++) { - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -425,7 +426,7 @@ static int netrigctl_open(RIG *rig) for (i = 0; i < HAMLIB_FLTLSTSIZ; i++) { - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -452,7 +453,7 @@ static int netrigctl_open(RIG *rig) chan_t chan_list[HAMLIB_CHANLSTSIZ]; /*!< Channel list, zero ended */ #endif - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -461,7 +462,7 @@ static int netrigctl_open(RIG *rig) rig->caps->max_rit = rs->max_rit = atol(buf); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -470,7 +471,7 @@ static int netrigctl_open(RIG *rig) rig->caps->max_xit = rs->max_xit = atol(buf); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -479,7 +480,7 @@ static int netrigctl_open(RIG *rig) rig->caps->max_ifshift = rs->max_ifshift = atol(buf); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -488,7 +489,7 @@ static int netrigctl_open(RIG *rig) rs->announces = atoi(buf); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -515,7 +516,7 @@ static int netrigctl_open(RIG *rig) rig->caps->preamp[ret] = rs->preamp[ret] = RIG_DBLST_END; - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -542,7 +543,7 @@ static int netrigctl_open(RIG *rig) rig->caps->attenuator[ret] = rs->attenuator[ret] = RIG_DBLST_END; - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -551,7 +552,7 @@ static int netrigctl_open(RIG *rig) rig->caps->has_get_func = rs->has_get_func = strtoll(buf, NULL, 0); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -560,7 +561,7 @@ static int netrigctl_open(RIG *rig) rig->caps->has_set_func = rs->has_set_func = strtoll(buf, NULL, 0); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -582,7 +583,7 @@ static int netrigctl_open(RIG *rig) #endif - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -591,7 +592,7 @@ static int netrigctl_open(RIG *rig) rig->caps->has_set_level = rs->has_set_level = strtoll(buf, NULL, 0); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -600,7 +601,7 @@ static int netrigctl_open(RIG *rig) rs->has_get_parm = strtoll(buf, NULL, 0); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -627,9 +628,12 @@ static int netrigctl_open(RIG *rig) rs->mode_list |= rs->tx_range_list[i].modes; rs->vfo_list |= rs->tx_range_list[i].vfo; } - if (rs->vfo_list == 0) { - rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo_list empty, defaulting to A/B\n", __func__); - rs->vfo_list = RIG_VFO_A|RIG_VFO_B; + + if (rs->vfo_list == 0) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo_list empty, defaulting to A/B\n", + __func__); + rs->vfo_list = RIG_VFO_A | RIG_VFO_B; } if (prot_ver == 0) { return RIG_OK; } @@ -640,7 +644,7 @@ static int netrigctl_open(RIG *rig) do { char setting[32], value[1024]; - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); strtok(buf, "\r\n"); // chop the EOL if (ret <= 0) @@ -891,7 +895,7 @@ static int netrigctl_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) CHKSCN1ARG(num_sscanf(buf, "%"SCNfreq, freq)); #if 0 // implement set_freq VFO later if it can be detected - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -962,7 +966,7 @@ static int netrigctl_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, *mode = rig_parse_mode(buf); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -1575,7 +1579,7 @@ static int netrigctl_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, *tx_mode = rig_parse_mode(buf); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -1595,7 +1599,8 @@ static int netrigctl_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, char buf[BUF_MAX]; char vfostr[16] = ""; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, vfotx=%s, split=%d\n", __func__, + rig_strvfo(vfo), rig_strvfo(tx_vfo), split); ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), RIG_VFO_A); @@ -1641,7 +1646,7 @@ static int netrigctl_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, *split = atoi(buf); - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -2163,7 +2168,7 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, ret); } - ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0); + ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1, 0, 1); if (ret <= 0) { @@ -2289,10 +2294,15 @@ static int netrigctl_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) int ret, len; char cmd[CMD_MAX]; char buf[BUF_MAX]; + char vfostr[16] = ""; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - len = sprintf(cmd, "J %s\n", rig_strvfop(op)); + ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo); + + if (ret != RIG_OK) { return ret; } + + len = sprintf(cmd, "G%s %s\n", vfostr, rig_strvfop(op)); ret = netrigctl_transaction(rig, cmd, len, buf); @@ -2555,7 +2565,8 @@ static int netrigctl_power2mW(RIG *rig, unsigned int *mwpower, float power, ENTERFUNC; // we shouldn't need any precision than microwatts - snprintf(cmdbuf, sizeof(cmdbuf), "\\power2mW %.3f %.0f %s\n", power, freq, rig_strrmode(mode)); + snprintf(cmdbuf, sizeof(cmdbuf), "\\power2mW %.3f %.0f %s\n", power, freq, + rig_strrmode(mode)); ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf); if (ret <= 0) @@ -2579,7 +2590,7 @@ struct rig_caps netrigctl_caps = RIG_MODEL(RIG_MODEL_NETRIGCTL), .model_name = "NET rigctl", .mfg_name = "Hamlib", - .version = "20211118.0", + .version = "20211123.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_OTHER, diff --git a/rigs/dummy/netrotctl.c b/rigs/dummy/netrotctl.c index deecdfe27..45883b421 100644 --- a/rigs/dummy/netrotctl.c +++ b/rigs/dummy/netrotctl.c @@ -57,7 +57,7 @@ static int netrotctl_transaction(ROT *rot, char *cmd, int len, char *buf) return ret; } - ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); if (ret < 0) { @@ -100,14 +100,14 @@ static int netrotctl_open(ROT *rot) return -RIG_EPROTO; } - ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); if (ret <= 0) { return (ret < 0) ? ret : -RIG_EPROTO; } - ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); if (ret <= 0) { @@ -116,7 +116,7 @@ static int netrotctl_open(ROT *rot) rs->min_az = atof(buf); - ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); if (ret <= 0) { @@ -125,7 +125,7 @@ static int netrotctl_open(ROT *rot) rs->max_az = atof(buf); - ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); if (ret <= 0) { @@ -134,7 +134,7 @@ static int netrotctl_open(ROT *rot) rs->min_el = atof(buf); - ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); if (ret <= 0) { @@ -198,7 +198,7 @@ static int netrotctl_get_position(ROT *rot, azimuth_t *az, elevation_t *el) *az = atof(buf); - ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); if (ret <= 0) { diff --git a/rigs/dummy/rot_dummy.c b/rigs/dummy/rot_dummy.c index 11ab5a367..9bd74f05d 100644 --- a/rigs/dummy/rot_dummy.c +++ b/rigs/dummy/rot_dummy.c @@ -190,6 +190,13 @@ static int dummy_rot_open(ROT *rot) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + if (rot->caps->rot_model == ROT_MODEL_DUMMY) + { + simulating = 1; + rig_debug(RIG_DEBUG_VERBOSE, "%s: dummy rotator so simulating speed\n", + __func__); + } + return RIG_OK; } @@ -918,7 +925,7 @@ const struct rot_caps dummy_rot_caps = ROT_MODEL(ROT_MODEL_DUMMY), .model_name = "Dummy", .mfg_name = "Hamlib", - .version = "20210207.0", + .version = "20211120.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_AZEL, diff --git a/rigs/dummy/tci1x.c b/rigs/dummy/tci1x.c new file mode 100644 index 000000000..fe38962c9 --- /dev/null +++ b/rigs/dummy/tci1x.c @@ -0,0 +1,2124 @@ +/* +* Hamlib TCI 1.X backend - main file +* Copyright (c) 2021 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 +#include +#include /* String function definitions */ +#include /* UNIX standard function definitions */ +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "dummy_common.h" + +#define DEBUG 1 +#define DEBUG_TRACE DEBUG_VERBOSE + +#define MAXCMDLEN 8192 +#define MAXBUFLEN 8192 +#define MAXARGLEN 128 +#define MAXBANDWIDTHLEN 4096 + +#define DEFAULTPATH "127.0.0.1:50001" + +#define FALSE 0 +#define TRUE (!FALSE) + +#define TCI_VFOS (RIG_VFO_A|RIG_VFO_B) + +#define TCI1X_MODES (RIG_MODE_USB | RIG_MODE_LSB | RIG_MODE_FM | RIG_MODE_AM) + +#define TCI1X_LEVELS (RIG_LEVEL_AF | RIG_LEVEL_RF | RIG_LEVEL_MICGAIN | RIG_LEVEL_STRENGTH | RIG_LEVEL_RFPOWER_METER | RIG_LEVEL_RFPOWER_METER_WATTS | RIG_LEVEL_RFPOWER) + +#define TCI1X_PARM (TOK_TCI1X_VERIFY_FREQ|TOK_TCI1X_VERIFY_PTT) + +#define streq(s1,s2) (strcmp(s1,s2)==0) + +static int tci1x_init(RIG *rig); +static int tci1x_open(RIG *rig); +static int tci1x_close(RIG *rig); +static int tci1x_cleanup(RIG *rig); +static int tci1x_set_freq(RIG *rig, vfo_t vfo, freq_t freq); +static int tci1x_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); +static int tci1x_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); +static int tci1x_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); +static int tci1x_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode, + pbwidth_t width); +static int tci1x_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int tci1x_get_vfo(RIG *rig, vfo_t *vfo); +static int tci1x_set_vfo(RIG *rig, vfo_t vfo); +static int tci1x_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); +static int tci1x_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); +static int tci1x_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq); +static int tci1x_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq); +static int tci1x_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int tci1x_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); +static int tci1x_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq, + rmode_t mode, pbwidth_t width); +static int tci1x_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *freq, + rmode_t *mode, pbwidth_t *width); +#ifdef XXNOTIMPLEMENTED +static int tci1x_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); +static int tci1x_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); + +static int tci1x_set_ext_parm(RIG *rig, token_t token, value_t val); +static int tci1x_get_ext_parm(RIG *rig, token_t token, value_t *val); +#endif + +static const char *tci1x_get_info(RIG *rig); +static int tci1x_power2mW(RIG *rig, unsigned int *mwpower, float power, + freq_t freq, rmode_t mode); +static int tci1x_mW2power(RIG *rig, float *power, unsigned int mwpower, + freq_t freq, rmode_t mode); + +struct tci1x_priv_data +{ + vfo_t curr_vfo; + char bandwidths[MAXBANDWIDTHLEN]; /* pipe delimited set returned from tci1x */ + int nbandwidths; + char info[8192]; + ptt_t ptt; + split_t split; + rmode_t curr_modeA; + rmode_t curr_modeB; + freq_t curr_freqA; + freq_t curr_freqB; + pbwidth_t curr_widthA; + pbwidth_t curr_widthB; + int has_get_modeA; /* True if this function is available */ + int has_get_bwA; /* True if this function is available */ + int has_verify_cmds; // has the verify cmd in FLRig 1.3.54.1 or higher + float powermeter_scale; /* So we can scale power meter to 0-1 */ + value_t parms[RIG_SETTING_MAX]; + struct ext_list *ext_parms; +}; + +/* level's and parm's tokens */ +#define TOK_TCI1X_VERIFY_FREQ TOKEN_BACKEND(1) +#define TOK_TCI1X_VERIFY_PTT TOKEN_BACKEND(2) + +static const struct confparams tci1x_ext_parms[] = +{ + { + TOK_TCI1X_VERIFY_FREQ, "VERIFY_FREQ", "Verify set_freq", "If true will verify set_freq otherwise is fire and forget", "0", RIG_CONF_CHECKBUTTON, {} + }, + { + TOK_TCI1X_VERIFY_PTT, "VERIFY_PTT", "Verify set_ptt", "If true will verify set_ptt otherwise set_ptt is fire and forget", "0", RIG_CONF_CHECKBUTTON, {} + }, + { RIG_CONF_END, NULL, } +}; + +const struct rig_caps tci1x_caps = +{ + RIG_MODEL(RIG_MODEL_TCI1X), + .model_name = "TCI1.X", + .mfg_name = "Expert Elec", + .version = "20211125.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, + .port_type = RIG_PORT_SERIAL, + .write_delay = 0, + .post_write_delay = 0, + .timeout = 1000, + .retry = 1, + + .has_get_func = RIG_FUNC_NONE, + .has_set_func = RIG_FUNC_NONE, + .has_get_level = TCI1X_LEVELS, + .has_set_level = RIG_LEVEL_SET(TCI1X_LEVELS), + .has_get_parm = TCI1X_PARM, + .has_set_parm = RIG_PARM_SET(TCI1X_PARM), + + .filters = { + RIG_FLT_END + }, + + .rx_range_list1 = {{ + .startf = kHz(1), .endf = GHz(10), .modes = TCI1X_MODES, + .low_power = -1, .high_power = -1, TCI_VFOS, RIG_ANT_1 + }, + RIG_FRNG_END, + }, + .tx_range_list1 = {RIG_FRNG_END,}, + .rx_range_list2 = {{ + .startf = kHz(1), .endf = GHz(10), .modes = TCI1X_MODES, + .low_power = -1, .high_power = -1, TCI_VFOS, RIG_ANT_1 + }, + RIG_FRNG_END, + }, + .tx_range_list2 = {RIG_FRNG_END,}, + .tuning_steps = { {TCI1X_MODES, 1}, {TCI1X_MODES, RIG_TS_ANY}, RIG_TS_END, }, + .priv = NULL, /* priv */ + + .extparms = tci1x_ext_parms, + + .rig_init = tci1x_init, + .rig_open = tci1x_open, + .rig_close = tci1x_close, + .rig_cleanup = tci1x_cleanup, + + .set_freq = tci1x_set_freq, + .get_freq = tci1x_get_freq, + .set_mode = tci1x_set_mode, + .get_mode = tci1x_get_mode, + .set_vfo = tci1x_set_vfo, + .get_vfo = tci1x_get_vfo, + .get_info = tci1x_get_info, + .set_ptt = tci1x_set_ptt, + .get_ptt = tci1x_get_ptt, + .set_split_mode = tci1x_set_split_mode, + .set_split_freq = tci1x_set_split_freq, + .get_split_freq = tci1x_get_split_freq, + .set_split_vfo = tci1x_set_split_vfo, + .get_split_vfo = tci1x_get_split_vfo, + .set_split_freq_mode = tci1x_set_split_freq_mode, + .get_split_freq_mode = tci1x_get_split_freq_mode, +#ifdef XXNOTIMPLEMENTED + .set_level = tci1x_set_level, + .get_level = tci1x_get_level, + .set_ext_parm = tci1x_set_ext_parm, + .get_ext_parm = tci1x_get_ext_parm, +#endif + .power2mW = tci1x_power2mW, + .mW2power = tci1x_mW2power +}; + +//Structure for mapping tci1x dynmamic modes to hamlib modes +//tci1x displays modes as the rig displays them +struct s_modeMap +{ + rmode_t mode_hamlib; + char *mode_tci1x; +}; + +//FLRig will provide us the modes for the selected rig +//We will then put them in this struct +static struct s_modeMap modeMap[] = +{ + {RIG_MODE_USB, NULL}, + {RIG_MODE_LSB, NULL}, + {RIG_MODE_PKTUSB, NULL}, + {RIG_MODE_PKTLSB, NULL}, + {RIG_MODE_AM, NULL}, + {RIG_MODE_FM, NULL}, + {RIG_MODE_FMN, NULL}, + {RIG_MODE_WFM, NULL}, + {RIG_MODE_CW, NULL}, + {RIG_MODE_CWR, NULL}, + {RIG_MODE_RTTY, NULL}, + {RIG_MODE_RTTYR, NULL}, + {RIG_MODE_C4FM, NULL}, + {0, NULL} +}; + +/* +* check_vfo +* No assumptions +*/ +static int check_vfo(vfo_t vfo) +{ + switch (vfo) + { + case RIG_VFO_A: + break; + + case RIG_VFO_TX: + case RIG_VFO_B: + break; + + case RIG_VFO_CURR: + break; // will default to A in which_vfo + + default: + RETURNFUNC(FALSE); + } + + RETURNFUNC(TRUE); +} + +/* +* +* read_transaction +* Assumes rig!=NULL, buf!=NULL, buf_len big enough to hold response +*/ +static int read_transaction(RIG *rig, char *buf, int buf_len) +{ + int retry; + struct rig_state *rs = &rig->state; + char *delims = ";"; + + ENTERFUNC; + + retry = 0; + + do + { + if (retry < 2) + { + rig_debug(RIG_DEBUG_WARN, "%s: retry needed? retry=%d\n", __func__, retry); + } + + int len = read_string(&rs->rigport, buf, buf_len, delims, + strlen(delims), 0, 1); + rig_debug(RIG_DEBUG_TRACE, "%s: string='%s'\n", __func__, buf); + + if (len <= 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: read_string error=%d\n", __func__, len); + continue; + } + + } + while (retry-- > 0 && strlen(buf) == 0); + + if (retry == 0) + { + rig_debug(RIG_DEBUG_WARN, "%s: retry timeout\n", __func__); + RETURNFUNC(-RIG_ETIMEOUT); + } + + RETURNFUNC(RIG_OK); +} + +/* +* write_transaction +* Assumes rig!=NULL, xml!=NULL, xml_len=total size of xml for response +*/ +static int write_transaction(RIG *rig, char *buf, int buf_len) +{ + + int try = rig->caps->retry; + + int retval = -RIG_EPROTO; + + struct rig_state *rs = &rig->state; + + ENTERFUNC; + + // This shouldn't ever happen...but just in case + // We need to avoid an empty write as rigctld replies with blank line + if (buf_len == 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: len==0??\n", __func__); + RETURNFUNC(retval); + } + + // appears we can lose sync if we don't clear things out + // shouldn't be anything for us now anyways + rig_flush(&rig->state.rigport); + + while (try-- >= 0 && retval != RIG_OK) + { + retval = write_block(&rs->rigport, buf, buf_len); + + if (retval < 0) + { + RETURNFUNC(-RIG_EIO); + } + } + + RETURNFUNC(retval); +} + +static int tci1x_transaction(RIG *rig, char *cmd, char *cmd_arg, char *value, + int value_len) +{ + int retry = 0; + char frame[1024]; + + ENTERFUNC; + + memset(frame, 0, sizeof(frame)); + + if (value) + { + value[0] = 0; + } + + frame[0] = 0x81; + frame[1] = strlen(cmd); + frame[2] = 0x00; + frame[3] = 0x00; + frame[4] = 0x00; + frame[5] = 0x00; + frame[6] = 0x00; + frame[7] = 0x00; + frame[8] = 0x00; + frame[9] = 0x00; + frame[10] = 0x00; + frame[11] = 0x00; + strcat(&frame[12], cmd); + + do + { + int retval; + + if (retry < 2) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s, retry=%d\n", __func__, cmd, retry); + } + + retval = write_transaction(rig, frame, strlen(cmd) + 12); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: write_transaction error=%d\n", __func__, retval); + + // if we get RIG_EIO the socket has probably disappeared + // so bubble up the error so port can re re-opened + if (retval == -RIG_EIO) { RETURNFUNC(retval); } + + hl_usleep(50 * 1000); // 50ms sleep if error + } + + read_transaction(rig, value, value_len); + + rig_debug(RIG_DEBUG_VERBOSE, "%s: value=%s\n", __func__, value); + + } + while ((value && (strlen(value) == 0)) + && retry--); // we'll do retries if needed + + if (value && strlen(value) == 0) { RETURNFUNC(RIG_EPROTO); } + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_init +* Assumes rig!=NULL +*/ +static int tci1x_init(RIG *rig) +{ + struct tci1x_priv_data *priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, rig->caps->version); + + rig->state.priv = (struct tci1x_priv_data *)malloc(sizeof( + struct tci1x_priv_data)); + + if (!rig->state.priv) + { + RETURNFUNC(-RIG_ENOMEM); + } + + priv = rig->state.priv; + + memset(priv, 0, sizeof(struct tci1x_priv_data)); + memset(priv->parms, 0, RIG_SETTING_MAX * sizeof(value_t)); + + /* + * set arbitrary initial status + */ + rig->state.current_vfo = RIG_VFO_A; + priv->split = 0; + priv->ptt = 0; + priv->curr_modeA = -1; + priv->curr_modeB = -1; + priv->curr_widthA = -1; + priv->curr_widthB = -1; + + if (!rig->caps) + { + RETURNFUNC(-RIG_EINVAL); + } + + strncpy(rig->state.rigport.pathname, DEFAULTPATH, + sizeof(rig->state.rigport.pathname)); + + priv->ext_parms = alloc_init_ext(tci1x_ext_parms); + + if (!priv->ext_parms) + { + RETURNFUNC(-RIG_ENOMEM); + } + + + RETURNFUNC(RIG_OK); +} + +/* +* modeMapGetTCI +* Assumes mode!=NULL +* Return the string for TCI for the given hamlib mode +*/ +static const char *modeMapGetTCI(rmode_t modeHamlib) +{ + int i; + + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + + for (i = 0; modeMap[i].mode_hamlib != 0; ++i) + { + if (modeMap[i].mode_tci1x == NULL) { continue; } + + rig_debug(RIG_DEBUG_TRACE, + "%s: checking modeMap[%d]=%.0f to modeHamlib=%.0f, mode_tci1x='%s'\n", __func__, + i, (double)modeMap[i].mode_hamlib, (double)modeHamlib, modeMap[i].mode_tci1x); + + if (modeMap[i].mode_hamlib == modeHamlib && strlen(modeMap[i].mode_tci1x) > 0) + { + rig_debug(RIG_DEBUG_TRACE, "%s matched mode=%.0f, returning '%s'\n", __func__, + (double)modeHamlib, modeMap[i].mode_tci1x); + return (modeMap[i].mode_tci1x); + } + } + + rig_debug(RIG_DEBUG_ERR, "%s: FlRig does not have mode: %s\n", __func__, + rig_strrmode(modeHamlib)); + return ("ERROR"); +} + +/* +* modeMapGetHamlib +* Assumes mode!=NULL +* Return the hamlib mode from the given TCI string +*/ +static rmode_t modeMapGetHamlib(const char *modeTCI) +{ + int i; + char modeTCICheck[MAXBUFLEN+2]; + + ENTERFUNC; + + snprintf(modeTCICheck, sizeof(modeTCICheck), "|%s|", modeTCI); + + for (i = 0; modeMap[i].mode_hamlib != 0; ++i) + { + rig_debug(RIG_DEBUG_TRACE, "%s: find '%s' in '%s'\n", __func__, + modeTCICheck, modeMap[i].mode_tci1x); + + if (modeMap[i].mode_tci1x + && strcmp(modeMap[i].mode_tci1x, modeTCICheck) == 0) + { + RETURNFUNC(modeMap[i].mode_hamlib); + } + } + + rig_debug(RIG_DEBUG_TRACE, "%s: mode requested: %s, not in modeMap\n", __func__, + modeTCI); + RETURNFUNC(RIG_MODE_NONE); +} + + +/* +* modeMapAdd +* Assumes modes!=NULL +*/ +static void modeMapAdd(rmode_t *modes, rmode_t mode_hamlib, char *mode_tci1x) +{ + int i; + int len1; + + rig_debug(RIG_DEBUG_TRACE, "%s:mode_tci1x=%s\n", __func__, mode_tci1x); + + // if we already have it just return + // We get ERROR if the mode is not known so non-ERROR is OK + if (modeMapGetHamlib(mode_tci1x) != RIG_MODE_NONE) { return; } + + len1 = strlen(mode_tci1x) + 3; /* bytes needed for allocating */ + + for (i = 0; modeMap[i].mode_hamlib != 0; ++i) + { + if (modeMap[i].mode_hamlib == mode_hamlib) + { + int len2; + *modes |= modeMap[i].mode_hamlib; + + /* we will pipe delimit all the entries for easier matching */ + /* all entries will have pipe symbol on both sides */ + if (modeMap[i].mode_tci1x == NULL) + { + modeMap[i].mode_tci1x = calloc(1, len1); + + if (modeMap[i].mode_tci1x == NULL) + { + rig_debug(RIG_DEBUG_ERR, "%s: error allocating memory for modeMap\n", + __func__); + return; + } + } + + len2 = strlen(modeMap[i].mode_tci1x); /* current len w/o null */ + modeMap[i].mode_tci1x = realloc(modeMap[i].mode_tci1x, + strlen(modeMap[i].mode_tci1x) + len1); + + if (strlen(modeMap[i].mode_tci1x) == 0) { modeMap[i].mode_tci1x[0] = '|'; } + + strncat(modeMap[i].mode_tci1x, mode_tci1x, len1 + len2); + strncat(modeMap[i].mode_tci1x, "|", len1 + len2); + rig_debug(RIG_DEBUG_TRACE, "%s: Adding mode=%s, index=%d, result=%s\n", + __func__, mode_tci1x, i, modeMap[i].mode_tci1x); + return; + } + } +} + +/* +* tci1x_open +* Assumes rig!=NULL, rig->state.priv!=NULL +*/ +static int tci1x_open(RIG *rig) +{ + int retval; + int trx_count = 0; + char value[MAXBUFLEN]; + char arg[MAXBUFLEN]; + rmode_t modes; + char *p; + char *pr; + //struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_VERBOSE, "%s: version %s\n", __func__, rig->caps->version); + char *websocket = + "GET / HTTP/1.1\r\nHost: localhost:50001\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: TnwnvtFT6akIBYQC7nh3vA==\r\nSec-WebSocket-Version: 13\r\n\r\n"; + + write_transaction(rig, websocket, strlen(websocket)); + + do + { + retval = read_transaction(rig, value, sizeof(value)); + rig_debug(RIG_DEBUG_VERBOSE, "%s: value=%s\n", __func__, value); + } + while (retval == RIG_OK && strlen(value) > 0); + + retval = tci1x_transaction(rig, "device;", NULL, value, sizeof(value)); + dump_hex((unsigned char *)value, strlen(value)); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: DEVICE failed: %s\n", __func__, + rigerror(retval)); + // we fall through and assume old version + //RETURNFUNC(retval); + } + + sscanf(&value[2], "device:%s", value); + + rig_debug(RIG_DEBUG_VERBOSE, "%s: TCI Device is %s\n", __func__, arg); + + // Receive only + retval = tci1x_transaction(rig, "receive_only;", NULL, value, sizeof(value)); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: RECEIVE_ONLY failed: %s\n", __func__, + rigerror(retval)); + // we fall through and assume old version + //RETURNFUNC(retval); + } + + sscanf(&value[2], "receive_only:%s", value); + rig_debug(RIG_DEBUG_VERBOSE, "%s: readonly is %s\n", __func__, arg); + + // TRX count + retval = tci1x_transaction(rig, "trx_count;", NULL, value, sizeof(value)); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: TRX_COUNT failed..not fatal: %s\n", __func__, + rigerror(retval)); + } + + sscanf(&value[2], "trx_count:%d", &trx_count); + rig_debug(RIG_DEBUG_VERBOSE, "Trx count=%d\n", trx_count); + + freq_t freq; + retval = tci1x_get_freq(rig, RIG_VFO_CURR, &freq); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: tci1x_get_freq not working!!\n", __func__); + //RETURNFUNC(RIG_EPROTO); + } + + rig->state.current_vfo = RIG_VFO_A; + rig_debug(RIG_DEBUG_TRACE, "%s: currvfo=%s value=%s\n", __func__, + rig_strvfo(rig->state.current_vfo), value); + //tci1x_get_split_vfo(rig, vfo, &priv->split, &vfo_tx); + RETURNFUNC(RIG_OK); + + /* find out available widths and modes */ + retval = tci1x_transaction(rig, "modulations_list;", NULL, value, + sizeof(value)); + + if (retval != RIG_OK) { RETURNFUNC(retval); } + + sscanf(&value[2], "modulations_list:%s", arg); + rig_debug(RIG_DEBUG_VERBOSE, "%s: modes=%s\n", __func__, arg); + modes = 0; + pr = value; + + /* The following modes in TCI are not implemented yet + A1A + AM-2 + AM6.0 + AM-D1 -- doesn't appear to be read/set + AM-D2 -- doesn't appear to be read/set + AM-D3 -- doesn't appear to be read/set + AMW -- don't have mode in rig.h + CW2.4 -- could be CW + CW500 -- could be CWN but CWN not in rig.h + CW-N -- could be CWN but CWN not in rig.h + CWN -- dcould be CWN but CWN not in rig.h + CW-NR -- don't have mode in rig.h + DATA2-LSB + DV + DV-R + F1B + FM-D1 -- doesn't appear to be read/set + FM-D2 -- doesn't appear to be read/set + FM-D3 -- doesn't appear to be read/set + H3E + M11 + USB-D -- doesn't appear to be read/set + USB-D1 -- doesn't appear to be read/set + USB-D2 -- doesn't appear to be read/set + USB-D3 -- doesn't appear to be read/set + USER-L -- doesn't appear to be read/set + USER-U -- doesn't appear to be read/set + */ + + for (p = strtok_r(value, ",", &pr); p != NULL; p = strtok_r(NULL, ",", &pr)) + { + if (streq(p, "AM-D")) { modeMapAdd(&modes, RIG_MODE_PKTAM, p); } + else if (streq(p, "AM")) { modeMapAdd(&modes, RIG_MODE_AM, p); } + else if (streq(p, "AM-N")) { modeMapAdd(&modes, RIG_MODE_AMN, p); } + else if (streq(p, "AMN")) { modeMapAdd(&modes, RIG_MODE_AMN, p); } + else if (streq(p, "CW")) { modeMapAdd(&modes, RIG_MODE_CW, p); } + else if (streq(p, "CW-L")) { modeMapAdd(&modes, RIG_MODE_CWR, p); } + else if (streq(p, "CW-LSB")) { modeMapAdd(&modes, RIG_MODE_CWR, p); } + else if (streq(p, "CW-R")) { modeMapAdd(&modes, RIG_MODE_CWR, p); } + else if (streq(p, "CW-U")) { modeMapAdd(&modes, RIG_MODE_CW, p); } + else if (streq(p, "CW-USB")) { modeMapAdd(&modes, RIG_MODE_CW, p); } + else if (streq(p, "CWL")) { modeMapAdd(&modes, RIG_MODE_CWR, p); } + else if (streq(p, "CWU")) { modeMapAdd(&modes, RIG_MODE_CW, p); } + else if (streq(p, "D-LSB")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); } + else if (streq(p, "D-USB")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "DATA")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "DATA-FM")) { modeMapAdd(&modes, RIG_MODE_PKTFM, p); } + else if (streq(p, "DATA-L")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); } + else if (streq(p, "DATA-R")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); } + else if (streq(p, "DATA-LSB")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); } + else if (streq(p, "DATA-USB")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "DATA-U")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "DIG")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "DIGI")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "DIGL")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); } + else if (streq(p, "DIGU")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "DSB")) { modeMapAdd(&modes, RIG_MODE_DSB, p); } + else if (streq(p, "FM")) { modeMapAdd(&modes, RIG_MODE_FM, p); } + else if (streq(p, "FM-D")) { modeMapAdd(&modes, RIG_MODE_PKTFM, p); } + else if (streq(p, "FMN")) { modeMapAdd(&modes, RIG_MODE_FMN, p); } + else if (streq(p, "FM-N")) { modeMapAdd(&modes, RIG_MODE_FMN, p); } + else if (streq(p, "FMW")) { modeMapAdd(&modes, RIG_MODE_WFM, p); } + else if (streq(p, "FSK")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); } + else if (streq(p, "FSK-R")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); } + else if (streq(p, "LCW")) { modeMapAdd(&modes, RIG_MODE_CWR, p); } + else if (streq(p, "LSB")) { modeMapAdd(&modes, RIG_MODE_LSB, p); } + else if (streq(p, "LSB-D")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); } + else if (streq(p, "LSB-D1")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); } + else if (streq(p, "LSB-D2")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); } + else if (streq(p, "LSB-D3")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); } + else if (streq(p, "NFM")) { modeMapAdd(&modes, RIG_MODE_FMN, p); } + else if (streq(p, "PKT")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); } + else if (streq(p, "PKT-FM")) { modeMapAdd(&modes, RIG_MODE_PKTFM, p); } + else if (streq(p, "PKT-L")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); } + else if (streq(p, "PKT-U")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); } + else if (streq(p, "PKT(L)")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); } + else if (streq(p, "PKT(U)")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); } + else if (streq(p, "PSK")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); } + else if (streq(p, "PSK-L")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); } + else if (streq(p, "PSK-R")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); } + else if (streq(p, "PSK-U")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); } + else if (streq(p, "RTTY")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); } + else if (streq(p, "RTTY-L")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); } + else if (streq(p, "RTTY-R")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); } + else if (streq(p, "RTTY-U")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); } + else if (streq(p, "RTTY(U)")) { modeMapAdd(&modes, RIG_MODE_RTTY, p); } + else if (streq(p, "RTTY(R")) { modeMapAdd(&modes, RIG_MODE_RTTYR, p); } + else if (streq(p, "SAH")) { modeMapAdd(&modes, RIG_MODE_SAH, p); } + else if (streq(p, "SAL")) { modeMapAdd(&modes, RIG_MODE_SAL, p); } + else if (streq(p, "SAM")) { modeMapAdd(&modes, RIG_MODE_SAM, p); } + else if (streq(p, "USB")) { modeMapAdd(&modes, RIG_MODE_USB, p); } + else if (streq(p, "USB-D")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "USB-D1")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "USB-D2")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "USB-D3")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "USER-U")) { modeMapAdd(&modes, RIG_MODE_PKTUSB, p); } + else if (streq(p, "USER-L")) { modeMapAdd(&modes, RIG_MODE_PKTLSB, p); } + else if (streq(p, "W-FM")) { modeMapAdd(&modes, RIG_MODE_WFM, p); } + else if (streq(p, "WFM")) { modeMapAdd(&modes, RIG_MODE_WFM, p); } + else if (streq(p, "UCW")) { modeMapAdd(&modes, RIG_MODE_CW, p); } + else if (streq(p, "C4FM")) { modeMapAdd(&modes, RIG_MODE_C4FM, p); } + else if (streq(p, "SPEC")) { modeMapAdd(&modes, RIG_MODE_SPEC, p); } + else if (streq(p, "DRM")) // we don't support DRM yet (or maybe ever) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: no mapping for mode %s\n", __func__, p); + } + else { rig_debug(RIG_DEBUG_ERR, "%s: Unknown mode (new?) for this rig='%s'\n", __func__, p); } + } + + rig->state.mode_list = modes; + + retval = rig_strrmodes(modes, value, sizeof(value)); + + if (retval != RIG_OK) // we might get TRUNC but we can still print the debug + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: %s\n", __func__, rigerror(retval)); + } + + rig_debug(RIG_DEBUG_VERBOSE, "%s: hamlib modes=%s\n", __func__, value); + + RETURNFUNC(retval); +} + +/* +* tci1x_close +* Assumes rig!=NULL +*/ +static int tci1x_close(RIG *rig) +{ + ENTERFUNC; + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_cleanup +* Assumes rig!=NULL, rig->state.priv!=NULL +*/ +static int tci1x_cleanup(RIG *rig) +{ + struct tci1x_priv_data *priv; + + rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__); + + if (!rig) + { + RETURNFUNC(-RIG_EINVAL); + } + + priv = (struct tci1x_priv_data *)rig->state.priv; + + free(priv->ext_parms); + free(rig->state.priv); + + rig->state.priv = NULL; + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_get_freq +* Assumes rig!=NULL, rig->state.priv!=NULL, freq!=NULL +*/ +static int tci1x_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) +{ + char value[MAXARGLEN]; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, + rig_strvfo(vfo)); + + + if (check_vfo(vfo) == FALSE) + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", + __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + if (vfo == RIG_VFO_CURR) + { + vfo = rig->state.current_vfo; + rig_debug(RIG_DEBUG_TRACE, "%s: get_freq2 vfo=%s\n", + __func__, rig_strvfo(vfo)); + } + + char *cmd = vfo == RIG_VFO_A ? "vfo:0:0;" : "vfo:0:1:"; + int retval; + int n; + + retval = tci1x_transaction(rig, cmd, NULL, value, sizeof(value)); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: tci1x_transaction failed retval=%s\n", __func__, + rigerror(retval)); + RETURNFUNC(retval); + } + + n = sscanf(&value[2], "vfo:%*d,%*d,%lf", freq); + rig_debug(RIG_DEBUG_VERBOSE, "%s: got '%s', scanned %d items\n", __func__, + value, n); + + if (*freq == 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: freq==0??\nvalue=%s\n", __func__, + value); + RETURNFUNC(-RIG_EPROTO); + } + else + { + rig_debug(RIG_DEBUG_TRACE, "%s: freq=%.0f\n", __func__, *freq); + } + + if (vfo == RIG_VFO_A) + { + priv->curr_freqA = *freq; + } + else + { + priv->curr_freqB = *freq; + } + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_set_freq +* assumes rig!=NULL, rig->state.priv!=NULL +*/ +static int tci1x_set_freq(RIG *rig, vfo_t vfo, freq_t freq) +{ + int retval; + char cmd_arg[MAXARGLEN]; + char *cmd; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.0f\n", __func__, + rig_strvfo(vfo), freq); + + if (check_vfo(vfo) == FALSE) + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", + __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + if (vfo == RIG_VFO_CURR) + { + vfo = rig->state.current_vfo; + } + else if (vfo == RIG_VFO_TX && priv->split) + { + vfo = RIG_VFO_B; // if split always TX on VFOB + } + + sprintf(cmd_arg, + "%.0f", freq); + + value_t val; + rig_get_ext_parm(rig, TOK_TCI1X_VERIFY_FREQ, &val); + rig_debug(RIG_DEBUG_VERBOSE, "%s: set_verify_vfoA/B=%d\n", __func__, val.i); + + if (vfo == RIG_VFO_A) + { + cmd = "rig.set_vfoA"; + + if (val.i) { cmd = "rig.set_verify_vfoA"; } + + rig_debug(RIG_DEBUG_TRACE, "%s %.0f\n", cmd, freq); + priv->curr_freqA = freq; + } + else + { + cmd = "rig.set_vfoB"; + + if (val.i) { cmd = "rig.set_verify_vfoB"; } + + rig_debug(RIG_DEBUG_TRACE, "%s %.0f\n", cmd, freq); + priv->curr_freqB = freq; + } + + retval = tci1x_transaction(rig, cmd, cmd_arg, NULL, 0); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_set_ptt +* Assumes rig!=NULL +*/ +static int tci1x_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) +{ + int retval; + char cmd_arg[MAXARGLEN]; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: ptt=%d\n", __func__, ptt); + + + if (check_vfo(vfo) == FALSE) + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", + __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + sprintf(cmd_arg, + "%d", + ptt); + + value_t val; + char *cmd = "rig.set_ptt"; + rig_get_ext_parm(rig, TOK_TCI1X_VERIFY_FREQ, &val); + rig_debug(RIG_DEBUG_VERBOSE, "%s: fast_set_ptt=%d\n", __func__, val.i); + + if (val.i) { cmd = "rig.set_ptt_fast"; } + + retval = tci1x_transaction(rig, cmd, cmd_arg, NULL, 0); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + priv->ptt = ptt; + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_get_ptt +* Assumes rig!=NUL, ptt!=NULL +*/ +static int tci1x_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) +{ + char value[MAXCMDLEN]; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, + rig_strvfo(vfo)); + + int retval; + + retval = tci1x_transaction(rig, "rig.get_ptt", NULL, value, sizeof(value)); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + *ptt = atoi(value); + rig_debug(RIG_DEBUG_TRACE, "%s: '%s'\n", __func__, value); + + priv->ptt = *ptt; + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_set_split_mode +* Assumes rig!=NULL +*/ +static int tci1x_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode, + pbwidth_t width) +{ + int retval; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n", + __func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width); + + switch (vfo) + { + case RIG_VFO_CURR: + vfo = rig->state.current_vfo; + break; + + case RIG_VFO_TX: + vfo = RIG_VFO_B; + break; + } + + // If no change don't do it...modes are kept up to date by client calls + // to get_mode and set_mode so should be current here + rig_debug(RIG_DEBUG_TRACE, "%s: vfoa privmode=%s\n", __func__, + rig_strrmode(priv->curr_modeA)); + rig_debug(RIG_DEBUG_TRACE, "%s: vfob privmode=%s\n", __func__, + rig_strrmode(priv->curr_modeB)); + + // save some VFO swapping .. may replace with VFO specific calls that won't cause VFO change + if (vfo == RIG_VFO_A && mode == priv->curr_modeA) { RETURNFUNC(RIG_OK); } + + if (vfo == RIG_VFO_B && mode == priv->curr_modeB) { RETURNFUNC(RIG_OK); } + + retval = tci1x_set_mode(rig, vfo, mode, width); + rig_debug(RIG_DEBUG_TRACE, "%s: set mode=%s\n", __func__, + rig_strrmode(mode)); + RETURNFUNC(retval); +} + +/* +* tci1x_set_mode +* Assumes rig!=NULL +*/ +static int tci1x_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) +{ + int retval; + int needBW; + int vfoSwitched; + char cmd_arg[MAXCMDLEN]; + char *p; + char *pttmode; + char *ttmode; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s mode=%s width=%d\n", + __func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width); + + + // if ptt is on do not set mode + if (priv->ptt) + { + rig_debug(RIG_DEBUG_TRACE, "%s: returning because priv->ptt=%d\n", __func__, + (int)priv->ptt); + RETURNFUNC(RIG_OK); + } + + if (vfo == RIG_VFO_CURR) + { + vfo = rig->state.current_vfo; + } + + if (check_vfo(vfo) == FALSE) + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", + __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + if (priv->ptt) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s set_mode call not made as PTT=1\n", __func__); + RETURNFUNC(RIG_OK); // just return OK and ignore this + } + + // Switch to VFOB if appropriate since we can't set mode directly + // MDB + vfoSwitched = 0; + rig_debug(RIG_DEBUG_TRACE, "%s: curr_vfo = %s\n", __func__, + rig_strvfo(rig->state.current_vfo)); + + // If we don't have the get_bwA call we have to switch VFOs ourself + if (!priv->has_get_bwA && vfo == RIG_VFO_B + && rig->state.current_vfo != RIG_VFO_B) + { + vfoSwitched = 1; + rig_debug(RIG_DEBUG_TRACE, "%s: switch to VFOB = %d\n", __func__, + vfoSwitched); + } + + if (vfoSwitched) // swap to B and we'll swap back later + { + rig_debug(RIG_DEBUG_TRACE, "%s: switching to VFOB = %d\n", __func__, + vfoSwitched); + retval = tci1x_set_vfo(rig, RIG_VFO_B); + + if (retval < 0) + { + RETURNFUNC(retval); + } + } + + // Set the mode + if (modeMapGetTCI(mode)) + { + ttmode = strdup(modeMapGetTCI(mode)); + } + else + { + rig_debug(RIG_DEBUG_ERR, "%s: modeMapGetFlRig failed on mode=%d\n", __func__, + (int)mode); + RETURNFUNC(-RIG_EINVAL); + } + + rig_debug(RIG_DEBUG_TRACE, "%s: got ttmode = %s\n", __func__, + ttmode == NULL ? "NULL" : ttmode); + + if (ttmode == NULL) + { + rig_debug(RIG_DEBUG_ERR, "%s: strdup failed\n", __func__); + RETURNFUNC(-RIG_EINTERNAL); + } + +// if (strncmp(ttmode,"ERROR",5)==0) RETURNFUNC(-RIG_EINTERN); + + pttmode = ttmode; + + if (ttmode[0] == '|') { pttmode = &ttmode[1]; } // remove first pipe symbol + + p = strchr(pttmode, '|'); + + if (p) { *p = 0; } // remove any other pipe + + sprintf(cmd_arg, "%s", pttmode); + free(ttmode); + + if (!priv->has_get_modeA) + { + retval = tci1x_transaction(rig, "rig.set_mode", cmd_arg, NULL, 0); + } + else + { + char *cmd = "rig.set_modeA"; + + if (vfo == RIG_VFO_B) + { + cmd = "rig.set_modeB"; + } + else + { + // we make VFO_B mode unknown so it expires the cache + priv->curr_modeB = RIG_MODE_NONE; + } + + retval = tci1x_transaction(rig, cmd, cmd_arg, NULL, 0); + } + + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: failed: %s\n", __func__, + rigerror(retval)); + RETURNFUNC(retval); + } + + // Determine if we need to update the bandwidth + needBW = 0; + + if (vfo == RIG_VFO_A) + { + needBW = priv->curr_widthA != width; + rig_debug(RIG_DEBUG_TRACE, "%s: bw change on VFOA, curr width=%d needBW=%d\n", + __func__, (int)width, needBW); + } + else if (vfo == RIG_VFO_B) + { + needBW = priv->curr_widthB != width; + rig_debug(RIG_DEBUG_TRACE, "%s: bw change on VFOB, curr width=%d needBW=%d\n", + __func__, (int)width, needBW); + } + else + { + rig_debug(RIG_DEBUG_TRACE, "%s: needBW unknown vfo=%s\n", __func__, + rig_strvfo(vfo)); + } + + // Need to update the bandwidth + if (width > 0 && needBW) + { + sprintf(cmd_arg, "%ld", + width); + + retval = tci1x_transaction(rig, "rig.set_bandwidth", cmd_arg, NULL, 0); + + if (retval < 0) + { + RETURNFUNC(retval); + } + } + + // Return to VFOA if needed + rig_debug(RIG_DEBUG_TRACE, "%s: switch to VFOA? = %d\n", __func__, + vfoSwitched); + + if (vfoSwitched) + { + rig_debug(RIG_DEBUG_TRACE, "%s: switching to VFOA\n", __func__); + retval = tci1x_set_vfo(rig, RIG_VFO_A); + + if (retval < 0) + { + RETURNFUNC(retval); + } + } + + if (vfo == RIG_VFO_A) + { + priv->curr_modeA = mode; + priv->curr_widthA = width; + } + else + { + priv->curr_modeB = mode; + priv->curr_widthB = width; + } + + rig_debug(RIG_DEBUG_TRACE, + "%s: return modeA=%s, widthA=%d\n,modeB=%s, widthB=%d\n", __func__, + rig_strrmode(priv->curr_modeA), (int)priv->curr_widthA, + rig_strrmode(priv->curr_modeB), (int)priv->curr_widthB); + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_get_mode +* Assumes rig!=NULL, rig->state.priv!=NULL, mode!=NULL +*/ +static int tci1x_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) +{ + int retval; + int vfoSwitched; + char value[MAXCMDLEN]; + char *cmdp; + vfo_t curr_vfo; + rmode_t my_mode; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, + rig_strvfo(vfo)); + + if (check_vfo(vfo) == FALSE) + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", + __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + curr_vfo = rig->state.current_vfo; + + if (vfo == RIG_VFO_CURR) + { + vfo = rig->state.current_vfo; + } + + rig_debug(RIG_DEBUG_TRACE, "%s: using vfo=%s\n", __func__, + rig_strvfo(vfo)); + + if (priv->ptt) + { + if (vfo == RIG_VFO_A) { *mode = priv->curr_modeA; } + else { *mode = priv->curr_modeB; } + + rig_debug(RIG_DEBUG_VERBOSE, "%s call not made as PTT=1\n", __func__); + RETURNFUNC(RIG_OK); // just return OK and ignore this + } + + // Switch to VFOB if appropriate + vfoSwitched = 0; + + if (priv->has_get_modeA == 0 && vfo == RIG_VFO_B && curr_vfo != RIG_VFO_B) + { + vfoSwitched = 1; + } + + if (vfoSwitched) + { + rig_debug(RIG_DEBUG_TRACE, "%s switch to VFOB=%d\n", __func__, + priv->has_get_modeA); + retval = tci1x_set_vfo(rig, RIG_VFO_B); + + if (retval < 0) + { + RETURNFUNC(retval); + } + } + + cmdp = "rig.get_mode"; /* default to old way */ + + if (priv->has_get_modeA) /* change to new way if we can */ + { + /* calling this way reduces VFO swapping */ + /* we get the cached value in tci1x */ + /* vfo B may not be getting polled though in TCI */ + /* so we may not be 100% accurate if op is twiddling knobs */ + cmdp = "rig.get_modeA"; + + if (vfo == RIG_VFO_B) { cmdp = "rig.get_modeB"; } + } + + retval = tci1x_transaction(rig, cmdp, NULL, value, sizeof(value)); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: %s failed: %s\n", __func__, cmdp, + rigerror(retval)); + RETURNFUNC(retval); + } + + my_mode = modeMapGetHamlib(value); + *mode = my_mode; + rig_debug(RIG_DEBUG_TRACE, "%s: mode='%s'\n", __func__, + rig_strrmode(*mode)); + + if (vfo == RIG_VFO_A) + { + priv->curr_modeA = *mode; + } + else + { + priv->curr_modeB = *mode; + } + + + /* Get the bandwidth */ + cmdp = "rig.get_bw"; /* default to old way */ + + if (priv->has_get_bwA) /* change to new way if we can */ + { + /* calling this way reduces VFO swapping */ + /* we get the cached value in tci1x */ + /* vfo B may not be getting polled though in TCI */ + /* so we may not be 100% accurate if op is twiddling knobs */ + cmdp = "rig.get_bwA"; + + if (vfo == RIG_VFO_B) { cmdp = "rig.get_bwB"; } + } + + retval = tci1x_transaction(rig, cmdp, NULL, value, sizeof(value)); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + rig_debug(RIG_DEBUG_TRACE, "%s: mode=%s width='%s'\n", __func__, + rig_strrmode(*mode), value); + + // we get 2 entries pipe separated for bandwidth, lower and upper + if (strlen(value) > 0) + { + char *p = value; + + /* we might get two values and then we want the 2nd one */ + if (strchr(value, '|') != NULL) { p = strchr(value, '|') + 1; } + + *width = atoi(p); + } + + if (vfo == RIG_VFO_A) + { + priv->curr_widthA = *width; + } + else + { + priv->curr_widthB = *width; + } + + // Return to VFOA if needed + if (vfoSwitched) + { + retval = tci1x_set_vfo(rig, RIG_VFO_A); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + } + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_set_vfo +* assumes rig!=NULL +*/ +static int tci1x_set_vfo(RIG *rig, vfo_t vfo) +{ + int retval; + char cmd_arg[MAXBUFLEN]; + struct rig_state *rs = &rig->state; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, + rig_strvfo(vfo)); + + + if (check_vfo(vfo) == FALSE) + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", + __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + if (vfo == RIG_VFO_TX) + { + rig_debug(RIG_DEBUG_TRACE, "%s: RIG_VFO_TX used\n", __func__); + vfo = RIG_VFO_B; // always TX on VFOB + } + + if (vfo == RIG_VFO_CURR) + { + vfo = rig->state.current_vfo; + } + + sprintf(cmd_arg, "%s", + vfo == RIG_VFO_A ? "A" : "B"); + retval = tci1x_transaction(rig, "rig.set_AB", cmd_arg, NULL, 0); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: rig.set_AB failed: %s\n", __func__, + rigerror(retval)); + RETURNFUNC(retval); + } + + rig->state.current_vfo = vfo; + rs->tx_vfo = RIG_VFO_B; // always VFOB + + /* for some rigs TCI turns off split when VFOA is selected */ + /* so if we are in split and asked for A we have to turn split back on */ + if (priv->split && vfo == RIG_VFO_A) + { + sprintf(cmd_arg, "%d", + priv->split); + retval = tci1x_transaction(rig, "rig.set_split", cmd_arg, NULL, 0); + + if (retval < 0) + { + RETURNFUNC(retval); + } + } + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_get_vfo +* assumes rig!=NULL, vfo != NULL +*/ +static int tci1x_get_vfo(RIG *rig, vfo_t *vfo) +{ + char value[MAXCMDLEN]; + + ENTERFUNC; + + + int retval; + retval = tci1x_transaction(rig, "rig.get_AB", NULL, value, sizeof(value)); + + if (retval < 0) + { + RETURNFUNC(retval); + } + + rig_debug(RIG_DEBUG_TRACE, "%s: vfo value=%s\n", __func__, value); + + switch (value[0]) + { + case 'A': + *vfo = RIG_VFO_A; + break; + + case 'B': + *vfo = RIG_VFO_B; + break; + + default: + *vfo = RIG_VFO_CURR; + RETURNFUNC(-RIG_EINVAL); + } + + if (check_vfo(*vfo) == FALSE) + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", + __func__, rig_strvfo(*vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + rig->state.current_vfo = *vfo; + + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, + rig_strvfo(*vfo)); + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_set_split_freq +* assumes rig!=NULL +*/ +static int tci1x_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) +{ + int retval; + char cmd_arg[MAXBUFLEN]; + freq_t qtx_freq; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s freq=%.1f\n", __func__, + rig_strvfo(vfo), tx_freq); + + if (check_vfo(vfo) == FALSE) + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", + __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + // we always split on VFOB so if no change just return + retval = tci1x_get_freq(rig, RIG_VFO_B, &qtx_freq); + + if (retval != RIG_OK) { RETURNFUNC(retval); } + + if (tx_freq == qtx_freq) { RETURNFUNC(RIG_OK); } + + sprintf(cmd_arg, + "%.6f", + tx_freq); + retval = tci1x_transaction(rig, "rig.set_vfoB", cmd_arg, NULL, 0); + + if (retval < 0) + { + RETURNFUNC(retval); + } + + priv->curr_freqB = tx_freq; + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_get_split_freq +* assumes rig!=NULL, tx_freq!=NULL +*/ +static int tci1x_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) +{ + int retval; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, + rig_strvfo(vfo)); + + retval = tci1x_get_freq(rig, RIG_VFO_B, tx_freq); + priv->curr_freqB = *tx_freq; + RETURNFUNC(retval); +} + +/* +* tci1x_set_split_vfo +* assumes rig!=NULL, tx_freq!=NULL +*/ +static int tci1x_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) +{ + int retval; + vfo_t qtx_vfo; + split_t qsplit; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + char cmd_arg[MAXBUFLEN]; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: tx_vfo=%s\n", __func__, + rig_strvfo(tx_vfo)); + + retval = tci1x_get_split_vfo(rig, RIG_VFO_A, &qsplit, &qtx_vfo); + + if (retval != RIG_OK) { RETURNFUNC(retval); } + + if (split == qsplit) { RETURNFUNC(RIG_OK); } + + if (priv->ptt) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s call not made as PTT=1\n", __func__); + RETURNFUNC(RIG_OK); // just return OK and ignore this + } + + sprintf(cmd_arg, "%d", + split); + retval = tci1x_transaction(rig, "rig.set_split", cmd_arg, NULL, 0); + + if (retval < 0) + { + RETURNFUNC(retval); + } + + priv->split = split; + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_get_split_vfo +* assumes rig!=NULL, tx_freq!=NULL +*/ +static int tci1x_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo) +{ + char value[MAXCMDLEN]; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + + int retval; + retval = tci1x_transaction(rig, "rig.get_split", NULL, value, sizeof(value)); + + if (retval < 0) + { + RETURNFUNC(retval); + } + + *tx_vfo = RIG_VFO_B; + *split = atoi(value); + priv->split = *split; + rig_debug(RIG_DEBUG_TRACE, "%s tx_vfo=%s, split=%d\n", __func__, + rig_strvfo(*tx_vfo), *split); + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_set_split_freq_mode +* assumes rig!=NULL +*/ +static int tci1x_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq, + rmode_t mode, pbwidth_t width) +{ + int retval; + rmode_t qmode; + pbwidth_t qwidth; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + + // we alway do split on VFOB + retval = tci1x_set_freq(rig, RIG_VFO_B, freq); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s tci1x_set_freq failed\n", __func__); + RETURNFUNC(retval); + } + + // Make VFOB mode match VFOA mode, keep VFOB width + retval = tci1x_get_mode(rig, RIG_VFO_B, &qmode, &qwidth); + + if (retval != RIG_OK) { RETURNFUNC(retval); } + + if (qmode == priv->curr_modeA) { RETURNFUNC(RIG_OK); } + + if (priv->ptt) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s set_mode call not made as PTT=1\n", __func__); + RETURNFUNC(RIG_OK); // just return OK and ignore this + } + + retval = tci1x_set_mode(rig, RIG_VFO_B, priv->curr_modeA, width); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s tci1x_set_mode failed\n", __func__); + RETURNFUNC(retval); + } + + retval = tci1x_set_vfo(rig, RIG_VFO_A); + + RETURNFUNC(retval); +} + +/* +* tci1x_get_split_freq_mode +* assumes rig!=NULL, freq!=NULL, mode!=NULL, width!=NULL +*/ +static int tci1x_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *freq, + rmode_t *mode, pbwidth_t *width) +{ + int retval; + + ENTERFUNC; + + if (vfo != RIG_VFO_CURR && vfo != RIG_VFO_TX) + { + RETURNFUNC(-RIG_ENTARGET); + } + + retval = tci1x_get_freq(rig, RIG_VFO_B, freq); + + if (RIG_OK == retval) + { + retval = tci1x_get_mode(rig, vfo, mode, width); + } + + RETURNFUNC(retval); +} + +#ifdef XXNOTIMPLEMENTED +static int tci1x_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) +{ + int retval; + char cmd_arg[MAXARGLEN]; + char *cmd; + char *param_type = "i4"; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s level=%d, val=%f\n", __func__, + rig_strvfo(vfo), (int)level, val.f); + + if (check_vfo(vfo) == FALSE) + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", + __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + switch (level) + { + case RIG_LEVEL_RF: cmd = "rig.set_rfgain"; val.f *= 100; break; + + case RIG_LEVEL_AF: cmd = "rig.set_volume"; val.f *= 100; break; + + case RIG_LEVEL_MICGAIN: cmd = "rig.set_micgain"; val.f *= 100; break; + + case RIG_LEVEL_RFPOWER: cmd = "rig.set_power"; val.f *= 100; break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: invalid level=%d\n", __func__, (int)level); + RETURNFUNC(-RIG_EINVAL); + } + + sprintf(cmd_arg, + "<%s>%d", + param_type, (int)val.f, param_type); + + + retval = tci1x_transaction(rig, cmd, cmd_arg, NULL, 0); + + if (retval < 0) + { + RETURNFUNC(retval); + } + + RETURNFUNC(RIG_OK); +} + +/* +* tci1x_get_level +* Assumes rig!=NULL, rig->state.priv!=NULL, val!=NULL +*/ +static int tci1x_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) +{ + char value[MAXARGLEN]; + char *cmd; + int retval; + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, + rig_strvfo(vfo)); + + + switch (level) + { + case RIG_LEVEL_AF: cmd = "rig.get_volume"; break; + + case RIG_LEVEL_RF: cmd = "rig.get_rfgain"; break; + + case RIG_LEVEL_MICGAIN: cmd = "rig.get_micgain"; break; + + case RIG_LEVEL_STRENGTH: cmd = "rig.get_smeter"; break; + + case RIG_LEVEL_RFPOWER: cmd = "rig.get_power"; break; + + case RIG_LEVEL_RFPOWER_METER_WATTS: + case RIG_LEVEL_RFPOWER_METER: cmd = "rig.get_pwrmeter"; break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown level=%d\n", __func__, (int)level); + RETURNFUNC(-RIG_EINVAL); + } + + retval = tci1x_transaction(rig, cmd, NULL, value, sizeof(value)); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: tci1x_transaction failed retval=%s\n", __func__, + rigerror(retval)); + RETURNFUNC(retval); + } + + // most levels are 0-100 -- may have to allow for different ranges + switch (level) + { + case RIG_LEVEL_STRENGTH: + val->i = atoi(value) - 54; + //if (val->i > 0) val->i /= 10; + rig_debug(RIG_DEBUG_TRACE, "%s: val.i='%s'(%d)\n", __func__, value, val->i); + break; + + case RIG_LEVEL_RFPOWER: + val->f = atof(value) / 100.0 * priv->powermeter_scale; + rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%g)\n", __func__, value, val->f); + break; + + case RIG_LEVEL_RFPOWER_METER: + val->f = atof(value) / 100.0 * priv->powermeter_scale; + rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%g)\n", __func__, value, val->f); + break; + + case RIG_LEVEL_RFPOWER_METER_WATTS: + val->f = atof(value) * priv->powermeter_scale; + rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%g)\n", __func__, value, val->f); + break; + + default: + val->f = atof(value) / 100; + rig_debug(RIG_DEBUG_TRACE, "%s: val.f='%s'(%f)\n", __func__, value, val->f); + } + + + RETURNFUNC(RIG_OK); +} +#endif + +/* +* tci1x_get_info +* assumes rig!=NULL +*/ +static const char *tci1x_get_info(RIG *rig) +{ + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + + return (priv->info); +} + +static int tci1x_power2mW(RIG *rig, unsigned int *mwpower, float power, + freq_t freq, rmode_t mode) +{ + struct tci1x_priv_data *priv = (struct tci1x_priv_data *) rig->state.priv; + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: passed power = %f\n", __func__, power); + rig_debug(RIG_DEBUG_TRACE, "%s: passed freq = %"PRIfreq" Hz\n", __func__, freq); + rig_debug(RIG_DEBUG_TRACE, "%s: passed mode = %s\n", __func__, + rig_strrmode(mode)); + + power *= priv->powermeter_scale; + *mwpower = (power * 100000); + + RETURNFUNC(RIG_OK); +} + +static int tci1x_mW2power(RIG *rig, float *power, unsigned int mwpower, + freq_t freq, rmode_t mode) +{ + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: passed mwpower = %u\n", __func__, mwpower); + rig_debug(RIG_DEBUG_TRACE, "%s: passed freq = %"PRIfreq" Hz\n", __func__, freq); + rig_debug(RIG_DEBUG_TRACE, "%s: passed mode = %s\n", __func__, + rig_strrmode(mode)); + + *power = ((float)mwpower / 100000); + + RETURNFUNC(RIG_OK); + +} + +#ifdef XXNOTIMPLEMENTED +static int tci1x_set_ext_parm(RIG *rig, token_t token, value_t val) +{ + struct tci1x_priv_data *priv = (struct tci1x_priv_data *)rig->state.priv; + char lstr[64]; + const struct confparams *cfp; + struct ext_list *epp; + + ENTERFUNC; + cfp = rig_ext_lookup_tok(rig, token); + + if (!cfp) + { + RETURNFUNC(-RIG_EINVAL); + } + + switch (token) + { + case TOK_TCI1X_VERIFY_FREQ: + case TOK_TCI1X_VERIFY_PTT: + if (val.i && !priv->has_verify_cmds) + { + rig_debug(RIG_DEBUG_ERR, + "%s: FLRig version 1.3.54.18 or higher needed to support fast functions\n", + __func__); + RETURNFUNC(-RIG_EINVAL); + } + + break; + + default: + RETURNFUNC(-RIG_EINVAL); + } + + switch (cfp->type) + { + case RIG_CONF_STRING: + strcpy(lstr, val.s); + break; + + + case RIG_CONF_COMBO: + sprintf(lstr, "%d", val.i); + break; + + case RIG_CONF_NUMERIC: + sprintf(lstr, "%f", val.f); + break; + + case RIG_CONF_CHECKBUTTON: + sprintf(lstr, "%s", val.i ? "ON" : "OFF"); + break; + + case RIG_CONF_BUTTON: + lstr[0] = '\0'; + break; + + default: + RETURNFUNC(-RIG_EINTERNAL); + } + + epp = find_ext(priv->ext_parms, token); + + if (!epp) + { + RETURNFUNC(-RIG_EINTERNAL); + } + + /* store value */ + epp->val = val; + + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s %s\n", __func__, + cfp->name, lstr); + + RETURNFUNC(RIG_OK); +} + +static int tci1x_get_ext_parm(RIG *rig, token_t token, value_t *val) +{ + struct tci1x_priv_data *priv = (struct tci1x_priv_data *)rig->state.priv; + const struct confparams *cfp; + struct ext_list *epp; + + ENTERFUNC; + /* TODO: load value from priv->ext_parms */ + + cfp = rig_ext_lookup_tok(rig, token); + + if (!cfp) + { + RETURNFUNC(-RIG_EINVAL); + } + + switch (token) + { + case TOK_TCI1X_VERIFY_FREQ: + case TOK_TCI1X_VERIFY_PTT: + break; + + default: + RETURNFUNC(-RIG_EINVAL); + } + + epp = find_ext(priv->ext_parms, token); + + if (!epp) + { + RETURNFUNC(-RIG_EINTERNAL); + } + + /* load value */ + *val = epp->val; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, + cfp->name); + + RETURNFUNC(RIG_OK); +} + + +static int tci1x_set_ext_parm(RIG *rig, setting_t parm, value_t val) +{ + struct tci1x_priv_data *priv = (struct tci1x_priv_data *)rig->state.priv; + int idx; + char pstr[32]; + + ENTERFUNC; + idx = rig_setting2idx(parm); + + if (idx >= RIG_SETTING_MAX) + { + RETURNFUNC(-RIG_EINVAL); + } + + if (RIG_PARM_IS_FLOAT(parm)) + { + sprintf(pstr, "%f", val.f); + } + else + { + sprintf(pstr, "%d", val.i); + } + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s %s\n", __func__, + rig_strparm(parm), pstr); + priv->parms[idx] = val; + + RETURNFUNC(RIG_OK); +} + +static int tci1x_get_ext_parm(RIG *rig, setting_t parm, value_t *val) +{ + struct tci1x_priv_data *priv = (struct tci1x_priv_data *)rig->state.priv; + int idx; + + ENTERFUNC; + idx = rig_setting2idx(parm); + + if (idx >= RIG_SETTING_MAX) + { + RETURNFUNC(-RIG_EINVAL); + } + + *val = priv->parms[idx]; + rig_debug(RIG_DEBUG_VERBOSE, "%s called %s\n", __func__, + rig_strparm(parm)); + + RETURNFUNC(RIG_OK); +} +#endif diff --git a/rigs/dummy/trxmanager.c b/rigs/dummy/trxmanager.c index 5d5192d32..2476870ff 100644 --- a/rigs/dummy/trxmanager.c +++ b/rigs/dummy/trxmanager.c @@ -243,7 +243,7 @@ static int read_transaction(RIG *rig, char *response, int response_len) rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__); len = read_string(&rs->rigport, response, response_len, delims, - strlen(delims), 0); + strlen(delims), 0, 1); if (len <= 0) { diff --git a/rigs/elad/elad.c b/rigs/elad/elad.c index 427fe6500..070791958 100644 --- a/rigs/elad/elad.c +++ b/rigs/elad/elad.c @@ -253,7 +253,7 @@ transaction_read: /* allow one extra byte for terminator we don't return */ len = min(datasize ? datasize + 1 : strlen(priv->verify_cmd) + 13, ELAD_MAX_BUF_LEN); - retval = read_string(&rs->rigport, buffer, len, cmdtrm, strlen(cmdtrm), 0); + retval = read_string(&rs->rigport, buffer, len, cmdtrm, strlen(cmdtrm), 0, 1); if (retval < 0) { @@ -3739,7 +3739,7 @@ DECLARE_PROBERIG_BACKEND(elad) } retval = write_block(port, "ID;", 3); - id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0); + id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0, 1); close(port->fd); if (retval != RIG_OK || id_len < 0) @@ -3800,7 +3800,7 @@ DECLARE_PROBERIG_BACKEND(elad) } retval = write_block(port, "K2;", 3); - id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0); + id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0, 1); close(port->fd); if (retval != RIG_OK) diff --git a/rigs/icmarine/icmarine.c b/rigs/icmarine/icmarine.c index 5fc194f47..5e99e681f 100644 --- a/rigs/icmarine/icmarine.c +++ b/rigs/icmarine/icmarine.c @@ -288,7 +288,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param, /* * Transceiver sends an echo of cmd followed by a CR/LF */ - retval = read_string(&rs->rigport, respbuf, BUFSZ, LF, strlen(LF), 0); + retval = read_string(&rs->rigport, respbuf, BUFSZ, LF, strlen(LF), 0, 1); if (retval < 0) { diff --git a/rigs/icom/Makefile.am b/rigs/icom/Makefile.am index ebb2ecab6..56fb9a630 100644 --- a/rigs/icom/Makefile.am +++ b/rigs/icom/Makefile.am @@ -9,7 +9,7 @@ ICOMSRC = ic706.c icr8500.c ic735.c ic775.c ic756.c \ ic707.c ic728.c ic751.c ic761.c \ ic78.c ic7800.c ic785x.c \ ic7000.c ic7100.c ic7200.c ic7300.c ic7600.c ic7610.c ic7700.c \ - icom.c icom.h icom_defs.h frame.c frame.h optoscan.c optoscan.h x108g.c + icom.c icom.h icom_defs.h frame.c frame.h ic7300.h optoscan.c optoscan.h x108g.c noinst_LTLIBRARIES = libhamlib-icom.la libhamlib_icom_la_SOURCES = $(ICOMSRC) diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c index c6351262f..dcbd6059b 100644 --- a/rigs/icom/frame.c +++ b/rigs/icom/frame.c @@ -138,7 +138,6 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, unsigned char ctrl_id; ENTERFUNC; - rig_lock(); memset(buf, 0, 200); memset(sendbuf, 0, MAXFRAMELEN); rs = &rig->state; @@ -164,7 +163,6 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, if (retval != RIG_OK) { set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(retval); } @@ -186,14 +184,12 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, { /* Nothing received, CI-V interface is not echoing */ set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_BUSERROR); } if (retval < 0) { set_transaction_inactive(rig); - rig_unlock(); /* Other error, return it */ RETURNFUNC(retval); } @@ -201,7 +197,6 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, if (retval < 1) { set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_EPROTO); } @@ -210,7 +205,6 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, case COL: /* Collision */ set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_BUSBUSY); case FI: @@ -221,7 +215,6 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, /* Timeout after reading at least one character */ /* Problem on ci-v bus? */ set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_BUSERROR); } @@ -231,7 +224,6 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, /* Problem on ci-v bus? */ /* Someone else got a packet in? */ set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_EPROTO); } @@ -241,7 +233,6 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, /* Problem on ci-v bus? */ /* Someone else got a packet in? */ set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_EPROTO); } } @@ -252,7 +243,6 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, if (data_len == NULL) { set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(RIG_OK); } @@ -283,7 +273,6 @@ read_another_frame: if (frm_len < 0) { - rig_unlock(); set_transaction_inactive(rig); /* RIG_TIMEOUT: timeout getting response, return timeout */ /* other error: return it */ @@ -292,7 +281,6 @@ read_another_frame: if (frm_len < 1) { - rig_unlock(); set_transaction_inactive(rig); RETURNFUNC(-RIG_EPROTO); } @@ -302,7 +290,6 @@ read_another_frame: if (retval < 0) { set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(retval); } @@ -311,7 +298,6 @@ read_another_frame: if (frm_len < 1) { rig_debug(RIG_DEBUG_ERR, "Unexpected frame len=%d\n", frm_len); - rig_unlock(); RETURNFUNC(-RIG_EPROTO); } @@ -320,7 +306,6 @@ read_another_frame: case COL: set_transaction_inactive(rig); /* Collision */ - rig_unlock(); RETURNFUNC(-RIG_BUSBUSY); case FI: @@ -329,21 +314,18 @@ read_another_frame: case NAK: set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_ERJCTED); default: set_transaction_inactive(rig); /* Timeout after reading at least one character */ /* Problem on ci-v bus? */ - rig_unlock(); RETURNFUNC(-RIG_EPROTO); } if (frm_len < ACKFRMLEN) { set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_EPROTO); } @@ -352,7 +334,6 @@ read_another_frame: if (frm_len == 6 && NAK == buf[frm_len - 2]) { set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_ERJCTED); } @@ -363,7 +344,6 @@ read_another_frame: if (FI != buf[frm_len - 1] && ACK != buf[frm_len - 1]) { set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_BUSBUSY); } @@ -372,7 +352,6 @@ read_another_frame: if (frm_data_len <= 0) { set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_EPROTO); } @@ -390,7 +369,6 @@ read_another_frame: if (elapsed_ms > rs->rigport.timeout) { set_transaction_inactive(rig); - rig_unlock(); RETURNFUNC(-RIG_ETIMEOUT); } @@ -400,13 +378,13 @@ read_another_frame: set_transaction_inactive(rig); *data_len = frm_data_len; - memcpy(data, buf + 4, *data_len); + + if (data != NULL && data_len != NULL) { memcpy(data, buf + 4, *data_len); } /* * TODO: check addresses in reply frame */ - rig_unlock(); RETURNFUNC(RIG_OK); } @@ -493,11 +471,13 @@ static int read_icom_frame_generic(hamlib_port_t *p, const unsigned char rxbuffe int i; if (direct) { - i = read_string_direct(p, rx_ptr, MAXFRAMELEN - read, icom_block_end, icom_block_end_length, 0); + i = read_string_direct(p, rx_ptr, MAXFRAMELEN - read, + icom_block_end, icom_block_end_length, 0, 1); } else { - i = read_string(p, rx_ptr, MAXFRAMELEN - read, icom_block_end, icom_block_end_length, 0); + i = read_string(p, rx_ptr, MAXFRAMELEN - read, + icom_block_end, icom_block_end_length, 0, 1); } if (i < 0 && i != RIG_BUSBUSY) /* die on errors */ diff --git a/rigs/icom/ic7100.c b/rigs/icom/ic7100.c index 5b4847399..68fdc5403 100644 --- a/rigs/icom/ic7100.c +++ b/rigs/icom/ic7100.c @@ -32,6 +32,7 @@ #include "idx_builtin.h" #include "bandplan.h" #include "token.h" +#include "misc.h" #define IC7100_MODES (RIG_MODE_SSB|RIG_MODE_CW|RIG_MODE_CWR|\ @@ -202,6 +203,106 @@ static const struct icom_priv_caps ic7100_priv_caps = .ant_count = 2 }; +// if hour < 0 then only date will be set +int ic7100_set_clock(RIG *rig, int year, int month, int day, int hour, int min, + int sec, double msec, int utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + unsigned char prmbuf[MAXFRAMELEN]; + + if (year >= 0) + { + prmbuf[0] = 0x01; + prmbuf[1] = 0x20; + to_bcd(&prmbuf[2], year / 100, 2); + to_bcd(&prmbuf[3], year % 100, 2); + to_bcd(&prmbuf[4], month, 2); + to_bcd(&prmbuf[5], day, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 6, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + if (hour >= 0) + { + prmbuf[0] = 0x01; + prmbuf[1] = 0x21; + to_bcd(&prmbuf[2], hour, 2); + to_bcd(&prmbuf[3], min, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 4, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + + prmbuf[0] = 0x01; + prmbuf[1] = 0x23; + rig_debug(RIG_DEBUG_ERR, "%s: utc_offset=%d\n", __func__, utc_offset); + to_bcd(&prmbuf[2], abs(utc_offset) / 100, 2); + to_bcd(&prmbuf[3], abs(utc_offset) % 100, 2); + to_bcd(&prmbuf[4], utc_offset >= 0 ? 0 : 1, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 5, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + return retval; +} + +int ic7100_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, + int *min, int *sec, double *msec, int *utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + int resplen; + unsigned char prmbuf[MAXFRAMELEN]; + unsigned char respbuf[MAXFRAMELEN]; + + prmbuf[0] = 0x01; + prmbuf[1] = 0x20; + resplen = sizeof(respbuf); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *year = from_bcd(&respbuf[4], 2) * 100 + from_bcd(&respbuf[5], 2); + *month = from_bcd(&respbuf[6], 2); + *day = from_bcd(&respbuf[7], 2); + + if (hour != NULL) + { + prmbuf[0] = 0x01; + prmbuf[1] = 0x21; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *hour = from_bcd(&respbuf[4], 2); + *min = from_bcd(&respbuf[5], 2); + *sec = 0; + *msec = 0; + + prmbuf[0] = 0x01; + prmbuf[1] = 0x23; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *utc_offset = from_bcd(&respbuf[4], 2) * 100; + *utc_offset += from_bcd(&respbuf[5], 2); + + if (respbuf[6] != 0x00) { *utc_offset *= -1; } + + //rig_debug(RIG_DEBUG_VERBOSE, + // "%s: %02d-%02d-%02dT%02d:%02d:%06.3lf%s%04d\n'", + // __func__, *year, *month, *day, *hour, *min, *sec + *msec / 1000, + // *utc_offset >= 0 ? "+" : "-", (unsigned)abs(*utc_offset)); + } + + return retval; +} + const struct rig_caps ic7100_caps = { RIG_MODEL(RIG_MODEL_IC7100), @@ -407,5 +508,7 @@ const struct rig_caps ic7100_caps = .get_powerstat = icom_get_powerstat, .send_morse = icom_send_morse, .stop_morse = icom_stop_morse, - .wait_morse = rig_wait_morse + .wait_morse = rig_wait_morse, + .set_clock = ic7100_set_clock, + .get_clock = ic7100_get_clock }; diff --git a/rigs/icom/ic7300.c b/rigs/icom/ic7300.c index e9fb53598..b01d192f4 100644 --- a/rigs/icom/ic7300.c +++ b/rigs/icom/ic7300.c @@ -24,7 +24,8 @@ #include "config.h" #endif -#include /* String function definitions */ +#include +#include #include #include "idx_builtin.h" @@ -35,9 +36,16 @@ #include "frame.h" #include "bandplan.h" #include "tones.h" +#include "misc.h" +#include "ic7300.h" static int ic7300_set_parm(RIG *rig, setting_t parm, value_t val); static int ic7300_get_parm(RIG *rig, setting_t parm, value_t *val); +int ic7300_set_clock(RIG *rig, int year, int month, int day, int hour, + int min, int sec, double msec, int utc_offset); +int ic7300_get_clock(RIG *rig, int *year, int *month, int *day, + int *hour, + int *min, int *sec, double *msec, int *utc_offset); #define IC7300_ALL_RX_MODES (RIG_MODE_FM|RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTFM|RIG_MODE_PKTAM) @@ -535,7 +543,7 @@ const struct rig_caps ic7300_caps = RIG_MODEL(RIG_MODEL_IC7300), .model_name = "IC-7300", .mfg_name = "Icom", - .version = BACKEND_VER ".5", + .version = BACKEND_VER ".6", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -759,7 +767,9 @@ const struct rig_caps ic7300_caps = .send_morse = icom_send_morse, .stop_morse = icom_stop_morse, .wait_morse = rig_wait_morse, - .send_voice_mem = icom_send_voice_mem + .send_voice_mem = icom_send_voice_mem, + .set_clock = ic7300_set_clock, + .get_clock = ic7300_get_clock }; const struct rig_caps ic9700_caps = @@ -767,7 +777,7 @@ const struct rig_caps ic9700_caps = RIG_MODEL(RIG_MODEL_IC9700), .model_name = "IC-9700", .mfg_name = "Icom", - .version = BACKEND_VER ".4", + .version = BACKEND_VER ".5", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1463,3 +1473,203 @@ int ic7300_get_parm(RIG *rig, setting_t parm, value_t *val) return RIG_OK; } + +// if hour < 0 then only date will be set +int ic7300_set_clock(RIG *rig, int year, int month, int day, int hour, int min, + int sec, double msec, int utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + unsigned char prmbuf[MAXFRAMELEN]; + + if (year >= 0) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x94; + to_bcd(&prmbuf[2], year / 100, 2); + to_bcd(&prmbuf[3], year % 100, 2); + to_bcd(&prmbuf[4], month, 2); + to_bcd(&prmbuf[5], day, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 6, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + if (hour >= 0) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x95; + to_bcd(&prmbuf[2], hour, 2); + to_bcd(&prmbuf[3], min, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 4, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + + prmbuf[0] = 0x00; + prmbuf[1] = 0x96; + rig_debug(RIG_DEBUG_ERR, "%s: utc_offset=%d\n", __func__, utc_offset); + to_bcd(&prmbuf[2], abs(utc_offset) / 100, 2); + to_bcd(&prmbuf[3], abs(utc_offset) % 100, 2); + to_bcd(&prmbuf[4], utc_offset >= 0 ? 0 : 1, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 5, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + return retval; +} + +int ic7300_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, + int *min, int *sec, double *msec, int *utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + int resplen; + unsigned char prmbuf[MAXFRAMELEN]; + unsigned char respbuf[MAXFRAMELEN]; + + prmbuf[0] = 0x00; + prmbuf[1] = 0x94; + resplen = sizeof(respbuf); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *year = from_bcd(&respbuf[4], 2) * 100 + from_bcd(&respbuf[5], 2); + *month = from_bcd(&respbuf[6], 2); + *day = from_bcd(&respbuf[7], 2); + + if (hour != NULL) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x95; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *hour = from_bcd(&respbuf[4], 2); + *min = from_bcd(&respbuf[5], 2); + *sec = 0; + *msec = 0; + + prmbuf[0] = 0x00; + prmbuf[1] = 0x96; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *utc_offset = from_bcd(&respbuf[4], 2) * 100; + *utc_offset += from_bcd(&respbuf[5], 2); + + if (respbuf[6] != 0x00) { *utc_offset *= -1; } + + //rig_debug(RIG_DEBUG_VERBOSE, + // "%s: %02d-%02d-%02dT%02d:%02d:%06.3lf%s%04d\n'", + // __func__, *year, *month, *day, *hour, *min, *sec + *msec / 1000, + // *utc_offset >= 0 ? "+" : "-", (unsigned)abs(*utc_offset)); + } + + return retval; +} + +// if hour < 0 then only date will be set +int ic9700_set_clock(RIG *rig, int year, int month, int day, int hour, int min, + int sec, double msec, int utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + unsigned char prmbuf[MAXFRAMELEN]; + + if (year >= 0) + { + prmbuf[0] = 0x01; + prmbuf[1] = 0x79; + to_bcd(&prmbuf[2], year / 100, 2); + to_bcd(&prmbuf[3], year % 100, 2); + to_bcd(&prmbuf[4], month, 2); + to_bcd(&prmbuf[5], day, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 6, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + if (hour >= 0) + { + prmbuf[0] = 0x01; + prmbuf[1] = 0x80; + to_bcd(&prmbuf[2], hour, 2); + to_bcd(&prmbuf[3], min, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 4, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + + prmbuf[0] = 0x01; + prmbuf[1] = 0x84; + rig_debug(RIG_DEBUG_ERR, "%s: utc_offset=%d\n", __func__, utc_offset); + to_bcd(&prmbuf[2], abs(utc_offset) / 100, 2); + to_bcd(&prmbuf[3], abs(utc_offset) % 100, 2); + to_bcd(&prmbuf[4], utc_offset >= 0 ? 0 : 1, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 5, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + return retval; +} + +int ic9700_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, + int *min, int *sec, double *msec, int *utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + int resplen; + unsigned char prmbuf[MAXFRAMELEN]; + unsigned char respbuf[MAXFRAMELEN]; + + prmbuf[0] = 0x01; + prmbuf[1] = 0x79; + resplen = sizeof(respbuf); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *year = from_bcd(&respbuf[4], 2) * 100 + from_bcd(&respbuf[5], 2); + *month = from_bcd(&respbuf[6], 2); + *day = from_bcd(&respbuf[7], 2); + + if (hour != NULL) + { + prmbuf[0] = 0x01; + prmbuf[1] = 0x80; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *hour = from_bcd(&respbuf[4], 2); + *min = from_bcd(&respbuf[5], 2); + *sec = 0; + *msec = 0; + + prmbuf[0] = 0x01; + prmbuf[1] = 0x84; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *utc_offset = from_bcd(&respbuf[4], 2) * 100; + *utc_offset += from_bcd(&respbuf[5], 2); + + if (respbuf[6] != 0x00) { *utc_offset *= -1; } + + //rig_debug(RIG_DEBUG_VERBOSE, + // "%s: %02d-%02d-%02dT%02d:%02d:%06.3lf%s%04d\n'", + // __func__, *year, *month, *day, *hour, *min, *sec + *msec / 1000, + // *utc_offset >= 0 ? "+" : "-", (unsigned)abs(*utc_offset)); + } + + return retval; +} diff --git a/rigs/icom/ic7300.h b/rigs/icom/ic7300.h new file mode 100644 index 000000000..a1973a011 --- /dev/null +++ b/rigs/icom/ic7300.h @@ -0,0 +1,8 @@ +#include "frame.h" +#include "misc.h" +extern int ic7300_set_clock(RIG *rig, int year, int month, int day, int hour, + int min, int sec, double msec, int utc_offset); +extern int ic7300_get_clock(RIG *rig, int *year, int *month, int *day, + int *hour, + int *min, int *sec, double *msec, int *utc_offset); + diff --git a/rigs/icom/ic7600.c b/rigs/icom/ic7600.c index 7f997b95e..909933dca 100644 --- a/rigs/icom/ic7600.c +++ b/rigs/icom/ic7600.c @@ -23,7 +23,8 @@ #include "config.h" #endif -#include /* String function definitions */ +#include +#include #include #include "token.h" @@ -32,6 +33,8 @@ #include "icom.h" #include "icom_defs.h" #include "bandplan.h" +#include "frame.h" +#include "misc.h" #define IC7600_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM|RIG_MODE_PSK|RIG_MODE_PSKR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTAM|RIG_MODE_PKTFM) #define IC7600_1HZ_TS_MODES IC7600_ALL_RX_MODES @@ -163,12 +166,113 @@ static const struct icom_priv_caps ic7600_priv_caps = .extcmds = ic7600_extcmds, /* Custom op parameters */ }; + +// if hour < 0 then only date will be set +int ic7600_set_clock(RIG *rig, int year, int month, int day, int hour, int min, + int sec, double msec, int utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + unsigned char prmbuf[MAXFRAMELEN]; + + if (year >= 0) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x53; + to_bcd(&prmbuf[2], year / 100, 2); + to_bcd(&prmbuf[3], year % 100, 2); + to_bcd(&prmbuf[4], month, 2); + to_bcd(&prmbuf[5], day, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 6, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + if (hour >= 0) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x54; + to_bcd(&prmbuf[2], hour, 2); + to_bcd(&prmbuf[3], min, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 4, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + + prmbuf[0] = 0x00; + prmbuf[1] = 0x56; + rig_debug(RIG_DEBUG_ERR, "%s: utc_offset=%d\n", __func__, utc_offset); + to_bcd(&prmbuf[2], abs(utc_offset) / 100, 2); + to_bcd(&prmbuf[3], abs(utc_offset) % 100, 2); + to_bcd(&prmbuf[4], utc_offset >= 0 ? 0 : 1, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 5, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + return retval; +} + +int ic7600_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, + int *min, int *sec, double *msec, int *utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + int resplen; + unsigned char prmbuf[MAXFRAMELEN]; + unsigned char respbuf[MAXFRAMELEN]; + + prmbuf[0] = 0x00; + prmbuf[1] = 0x53; + resplen = sizeof(respbuf); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *year = from_bcd(&respbuf[4], 2) * 100 + from_bcd(&respbuf[5], 2); + *month = from_bcd(&respbuf[6], 2); + *day = from_bcd(&respbuf[7], 2); + + if (hour != NULL) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x54; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *hour = from_bcd(&respbuf[4], 2); + *min = from_bcd(&respbuf[5], 2); + *sec = 0; + *msec = 0; + + prmbuf[0] = 0x00; + prmbuf[1] = 0x56; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *utc_offset = from_bcd(&respbuf[4], 2) * 100; + *utc_offset += from_bcd(&respbuf[5], 2); + + if (respbuf[6] != 0x00) { *utc_offset *= -1; } + + //rig_debug(RIG_DEBUG_VERBOSE, + // "%s: %02d-%02d-%02dT%02d:%02d:%06.3lf%s%04d\n'", + // __func__, *year, *month, *day, *hour, *min, *sec + *msec / 1000, + // *utc_offset >= 0 ? "+" : "-", (unsigned)abs(*utc_offset)); + } + + return retval; +} + const struct rig_caps ic7600_caps = { RIG_MODEL(RIG_MODEL_IC7600), .model_name = "IC-7600", .mfg_name = "Icom", - .version = BACKEND_VER ".1", + .version = BACKEND_VER ".2", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -343,5 +447,7 @@ const struct rig_caps ic7600_caps = .get_split_vfo = icom_get_split_vfo, .set_powerstat = icom_set_powerstat, .get_powerstat = icom_get_powerstat, - .send_morse = icom_send_morse + .send_morse = icom_send_morse, + .set_clock = ic7600_set_clock, + .get_clock = ic7600_get_clock }; diff --git a/rigs/icom/ic7610.c b/rigs/icom/ic7610.c index 3cfeb1bec..1559e8453 100644 --- a/rigs/icom/ic7610.c +++ b/rigs/icom/ic7610.c @@ -24,7 +24,8 @@ #include "config.h" #endif -#include /* String function definitions */ +#include +#include #include #include "token.h" @@ -33,6 +34,8 @@ #include "icom.h" #include "icom_defs.h" #include "bandplan.h" +#include "frame.h" +#include "misc.h" #define IC7610_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM|RIG_MODE_PSK|RIG_MODE_PSKR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTAM|RIG_MODE_PKTFM) #define IC7610_1HZ_TS_MODES IC7610_ALL_RX_MODES @@ -243,12 +246,113 @@ static const struct icom_priv_caps ic7610_priv_caps = .extcmds = ic7610_extcmds, }; + +// if hour < 0 then only date will be set +int ic7610_set_clock(RIG *rig, int year, int month, int day, int hour, int min, + int sec, double msec, int utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + unsigned char prmbuf[MAXFRAMELEN]; + + if (year >= 0) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x58; + to_bcd(&prmbuf[2], year / 100, 2); + to_bcd(&prmbuf[3], year % 100, 2); + to_bcd(&prmbuf[4], month, 2); + to_bcd(&prmbuf[5], day, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 6, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + if (hour >= 0) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x59; + to_bcd(&prmbuf[2], hour, 2); + to_bcd(&prmbuf[3], min, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 4, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + + prmbuf[0] = 0x00; + prmbuf[1] = 0x62; + rig_debug(RIG_DEBUG_ERR, "%s: utc_offset=%d\n", __func__, utc_offset); + to_bcd(&prmbuf[2], abs(utc_offset) / 100, 2); + to_bcd(&prmbuf[3], abs(utc_offset) % 100, 2); + to_bcd(&prmbuf[4], utc_offset >= 0 ? 0 : 1, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 5, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + return retval; +} + +int ic7610_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, + int *min, int *sec, double *msec, int *utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + int resplen; + unsigned char prmbuf[MAXFRAMELEN]; + unsigned char respbuf[MAXFRAMELEN]; + + prmbuf[0] = 0x00; + prmbuf[1] = 0x58; + resplen = sizeof(respbuf); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *year = from_bcd(&respbuf[4], 2) * 100 + from_bcd(&respbuf[5], 2); + *month = from_bcd(&respbuf[6], 2); + *day = from_bcd(&respbuf[7], 2); + + if (hour != NULL) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x59; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *hour = from_bcd(&respbuf[4], 2); + *min = from_bcd(&respbuf[5], 2); + *sec = 0; + *msec = 0; + + prmbuf[0] = 0x00; + prmbuf[1] = 0x62; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *utc_offset = from_bcd(&respbuf[4], 2) * 100; + *utc_offset += from_bcd(&respbuf[5], 2); + + if (respbuf[6] != 0x00) { *utc_offset *= -1; } + + //rig_debug(RIG_DEBUG_VERBOSE, + // "%s: %02d-%02d-%02dT%02d:%02d:%06.3lf%s%04d\n'", + // __func__, *year, *month, *day, *hour, *min, *sec + *msec / 1000, + // *utc_offset >= 0 ? "+" : "-", (unsigned)abs(*utc_offset)); + } + + return retval; +} + const struct rig_caps ic7610_caps = { RIG_MODEL(RIG_MODEL_IC7610), .model_name = "IC-7610", .mfg_name = "Icom", - .version = BACKEND_VER ".4", + .version = BACKEND_VER ".5", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -478,5 +582,7 @@ const struct rig_caps ic7610_caps = .send_morse = icom_send_morse, .stop_morse = icom_stop_morse, .wait_morse = rig_wait_morse, - .send_voice_mem = rig_send_voice_mem + .send_voice_mem = rig_send_voice_mem, + .set_clock = ic7610_set_clock, + .get_clock = ic7610_get_clock }; diff --git a/rigs/icom/ic7700.c b/rigs/icom/ic7700.c index 9b0204527..7e215ca71 100644 --- a/rigs/icom/ic7700.c +++ b/rigs/icom/ic7700.c @@ -23,7 +23,8 @@ #include "config.h" #endif -#include /* String function definitions */ +#include +#include #include #include "token.h" @@ -32,6 +33,8 @@ #include "icom.h" #include "icom_defs.h" #include "bandplan.h" +#include "frame.h" +#include "misc.h" #define IC7700_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTFM|RIG_MODE_PSK|RIG_MODE_PSKR) #define IC7700_AM_TX_MODES (RIG_MODE_AM|RIG_MODE_PKTAM) @@ -146,6 +149,106 @@ static const struct icom_priv_caps ic7700_priv_caps = .extcmds = ic7700_extcmds, }; +// if hour < 0 then only date will be set +int ic7700_set_clock(RIG *rig, int year, int month, int day, int hour, int min, + int sec, double msec, int utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + unsigned char prmbuf[MAXFRAMELEN]; + + if (year >= 0) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x58; + to_bcd(&prmbuf[2], year / 100, 2); + to_bcd(&prmbuf[3], year % 100, 2); + to_bcd(&prmbuf[4], month, 2); + to_bcd(&prmbuf[5], day, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 6, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + if (hour >= 0) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x59; + to_bcd(&prmbuf[2], hour, 2); + to_bcd(&prmbuf[3], min, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 4, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + + prmbuf[0] = 0x00; + prmbuf[1] = 0x61; + rig_debug(RIG_DEBUG_ERR, "%s: utc_offset=%d\n", __func__, utc_offset); + to_bcd(&prmbuf[2], abs(utc_offset) / 100, 2); + to_bcd(&prmbuf[3], abs(utc_offset) % 100, 2); + to_bcd(&prmbuf[4], utc_offset >= 0 ? 0 : 1, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 5, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + return retval; +} + +int ic7700_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, + int *min, int *sec, double *msec, int *utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + int resplen; + unsigned char prmbuf[MAXFRAMELEN]; + unsigned char respbuf[MAXFRAMELEN]; + + prmbuf[0] = 0x00; + prmbuf[1] = 0x58; + resplen = sizeof(respbuf); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *year = from_bcd(&respbuf[4], 2) * 100 + from_bcd(&respbuf[5], 2); + *month = from_bcd(&respbuf[6], 2); + *day = from_bcd(&respbuf[7], 2); + + if (hour != NULL) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x59; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *hour = from_bcd(&respbuf[4], 2); + *min = from_bcd(&respbuf[5], 2); + *sec = 0; + *msec = 0; + + prmbuf[0] = 0x00; + prmbuf[1] = 0x61; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *utc_offset = from_bcd(&respbuf[4], 2) * 100; + *utc_offset += from_bcd(&respbuf[5], 2); + + if (respbuf[6] != 0x00) { *utc_offset *= -1; } + + //rig_debug(RIG_DEBUG_VERBOSE, + // "%s: %02d-%02d-%02dT%02d:%02d:%06.3lf%s%04d\n'", + // __func__, *year, *month, *day, *hour, *min, *sec + *msec / 1000, + // *utc_offset >= 0 ? "+" : "-", (unsigned)abs(*utc_offset)); + } + + return retval; +} + const struct rig_caps ic7700_caps = { RIG_MODEL(RIG_MODEL_IC7700), @@ -325,5 +428,7 @@ const struct rig_caps ic7700_caps = .get_powerstat = icom_get_powerstat, .send_morse = icom_send_morse, .stop_morse = icom_stop_morse, - .wait_morse = rig_wait_morse + .wait_morse = rig_wait_morse, + .set_clock = ic7700_set_clock, + .get_clock = ic7700_get_clock }; diff --git a/rigs/icom/ic7800.c b/rigs/icom/ic7800.c index 8bb138292..e878aba80 100644 --- a/rigs/icom/ic7800.c +++ b/rigs/icom/ic7800.c @@ -24,6 +24,7 @@ #endif #include /* String function definitions */ +#include #include #include "token.h" @@ -32,6 +33,7 @@ #include "icom.h" #include "icom_defs.h" #include "bandplan.h" +#include "ic7300.h" #define IC7800_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM|RIG_MODE_PSK|RIG_MODE_PSKR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTAM|RIG_MODE_PKTFM) #define IC7800_1HZ_TS_MODES IC7800_ALL_RX_MODES @@ -154,7 +156,7 @@ const struct rig_caps ic7800_caps = RIG_MODEL(RIG_MODEL_IC7800), .model_name = "IC-7800", .mfg_name = "Icom", - .version = BACKEND_VER ".3", + .version = BACKEND_VER ".5", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -328,7 +330,9 @@ const struct rig_caps ic7800_caps = .get_powerstat = icom_get_powerstat, .send_morse = icom_send_morse, .stop_morse = icom_stop_morse, - .wait_morse = rig_wait_morse + .wait_morse = rig_wait_morse, + .set_clock = ic7300_set_clock, + .get_clock = ic7300_get_clock, }; /* @@ -402,3 +406,103 @@ int ic7800_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return RIG_OK; } + +// if hour < 0 then only date will be set +int ic7800_set_clock(RIG *rig, int year, int month, int day, int hour, int min, + int sec, double msec, int utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + unsigned char prmbuf[MAXFRAMELEN]; + + if (year >= 0) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x59; + to_bcd(&prmbuf[2], year / 100, 2); + to_bcd(&prmbuf[3], year % 100, 2); + to_bcd(&prmbuf[4], month, 2); + to_bcd(&prmbuf[5], day, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 6, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + if (hour >= 0) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x60; + to_bcd(&prmbuf[2], hour, 2); + to_bcd(&prmbuf[3], min, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 4, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + + prmbuf[0] = 0x00; + prmbuf[1] = 0x62; + rig_debug(RIG_DEBUG_ERR, "%s: utc_offset=%d\n", __func__, utc_offset); + to_bcd(&prmbuf[2], abs(utc_offset) / 100, 2); + to_bcd(&prmbuf[3], abs(utc_offset) % 100, 2); + to_bcd(&prmbuf[4], utc_offset >= 0 ? 0 : 1, 2); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 5, NULL, NULL); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s(%d): %s\b", __func__, __LINE__, rigerror(retval)); + } + } + + return retval; +} + +int ic7800_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, + int *min, int *sec, double *msec, int *utc_offset) +{ + int cmd = 0x1a; + int subcmd = 0x05; + int retval = RIG_OK; + int resplen; + unsigned char prmbuf[MAXFRAMELEN]; + unsigned char respbuf[MAXFRAMELEN]; + + prmbuf[0] = 0x00; + prmbuf[1] = 0x59; + resplen = sizeof(respbuf); + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *year = from_bcd(&respbuf[4], 2) * 100 + from_bcd(&respbuf[5], 2); + *month = from_bcd(&respbuf[6], 2); + *day = from_bcd(&respbuf[7], 2); + + if (hour != NULL) + { + prmbuf[0] = 0x00; + prmbuf[1] = 0x60; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *hour = from_bcd(&respbuf[4], 2); + *min = from_bcd(&respbuf[5], 2); + *sec = 0; + *msec = 0; + + prmbuf[0] = 0x00; + prmbuf[1] = 0x62; + retval = icom_transaction(rig, cmd, subcmd, prmbuf, 2, respbuf, &resplen); + *utc_offset = from_bcd(&respbuf[4], 2) * 100; + *utc_offset += from_bcd(&respbuf[5], 2); + + if (respbuf[6] != 0x00) { *utc_offset *= -1; } + + //rig_debug(RIG_DEBUG_VERBOSE, + // "%s: %02d-%02d-%02dT%02d:%02d:%06.3lf%s%04d\n'", + // __func__, *year, *month, *day, *hour, *min, *sec + *msec / 1000, + // *utc_offset >= 0 ? "+" : "-", (unsigned)abs(*utc_offset)); + } + + return retval; +} diff --git a/rigs/icom/ic785x.c b/rigs/icom/ic785x.c index 5fe2afcf8..db2e58c31 100644 --- a/rigs/icom/ic785x.c +++ b/rigs/icom/ic785x.c @@ -33,6 +33,7 @@ #include "icom.h" #include "icom_defs.h" #include "bandplan.h" +#include "ic7300.h" #define IC785x_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_FM|RIG_MODE_PSK|RIG_MODE_PSKR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB|RIG_MODE_PKTAM|RIG_MODE_PKTFM) #define IC785x_1HZ_TS_MODES IC785x_ALL_RX_MODES @@ -242,7 +243,7 @@ const struct rig_caps ic785x_caps = RIG_MODEL(RIG_MODEL_IC785x), .model_name = "IC-7850/7851", .mfg_name = "Icom", - .version = BACKEND_VER ".2", + .version = BACKEND_VER ".3", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -472,7 +473,9 @@ const struct rig_caps ic785x_caps = .get_powerstat = icom_get_powerstat, .send_morse = icom_send_morse, .stop_morse = icom_stop_morse, - .wait_morse = rig_wait_morse + .wait_morse = rig_wait_morse, + .set_clock = ic7300_set_clock, + .get_clock = ic7300_get_clock }; int ic785x_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 0e8cb8b48..5be099e42 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -791,9 +791,11 @@ static vfo_t icom_current_vfo_x25(RIG *rig) { // we can't change freqs unless rig is idle and we don't know that // so we only check vfo once when freqs are equal - rig_debug(RIG_DEBUG_TRACE,"%s: vfo already determined...returning current_vfo", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: vfo already determined...returning current_vfo", + __func__); return rig->state.current_vfo; } + priv->vfo_flag = 1; fOffset = 100; @@ -884,9 +886,11 @@ static vfo_t icom_current_vfo(RIG *rig) { // we can't change freqs unless rig is idle and we don't know that // so we only check vfo once when freqs are equal - rig_debug(RIG_DEBUG_TRACE,"%s: vfo already determined...returning current_vfo", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: vfo already determined...returning current_vfo", + __func__); return rig->state.current_vfo; } + priv->vfo_flag = 1; fOffset = 100; @@ -980,13 +984,16 @@ retry_open: else if (retval != RIG_OK) { // didnt' ask for power on so let's retry one more time - rig_debug(RIG_DEBUG_ERR, "%s: rig error getting frequency retry=%d, err=%s\n", __func__,retry_flag,rigerror(retval)); + rig_debug(RIG_DEBUG_ERR, "%s: rig error getting frequency retry=%d, err=%s\n", + __func__, retry_flag, rigerror(retval)); + if (retry_flag) { retry_flag = 0; - hl_usleep(500*1000); // 500ms pause + hl_usleep(500 * 1000); // 500ms pause goto retry_open; } + RETURNFUNC(retval); } @@ -1360,6 +1367,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) case RIG_VFO_NONE: // VFO_NONE will become VFO_CURR rig->state.current_vfo = RIG_VFO_CURR; + case RIG_VFO_CURR: priv->curr_freq = freq; break; case RIG_VFO_OTHER: priv->other_freq = freq; break; @@ -1638,6 +1646,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) case RIG_VFO_NONE: // VFO_NONE will become VFO_CURR rig->state.current_vfo = RIG_VFO_CURR; + case RIG_VFO_CURR: priv->curr_freq = *freq; break; default: @@ -1762,8 +1771,8 @@ int icom_set_xit_new(RIG *rig, vfo_t vfo, shortfreq_t ts) and some models like IC910/Omni VI Plus have a different meaning for this subcommand */ - -int filtericom[] = { 50,100,150,200,250,300,350,400,450,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600 }; + +int filtericom[] = { 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600 }; pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode) { @@ -1812,7 +1821,8 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode) if (-RIG_ERJCTED == retval) { - if (priv->no_1a_03_cmd == ENUM_1A_03_UNK) { + if (priv->no_1a_03_cmd == ENUM_1A_03_UNK) + { priv->no_1a_03_cmd = ENUM_1A_03_NO; /* do not keep asking */ return (RIG_OK); } @@ -1839,10 +1849,13 @@ pbwidth_t icom_get_dsp_flt(RIG *rig, rmode_t mode) if (mode & RIG_MODE_AM) { - if (i > 49) { - rig_debug(RIG_DEBUG_ERR, "%s: Expected max 49, got %d for filter\n", __func__, i); + if (i > 49) + { + rig_debug(RIG_DEBUG_ERR, "%s: Expected max 49, got %d for filter\n", __func__, + i); RETURNFUNC(-RIG_EPROTO); } + return ((i + 1) * 200); /* All Icoms that we know of */ } else if (mode & @@ -1869,9 +1882,10 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width) S_MEM_FILT_WDTH; ENTERFUNC; - rig_debug(RIG_DEBUG_TRACE, "%s: mode=%s, width=%d\n", __func__, rig_strrmode(mode), (int)width); + rig_debug(RIG_DEBUG_TRACE, "%s: mode=%s, width=%d\n", __func__, + rig_strrmode(mode), (int)width); + - if (RIG_PASSBAND_NOCHANGE == width) { RETURNFUNC(RIG_OK); @@ -1903,7 +1917,8 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width) RETURNFUNC(-RIG_EINVAL); } } - if (priv->no_1a_03_cmd == ENUM_1A_03_NO) RETURNFUNC(RIG_OK); // don't bother to try since it doesn't work + + if (priv->no_1a_03_cmd == ENUM_1A_03_NO) { RETURNFUNC(RIG_OK); } // don't bother to try since it doesn't work if (mode & RIG_MODE_AM) { @@ -1922,12 +1937,14 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width) } else { - rig_debug(RIG_DEBUG_VERBOSE, "%s: unknown mode=%s\n", __func__, rig_strrmode(mode)); + rig_debug(RIG_DEBUG_VERBOSE, "%s: unknown mode=%s\n", __func__, + rig_strrmode(mode)); RETURNFUNC(RIG_OK); } to_bcd(&flt_ext, flt_idx, 2); - rig_debug(RIG_DEBUG_VERBOSE, "%s: flt_ext=%d, flt_idx=%d\n", __func__, flt_ext, flt_idx); + rig_debug(RIG_DEBUG_VERBOSE, "%s: flt_ext=%d, flt_idx=%d\n", __func__, flt_ext, + flt_idx); retval = icom_transaction(rig, C_CTL_MEM, fw_sub_cmd, &flt_ext, 1, ackbuf, &ack_len); @@ -2168,6 +2185,7 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, } } } + icom_set_dsp_flt(rig, mode, width); RETURNFUNC(retval); @@ -2421,7 +2439,10 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) TRACE; - rig_debug(RIG_DEBUG_VERBOSE, "%s: targetable=%x, targetable_mode=%x, and=%d\n", __func__, rig->caps->targetable_vfo,RIG_TARGETABLE_MODE, rig->caps->targetable_vfo & RIG_TARGETABLE_MODE); + rig_debug(RIG_DEBUG_VERBOSE, "%s: targetable=%x, targetable_mode=%x, and=%d\n", + __func__, rig->caps->targetable_vfo, RIG_TARGETABLE_MODE, + rig->caps->targetable_vfo & RIG_TARGETABLE_MODE); + // IC7800 can set but not read with 0x26 if ((rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && (rig->caps->rig_model != RIG_MODEL_IC7800)) @@ -2722,8 +2743,10 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) case RIG_VFO_MAIN: icvfo = S_MAIN; + // If not split or satmode then we must want VFOA if (VFO_HAS_MAIN_SUB_A_B_ONLY && !priv->split_on && !rig->state.cache.satmode) { icvfo = S_VFOA; } + break; case RIG_VFO_SUB: @@ -2861,10 +2884,51 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) break; + case RIG_VFO_OTHER: + switch (rig->state.current_vfo) + { + case RIG_VFO_A: + icvfo = vfo = RIG_VFO_B; + break; + + case RIG_VFO_B: + icvfo = vfo = RIG_VFO_A; + break; + + case RIG_VFO_MAIN: + icvfo = vfo = RIG_VFO_SUB; + break; + + case RIG_VFO_SUB: + icvfo = vfo = RIG_VFO_MAIN; + break; + + case RIG_VFO_MAIN_A: + icvfo = vfo = RIG_VFO_MAIN_B; + break; + + case RIG_VFO_MAIN_B: + icvfo = vfo = RIG_VFO_MAIN_A; + break; + + case RIG_VFO_SUB_A: + icvfo = vfo = RIG_VFO_SUB_B; + break; + + case RIG_VFO_SUB_B: + icvfo = vfo = RIG_VFO_SUB_A; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo '%s'\n", __func__, + rig_strvfo(rig->state.current_vfo)); + } + default: if (!priv->x25cmdfails) - rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, - rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, + rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); } @@ -7685,7 +7749,7 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) priv->serial_USB_echo_off = 1; retval = icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len); - hl_usleep(4000*1000); // give some time to wake up + hl_usleep(4000 * 1000); // give some time to wake up break; @@ -7707,8 +7771,11 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) // need to see if echo is on or not first // until such time as rig is awake we don't know retval = icom_get_usb_echo_off(rig); - if (retval == -RIG_ETIMEOUT) { - rig_debug(RIG_DEBUG_WARN, "%s: get_usb_echo_off timeout...try#%d\n", __func__, i+1); + + if (retval == -RIG_ETIMEOUT) + { + rig_debug(RIG_DEBUG_WARN, "%s: get_usb_echo_off timeout...try#%d\n", __func__, + i + 1); continue; } @@ -7729,6 +7796,7 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) __func__, i + 1, retry); } } + rs->rigport.retry = retry_save; if (i == retry) diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 56a896c99..53b325fe3 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "20211115" +#define BACKEND_VER "20211120" #define ICOM_IS_SECONDARY_VFO(vfo) ((vfo) & (RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B)) #define ICOM_GET_VFO_NUMBER(vfo) (ICOM_IS_SECONDARY_VFO(vfo) ? 0x01 : 0x00) diff --git a/rigs/icom/optoscan.c b/rigs/icom/optoscan.c index 85f408522..7f586e090 100644 --- a/rigs/icom/optoscan.c +++ b/rigs/icom/optoscan.c @@ -245,9 +245,9 @@ int optoscan_recv_dtmf(RIG *rig, vfo_t vfo, char *digits, int *length) unsigned char dtmfbuf[MAXFRAMELEN], digit; int len, digitpos; const unsigned char xlate[] = {'0', '1', '2', '3', '4', '5', '6', - '7', '8', '9', 'A', 'B', 'C', 'D', - '*', '#' - }; + '7', '8', '9', 'A', 'B', 'C', 'D', + '*', '#' + }; digitpos = 0; do diff --git a/rigs/jrc/jrc.c b/rigs/jrc/jrc.c index 7a5583b9f..d8f5aa7a3 100644 --- a/rigs/jrc/jrc.c +++ b/rigs/jrc/jrc.c @@ -93,7 +93,7 @@ static int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return 0; } - retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0); + retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0, 1); set_transaction_inactive(rig); @@ -1632,7 +1632,7 @@ int jrc_decode_event(RIG *rig) //#define SETUP_STATUS_LEN 17 //count = read_string(&rs->rigport, buf, SETUP_STATUS_LEN, "", 0); - count = read_string(&rs->rigport, buf, priv->info_len, "", 0, 0); + count = read_string(&rs->rigport, buf, priv->info_len, "", 0, 0, 1); if (count < 0) { diff --git a/rigs/kachina/kachina.c b/rigs/kachina/kachina.c index df1aecba0..138c26006 100644 --- a/rigs/kachina/kachina.c +++ b/rigs/kachina/kachina.c @@ -93,7 +93,7 @@ static int kachina_transaction(RIG *rig, unsigned char cmd1, unsigned char cmd2) return retval; } - count = read_string(&rs->rigport, (char *) buf4, 1, "", 0, 0); + count = read_string(&rs->rigport, (char *) buf4, 1, "", 0, 0, 1); if (count != 1) { @@ -128,7 +128,7 @@ static int kachina_trans_n(RIG *rig, unsigned char cmd1, const char *data, return retval; } - count = read_string(&rs->rigport, (char *) buf, 1, "", 0, 0); + count = read_string(&rs->rigport, (char *) buf, 1, "", 0, 0, 1); if (count != 1) { @@ -273,7 +273,7 @@ int kachina_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) rig_flush(&rig->state.rigport); count = read_string(&rig->state.rigport, (char *) buf, 31, rcv_signal_range, - 128, 0); + 128, 0, 1); if (count < 1) { diff --git a/rigs/kenwood/elecraft.c b/rigs/kenwood/elecraft.c index ad2a6e06c..e5796b247 100644 --- a/rigs/kenwood/elecraft.c +++ b/rigs/kenwood/elecraft.c @@ -135,7 +135,7 @@ int elecraft_open(RIG *rig) return err; } - err = read_string(&rs->rigport, buf, sizeof(buf), ";", 1, 0); + err = read_string(&rs->rigport, buf, sizeof(buf), ";", 1, 0, 1); if (err < 0) { @@ -477,12 +477,12 @@ int elecraft_get_firmware_revision_level(RIG *rig, const char *cmd, int elecraft_get_vfo_tq(RIG *rig, vfo_t *vfo) { int retval; - int fr,ft,tq; + int fr, ft, tq; char cmdbuf[10]; char splitbuf[12]; - memset(splitbuf,0,sizeof(splitbuf)); - snprintf(cmdbuf,sizeof(cmdbuf),"FR;"); + memset(splitbuf, 0, sizeof(splitbuf)); + snprintf(cmdbuf, sizeof(cmdbuf), "FR;"); retval = kenwood_safe_transaction(rig, cmdbuf, splitbuf, 12, 3); if (retval != RIG_OK) @@ -490,11 +490,12 @@ int elecraft_get_vfo_tq(RIG *rig, vfo_t *vfo) RETURNFUNC(retval); } - if(sscanf(splitbuf, "FR%1d", &fr) != 1) + if (sscanf(splitbuf, "FR%1d", &fr) != 1) { rig_debug(RIG_DEBUG_ERR, "%s: unable to parse FR '%s'\n", __func__, splitbuf); } - snprintf(cmdbuf,sizeof(cmdbuf),"FT;"); + + snprintf(cmdbuf, sizeof(cmdbuf), "FT;"); retval = kenwood_safe_transaction(rig, cmdbuf, splitbuf, 12, 3); if (retval != RIG_OK) @@ -502,11 +503,12 @@ int elecraft_get_vfo_tq(RIG *rig, vfo_t *vfo) RETURNFUNC(retval); } - if(sscanf(splitbuf, "FT%1d", &ft) != 1) + if (sscanf(splitbuf, "FT%1d", &ft) != 1) { rig_debug(RIG_DEBUG_ERR, "%s: unable to parse FT '%s'\n", __func__, splitbuf); } - snprintf(cmdbuf,sizeof(cmdbuf),"TQ;"); + + snprintf(cmdbuf, sizeof(cmdbuf), "TQ;"); retval = kenwood_safe_transaction(rig, cmdbuf, splitbuf, 12, 3); if (retval != RIG_OK) @@ -514,13 +516,17 @@ int elecraft_get_vfo_tq(RIG *rig, vfo_t *vfo) RETURNFUNC(retval); } - if(sscanf(splitbuf, "TQ%1d", &tq) != 1) + if (sscanf(splitbuf, "TQ%1d", &tq) != 1) { rig_debug(RIG_DEBUG_ERR, "%s: unable to parse TQ '%s'\n", __func__, splitbuf); } + *vfo = RIG_VFO_A; - if (tq && ft == 1) *vfo = RIG_VFO_B; - if (!tq && fr == 1) *vfo = RIG_VFO_B; + + if (tq && ft == 1) { *vfo = RIG_VFO_B; } + + if (!tq && fr == 1) { *vfo = RIG_VFO_B; } + RETURNFUNC(RIG_OK); } diff --git a/rigs/kenwood/flex6xxx.c b/rigs/kenwood/flex6xxx.c index 1938821c9..b46c979d1 100644 --- a/rigs/kenwood/flex6xxx.c +++ b/rigs/kenwood/flex6xxx.c @@ -919,6 +919,7 @@ int powersdr_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) __func__, lvlbuf); return -RIG_EPROTO; } + n = val->i; val->f = (n + 20.0) / (120.0 - -20.0); diff --git a/rigs/kenwood/ic10.c b/rigs/kenwood/ic10.c index c393e3f6a..7053249ae 100644 --- a/rigs/kenwood/ic10.c +++ b/rigs/kenwood/ic10.c @@ -110,7 +110,7 @@ transaction: } // this should be the ID response - retval = read_string(&rs->rigport, buffer, sizeof(buffer), ";", 1, 0); + retval = read_string(&rs->rigport, buffer, sizeof(buffer), ";", 1, 0, 1); // might be ?; too if (buffer[0] == '?' && retry_cmd++ < rs->rigport.retry) @@ -129,7 +129,7 @@ transaction: return RIG_OK; } - retval = read_string(&rs->rigport, data, 50, ";", 1, 0); + retval = read_string(&rs->rigport, data, 50, ";", 1, 0, 1); if (retval == -RIG_ETIMEOUT) { diff --git a/rigs/kenwood/k3.c b/rigs/kenwood/k3.c index c8517b141..ea42670b5 100644 --- a/rigs/kenwood/k3.c +++ b/rigs/kenwood/k3.c @@ -959,6 +959,7 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) cmd_bw_len = 7; } + if (!mode || !width) { return -RIG_EINVAL; @@ -978,7 +979,8 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) if (temp_m == RIG_MODE_RTTY) { - err = kenwood_safe_transaction(rig, cmd_mode, buf, KENWOOD_MAX_BUF_LEN, strlen(cmd_mode)+1); + err = kenwood_safe_transaction(rig, cmd_mode, buf, KENWOOD_MAX_BUF_LEN, + strlen(cmd_mode) + 1); if (err != RIG_OK) { @@ -1005,7 +1007,8 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } else if (temp_m == RIG_MODE_RTTYR) { - err = kenwood_safe_transaction(rig, cmd_mode, buf, KENWOOD_MAX_BUF_LEN, strlen(cmd_mode)+1); + err = kenwood_safe_transaction(rig, cmd_mode, buf, KENWOOD_MAX_BUF_LEN, + strlen(cmd_mode) + 1); if (err != RIG_OK) { @@ -1039,7 +1042,8 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) /* The K3 is not limited to specific filter widths so we can query * the actual bandwidth using the BW command */ - err = kenwood_safe_transaction(rig, cmd_bw, buf, KENWOOD_MAX_BUF_LEN, cmd_bw_len); + err = kenwood_safe_transaction(rig, cmd_bw, buf, KENWOOD_MAX_BUF_LEN, + cmd_bw_len); if (err != RIG_OK) { @@ -1047,7 +1051,7 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return err; } - *width = atoi(&buf[cmd_bw_len-4]) * 10; + *width = atoi(&buf[cmd_bw_len - 4]) * 10; return RIG_OK; } @@ -1086,28 +1090,30 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { - int err,err2; + int err, err2; char cmd_m[5]; char buf[KENWOOD_MAX_BUF_LEN]; char *dtcmd; struct kenwood_priv_caps *caps = kenwood_caps(rig); struct kenwood_priv_data *priv = rig->state.priv; - rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s mode=%s width=%d\n", __func__, rig_strvfo(vfo), rig_strrmode(mode), (int)width); + rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s mode=%s width=%d\n", __func__, + rig_strvfo(vfo), rig_strrmode(mode), (int)width); if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; } - rmode_t tmodeA,tmodeB; + rmode_t tmodeA, tmodeB; pbwidth_t twidth; err = k3_get_mode(rig, RIG_VFO_A, &tmodeA, &twidth); err2 = k3_get_mode(rig, RIG_VFO_B, &tmodeB, &twidth); // we keep both vfos in the same mode -- any reason they should ever be differnet? If so, fix this // if we change mode on one VFO we'll also change the other - if (err == RIG_OK && err2 == RIG_OK && tmodeA == mode && tmodeB == mode && width == RIG_PASSBAND_NOCHANGE) + if (err == RIG_OK && err2 == RIG_OK && tmodeA == mode && tmodeB == mode + && width == RIG_PASSBAND_NOCHANGE) { rig_debug(RIG_DEBUG_TRACE, "%s(%d): mode/width no change, skipping\n", __FILE__, __LINE__); @@ -1116,11 +1122,14 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) else { rig_debug(RIG_DEBUG_TRACE, - "%s(%d): changing oldmode=A=%s B=%s, to mode=%s, oldwidth=%ld, to width=%ld\n", __FILE__, - __LINE__, rig_strrmode(tmodeA), rig_strrmode(tmodeB), rig_strrmode(mode), twidth, width); + "%s(%d): changing oldmode=A=%s B=%s, to mode=%s, oldwidth=%ld, to width=%ld\n", + __FILE__, + __LINE__, rig_strrmode(tmodeA), rig_strrmode(tmodeB), rig_strrmode(mode), + twidth, width); } dtcmd = "DT"; + if ((priv->is_k4 || priv->is_k4d || priv->is_k4hd) && vfo == RIG_VFO_B) { dtcmd = "DT$"; @@ -2699,7 +2708,9 @@ int k4_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); snprintf(cmd, sizeof(cmd), "RX"); - if (ptt) cmd[0] = 'T'; + + if (ptt) { cmd[0] = 'T'; } + retval = kenwood_transaction(rig, cmd, NULL, 0); if (retval != RIG_OK) @@ -2709,20 +2720,23 @@ int k4_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) do { - hl_usleep(10*1000); + hl_usleep(10 * 1000); retval = kenwood_safe_transaction(rig, "TQ", pttbuf, 6, 3); if (retval != RIG_OK) { return retval; } - ptt2 = pttbuf[2] == '1'? RIG_PTT_ON : RIG_PTT_OFF; + + ptt2 = pttbuf[2] == '1' ? RIG_PTT_ON : RIG_PTT_OFF; + if (ptt2 != ptt) { rig_debug(RIG_DEBUG_TRACE, "%s: ptt=%d, expected=%d\n", __func__, ptt2, ptt); } - } while (ptt != ptt2); + } + while (ptt != ptt2); return RIG_OK; } diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 6489945c0..79df3c436 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -268,7 +268,8 @@ int kenwood_transaction(RIG *rig, const char *cmdstr, char *data, if (cache_age_ms < 500) // 500ms cache time { - rig_debug(RIG_DEBUG_TRACE, "%s: cache hit, age=%dms\n", __func__, cache_age_ms); + rig_debug(RIG_DEBUG_TRACE, "%s(%d): cache hit, age=%dms\n", __func__, __LINE__, + cache_age_ms); if (data) { strncpy(data, priv->last_if_response, datasize); } @@ -369,7 +370,8 @@ transaction_read: /* allow room for most any response */ len = min(datasize ? datasize + 1 : strlen(priv->verify_cmd) + 48, KENWOOD_MAX_BUF_LEN); - retval = read_string(&rs->rigport, buffer, len, cmdtrm_str, strlen(cmdtrm_str), 0); + retval = read_string(&rs->rigport, buffer, len, cmdtrm_str, strlen(cmdtrm_str), + 0, 1); rig_debug(RIG_DEBUG_TRACE, "%s: read_string(len=%d)='%s'\n", __func__, (int)strlen(buffer), buffer); @@ -466,9 +468,11 @@ transaction_read: { rig_debug(RIG_DEBUG_ERR, "%s: Unknown command or rig busy '%s'\n", __func__, cmdstr); + // sometimes IF; command after TX; will return ? but still return IF response - if (retry_read++ <= 1) { - hl_usleep(100*1000); + if (retry_read++ <= 1) + { + hl_usleep(100 * 1000); goto transaction_read; } } @@ -1065,11 +1069,16 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) * This prevents a 1.8 second delay in PowerSDR when switching VFOs * We'll do this once if curr_mode has not been set yet */ - if (priv->is_emulation && priv->curr_mode > 0) { RETURNFUNC(RIG_OK); } + if (priv->is_emulation && priv->curr_mode > 0) + { + TRACE; + RETURNFUNC(RIG_OK); + } if (rig->state.current_vfo == vfo) { - rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo already is %s...skipping\n", __func__, rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo already is %s...skipping\n", __func__, + rig_strvfo(vfo)); RETURNFUNC(RIG_OK); } @@ -1088,6 +1097,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) break; case RIG_VFO_CURR: + TRACE; rig->state.current_vfo = RIG_VFO_CURR; RETURNFUNC(RIG_OK); @@ -1122,6 +1132,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) } } + TRACE; snprintf(cmdbuf, sizeof(cmdbuf), "FR%c", vfo_function); // as we change VFO we will change split to the other VFO @@ -1150,6 +1161,8 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) { RETURNFUNC(retval); } + + TRACE; rig->state.current_vfo = vfo; /* if FN command then there's no FT or FR */ @@ -1159,15 +1172,57 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) RETURNFUNC(RIG_OK); } + TRACE; + // some rigs need split turned on after VFOA is set - if (vfo == RIG_VFO_A && priv->split == RIG_SPLIT_ON) + if (priv->split == RIG_SPLIT_ON) { - rig_set_split_vfo(rig, RIG_VFO_CURR, 1, priv->tx_vfo); + // so let's figure out who the rx_vfo is based on the tx_vfo + TRACE; + vfo_t rx_vfo = RIG_VFO_A; + + switch (priv->tx_vfo) + { + case RIG_VFO_A: + rx_vfo = RIG_VFO_B; + break; + + case RIG_VFO_MAIN: + rx_vfo = RIG_VFO_SUB; + break; + + case RIG_VFO_MAIN_A: + rx_vfo = RIG_VFO_MAIN_B; + break; + + case RIG_VFO_B: + rx_vfo = RIG_VFO_A; + break; + + case RIG_VFO_SUB: + rx_vfo = RIG_VFO_MAIN; + break; + + case RIG_VFO_SUB_B: + rx_vfo = RIG_VFO_MAIN_A; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unhandled VFO=%s, deafaulting to VFOA\n", + __func__, rig_strvfo(priv->tx_vfo)); + + } + + retval = rig_set_split_vfo(rig, rx_vfo, 1, priv->tx_vfo); } +#if 0 /* set TX VFO */ cmdbuf[1] = 'T'; RETURNFUNC(kenwood_transaction(rig, cmdbuf, NULL, 0)); +#else + RETURNFUNC(retval); +#endif } @@ -1241,9 +1296,10 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) char cmdbuf[12]; int retval; unsigned char vfo_function; - split_t tsplit=0; + split_t tsplit = 0; - rig_debug(RIG_DEBUG_VERBOSE, "%s called %s,%d,%s\n", __func__, rig_strvfo(vfo), split, rig_strvfo(txvfo)); + rig_debug(RIG_DEBUG_VERBOSE, "%s called %s,%d,%s\n", __func__, rig_strvfo(vfo), + split, rig_strvfo(txvfo)); if (RIG_IS_TS990S) { @@ -1259,57 +1315,66 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) RETURNFUNC(kenwood_transaction(rig, cmdbuf, NULL, 0)); } - if (vfo == RIG_VFO_CURR) vfo = rig->state.current_vfo; + if (vfo == RIG_VFO_CURR) { vfo = rig->state.current_vfo; } - switch (vfo) + switch (vfo) + { + case RIG_VFO_A: vfo_function = '0'; break; + + case RIG_VFO_B: vfo_function = '1'; break; + + case RIG_VFO_MEM: vfo_function = '2'; break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + rig_get_split(rig, vfo, &tsplit); + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): tsplit=%d, split=%d\n", __func__, + __LINE__, tsplit, split); + + if (tsplit == split) + { + rig_debug(RIG_DEBUG_TRACE, "%s: split already set\n", __func__); + RETURNFUNC(RIG_OK); + } + + /* set RX VFO */ + snprintf(cmdbuf, sizeof(cmdbuf), "FR%c", vfo_function); + + // FR can turn off split on some Kenwood rigs + // So we'll turn it back on just in case + TRACE; + + if (split) + { + if (vfo_function == '0') { - case RIG_VFO_A: vfo_function = '0'; break; - - case RIG_VFO_B: vfo_function = '1'; break; - - case RIG_VFO_MEM: vfo_function = '2'; break; - - default: - rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", __func__, rig_strvfo(vfo)); - RETURNFUNC(-RIG_EINVAL); + TRACE; + strcat(cmdbuf, ";FT1"); } - - rig_get_split(rig, vfo, &tsplit); - - if (tsplit == split) + else { - rig_debug(RIG_DEBUG_TRACE, "%s: split already set\n", __func__); - RETURNFUNC(RIG_OK); + TRACE; + strcat(cmdbuf, ";FT0"); } + } + else + { + strcat(cmdbuf, ";FT0"); + } - /* set RX VFO */ - snprintf(cmdbuf, sizeof(cmdbuf), "FR%c", vfo_function); + retval = kenwood_transaction(rig, cmdbuf, NULL, 0); - // FR can turn off split on some Kenwood rigs - // So we'll turn it back on just in case - if (split && vfo_function == '0') { strcat(cmdbuf, ";FT1"); } + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } - if (priv->split) - { - if (vfo_function == '0') - { - strcat(cmdbuf, ";FT1"); - } - else - { - strcat(cmdbuf, ";FT0"); - } - } - - retval = kenwood_transaction(rig, cmdbuf, NULL, 0); - - if (retval != RIG_OK) - { - RETURNFUNC(retval); - } - rig->state.cache.split = split; - rig->state.cache.split_vfo = txvfo; - elapsed_ms(&rig->state.cache.time_split, HAMLIB_ELAPSED_SET); + rig->state.cache.split = split; + rig->state.cache.split_vfo = txvfo; + elapsed_ms(&rig->state.cache.time_split, HAMLIB_ELAPSED_SET); /* Split off means Rx and Tx are the same */ if (split == RIG_SPLIT_OFF) @@ -1327,14 +1392,18 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) } } - if (txvfo == RIG_VFO_CURR && vfo == RIG_VFO_A) { - if (vfo == RIG_VFO_A) txvfo = RIG_VFO_B; - else if (vfo == RIG_VFO_B) txvfo = RIG_VFO_A; - else { - rig_debug(RIG_DEBUG_ERR, "%s: unsupported split VFO=%s\n", __func__, rig_strvfo(txvfo)); + if (txvfo == RIG_VFO_CURR && vfo == RIG_VFO_A) + { + if (vfo == RIG_VFO_A) { txvfo = RIG_VFO_B; } + else if (vfo == RIG_VFO_B) { txvfo = RIG_VFO_A; } + else + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported split VFO=%s\n", __func__, + rig_strvfo(txvfo)); RETURNFUNC(-RIG_EINVAL); } } + switch (txvfo) { case RIG_VFO_VFO: @@ -1358,29 +1427,27 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) */ tsplit = RIG_SPLIT_OFF; // default in case rig does not set split status retval = rig_get_split(rig, vfo, &tsplit); + // and it should be OK to do a SPLIT_OFF at any time so we won's skip that if (retval == RIG_OK && split == RIG_SPLIT_ON && tsplit == RIG_SPLIT_ON) { rig_debug(RIG_DEBUG_VERBOSE, "%s: already set split=%d\n", __func__, tsplit); - RETURNFUNC(RIG_OK); + RETURNFUNC(RIG_OK); } - rig_debug(RIG_DEBUG_VERBOSE, "%s: split is=%d, split wants=%d\n", __func__, tsplit, split); + + rig_debug(RIG_DEBUG_VERBOSE, "%s: split is=%d, split wants=%d\n", __func__, + tsplit, split); /* set TX VFO */ // if turning on split need to do some VFOB setup on Elecraft rigs to avoid SPLIT N/A and ER59 messages - if (rig->caps->rig_model == RIG_MODEL_K4 // Elecraft needs VFOB to be same band as VFOA - ||rig->caps->rig_model == RIG_MODEL_K3 - ||rig->caps->rig_model == RIG_MODEL_KX2 - ||rig->caps->rig_model == RIG_MODEL_KX3) + if (rig->caps->rig_model == + RIG_MODEL_K4 // Elecraft needs VFOB to be same band as VFOA + || rig->caps->rig_model == RIG_MODEL_K3 + || rig->caps->rig_model == RIG_MODEL_KX2 + || rig->caps->rig_model == RIG_MODEL_KX3) { rig_set_freq(rig, RIG_VFO_B, rig->state.cache.freqMainA); - snprintf(cmdbuf, sizeof(cmdbuf), "FT%c", vfo_function); } - else - { - snprintf(cmdbuf, sizeof(cmdbuf), "FT%c", vfo_function); - } - retval = kenwood_transaction(rig, cmdbuf, NULL, 0); if (retval != RIG_OK) { @@ -1501,11 +1568,43 @@ int kenwood_get_split_vfo_if(RIG *rig, vfo_t rxvfo, split_t *split, switch (priv->info[30]) { case '0': - *txvfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A; + if (rig->state.rx_vfo == RIG_VFO_A) + { + TRACE; + *txvfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A; + } + else if (rig->state.rx_vfo == RIG_VFO_B) + { + TRACE; + *txvfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A; + } + else + { + rig_debug(RIG_DEBUG_WARN, "%s(%d): unknown rxVFO=%s\n", __func__, __LINE__, + rig_strvfo(rig->state.rx_vfo)); + *txvfo = RIG_VFO_A; // pick a default + } + break; case '1': - *txvfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_A : RIG_VFO_B; + if (rig->state.rx_vfo == RIG_VFO_A) + { + TRACE; + *txvfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_A : RIG_VFO_B; + } + else if (rig->state.rx_vfo == RIG_VFO_B) + { + TRACE; + *txvfo = priv->tx_vfo = (*split && !transmitting) ? RIG_VFO_B : RIG_VFO_A; + } + else + { + rig_debug(RIG_DEBUG_WARN, "%s(%d): unknown rxVFO=%s\n", __func__, __LINE__, + rig_strvfo(rig->state.rx_vfo)); + *txvfo = RIG_VFO_A; // pick a default + } + break; case '2': @@ -1619,6 +1718,7 @@ int kenwood_set_freq(RIG *rig, vfo_t vfo, freq_t freq) } rig_get_freq(rig, tvfo, &tfreq); + if (tfreq == freq) { rig_debug(RIG_DEBUG_TRACE, "%s: no freq change needed\n", __func__); @@ -2062,9 +2162,24 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) struct kenwood_priv_data *priv = rig->state.priv; struct kenwood_priv_caps *caps = kenwood_caps(rig); + rig_debug(RIG_DEBUG_VERBOSE, + "%s called, vfo=%s, mode=%s, width=%d, curr_vfo=%s\n", __func__, + rig_strvfo(vfo), rig_strrmode(mode), (int)width, + rig_strvfo(rig->state.current_vfo)); - rig_debug(RIG_DEBUG_VERBOSE, "%s called, vfo=%s, mode=%s, width=%d\n", __func__, - rig_strvfo(vfo), rig_strrmode(mode), (int)width); + // we wont' set opposite VFO if the mode is the same as requested + // setting VFOB mode requires split modifications which cause VFO flashing + // this should generally work unless the user changes mode on VFOB + // in which case VFOB won't get mode changed until restart + if (priv->split && (priv->tx_vfo & (RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_A))) + { + if (priv->modeB == mode) + { + rig_debug(RIG_DEBUG_TRACE, "%s: VFOB mode already %s so ignoring request\n", + __func__, rig_strrmode(mode)); + return (RIG_OK); + } + } if (RIG_IS_TS590S || RIG_IS_TS590SG || RIG_IS_TS950S || RIG_IS_TS950SDX) { @@ -2094,7 +2209,10 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { /* emulations like PowerSDR and SmartSDR normally hijack the RTTY modes for SSB-DATA AFSK modes */ - rig_debug(RIG_DEBUG_VERBOSE, "%s: emulate=%d, HPSDR=%d, changing PKT mode to RTTY\n", __func__, priv->is_emulation, RIG_IS_HPSDR); + rig_debug(RIG_DEBUG_VERBOSE, + "%s: emulate=%d, HPSDR=%d, changing PKT mode to RTTY\n", __func__, + priv->is_emulation, RIG_IS_HPSDR); + if (RIG_MODE_PKTLSB == mode) { mode = RIG_MODE_RTTY; } if (RIG_MODE_PKTUSB == mode) { mode = RIG_MODE_RTTYR; } @@ -2175,18 +2293,37 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) datamode = 1; } } - rig_debug(RIG_DEBUG_VERBOSE, "%s: curr_mode=%s, new_mode=%s\n", __func__, rig_strrmode(priv->curr_mode), rig_strrmode(mode)); + + rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s, curr_mode=%s, new_mode=%s\n", + __func__, rig_strvfo(vfo), rig_strrmode(priv->curr_mode), rig_strrmode(mode)); + // only change mode if needed if (priv->curr_mode != mode) { snprintf(buf, sizeof(buf), "MD%c", c); err = kenwood_transaction(rig, buf, NULL, 0); } + + // determine if we need to set datamode on A or B needdata = 0; - if ((vfo == RIG_VFO_A) && ((priv->datamodeA == 0 && datamode) || (priv->datamodeA == 1 && !datamode))) + + if (vfo == RIG_VFO_CURR) + { + TRACE; + vfo = rig->state.current_vfo; + } + + if ((vfo & (RIG_VFO_A | RIG_VFO_MAIN)) && ((priv->datamodeA == 0 && datamode) + || (priv->datamodeA == 1 && !datamode))) + { needdata = 1; - if ((vfo == RIG_VFO_B) && ((priv->datamodeB == 0 && datamode) || (priv->datamodeB == 1 && !datamode))) + } + + if ((vfo & (RIG_VFO_B | RIG_VFO_SUB)) && ((priv->datamodeB == 0 && datamode) + || (priv->datamodeB == 1 && !datamode))) + { needdata = 1; + } if (needdata) { @@ -2196,6 +2333,11 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (err != RIG_OK) { RETURNFUNC(err); } } + else if (datamode) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): datamode set on %s not needed\n", + __func__, __LINE__, rig_strvfo(vfo)); + } if (RIG_PASSBAND_NOCHANGE == width) { RETURNFUNC(RIG_OK); } @@ -2339,7 +2481,8 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) struct kenwood_priv_data *priv = rig->state.priv; struct kenwood_priv_caps *caps = kenwood_caps(rig); - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called, curr_vfo=%s\n", __func__, + rig_strvfo(rig->state.current_vfo)); if (!mode || !width) { @@ -2351,7 +2494,8 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) /* only need to get it if it has to be initialized */ if (priv->curr_mode > 0 && priv->is_emulation && vfo == RIG_VFO_B) { - RETURNFUNC(priv->curr_mode); + rig->state.current_vfo = RIG_VFO_A; + RETURNFUNC(RIG_OK); } if (RIG_IS_TS990S) @@ -2382,7 +2526,8 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } else { - if (vfo == RIG_VFO_B && rig->caps->rig_model == RIG_MODEL_K4) // K4 new MD$ command for VFOB + if (vfo == RIG_VFO_B + && rig->caps->rig_model == RIG_MODEL_K4) // K4 new MD$ command for VFOB { snprintf(cmd, sizeof(cmd), "MD$"); offs = 3; @@ -2416,7 +2561,10 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { /* emulations like PowerSDR and SmartSDR normally hijack the RTTY modes for SSB-DATA AFSK modes */ - rig_debug(RIG_DEBUG_VERBOSE, "%s: emulate=%d, HPSDR=%d, changing RTTY mode to PKT\n", __func__, priv->is_emulation, RIG_IS_HPSDR); + rig_debug(RIG_DEBUG_VERBOSE, + "%s: emulate=%d, HPSDR=%d, changing RTTY mode to PKT\n", __func__, + priv->is_emulation, RIG_IS_HPSDR); + if (RIG_MODE_RTTY == *mode) { *mode = RIG_MODE_PKTLSB; } if (RIG_MODE_RTTYR == *mode) { *mode = RIG_MODE_PKTUSB; } @@ -2434,8 +2582,9 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) if ('1' == modebuf[2]) { - if (vfo == RIG_VFO_A) priv->datamodeA = 1; - else priv->datamodeB = 1; + if (vfo == RIG_VFO_A) { priv->datamodeA = 1; } + else { priv->datamodeB = 1; } + switch (*mode) { case RIG_MODE_USB: *mode = RIG_MODE_PKTUSB; break; @@ -2451,8 +2600,8 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } else { - if (vfo == RIG_VFO_A) priv->datamodeA = 0; - else priv->datamodeB = 0; + if (vfo == RIG_VFO_A) { priv->datamodeA = 0; } + else { priv->datamodeB = 0; } } } @@ -2472,9 +2621,9 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { *width = rig_passband_normal(rig, *mode); } - - if (vfo == RIG_VFO_A) priv->modeA = *mode; - else priv->modeB = *mode; + + if (vfo == RIG_VFO_A) { priv->modeA = *mode; } + else { priv->modeB = *mode; } RETURNFUNC(RIG_OK); } @@ -2541,7 +2690,7 @@ static int kenwood_get_micgain_minmax(RIG *rig, int *micgain_now, if (retval != RIG_OK) { RETURNFUNC(retval); } - retval = read_string(&rs->rigport, levelbuf, sizeof(levelbuf), NULL, 0, 0); + retval = read_string(&rs->rigport, levelbuf, sizeof(levelbuf), NULL, 0, 0, 1); rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval); @@ -2640,7 +2789,7 @@ static int kenwood_get_power_minmax(RIG *rig, int *power_now, int *power_min, if (retval != RIG_OK) { RETURNFUNC(retval); } - retval = read_string(&rs->rigport, levelbuf, sizeof(levelbuf), NULL, 0, 0); + retval = read_string(&rs->rigport, levelbuf, sizeof(levelbuf), NULL, 0, 0, 1); rig_debug(RIG_DEBUG_TRACE, "%s: retval=%d\n", __func__, retval); @@ -4477,18 +4626,15 @@ int kenwood_set_trn(RIG *rig, int trn) case RIG_MODEL_TS990S: RETURNFUNC(kenwood_transaction(rig, (trn == RIG_TRN_RIG) ? "AI2" : "AI0", NULL, 0)); - break; case RIG_MODEL_THD7A: case RIG_MODEL_THD74: RETURNFUNC(kenwood_transaction(rig, (trn == RIG_TRN_RIG) ? "AI 1" : "AI 0", buf, sizeof buf)); - break; default: RETURNFUNC(kenwood_transaction(rig, (trn == RIG_TRN_RIG) ? "AI1" : "AI0", NULL, 0)); - break; } } @@ -5307,7 +5453,7 @@ DECLARE_PROBERIG_BACKEND(kenwood) } retval = write_block(port, "ID;", 3); - id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0); + id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0, 1); close(port->fd); if (retval != RIG_OK || id_len < 0) @@ -5374,7 +5520,7 @@ DECLARE_PROBERIG_BACKEND(kenwood) } retval = write_block(port, "K2;", 3); - id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0); + id_len = read_string(port, idbuf, IDBUFSZ, ";\r", 2, 0, 1); close(port->fd); if (retval != RIG_OK) diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index e31db932b..b7181d1ed 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -28,7 +28,7 @@ #include "token.h" #include "misc.h" -#define BACKEND_VER "20211118" +#define BACKEND_VER "20211128" #define EOM_KEN ';' #define EOM_TH '\r' diff --git a/rigs/kenwood/ts480.c b/rigs/kenwood/ts480.c index 190b72f03..029123ce7 100644 --- a/rigs/kenwood/ts480.c +++ b/rigs/kenwood/ts480.c @@ -442,7 +442,7 @@ static int ts480_read_meters(RIG *rig, int *swr, int *comp, int *alc) // TS-480 returns values for all meters at the same time, for example: RM10000;RM20000;RM30000; - retval = read_string(&rs->rigport, ackbuf, expected_len + 1, NULL, 0, 0); + retval = read_string(&rs->rigport, ackbuf, expected_len + 1, NULL, 0, 0, 1); rig_debug(RIG_DEBUG_TRACE, "%s: read_string retval=%d\n", __func__, retval); diff --git a/rigs/kenwood/ts890s.c b/rigs/kenwood/ts890s.c index 09ea0410e..24f8d7367 100644 --- a/rigs/kenwood/ts890s.c +++ b/rigs/kenwood/ts890s.c @@ -224,6 +224,7 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) default: return kenwood_get_level(rig, vfo, level, val); } + return -RIG_EINTERNAL; } diff --git a/rigs/kenwood/xg3.c b/rigs/kenwood/xg3.c index 54b136344..1251378c0 100644 --- a/rigs/kenwood/xg3.c +++ b/rigs/kenwood/xg3.c @@ -285,7 +285,7 @@ int xg3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return retval; } - retval = read_string(&rs->rigport, replybuf, replysize, ";", 1, 0); + retval = read_string(&rs->rigport, replybuf, replysize, ";", 1, 0, 1); if (retval < 0) { @@ -462,7 +462,7 @@ int xg3_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return retval; } - retval = read_string(&rs->rigport, freqbuf, freqsize, ";", 1, 0); + retval = read_string(&rs->rigport, freqbuf, freqsize, ";", 1, 0, 1); if (retval < 0) { @@ -514,7 +514,7 @@ int xg3_get_powerstat(RIG *rig, powerstat_t *status) if (retval == RIG_OK) { char reply[32]; - retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1, 0); + retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1, 0, 1); *status = RIG_POWER_ON; priv->powerstat = RIG_POWER_ON; } @@ -578,7 +578,7 @@ int xg3_get_mem(RIG *rig, vfo_t vfo, int *ch) return retval; } - retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1, 0); + retval = read_string(&rs->rigport, reply, sizeof(reply), ";", 1, 0, 1); if (retval < 0) { diff --git a/rigs/kit/funcube.c b/rigs/kit/funcube.c index 1f6aee182..c2ab99436 100644 --- a/rigs/kit/funcube.c +++ b/rigs/kit/funcube.c @@ -75,7 +75,8 @@ static int funcubepro_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); static const char *funcube_get_info(RIG *rig); -static int funcube_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int funcube_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); static const struct confparams funcube_cfg_params[] = { @@ -943,7 +944,8 @@ int funcubepro_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return RIG_OK; } -static int funcube_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) +static int funcube_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width) { if (rig->caps->rig_model == RIG_MODEL_FUNCUBEDONGLE) { @@ -953,6 +955,7 @@ static int funcube_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width { *mode = RIG_MODE_IQ; } + *width = 192000; return RIG_OK; } diff --git a/rigs/kit/rs_hfiq.c b/rigs/kit/rs_hfiq.c index 92b1b59d5..3618cd0a4 100644 --- a/rigs/kit/rs_hfiq.c +++ b/rigs/kit/rs_hfiq.c @@ -102,7 +102,7 @@ static int rshfiq_open(RIG *rig) return retval; } - retval = read_string(&rig->state.rigport, versionstr, 20, stopset, 2, 0); + retval = read_string(&rig->state.rigport, versionstr, 20, stopset, 2, 0, 1); } if (retval <= 0) @@ -191,7 +191,7 @@ static int rshfiq_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return retval; } - retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0); + retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0, 1); if (retval <= 0) { @@ -276,7 +276,7 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) stopset[0] = '\r'; stopset[1] = '\n'; - retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0); + retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0, 1); rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER reply=%s\n", cmdstr); @@ -314,7 +314,7 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) stopset[0] = '\r'; stopset[1] = '\n'; - retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0); + retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2, 0, 1); rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER reply=%s\n", cmdstr); diff --git a/rigs/lowe/lowe.c b/rigs/lowe/lowe.c index ad561b1ab..a9d14478e 100644 --- a/rigs/lowe/lowe.c +++ b/rigs/lowe/lowe.c @@ -79,7 +79,7 @@ int lowe_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return 0; } - retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0); + retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0, 1); if (retval == -RIG_ETIMEOUT) { @@ -342,7 +342,7 @@ DECLARE_PROBERIG_BACKEND(lowe) } retval = write_block(port, "TYP?" EOM, 4); - id_len = read_string(port, idbuf, BUFSZ, CR, 2, 0); + id_len = read_string(port, idbuf, BUFSZ, CR, 2, 0, 1); close(port->fd); diff --git a/rigs/prm80/prm80.c b/rigs/prm80/prm80.c index 6da02693e..5ba68be6d 100644 --- a/rigs/prm80/prm80.c +++ b/rigs/prm80/prm80.c @@ -170,7 +170,7 @@ static int read_prompt_and_send(hamlib_port_t *rigport, buflen = (data_len == NULL) ? sizeof(buf) : *data_len; - retval = read_string(rigport, data, buflen, delimiter, 1, 0); + retval = read_string(rigport, data, buflen, delimiter, 1, 0, 1); if (retval < 0) { @@ -230,7 +230,7 @@ static int prm80_wait_for_prompt(hamlib_port_t *rigport) int retval; // Read up to the '>' prompt and discard content. - retval = read_string(rigport, buf, sizeof(buf), ">", 1, 0); + retval = read_string(rigport, buf, sizeof(buf), ">", 1, 0, 1); if (retval < 0) { @@ -910,7 +910,7 @@ int prm80_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan) if (ret == 3 && buf[2] == 'T') { // Read the question - ret = read_string(&rs->rigport, buf, sizeof(buf), "?", 1, 0); + ret = read_string(&rs->rigport, buf, sizeof(buf), "?", 1, 0, 1); if (ret < 0) { @@ -1126,7 +1126,7 @@ static int prm80_get_rawstr_RAM(RIG *rig, value_t *val) } // Read CRLF - ret = read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0); + ret = read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0, 1); if (ret < 0) { @@ -1142,7 +1142,7 @@ static int prm80_get_rawstr_RAM(RIG *rig, value_t *val) for (i = 0; i < (RSSI_HOLD_ADDR / 16) + 1; i++) { - ret = read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0); + ret = read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0, 1); if (ret < 0) { @@ -1158,7 +1158,7 @@ static int prm80_get_rawstr_RAM(RIG *rig, value_t *val) // discard the remaining content of RAM print for (i = 0; i < (16 - RSSI_HOLD_ADDR / 16) - 1; i++) { - read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0); + read_string(&rs->rigport, buf, BUFSZ, "\n", 1, 0, 1); } prm80_wait_for_prompt(&rs->rigport); @@ -1281,7 +1281,7 @@ const char *prm80_get_info(RIG *rig) return NULL; } - ret = read_string(&rs->rigport, s_buf, BUFSZ, ">", 1, 0); + ret = read_string(&rs->rigport, s_buf, BUFSZ, ">", 1, 0, 1); if (ret < 0) { diff --git a/rigs/racal/ra37xx.c b/rigs/racal/ra37xx.c index bee3c6e66..353ba2d5a 100644 --- a/rigs/racal/ra37xx.c +++ b/rigs/racal/ra37xx.c @@ -122,7 +122,7 @@ static int ra37xx_one_transaction(RIG *rig, const char *cmd, char *data, do { - retval = read_string(&rs->rigport, respbuf, BUFSZ, EOM, strlen(EOM), 0); + retval = read_string(&rs->rigport, respbuf, BUFSZ, EOM, strlen(EOM), 0, 1); if (retval < 0) { diff --git a/rigs/racal/racal.c b/rigs/racal/racal.c index dc6dad86b..cc3b5050b 100644 --- a/rigs/racal/racal.c +++ b/rigs/racal/racal.c @@ -100,7 +100,7 @@ static int racal_transaction(RIG *rig, const char *cmd, char *data, return retval; } - retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0); + retval = read_string(&rs->rigport, data, BUFSZ, EOM, strlen(EOM), 0, 1); if (retval <= 0) { diff --git a/rigs/rft/rft.c b/rigs/rft/rft.c index 7b544b8fb..d5960f7e6 100644 --- a/rigs/rft/rft.c +++ b/rigs/rft/rft.c @@ -71,7 +71,7 @@ int rft_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return 0; } - retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0); + retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0, 1); if (retval == -RIG_ETIMEOUT) { diff --git a/rigs/rs/gp2000.c b/rigs/rs/gp2000.c index 6455fa0a9..d0c80c52e 100644 --- a/rigs/rs/gp2000.c +++ b/rigs/rs/gp2000.c @@ -89,7 +89,7 @@ gp2000_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return RIG_OK; } - retval = read_string(&rs->rigport, data, RESPSZ, CR, 1, 0); + retval = read_string(&rs->rigport, data, RESPSZ, CR, 1, 0, 1); if (retval < 0) { diff --git a/rigs/rs/rs.c b/rigs/rs/rs.c index bde748edb..b60056eb1 100644 --- a/rigs/rs/rs.c +++ b/rigs/rs/rs.c @@ -80,7 +80,7 @@ int rs_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return RIG_OK; } - retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0); + retval = read_string(&rs->rigport, data, BUFSZ, CR, 1, 0, 1); if (retval < 0) { diff --git a/rigs/skanti/skanti.c b/rigs/skanti/skanti.c index 8ad178985..347900aef 100644 --- a/rigs/skanti/skanti.c +++ b/rigs/skanti/skanti.c @@ -88,7 +88,7 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len, * Transceiver sends back ">" */ char retbuf[BUFSZ + 1]; - retval = read_string(&rs->rigport, retbuf, BUFSZ, PROMPT, strlen(PROMPT), 0); + retval = read_string(&rs->rigport, retbuf, BUFSZ, PROMPT, strlen(PROMPT), 0, 1); if (retval < 0) { @@ -107,7 +107,7 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len, } } - retval = read_string(&rs->rigport, data, BUFSZ, LF, strlen(LF), 0); + retval = read_string(&rs->rigport, data, BUFSZ, LF, strlen(LF), 0, 1); if (retval == -RIG_ETIMEOUT) { diff --git a/rigs/tentec/omnivii.c b/rigs/tentec/omnivii.c index 34192a637..584cd880d 100644 --- a/rigs/tentec/omnivii.c +++ b/rigs/tentec/omnivii.c @@ -288,7 +288,8 @@ static int tt588_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, if (data) { - retval = read_string(&rs->rigport, data, (*data_len) + 1, term, strlen(term), 0); + retval = read_string(&rs->rigport, data, (*data_len) + 1, term, strlen(term), 0, + 1); if (retval != -RIG_ETIMEOUT) { @@ -310,7 +311,7 @@ static int tt588_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, write_block(&rs->rigport, "XX" EOM, 3); // we wont' worry about the response here retval = read_string(&rs->rigport, xxbuf, sizeof(xxbuf), "", - 0, 0); // this should timeout + 0, 0, 1); // this should timeout if (retval != RIG_OK) { diff --git a/rigs/tentec/orion.c b/rigs/tentec/orion.c index 823477bc4..b1aebe475 100644 --- a/rigs/tentec/orion.c +++ b/rigs/tentec/orion.c @@ -156,7 +156,7 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, #endif *data_len = data_len_init; /* restore orig. buffer length */ *data_len = read_string(&rs->rigport, data, *data_len, - EOM, strlen(EOM), 0); + EOM, strlen(EOM), 0, 1); if (!strncmp(data, "Z!", 2)) // command unrecognized?? { @@ -197,7 +197,7 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, passcount, itry); *data_len = data_len_init; /* restore orig. buffer length */ read_string(&rs->rigport, data, *data_len, - EOM, strlen(EOM), 0); // purge the input stream... + EOM, strlen(EOM), 0, 1); // purge the input stream... continue; // now go retry the full command } } diff --git a/rigs/tentec/rx331.c b/rigs/tentec/rx331.c index f9737100b..5e41cef0f 100644 --- a/rigs/tentec/rx331.c +++ b/rigs/tentec/rx331.c @@ -269,7 +269,7 @@ static int rx331_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return RIG_OK; } - retval = read_string(&rs->rigport, data, BUFSZ, EOM, 1, 0); + retval = read_string(&rs->rigport, data, BUFSZ, EOM, 1, 0, 1); if (retval < 0) { @@ -780,6 +780,7 @@ int rx331_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { return -RIG_EPROTO; } + f = val->i / 120.0; val->f = 1.0 - f; diff --git a/rigs/tentec/rx340.c b/rigs/tentec/rx340.c index 8a8245a41..1edcf642a 100644 --- a/rigs/tentec/rx340.c +++ b/rigs/tentec/rx340.c @@ -219,7 +219,7 @@ static int rx340_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return RIG_OK; } - retval = read_string(&rs->rigport, data, BUFSZ, EOM, 1, 0); + retval = read_string(&rs->rigport, data, BUFSZ, EOM, 1, 0, 1); if (retval < 0) { diff --git a/rigs/tentec/tentec.c b/rigs/tentec/tentec.c index 2c022a952..00a4ee9f3 100644 --- a/rigs/tentec/tentec.c +++ b/rigs/tentec/tentec.c @@ -85,7 +85,7 @@ int tentec_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return 0; } - retval = read_string(&rs->rigport, data, *data_len, NULL, 0, 0); + retval = read_string(&rs->rigport, data, *data_len, NULL, 0, 0, 1); if (retval == -RIG_ETIMEOUT) { diff --git a/rigs/tentec/tt550.c b/rigs/tentec/tt550.c index edfc18d2f..0679d130b 100644 --- a/rigs/tentec/tt550.c +++ b/rigs/tentec/tt550.c @@ -103,7 +103,7 @@ tt550_transaction(RIG *rig, const char *cmd, int cmd_len, char *data, return 0; } - retval = read_string(&rs->rigport, data, *data_len, NULL, 0, 0); + retval = read_string(&rs->rigport, data, *data_len, NULL, 0, 0, 1); if (retval == -RIG_ETIMEOUT) { @@ -1699,7 +1699,8 @@ tt550_decode_event(RIG *rig) priv = (struct tt550_priv_data *) rs->priv; - data_len = read_string(&rs->rigport, (char *) buf, MAXFRAMELEN, "\n\r", 2, 0); + data_len = read_string(&rs->rigport, (char *) buf, MAXFRAMELEN, "\n\r", 2, 0, + 1); if (data_len == -RIG_ETIMEOUT) diff --git a/rigs/uniden/uniden.c b/rigs/uniden/uniden.c index a583dfa90..486787d1a 100644 --- a/rigs/uniden/uniden.c +++ b/rigs/uniden/uniden.c @@ -156,7 +156,7 @@ transaction_write: } memset(data, 0, *datasize); - retval = read_string(&rs->rigport, data, *datasize, EOM, strlen(EOM), 0); + retval = read_string(&rs->rigport, data, *datasize, EOM, strlen(EOM), 0, 1); if (retval < 0) { @@ -838,7 +838,7 @@ DECLARE_PROBERIG_BACKEND(uniden) } retval = write_block(port, "SI"EOM, 3); - id_len = read_string(port, idbuf, IDBUFSZ, EOM, 1, 0); + id_len = read_string(port, idbuf, IDBUFSZ, EOM, 1, 0, 1); close(port->fd); if (retval != RIG_OK || id_len < 0) diff --git a/rigs/uniden/uniden_digital.c b/rigs/uniden/uniden_digital.c index f2f130ab4..e53bfacce 100644 --- a/rigs/uniden/uniden_digital.c +++ b/rigs/uniden/uniden_digital.c @@ -138,7 +138,7 @@ transaction_write: } memset(data, 0, *datasize); - retval = read_string(&rs->rigport, data, *datasize, EOM, strlen(EOM), 0); + retval = read_string(&rs->rigport, data, *datasize, EOM, strlen(EOM), 0, 1); if (retval < 0) { diff --git a/rigs/yaesu/frg100.c b/rigs/yaesu/frg100.c index 1f459dd2b..cecb4a764 100644 --- a/rigs/yaesu/frg100.c +++ b/rigs/yaesu/frg100.c @@ -36,7 +36,8 @@ #include "yaesu.h" #include "frg100.h" -enum frg100_native_cmd_e { +enum frg100_native_cmd_e +{ FRG100_NATIVE_RECALL_MEM = 0, /* 0x02, p1=ch */ FRG100_NATIVE_VFO_TO_MEM, /* 0x03, p1=ch, p2=0 */ FRG100_NATIVE_MEM_HIDE, /* 0x03, p1=ch, p2=1 */ diff --git a/rigs/yaesu/ft100.c b/rigs/yaesu/ft100.c index 0c698255e..293ce077a 100644 --- a/rigs/yaesu/ft100.c +++ b/rigs/yaesu/ft100.c @@ -41,51 +41,52 @@ #include "misc.h" #include "bandplan.h" -enum ft100_native_cmd_e { +enum ft100_native_cmd_e +{ - FT100_NATIVE_CAT_LOCK_ON = 0, - FT100_NATIVE_CAT_LOCK_OFF, - FT100_NATIVE_CAT_PTT_ON, - FT100_NATIVE_CAT_PTT_OFF, - FT100_NATIVE_CAT_SET_FREQ, - FT100_NATIVE_CAT_SET_MODE_LSB, - FT100_NATIVE_CAT_SET_MODE_USB, - FT100_NATIVE_CAT_SET_MODE_CW, - FT100_NATIVE_CAT_SET_MODE_CWR, - FT100_NATIVE_CAT_SET_MODE_AM, - FT100_NATIVE_CAT_SET_MODE_FM, - FT100_NATIVE_CAT_SET_MODE_DIG, - FT100_NATIVE_CAT_SET_MODE_WFM, - FT100_NATIVE_CAT_CLAR_ON, - FT100_NATIVE_CAT_CLAR_OFF, - FT100_NATIVE_CAT_SET_CLAR_FREQ, - FT100_NATIVE_CAT_SET_VFOAB, - FT100_NATIVE_CAT_SET_VFOA, - FT100_NATIVE_CAT_SET_VFOB, - FT100_NATIVE_CAT_SPLIT_ON, - FT100_NATIVE_CAT_SPLIT_OFF, - FT100_NATIVE_CAT_SET_RPT_SHIFT_MINUS, - FT100_NATIVE_CAT_SET_RPT_SHIFT_PLUS, - FT100_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, - FT100_NATIVE_CAT_SET_RPT_OFFSET, -/* fix me */ - FT100_NATIVE_CAT_SET_DCS_ON, - FT100_NATIVE_CAT_SET_CTCSS_ENC_ON, - FT100_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON, - FT100_NATIVE_CAT_SET_CTCSS_DCS_OFF, -/* em xif */ - FT100_NATIVE_CAT_SET_CTCSS_FREQ, - FT100_NATIVE_CAT_SET_DCS_CODE, - FT100_NATIVE_CAT_GET_RX_STATUS, - FT100_NATIVE_CAT_GET_TX_STATUS, - FT100_NATIVE_CAT_GET_FREQ_MODE_STATUS, - FT100_NATIVE_CAT_PWR_WAKE, - FT100_NATIVE_CAT_PWR_ON, - FT100_NATIVE_CAT_PWR_OFF, - FT100_NATIVE_CAT_READ_STATUS, - FT100_NATIVE_CAT_READ_METERS, - FT100_NATIVE_CAT_READ_FLAGS, - FT100_NATIVE_SIZE /* end marker */ + FT100_NATIVE_CAT_LOCK_ON = 0, + FT100_NATIVE_CAT_LOCK_OFF, + FT100_NATIVE_CAT_PTT_ON, + FT100_NATIVE_CAT_PTT_OFF, + FT100_NATIVE_CAT_SET_FREQ, + FT100_NATIVE_CAT_SET_MODE_LSB, + FT100_NATIVE_CAT_SET_MODE_USB, + FT100_NATIVE_CAT_SET_MODE_CW, + FT100_NATIVE_CAT_SET_MODE_CWR, + FT100_NATIVE_CAT_SET_MODE_AM, + FT100_NATIVE_CAT_SET_MODE_FM, + FT100_NATIVE_CAT_SET_MODE_DIG, + FT100_NATIVE_CAT_SET_MODE_WFM, + FT100_NATIVE_CAT_CLAR_ON, + FT100_NATIVE_CAT_CLAR_OFF, + FT100_NATIVE_CAT_SET_CLAR_FREQ, + FT100_NATIVE_CAT_SET_VFOAB, + FT100_NATIVE_CAT_SET_VFOA, + FT100_NATIVE_CAT_SET_VFOB, + FT100_NATIVE_CAT_SPLIT_ON, + FT100_NATIVE_CAT_SPLIT_OFF, + FT100_NATIVE_CAT_SET_RPT_SHIFT_MINUS, + FT100_NATIVE_CAT_SET_RPT_SHIFT_PLUS, + FT100_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, + FT100_NATIVE_CAT_SET_RPT_OFFSET, + /* fix me */ + FT100_NATIVE_CAT_SET_DCS_ON, + FT100_NATIVE_CAT_SET_CTCSS_ENC_ON, + FT100_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON, + FT100_NATIVE_CAT_SET_CTCSS_DCS_OFF, + /* em xif */ + FT100_NATIVE_CAT_SET_CTCSS_FREQ, + FT100_NATIVE_CAT_SET_DCS_CODE, + FT100_NATIVE_CAT_GET_RX_STATUS, + FT100_NATIVE_CAT_GET_TX_STATUS, + FT100_NATIVE_CAT_GET_FREQ_MODE_STATUS, + FT100_NATIVE_CAT_PWR_WAKE, + FT100_NATIVE_CAT_PWR_ON, + FT100_NATIVE_CAT_PWR_OFF, + FT100_NATIVE_CAT_READ_STATUS, + FT100_NATIVE_CAT_READ_METERS, + FT100_NATIVE_CAT_READ_FLAGS, + FT100_NATIVE_SIZE /* end marker */ }; /* @@ -95,41 +96,41 @@ enum ft100_native_cmd_e { */ typedef struct { - unsigned char band_no; - unsigned char freq[4]; - unsigned char mode; - unsigned char ctcss; - unsigned char dcs; - unsigned char flag1; - unsigned char flag2; - unsigned char clarifier[2]; - unsigned char not_used; - unsigned char step1; - unsigned char step2; - unsigned char filter; + unsigned char band_no; + unsigned char freq[4]; + unsigned char mode; + unsigned char ctcss; + unsigned char dcs; + unsigned char flag1; + unsigned char flag2; + unsigned char clarifier[2]; + unsigned char not_used; + unsigned char step1; + unsigned char step2; + unsigned char filter; - unsigned char stuffing[16]; + unsigned char stuffing[16]; } - FT100_STATUS_INFO; +FT100_STATUS_INFO; typedef struct { - unsigned char mic_switch_1; - unsigned char tx_fwd_power; - unsigned char tx_rev_power; - unsigned char s_meter; - unsigned char mic_level; - unsigned char squelch_level; - unsigned char mic_switch_2; - unsigned char final_temp; - unsigned char alc_level; + unsigned char mic_switch_1; + unsigned char tx_fwd_power; + unsigned char tx_rev_power; + unsigned char s_meter; + unsigned char mic_level; + unsigned char squelch_level; + unsigned char mic_switch_2; + unsigned char final_temp; + unsigned char alc_level; } - FT100_METER_INFO; +FT100_METER_INFO; typedef struct { - unsigned char byte[8]; + unsigned char byte[8]; } FT100_FLAG_INFO; @@ -161,8 +162,10 @@ static int ft100_set_parm(RIG *rig, setting_t parm, value_t val); static int ft100_get_parm(RIG *rig, setting_t parm, value_t *val); #endif -static int ft100_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); -static int ft100_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); +static int ft100_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int ft100_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); static int ft100_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift); static int ft100_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *shift); @@ -525,7 +528,7 @@ static int ft100_send_priv_cmd(RIG *rig, unsigned char cmd_index) if (!rig) { return -RIG_EINVAL; } return write_block(&rig->state.rigport, (char *) &ncmd[cmd_index].nseq, - YAESU_CMD_LENGTH); + YAESU_CMD_LENGTH); } static int ft100_read_status(RIG *rig) @@ -920,18 +923,24 @@ int ft100_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { case RIG_PTT_ON: cmd_index = FT100_NATIVE_CAT_PTT_ON; - if (split) rig_set_vfo(rig,RIG_VFO_B); + + if (split) { rig_set_vfo(rig, RIG_VFO_B); } + break; case RIG_PTT_OFF: cmd_index = FT100_NATIVE_CAT_PTT_OFF; - if (split) rig_set_vfo(rig,RIG_VFO_A); - hl_usleep(100*1000); // give ptt some time to do it's thing -- fake it was not reseting freq after tx + + if (split) { rig_set_vfo(rig, RIG_VFO_A); } + + hl_usleep(100 * + 1000); // give ptt some time to do it's thing -- fake it was not reseting freq after tx break; default: return -RIG_EINVAL; } + return ft100_send_priv_cmd(rig, cmd_index); } @@ -974,9 +983,11 @@ int ft100_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) rig_debug(RIG_DEBUG_VERBOSE, "%s: %s\n", __func__, rig_strlevel(level)); // if in split have to switch to VFOB to read power and back to VFOA - if (split && ptt) rig_set_vfo(rig, RIG_VFO_B); + if (split && ptt) { rig_set_vfo(rig, RIG_VFO_B); } + ret = ft100_send_priv_cmd(rig, FT100_NATIVE_CAT_READ_METERS); - if (split && ptt) rig_set_vfo(rig, RIG_VFO_A); + + if (split && ptt) { rig_set_vfo(rig, RIG_VFO_A); } if (ret != RIG_OK) { diff --git a/rigs/yaesu/ft1000d.c b/rigs/yaesu/ft1000d.c index 04b75b798..62b5106fb 100644 --- a/rigs/yaesu/ft1000d.c +++ b/rigs/yaesu/ft1000d.c @@ -44,73 +44,74 @@ #include "ft1000d.h" // FT1000D native commands -enum FT1000D_native_cmd_e { - FT1000D_NATIVE_SPLIT_OFF = 0, - FT1000D_NATIVE_SPLIT_ON, - FT1000D_NATIVE_RECALL_MEM, - FT1000D_NATIVE_VFO_TO_MEM, - FT1000D_NATIVE_LOCK_OFF, - FT1000D_NATIVE_LOCK_ON, - FT1000D_NATIVE_VFO_A, - FT1000D_NATIVE_VFO_B, - FT1000D_NATIVE_MEM_TO_VFO, - FT1000D_NATIVE_VFO_STEP_UP, - FT1000D_NATIVE_VFO_STEP_UP_FAST, - FT1000D_NATIVE_VFO_STEP_DOWN, - FT1000D_NATIVE_VFO_STEP_DOWN_FAST, - FT1000D_NATIVE_RX_CLARIFIER_OFF, - FT1000D_NATIVE_RX_CLARIFIER_ON, - FT1000D_NATIVE_TX_CLARIFIER_OFF, - FT1000D_NATIVE_TX_CLARIFIER_ON, - FT1000D_NATIVE_CLEAR_CLARIFIER_OFFSET, - FT1000D_NATIVE_CLARIFIER_OPS, - FT1000D_NATIVE_FREQ_SET, - FT1000D_NATIVE_MODE_SET_LSB, - FT1000D_NATIVE_MODE_SET_USB, - FT1000D_NATIVE_MODE_SET_CW_W, - FT1000D_NATIVE_MODE_SET_CW_N, - FT1000D_NATIVE_MODE_SET_AM_W, - FT1000D_NATIVE_MODE_SET_AM_N, - FT1000D_NATIVE_MODE_SET_FM, - FT1000D_NATIVE_MODE_SET_RTTY_LSB, - FT1000D_NATIVE_MODE_SET_RTTY_USB, - FT1000D_NATIVE_MODE_SET_PKT_LSB, - FT1000D_NATIVE_MODE_SET_PKT_FM, - FT1000D_NATIVE_MODE_SUB_VFOB_SET_LSB, /* Added December 2016 */ - FT1000D_NATIVE_MODE_SUB_VFOB_SET_USB, /* Added December 2016 */ - FT1000D_NATIVE_MODE_SUB_VFOB_SET_CW_W, /* Added December 2016 */ - FT1000D_NATIVE_MODE_SUB_VFOB_SET_CW_N, /* Added December 2016 */ - FT1000D_NATIVE_MODE_SUB_VFOB_SET_AM_W, /* Added December 2016 */ - FT1000D_NATIVE_MODE_SUB_VFOB_SET_AM_N, /* Added December 2016 */ - FT1000D_NATIVE_MODE_SUB_VFOB_SET_FM, /* Added December 2016 */ - FT1000D_NATIVE_MODE_SUB_VFOB_SET_RTTY_LSB, /* Added December 2016 */ - FT1000D_NATIVE_MODE_SUB_VFOB_SET_RTTY_USB, /* Added December 2016 */ - FT1000D_NATIVE_MODE_SUB_VFOB_SET_PKT_LSB, /* Added December 2016 */ - FT1000D_NATIVE_MODE_SUB_VFOB_SET_PKT_FM, /* Added December 2016 */ - FT1000D_NATIVE_PACING, - FT1000D_NATIVE_PTT_OFF, - FT1000D_NATIVE_PTT_ON, - FT1000D_NATIVE_UPDATE_ALL_DATA, - FT1000D_NATIVE_UPDATE_MEM_CHNL, - FT1000D_NATIVE_UPDATE_OP_DATA, - FT1000D_NATIVE_UPDATE_VFO_DATA, - FT1000D_NATIVE_UPDATE_MEM_CHNL_DATA, - FT1000D_NATIVE_TUNER_OFF, - FT1000D_NATIVE_TUNER_ON, - FT1000D_NATIVE_TUNER_START, - FT1000D_NATIVE_RPTR_SHIFT_NONE, - FT1000D_NATIVE_RPTR_SHIFT_MINUS, - FT1000D_NATIVE_RPTR_SHIFT_PLUS, - FT1000D_NATIVE_VFO_TO_VFO, - FT1000D_NATIVE_SET_SUB_VFO_FREQ, - FT1000D_NATIVE_BANDWIDTH, - FT1000D_NATIVE_OP_FREQ_STEP_UP, - FT1000D_NATIVE_OP_FREQ_STEP_DOWN, - FT1000D_NATIVE_READ_METER, - FT1000D_NATIVE_DIM_LEVEL, - FT1000D_NATIVE_RPTR_OFFSET, - FT1000D_NATIVE_READ_FLAGS, - FT1000D_NATIVE_SIZE +enum FT1000D_native_cmd_e +{ + FT1000D_NATIVE_SPLIT_OFF = 0, + FT1000D_NATIVE_SPLIT_ON, + FT1000D_NATIVE_RECALL_MEM, + FT1000D_NATIVE_VFO_TO_MEM, + FT1000D_NATIVE_LOCK_OFF, + FT1000D_NATIVE_LOCK_ON, + FT1000D_NATIVE_VFO_A, + FT1000D_NATIVE_VFO_B, + FT1000D_NATIVE_MEM_TO_VFO, + FT1000D_NATIVE_VFO_STEP_UP, + FT1000D_NATIVE_VFO_STEP_UP_FAST, + FT1000D_NATIVE_VFO_STEP_DOWN, + FT1000D_NATIVE_VFO_STEP_DOWN_FAST, + FT1000D_NATIVE_RX_CLARIFIER_OFF, + FT1000D_NATIVE_RX_CLARIFIER_ON, + FT1000D_NATIVE_TX_CLARIFIER_OFF, + FT1000D_NATIVE_TX_CLARIFIER_ON, + FT1000D_NATIVE_CLEAR_CLARIFIER_OFFSET, + FT1000D_NATIVE_CLARIFIER_OPS, + FT1000D_NATIVE_FREQ_SET, + FT1000D_NATIVE_MODE_SET_LSB, + FT1000D_NATIVE_MODE_SET_USB, + FT1000D_NATIVE_MODE_SET_CW_W, + FT1000D_NATIVE_MODE_SET_CW_N, + FT1000D_NATIVE_MODE_SET_AM_W, + FT1000D_NATIVE_MODE_SET_AM_N, + FT1000D_NATIVE_MODE_SET_FM, + FT1000D_NATIVE_MODE_SET_RTTY_LSB, + FT1000D_NATIVE_MODE_SET_RTTY_USB, + FT1000D_NATIVE_MODE_SET_PKT_LSB, + FT1000D_NATIVE_MODE_SET_PKT_FM, + FT1000D_NATIVE_MODE_SUB_VFOB_SET_LSB, /* Added December 2016 */ + FT1000D_NATIVE_MODE_SUB_VFOB_SET_USB, /* Added December 2016 */ + FT1000D_NATIVE_MODE_SUB_VFOB_SET_CW_W, /* Added December 2016 */ + FT1000D_NATIVE_MODE_SUB_VFOB_SET_CW_N, /* Added December 2016 */ + FT1000D_NATIVE_MODE_SUB_VFOB_SET_AM_W, /* Added December 2016 */ + FT1000D_NATIVE_MODE_SUB_VFOB_SET_AM_N, /* Added December 2016 */ + FT1000D_NATIVE_MODE_SUB_VFOB_SET_FM, /* Added December 2016 */ + FT1000D_NATIVE_MODE_SUB_VFOB_SET_RTTY_LSB, /* Added December 2016 */ + FT1000D_NATIVE_MODE_SUB_VFOB_SET_RTTY_USB, /* Added December 2016 */ + FT1000D_NATIVE_MODE_SUB_VFOB_SET_PKT_LSB, /* Added December 2016 */ + FT1000D_NATIVE_MODE_SUB_VFOB_SET_PKT_FM, /* Added December 2016 */ + FT1000D_NATIVE_PACING, + FT1000D_NATIVE_PTT_OFF, + FT1000D_NATIVE_PTT_ON, + FT1000D_NATIVE_UPDATE_ALL_DATA, + FT1000D_NATIVE_UPDATE_MEM_CHNL, + FT1000D_NATIVE_UPDATE_OP_DATA, + FT1000D_NATIVE_UPDATE_VFO_DATA, + FT1000D_NATIVE_UPDATE_MEM_CHNL_DATA, + FT1000D_NATIVE_TUNER_OFF, + FT1000D_NATIVE_TUNER_ON, + FT1000D_NATIVE_TUNER_START, + FT1000D_NATIVE_RPTR_SHIFT_NONE, + FT1000D_NATIVE_RPTR_SHIFT_MINUS, + FT1000D_NATIVE_RPTR_SHIFT_PLUS, + FT1000D_NATIVE_VFO_TO_VFO, + FT1000D_NATIVE_SET_SUB_VFO_FREQ, + FT1000D_NATIVE_BANDWIDTH, + FT1000D_NATIVE_OP_FREQ_STEP_UP, + FT1000D_NATIVE_OP_FREQ_STEP_DOWN, + FT1000D_NATIVE_READ_METER, + FT1000D_NATIVE_DIM_LEVEL, + FT1000D_NATIVE_RPTR_OFFSET, + FT1000D_NATIVE_READ_FLAGS, + FT1000D_NATIVE_SIZE }; static int ft1000d_init(RIG *rig); @@ -120,20 +121,28 @@ static int ft1000d_close(RIG *rig); static int ft1000d_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int ft1000d_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); static int ft1000d_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); -static int ft1000d_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int ft1000d_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); static int ft1000d_set_vfo(RIG *rig, vfo_t vfo); static int ft1000d_get_vfo(RIG *rig, vfo_t *vfo); static int ft1000d_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int ft1000d_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); static int ft1000d_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift); -static int ft1000d_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift); +static int ft1000d_get_rptr_shift(RIG *rig, vfo_t vfo, + rptr_shift_t *rptr_shift); static int ft1000d_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs); -static int ft1000d_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq); /* Added December 2016 */ -static int ft1000d_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq); /* Added December 2016 */ -static int ft1000d_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); -static int ft1000d_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); -static int ft1000d_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width); /* Added December 2016 */ -static int ft1000d_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_width); /* Added December 2016 */ +static int ft1000d_set_split_freq(RIG *rig, vfo_t vfo, + freq_t tx_freq); /* Added December 2016 */ +static int ft1000d_get_split_freq(RIG *rig, vfo_t vfo, + freq_t *tx_freq); /* Added December 2016 */ +static int ft1000d_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int ft1000d_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); +static int ft1000d_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, + pbwidth_t tx_width); /* Added December 2016 */ +static int ft1000d_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, + pbwidth_t *tx_width); /* Added December 2016 */ static int ft1000d_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int ft1000d_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit); static int ft1000d_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); @@ -141,12 +150,14 @@ static int ft1000d_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); static int ft1000d_set_parm(RIG *rig, setting_t parm, value_t val); static int ft1000d_set_xit(RIG *rig, vfo_t vfo, shortfreq_t xit); static int ft1000d_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit); -static int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value); +static int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level, + value_t *value); static int ft1000d_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); static int ft1000d_set_mem(RIG *rig, vfo_t vfo, int ch); static int ft1000d_get_mem(RIG *rig, vfo_t vfo, int *ch); -static int ft1000d_set_channel (RIG *rig, vfo_t vfo, const channel_t *chan); -static int ft1000d_get_channel (RIG *rig, vfo_t vfo, channel_t *chan, int read_only); +static int ft1000d_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan); +static int ft1000d_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, + int read_only); @@ -1121,7 +1132,8 @@ static int ft1000d_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs) * the correct TX VFO is selected by the rig in split mode. * An error is returned if vfo and tx_vfo are the same. */ -static int ft1000d_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) +static int ft1000d_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo) { struct ft1000d_priv_data *priv; unsigned char ci; @@ -1222,7 +1234,8 @@ static int ft1000d_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vf * Comments: The passed value for the vfo is ignored in order to * preserve the current split vfo system settings. */ -static int ft1000d_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) +static int ft1000d_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo) { struct ft1000d_priv_data *priv; int err; @@ -2076,7 +2089,8 @@ static int ft1000d_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) * In all other cases the passed vfo is selected if it differs * from the currently selected VFO. */ -static int ft1000d_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) +static int ft1000d_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width) { struct ft1000d_priv_data *priv; unsigned char *p; @@ -2435,7 +2449,8 @@ static int ft1000d_get_vfo(RIG *rig, vfo_t *vfo) * In all other cases the passed vfo is selected if it differs * from the currently selected VFO. */ -static int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) +static int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level, + value_t *value) { struct ft1000d_priv_data *priv; unsigned char mdata[YAESU_CMD_LENGTH]; @@ -2480,7 +2495,8 @@ static int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *valu return err; } - err = read_block(&rig->state.rigport, (char *) mdata, FT1000D_READ_METER_LENGTH); + err = read_block(&rig->state.rigport, (char *) mdata, + FT1000D_READ_METER_LENGTH); if (err < 0) { @@ -2798,7 +2814,8 @@ static int ft1000d_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan) * Status for split operation, active rig functions and tuning steps * are only relevant for currVFO */ -static int ft1000d_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) +static int ft1000d_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, + int read_only) { struct ft1000d_priv_data *priv; ft1000d_op_data_t *p; @@ -3279,7 +3296,8 @@ static int ft1000d_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_on * Returns: RIG_OK if all called functions are successful, * otherwise returns error from called functiion */ -static int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) +static int ft1000d_get_update_data(RIG *rig, unsigned char ci, + unsigned short ch) { struct rig_state *rig_s; struct ft1000d_priv_data *priv; @@ -3447,8 +3465,8 @@ static int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) * otherwise returns error from called functiion */ static int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, - unsigned char p1, unsigned char p2, - unsigned char p3, unsigned char p4) + unsigned char p1, unsigned char p2, + unsigned char p3, unsigned char p4) { struct ft1000d_priv_data *priv; int err; @@ -3768,7 +3786,7 @@ static int ft1000d_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) */ static int ft1000d_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, - pbwidth_t tx_width) + pbwidth_t tx_width) { int err; unsigned char bw; @@ -3901,7 +3919,7 @@ static int ft1000d_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, */ static int ft1000d_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, - pbwidth_t *tx_width) + pbwidth_t *tx_width) { struct ft1000d_priv_data *priv; int err; diff --git a/rigs/yaesu/ft1000mp.c b/rigs/yaesu/ft1000mp.c index c5330e5f5..0868c89d0 100644 --- a/rigs/yaesu/ft1000mp.c +++ b/rigs/yaesu/ft1000mp.c @@ -117,10 +117,13 @@ static int ft1000mp_open(RIG *rig); static int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int ft1000mp_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); static int ft1000mp_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq); -static int ft1000mp_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq, rmode_t mode, pbwidth_t width); +static int ft1000mp_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq, + rmode_t mode, pbwidth_t width); static int ft1000mp_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq); -static int ft1000mp_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); -static int ft1000mp_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); +static int ft1000mp_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int ft1000mp_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); static int ft1000mp_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); /* select mode */ static int ft1000mp_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, @@ -131,7 +134,8 @@ static int ft1000mp_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int ft1000mp_set_xit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int ft1000mp_set_rxit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int ft1000mp_get_rxit(RIG *rig, vfo_t vfo, shortfreq_t *rit); -static int ft1000mp_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); +static int ft1000mp_get_level(RIG *rig, vfo_t vfo, setting_t level, + value_t *val); static int ft1000mp_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int ft1000mp_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); static int ft1000mp_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status); @@ -423,7 +427,7 @@ const struct rig_caps ft1000mp_caps = .set_split_freq = ft1000mp_set_split_freq, .get_split_freq = ft1000mp_get_split_freq, - .set_split_freq_mode =ft1000mp_set_split_freq_mode, + .set_split_freq_mode = ft1000mp_set_split_freq_mode, .set_split_vfo = ft1000mp_set_split_vfo, .get_split_vfo = ft1000mp_get_split_vfo, @@ -558,7 +562,7 @@ const struct rig_caps ft1000mpmkv_caps = .set_split_freq = ft1000mp_set_split_freq, .get_split_freq = ft1000mp_get_split_freq, - .set_split_freq_mode =ft1000mp_set_split_freq_mode, + .set_split_freq_mode = ft1000mp_set_split_freq_mode, .set_split_vfo = ft1000mp_set_split_vfo, .get_split_vfo = ft1000mp_get_split_vfo, @@ -693,7 +697,7 @@ const struct rig_caps ft1000mpmkvfld_caps = .set_split_freq = ft1000mp_set_split_freq, .get_split_freq = ft1000mp_get_split_freq, - .set_split_freq_mode =ft1000mp_set_split_freq_mode, + .set_split_freq_mode = ft1000mp_set_split_freq_mode, .set_split_vfo = ft1000mp_set_split_vfo, .get_split_vfo = ft1000mp_get_split_vfo, @@ -815,7 +819,8 @@ static int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) p = (struct ft1000mp_priv_data *)rig->state.priv; - rig_debug(RIG_DEBUG_TRACE, "%s: requested freq on %s = %"PRIfreq" Hz \n", __func__, + rig_debug(RIG_DEBUG_TRACE, "%s: requested freq on %s = %"PRIfreq" Hz \n", + __func__, rig_strvfo(vfo), freq); if (vfo == RIG_VFO_CURR) @@ -1066,7 +1071,8 @@ static int ft1000mp_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) * */ -static int ft1000mp_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) +static int ft1000mp_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width) { struct ft1000mp_priv_data *priv; unsigned char mymode; /* ft1000mp mode */ @@ -1324,6 +1330,7 @@ static int ft1000mp_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) rig_debug(RIG_DEBUG_ERR, "%s: Unsupported set_func %s", __func__, rig_strfunc(func)); } + RETURNFUNC(-RIG_EINVAL); } @@ -1515,7 +1522,8 @@ static int ft1000mp_get_rxit(RIG *rig, vfo_t vfo, shortfreq_t *rit) } -static int ft1000mp_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) +static int ft1000mp_get_level(RIG *rig, vfo_t vfo, setting_t level, + value_t *val) { struct ft1000mp_priv_data *priv; struct rig_state *rs; @@ -1687,13 +1695,15 @@ static int ft1000mp_send_priv_cmd(RIG *rig, unsigned char ci) __func__); RETURNFUNC(-RIG_EINVAL); } + write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); RETURNFUNC(RIG_OK); } -static int ft1000mp_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) +static int ft1000mp_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo) { unsigned char cmd_index = 0; /* index of sequence to send */ @@ -1730,7 +1740,8 @@ static int ft1000mp_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_v * */ -static int ft1000mp_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) +static int ft1000mp_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo) { struct ft1000mp_priv_data *p; int retval; @@ -1772,7 +1783,8 @@ static int ft1000mp_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) RETURNFUNC(ft1000mp_set_freq(rig, RIG_VFO_B, tx_freq)); } -static int ft1000mp_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq, rmode_t mode, pbwidth_t width) +static int ft1000mp_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq, + rmode_t mode, pbwidth_t width) { // don't believe mode on VFOB can be different than mode on VFOA return ft1000mp_set_split_freq(rig, vfo, freq); diff --git a/rigs/yaesu/ft1200.c b/rigs/yaesu/ft1200.c index 06e43e361..d6b11cb32 100644 --- a/rigs/yaesu/ft1200.c +++ b/rigs/yaesu/ft1200.c @@ -152,7 +152,7 @@ const struct rig_caps ftdx1200_caps = RIG_MODEL(RIG_MODEL_FTDX1200), .model_name = "FTDX-1200", .mfg_name = "Yaesu", - .version = NEWCAT_VER ".2", + .version = NEWCAT_VER ".3", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -320,4 +320,6 @@ const struct rig_caps ftdx1200_caps = .set_ext_level = newcat_set_ext_level, .get_ext_level = newcat_get_ext_level, .send_morse = newcat_send_morse, + .set_clock = newcat_set_clock, + .get_clock = newcat_get_clock }; diff --git a/rigs/yaesu/ft600.c b/rigs/yaesu/ft600.c index 6cba615ae..b3e76716b 100644 --- a/rigs/yaesu/ft600.c +++ b/rigs/yaesu/ft600.c @@ -41,47 +41,48 @@ #include "misc.h" #include "bandplan.h" -enum ft600_native_cmd_e { +enum ft600_native_cmd_e +{ - FT600_NATIVE_CAT_LOCK_ON = 0, - FT600_NATIVE_CAT_LOCK_OFF, - FT600_NATIVE_CAT_PTT_ON, - FT600_NATIVE_CAT_PTT_OFF, - FT600_NATIVE_CAT_SET_FREQ, - FT600_NATIVE_CAT_SET_MODE_LSB, - FT600_NATIVE_CAT_SET_MODE_USB, - FT600_NATIVE_CAT_SET_MODE_DIG, - FT600_NATIVE_CAT_SET_MODE_CW, - FT600_NATIVE_CAT_SET_MODE_AM, - FT600_NATIVE_CAT_CLAR_ON, - FT600_NATIVE_CAT_CLAR_OFF, - FT600_NATIVE_CAT_SET_CLAR_FREQ, - FT600_NATIVE_CAT_SET_VFOAB, - FT600_NATIVE_CAT_SET_VFOA, - FT600_NATIVE_CAT_SET_VFOB, - FT600_NATIVE_CAT_SPLIT_ON, - FT600_NATIVE_CAT_SPLIT_OFF, - FT600_NATIVE_CAT_SET_RPT_SHIFT_MINUS, - FT600_NATIVE_CAT_SET_RPT_SHIFT_PLUS, - FT600_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, - FT600_NATIVE_CAT_SET_RPT_OFFSET, -/* fix me */ - FT600_NATIVE_CAT_SET_DCS_ON, - FT600_NATIVE_CAT_SET_CTCSS_ENC_ON, - FT600_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON, - FT600_NATIVE_CAT_SET_CTCSS_DCS_OFF, -/* em xif */ - FT600_NATIVE_CAT_SET_CTCSS_FREQ, - FT600_NATIVE_CAT_SET_DCS_CODE, - FT600_NATIVE_CAT_GET_RX_STATUS, - FT600_NATIVE_CAT_GET_TX_STATUS, - FT600_NATIVE_CAT_GET_FREQ_MODE_STATUS, - FT600_NATIVE_CAT_PWR_WAKE, - FT600_NATIVE_CAT_PWR_ON, - FT600_NATIVE_CAT_PWR_OFF, - FT600_NATIVE_CAT_READ_STATUS, - FT600_NATIVE_CAT_READ_METERS, - FT600_NATIVE_CAT_READ_FLAGS + FT600_NATIVE_CAT_LOCK_ON = 0, + FT600_NATIVE_CAT_LOCK_OFF, + FT600_NATIVE_CAT_PTT_ON, + FT600_NATIVE_CAT_PTT_OFF, + FT600_NATIVE_CAT_SET_FREQ, + FT600_NATIVE_CAT_SET_MODE_LSB, + FT600_NATIVE_CAT_SET_MODE_USB, + FT600_NATIVE_CAT_SET_MODE_DIG, + FT600_NATIVE_CAT_SET_MODE_CW, + FT600_NATIVE_CAT_SET_MODE_AM, + FT600_NATIVE_CAT_CLAR_ON, + FT600_NATIVE_CAT_CLAR_OFF, + FT600_NATIVE_CAT_SET_CLAR_FREQ, + FT600_NATIVE_CAT_SET_VFOAB, + FT600_NATIVE_CAT_SET_VFOA, + FT600_NATIVE_CAT_SET_VFOB, + FT600_NATIVE_CAT_SPLIT_ON, + FT600_NATIVE_CAT_SPLIT_OFF, + FT600_NATIVE_CAT_SET_RPT_SHIFT_MINUS, + FT600_NATIVE_CAT_SET_RPT_SHIFT_PLUS, + FT600_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, + FT600_NATIVE_CAT_SET_RPT_OFFSET, + /* fix me */ + FT600_NATIVE_CAT_SET_DCS_ON, + FT600_NATIVE_CAT_SET_CTCSS_ENC_ON, + FT600_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON, + FT600_NATIVE_CAT_SET_CTCSS_DCS_OFF, + /* em xif */ + FT600_NATIVE_CAT_SET_CTCSS_FREQ, + FT600_NATIVE_CAT_SET_DCS_CODE, + FT600_NATIVE_CAT_GET_RX_STATUS, + FT600_NATIVE_CAT_GET_TX_STATUS, + FT600_NATIVE_CAT_GET_FREQ_MODE_STATUS, + FT600_NATIVE_CAT_PWR_WAKE, + FT600_NATIVE_CAT_PWR_ON, + FT600_NATIVE_CAT_PWR_OFF, + FT600_NATIVE_CAT_READ_STATUS, + FT600_NATIVE_CAT_READ_METERS, + FT600_NATIVE_CAT_READ_FLAGS }; @@ -92,28 +93,28 @@ enum ft600_native_cmd_e { */ typedef struct { - unsigned char band_no; - unsigned char freq[16]; - unsigned char mode; - unsigned char ctcss; - unsigned char dcs; - unsigned char flag1; - unsigned char flag2; - unsigned char clarifier[2]; - unsigned char not_used; - unsigned char step1; - unsigned char step2; - unsigned char filter; + unsigned char band_no; + unsigned char freq[16]; + unsigned char mode; + unsigned char ctcss; + unsigned char dcs; + unsigned char flag1; + unsigned char flag2; + unsigned char clarifier[2]; + unsigned char not_used; + unsigned char step1; + unsigned char step2; + unsigned char filter; // cppcheck-suppress * - unsigned char stuffing[16]; + unsigned char stuffing[16]; } - FT600_STATUS_INFO; +FT600_STATUS_INFO; typedef struct { - unsigned char byte[8]; + unsigned char byte[8]; } // cppcheck-suppress * FT600_FLAG_INFO; @@ -396,7 +397,8 @@ static int ft600_send_priv_cmd(RIG *rig, unsigned char cmd_index) if (!rig) { return -RIG_EINVAL; } - return write_block(&rig->state.rigport, (char *) &ncmd[cmd_index].nseq, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) &ncmd[cmd_index].nseq, + YAESU_CMD_LENGTH); } static int ft600_read_status(RIG *rig) diff --git a/rigs/yaesu/ft747.c b/rigs/yaesu/ft747.c index 2ecd94d0a..5c7e017ae 100644 --- a/rigs/yaesu/ft747.c +++ b/rigs/yaesu/ft747.c @@ -52,35 +52,36 @@ * */ -enum ft747_native_cmd_e { - FT_747_NATIVE_SPLIT_OFF = 0, - FT_747_NATIVE_SPLIT_ON, - FT_747_NATIVE_RECALL_MEM, - FT_747_NATIVE_VFO_TO_MEM, - FT_747_NATIVE_DLOCK_OFF, - FT_747_NATIVE_DLOCK_ON, - FT_747_NATIVE_VFO_A, - FT_747_NATIVE_VFO_B, - FT_747_NATIVE_M_TO_VFO, - FT_747_NATIVE_UP_500K, - FT_747_NATIVE_DOWN_500K, - FT_747_NATIVE_CLARIFY_OFF, - FT_747_NATIVE_CLARIFY_ON, - FT_747_NATIVE_FREQ_SET, - FT_747_NATIVE_MODE_SET_LSB, - FT_747_NATIVE_MODE_SET_USB, - FT_747_NATIVE_MODE_SET_CWW, - FT_747_NATIVE_MODE_SET_CWN, - FT_747_NATIVE_MODE_SET_AMW, - FT_747_NATIVE_MODE_SET_AMN, - FT_747_NATIVE_MODE_SET_FMW, - FT_747_NATIVE_MODE_SET_FMN, - FT_747_NATIVE_PACING, - FT_747_NATIVE_PTT_OFF, - FT_747_NATIVE_PTT_ON, - FT_747_NATIVE_UPDATE, - FT_747_NATIVE_SIZE /* end marker, value indicates number of */ - /* native cmd entries */ +enum ft747_native_cmd_e +{ + FT_747_NATIVE_SPLIT_OFF = 0, + FT_747_NATIVE_SPLIT_ON, + FT_747_NATIVE_RECALL_MEM, + FT_747_NATIVE_VFO_TO_MEM, + FT_747_NATIVE_DLOCK_OFF, + FT_747_NATIVE_DLOCK_ON, + FT_747_NATIVE_VFO_A, + FT_747_NATIVE_VFO_B, + FT_747_NATIVE_M_TO_VFO, + FT_747_NATIVE_UP_500K, + FT_747_NATIVE_DOWN_500K, + FT_747_NATIVE_CLARIFY_OFF, + FT_747_NATIVE_CLARIFY_ON, + FT_747_NATIVE_FREQ_SET, + FT_747_NATIVE_MODE_SET_LSB, + FT_747_NATIVE_MODE_SET_USB, + FT_747_NATIVE_MODE_SET_CWW, + FT_747_NATIVE_MODE_SET_CWN, + FT_747_NATIVE_MODE_SET_AMW, + FT_747_NATIVE_MODE_SET_AMN, + FT_747_NATIVE_MODE_SET_FMW, + FT_747_NATIVE_MODE_SET_FMN, + FT_747_NATIVE_PACING, + FT_747_NATIVE_PTT_OFF, + FT_747_NATIVE_PTT_ON, + FT_747_NATIVE_UPDATE, + FT_747_NATIVE_SIZE /* end marker, value indicates number of */ + /* native cmd entries */ }; @@ -169,8 +170,10 @@ static int ft747_close(RIG *rig); static int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int ft747_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); -static int ft747_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); /* select mode */ -static int ft747_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); /* get mode */ +static int ft747_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, + pbwidth_t width); /* select mode */ +static int ft747_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); /* get mode */ static int ft747_set_vfo(RIG *rig, vfo_t vfo); /* select vfo */ static int ft747_get_vfo(RIG *rig, vfo_t *vfo); /* get vfo */ @@ -1049,7 +1052,8 @@ static int ft747_send_priv_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - return write_block(&rig->state.rigport, (char *) ft747_ncmd[ci].nseq, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) ft747_ncmd[ci].nseq, + YAESU_CMD_LENGTH); } diff --git a/rigs/yaesu/ft757gx.c b/rigs/yaesu/ft757gx.c index caaec1400..81efbcd96 100644 --- a/rigs/yaesu/ft757gx.c +++ b/rigs/yaesu/ft757gx.c @@ -63,8 +63,10 @@ static int ft757_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int ft757_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); static int ft757gx_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); -static int ft757_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); /* select mode */ -static int ft757_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); /* get mode */ +static int ft757_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, + pbwidth_t width); /* select mode */ +static int ft757_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); /* get mode */ static int ft757_set_vfo(RIG *rig, vfo_t vfo); /* select vfo */ static int ft757_get_vfo(RIG *rig, vfo_t *vfo); /* get vfo */ diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index fbf75c5f7..8b4e43f97 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -169,9 +169,9 @@ static int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power, static int ft817_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq, rmode_t mode); static int ft817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, - ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx); + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx); static int ft818_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, - ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx); + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx); /* Native ft817 cmd set prototypes. These are READ ONLY as each */ /* rig instance will copy from these and modify if required . */ @@ -320,8 +320,8 @@ const struct rig_caps ft817_caps = .has_get_func = RIG_FUNC_NONE, .has_set_func = RIG_FUNC_LOCK | RIG_FUNC_TONE | RIG_FUNC_TSQL, .has_get_level = - RIG_LEVEL_STRENGTH | RIG_LEVEL_RAWSTR | RIG_LEVEL_RFPOWER | - RIG_LEVEL_ALC | RIG_LEVEL_SWR, + RIG_LEVEL_STRENGTH | RIG_LEVEL_RAWSTR | RIG_LEVEL_RFPOWER | + RIG_LEVEL_ALC | RIG_LEVEL_SWR, .has_set_level = RIG_LEVEL_NONE, .has_get_parm = RIG_PARM_NONE, .has_set_parm = RIG_PARM_NONE, @@ -466,8 +466,8 @@ const struct rig_caps ft818_caps = .has_get_func = RIG_FUNC_NONE, .has_set_func = RIG_FUNC_LOCK | RIG_FUNC_TONE | RIG_FUNC_TSQL, .has_get_level = - RIG_LEVEL_STRENGTH | RIG_LEVEL_RAWSTR | RIG_LEVEL_RFPOWER | - RIG_LEVEL_ALC | RIG_LEVEL_SWR, + RIG_LEVEL_STRENGTH | RIG_LEVEL_RAWSTR | RIG_LEVEL_RFPOWER | + RIG_LEVEL_ALC | RIG_LEVEL_SWR, .has_set_level = RIG_LEVEL_NONE, .has_get_parm = RIG_PARM_NONE, .has_set_parm = RIG_PARM_NONE, @@ -729,7 +729,7 @@ static int ft817_get_status(RIG *rig, int status) case FT817_NATIVE_CAT_GET_TX_METERING: data = result; - len = sizeof(result)/sizeof(result[0]); /* We expect two bytes */ + len = sizeof(result) / sizeof(result[0]); /* We expect two bytes */ tv = &p->tx_level_tv; break; @@ -762,50 +762,51 @@ static int ft817_get_status(RIG *rig, int status) if (n != len) { rig_debug(RIG_DEBUG_VERBOSE, "%s: Length mismatch exp %d got %d!\n", - __func__, len, n); + __func__, len, n); return -RIG_EIO; } - switch(status) + switch (status) { case FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS: + { + /* Only in digimode we need fetch to extra bits from EEPROM. + * This save communication cycle for all other modes. + * Because mode and frequency are shared this saves also when + * getting the frequency. */ + switch (p->fm_status[4] & 0x7f) { - /* Only in digimode we need fetch to extra bits from EEPROM. - * This save communication cycle for all other modes. - * Because mode and frequency are shared this saves also when - * getting the frequency. */ - switch (p->fm_status[4] & 0x7f) + unsigned char dig_mode; + + case 0x0a: + if ((n = ft817_read_eeprom(rig, 0x0065, &dig_mode)) < 0) { - unsigned char dig_mode; - case 0x0a: - if ((n = ft817_read_eeprom(rig, 0x0065, &dig_mode)) < 0) - { - return n; - } - - /* Top 3 bit define the digi mode */ - p->dig_mode = dig_mode >> 5; - - default: - break; + return n; } + + /* Top 3 bit define the digi mode */ + p->dig_mode = dig_mode >> 5; + + default: + break; } - break; + } + break; case FT817_NATIVE_CAT_GET_TX_METERING: - /* FT-817 returns 2 bytes with 4 nibbles. - * Extract raw values here; - * convert to float when they are requested. */ - p->swr_level = result[0] & 0xF; - p->pwr_level = result[0] >> 4; - p->alc_level = result[1] & 0xF; - p->mod_level = result[1] >> 4; - rig_debug(RIG_DEBUG_TRACE, "%s: swr: %d, pwr %d, alc %d, mod %d\n", - __func__, - p->swr_level, - p->pwr_level, - p->alc_level, - p->mod_level); + /* FT-817 returns 2 bytes with 4 nibbles. + * Extract raw values here; + * convert to float when they are requested. */ + p->swr_level = result[0] & 0xF; + p->pwr_level = result[0] >> 4; + p->alc_level = result[1] & 0xF; + p->mod_level = result[1] >> 4; + rig_debug(RIG_DEBUG_TRACE, "%s: swr: %d, pwr %d, alc %d, mod %d\n", + __func__, + p->swr_level, + p->pwr_level, + p->alc_level, + p->mod_level); break; } @@ -837,7 +838,7 @@ static int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) f1 = f2; f2 = from_bcd_be(p->fm_status, 8); - dump_hex(p->fm_status, sizeof(p->fm_status)/sizeof(p->fm_status[0])); + dump_hex(p->fm_status, sizeof(p->fm_status) / sizeof(p->fm_status[0])); } #if 1 // user must be twiddling the VFO @@ -945,7 +946,8 @@ static int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return RIG_OK; } -static int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) +static int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; ptt_t ptt; @@ -954,6 +956,7 @@ static int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vf rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); n = ft817_get_ptt(rig, 0, &ptt); + if (n != RIG_OK) { return n; @@ -967,6 +970,7 @@ static int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vf /* Get split status from EEPROM */ n = ft817_read_eeprom(rig, 0x7a, &c); + if (n != RIG_OK) { return n; @@ -1003,7 +1007,8 @@ static int ft817_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) return RIG_OK; } -static int ft817_get_tx_level(RIG *rig, value_t *val, unsigned char *tx_level, const cal_table_float_t *cal) +static int ft817_get_tx_level(RIG *rig, value_t *val, unsigned char *tx_level, + const cal_table_float_t *cal) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; @@ -1023,6 +1028,7 @@ static int ft817_get_tx_level(RIG *rig, value_t *val, unsigned char *tx_level, c * perhaps pointless retries + timeouts. */ n = ft817_get_ptt(rig, 0, &ptt); + if (n != RIG_OK) { return n; @@ -1035,6 +1041,7 @@ static int ft817_get_tx_level(RIG *rig, value_t *val, unsigned char *tx_level, c } n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_METERING); + if (n != RIG_OK) { return n; @@ -1114,6 +1121,7 @@ static int ft817_get_raw_smeter_level(RIG *rig, value_t *val) static int ft817_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; + switch (level) { @@ -1125,7 +1133,8 @@ static int ft817_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return ft817_get_raw_smeter_level(rig, val); case RIG_LEVEL_RFPOWER: - return ft817_get_tx_level(rig, val, &p->pwr_level, &rig->caps->rfpower_meter_cal); + return ft817_get_tx_level(rig, val, &p->pwr_level, + &rig->caps->rfpower_meter_cal); case RIG_LEVEL_ALC: return ft817_get_tx_level(rig, val, &p->alc_level, &rig->caps->alc_cal); @@ -1179,6 +1188,7 @@ static int ft818_817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, /* Read eeprom for current 'band' for both VFO's */ ret = ft817_read_eeprom(rig, 0x59, &eeprom_band); + if (ret != RIG_OK) { return ret; @@ -1188,6 +1198,7 @@ static int ft818_817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, * The FT818/817 stores antenna per band not per VFO! * So changing antenna will change for both VFO's */ ret = ft817_read_eeprom(rig, 0x7A, &eeprom_ant); + if (ret != RIG_OK) { return ret; @@ -1200,18 +1211,20 @@ static int ft818_817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, } /* band info is 4 bit per VFO, for A lower nibble, B is upper nible */ - switch (vfo) { - case RIG_VFO_A: - eeprom_band &= 0xF; - break; - case RIG_VFO_B: - eeprom_band = eeprom_band >> 4; + switch (vfo) + { + case RIG_VFO_A: + eeprom_band &= 0xF; break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %0x!\n", - __func__, vfo); - return -RIG_EINTERNAL; + case RIG_VFO_B: + eeprom_band = eeprom_band >> 4; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %0x!\n", + __func__, vfo); + return -RIG_EINTERNAL; } /* The 818 and the 817 differ in bands: the 818 has 60m. @@ -1233,43 +1246,44 @@ static int ft818_817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, */ - switch (eeprom_band) { - case 0: /* 160M */ - case 1: /* 80M */ - case 2: /* 60M, 818 only */ - case 3: /* 40M */ - case 4: /* 30M */ - case 5: /* 20M */ - case 6: /* 17M */ - case 7: /* 15M */ - case 8: /* 12M */ - case 9: /* 10M */ - /* All HF use the same antenna setting, bit 0 */ - eeprom_ant &= 1<<0; + switch (eeprom_band) + { + case 0: /* 160M */ + case 1: /* 80M */ + case 2: /* 60M, 818 only */ + case 3: /* 40M */ + case 4: /* 30M */ + case 5: /* 20M */ + case 6: /* 17M */ + case 7: /* 15M */ + case 8: /* 12M */ + case 9: /* 10M */ + /* All HF use the same antenna setting, bit 0 */ + eeprom_ant &= 1 << 0; break; - case 0xA: /* 6m, bit 1 */ - eeprom_ant &= 1<<1; + case 0xA: /* 6m, bit 1 */ + eeprom_ant &= 1 << 1; break; - case 0xB: /* FM BCB 76Mhz - 108Mhz, bit 2 */ - eeprom_ant &= 1<<2; + case 0xB: /* FM BCB 76Mhz - 108Mhz, bit 2 */ + eeprom_ant &= 1 << 2; break; - case 0xC: /* Airband, bit 3 */ - eeprom_ant &= 1<<3; + case 0xC: /* Airband, bit 3 */ + eeprom_ant &= 1 << 3; break; - case 0xD: /* 2M, bit 4 */ - eeprom_ant &= 1<<4; + case 0xD: /* 2M, bit 4 */ + eeprom_ant &= 1 << 4; break; - case 0xE: /* 70cm / UHF, bit 5 */ - eeprom_ant &= 1<<5; + case 0xE: /* 70cm / UHF, bit 5 */ + eeprom_ant &= 1 << 5; break; - case 0xF: /* Free-tuning?, bit 6 */ - eeprom_ant &= 1<<6; + case 0xF: /* Free-tuning?, bit 6 */ + eeprom_ant &= 1 << 6; break; } @@ -1281,18 +1295,18 @@ static int ft818_817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, } static int ft817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, - ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { return ft818_817_get_ant(rig, vfo, ant, option, ant_curr, ant_tx, ant_rx, - true); + true); } static int ft818_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, - ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) + ant_t *ant_curr, ant_t *ant_tx, ant_t *ant_rx) { return ft818_817_get_ant(rig, vfo, ant, option, ant_curr, ant_tx, ant_rx, - false); + false); } /* ---------------------------------------------------------------------- */ @@ -1517,6 +1531,7 @@ static int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { int n; n = ft817_send_cmd(rig, index); + if (n < 0 && n != -RIG_ERJCTED) { rig_debug(RIG_DEBUG_ERR, "%s: send ptt cmd failed\n", __func__); @@ -1526,6 +1541,7 @@ static int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) /* Read TX status it contains the PTT flag. * Use TX_STATUS instead of ft817_get_ptt to skip the cache. */ n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_STATUS); + if (n < 0 && n != -RIG_ERJCTED) { rig_debug(RIG_DEBUG_ERR, "%s: get ptt cmd failed\n", __func__); @@ -1535,6 +1551,7 @@ static int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) /* Should be in cache now! But if above command was rejected * we will still try again here. */ n = ft817_get_ptt(rig, vfo, &ptt_response); + if (n < 0 && n != -RIG_ERJCTED) { rig_debug(RIG_DEBUG_ERR, "%s: get ptt cmd failed\n", __func__); @@ -1863,7 +1880,7 @@ static int ft817_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) 1 bar = 0.5W */ static int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power, - freq_t freq, rmode_t mode) + freq_t freq, rmode_t mode) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); *mwpower = (int)(power * 6000); @@ -1873,7 +1890,7 @@ static int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power, /* FIXME: currently ignores mode and freq */ static int ft817_mW2power(RIG *rig, float *power, unsigned int mwpower, - freq_t freq, rmode_t mode) + freq_t freq, rmode_t mode) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); *power = mwpower / 6000.0; diff --git a/rigs/yaesu/ft840.c b/rigs/yaesu/ft840.c index 04435a277..6e37955be 100644 --- a/rigs/yaesu/ft840.c +++ b/rigs/yaesu/ft840.c @@ -45,31 +45,32 @@ * */ -enum ft840_native_cmd_e { - FT840_NATIVE_SPLIT_OFF = 0, - FT840_NATIVE_SPLIT_ON, - FT840_NATIVE_RECALL_MEM, - FT840_NATIVE_VFO_TO_MEM, - FT840_NATIVE_VFO_A, - FT840_NATIVE_VFO_B, - FT840_NATIVE_MEM_TO_VFO, - FT840_NATIVE_CLARIFIER_OPS, - FT840_NATIVE_FREQ_SET, - FT840_NATIVE_MODE_SET, - FT840_NATIVE_PACING, - FT840_NATIVE_PTT_OFF, - FT840_NATIVE_PTT_ON, - FT840_NATIVE_MEM_CHNL, - FT840_NATIVE_OP_DATA, - FT840_NATIVE_VFO_DATA, - FT840_NATIVE_MEM_CHNL_DATA, - FT840_NATIVE_TUNER_OFF, - FT840_NATIVE_TUNER_ON, - FT840_NATIVE_TUNER_START, - FT840_NATIVE_READ_METER, - FT840_NATIVE_READ_FLAGS, - FT840_NATIVE_SIZE /* end marker, value indicates number of */ - /* native cmd entries */ +enum ft840_native_cmd_e +{ + FT840_NATIVE_SPLIT_OFF = 0, + FT840_NATIVE_SPLIT_ON, + FT840_NATIVE_RECALL_MEM, + FT840_NATIVE_VFO_TO_MEM, + FT840_NATIVE_VFO_A, + FT840_NATIVE_VFO_B, + FT840_NATIVE_MEM_TO_VFO, + FT840_NATIVE_CLARIFIER_OPS, + FT840_NATIVE_FREQ_SET, + FT840_NATIVE_MODE_SET, + FT840_NATIVE_PACING, + FT840_NATIVE_PTT_OFF, + FT840_NATIVE_PTT_ON, + FT840_NATIVE_MEM_CHNL, + FT840_NATIVE_OP_DATA, + FT840_NATIVE_VFO_DATA, + FT840_NATIVE_MEM_CHNL_DATA, + FT840_NATIVE_TUNER_OFF, + FT840_NATIVE_TUNER_ON, + FT840_NATIVE_TUNER_START, + FT840_NATIVE_READ_METER, + FT840_NATIVE_READ_FLAGS, + FT840_NATIVE_SIZE /* end marker, value indicates number of */ + /* native cmd entries */ }; /* diff --git a/rigs/yaesu/ft847.c b/rigs/yaesu/ft847.c index 84aca3961..c682f0da5 100644 --- a/rigs/yaesu/ft847.c +++ b/rigs/yaesu/ft847.c @@ -65,96 +65,97 @@ * */ -enum ft847_native_cmd_e { +enum ft847_native_cmd_e +{ - /* Set commands to the rig */ + /* Set commands to the rig */ - FT_847_NATIVE_CAT_ON = 0, - FT_847_NATIVE_CAT_OFF, + FT_847_NATIVE_CAT_ON = 0, + FT_847_NATIVE_CAT_OFF, - FT_847_NATIVE_CAT_PTT_ON, - FT_847_NATIVE_CAT_PTT_OFF, + FT_847_NATIVE_CAT_PTT_ON, + FT_847_NATIVE_CAT_PTT_OFF, - FT_847_NATIVE_CAT_SAT_MODE_ON, - FT_847_NATIVE_CAT_SAT_MODE_OFF, + FT_847_NATIVE_CAT_SAT_MODE_ON, + FT_847_NATIVE_CAT_SAT_MODE_OFF, - FT_847_NATIVE_CAT_SET_FREQ_MAIN, - FT_847_NATIVE_CAT_SET_FREQ_SAT_RX_VFO, - FT_847_NATIVE_CAT_SET_FREQ_SAT_TX_VFO, + FT_847_NATIVE_CAT_SET_FREQ_MAIN, + FT_847_NATIVE_CAT_SET_FREQ_SAT_RX_VFO, + FT_847_NATIVE_CAT_SET_FREQ_SAT_TX_VFO, - FT_847_NATIVE_CAT_SET_MODE_MAIN_LSB, /* MAIN VFO */ - FT_847_NATIVE_CAT_SET_MODE_MAIN_USB, - FT_847_NATIVE_CAT_SET_MODE_MAIN_CW, - FT_847_NATIVE_CAT_SET_MODE_MAIN_CWR, - FT_847_NATIVE_CAT_SET_MODE_MAIN_AM, - FT_847_NATIVE_CAT_SET_MODE_MAIN_FM, - FT_847_NATIVE_CAT_SET_MODE_MAIN_CWN, - FT_847_NATIVE_CAT_SET_MODE_MAIN_CWRN, - FT_847_NATIVE_CAT_SET_MODE_MAIN_AMN, - FT_847_NATIVE_CAT_SET_MODE_MAIN_FMN, + FT_847_NATIVE_CAT_SET_MODE_MAIN_LSB, /* MAIN VFO */ + FT_847_NATIVE_CAT_SET_MODE_MAIN_USB, + FT_847_NATIVE_CAT_SET_MODE_MAIN_CW, + FT_847_NATIVE_CAT_SET_MODE_MAIN_CWR, + FT_847_NATIVE_CAT_SET_MODE_MAIN_AM, + FT_847_NATIVE_CAT_SET_MODE_MAIN_FM, + FT_847_NATIVE_CAT_SET_MODE_MAIN_CWN, + FT_847_NATIVE_CAT_SET_MODE_MAIN_CWRN, + FT_847_NATIVE_CAT_SET_MODE_MAIN_AMN, + FT_847_NATIVE_CAT_SET_MODE_MAIN_FMN, - FT_847_NATIVE_CAT_SET_MODE_SAT_RX_LSB, /* SAT RX VFO */ - FT_847_NATIVE_CAT_SET_MODE_SAT_RX_USB, - FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CW, - FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CWR, - FT_847_NATIVE_CAT_SET_MODE_SAT_RX_AM, - FT_847_NATIVE_CAT_SET_MODE_SAT_RX_FM, - FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CWN, - FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CWRN, - FT_847_NATIVE_CAT_SET_MODE_SAT_RX_AMN, - FT_847_NATIVE_CAT_SET_MODE_SAT_RX_FMN, + FT_847_NATIVE_CAT_SET_MODE_SAT_RX_LSB, /* SAT RX VFO */ + FT_847_NATIVE_CAT_SET_MODE_SAT_RX_USB, + FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CW, + FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CWR, + FT_847_NATIVE_CAT_SET_MODE_SAT_RX_AM, + FT_847_NATIVE_CAT_SET_MODE_SAT_RX_FM, + FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CWN, + FT_847_NATIVE_CAT_SET_MODE_SAT_RX_CWRN, + FT_847_NATIVE_CAT_SET_MODE_SAT_RX_AMN, + FT_847_NATIVE_CAT_SET_MODE_SAT_RX_FMN, - FT_847_NATIVE_CAT_SET_MODE_SAT_TX_LSB, /* SAT TX VFO */ - FT_847_NATIVE_CAT_SET_MODE_SAT_TX_USB, - FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CW, - FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CWR, - FT_847_NATIVE_CAT_SET_MODE_SAT_TX_AM, - FT_847_NATIVE_CAT_SET_MODE_SAT_TX_FM, - FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CWN, - FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CWRN, - FT_847_NATIVE_CAT_SET_MODE_SAT_TX_AMN, - FT_847_NATIVE_CAT_SET_MODE_SAT_TX_FMN, + FT_847_NATIVE_CAT_SET_MODE_SAT_TX_LSB, /* SAT TX VFO */ + FT_847_NATIVE_CAT_SET_MODE_SAT_TX_USB, + FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CW, + FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CWR, + FT_847_NATIVE_CAT_SET_MODE_SAT_TX_AM, + FT_847_NATIVE_CAT_SET_MODE_SAT_TX_FM, + FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CWN, + FT_847_NATIVE_CAT_SET_MODE_SAT_TX_CWRN, + FT_847_NATIVE_CAT_SET_MODE_SAT_TX_AMN, + FT_847_NATIVE_CAT_SET_MODE_SAT_TX_FMN, - FT_847_NATIVE_CAT_SET_DCS_ON_MAIN, /* MAIN CTCSS/DCS */ - FT_847_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON_MAIN, - FT_847_NATIVE_CAT_SET_CTCSS_ENC_ON_MAIN, - FT_847_NATIVE_CAT_SET_CTCSS_DCS_OFF_MAIN, + FT_847_NATIVE_CAT_SET_DCS_ON_MAIN, /* MAIN CTCSS/DCS */ + FT_847_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON_MAIN, + FT_847_NATIVE_CAT_SET_CTCSS_ENC_ON_MAIN, + FT_847_NATIVE_CAT_SET_CTCSS_DCS_OFF_MAIN, - FT_847_NATIVE_CAT_SET_DCS_ON_SAT_RX, /* SAT RX CTCSS/DCS */ - FT_847_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON_SAT_RX, - FT_847_NATIVE_CAT_SET_CTCSS_ENC_ON_SAT_RX, - FT_847_NATIVE_CAT_SET_CTCSS_DCS_OFF_SAT_RX, + FT_847_NATIVE_CAT_SET_DCS_ON_SAT_RX, /* SAT RX CTCSS/DCS */ + FT_847_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON_SAT_RX, + FT_847_NATIVE_CAT_SET_CTCSS_ENC_ON_SAT_RX, + FT_847_NATIVE_CAT_SET_CTCSS_DCS_OFF_SAT_RX, - FT_847_NATIVE_CAT_SET_DCS_ON_SAT_TX, /* SAT TX CTCSS/DCS */ - FT_847_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON_SAT_TX, - FT_847_NATIVE_CAT_SET_CTCSS_ENC_ON_SAT_TX, - FT_847_NATIVE_CAT_SET_CTCSS_DCS_OFF_SAT_TX, + FT_847_NATIVE_CAT_SET_DCS_ON_SAT_TX, /* SAT TX CTCSS/DCS */ + FT_847_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON_SAT_TX, + FT_847_NATIVE_CAT_SET_CTCSS_ENC_ON_SAT_TX, + FT_847_NATIVE_CAT_SET_CTCSS_DCS_OFF_SAT_TX, - FT_847_NATIVE_CAT_SET_CTCSS_FREQ_MAIN, /* CTCSS Freq */ - FT_847_NATIVE_CAT_SET_CTCSS_FREQ_SAT_RX, - FT_847_NATIVE_CAT_SET_CTCSS_FREQ_SAT_TX, + FT_847_NATIVE_CAT_SET_CTCSS_FREQ_MAIN, /* CTCSS Freq */ + FT_847_NATIVE_CAT_SET_CTCSS_FREQ_SAT_RX, + FT_847_NATIVE_CAT_SET_CTCSS_FREQ_SAT_TX, - FT_847_NATIVE_CAT_SET_DCS_CODE_MAIN, /* DCS code */ - FT_847_NATIVE_CAT_SET_DCS_CODE_SAT_RX, - FT_847_NATIVE_CAT_SET_DCS_CODE_SAT_TX, + FT_847_NATIVE_CAT_SET_DCS_CODE_MAIN, /* DCS code */ + FT_847_NATIVE_CAT_SET_DCS_CODE_SAT_RX, + FT_847_NATIVE_CAT_SET_DCS_CODE_SAT_TX, - FT_847_NATIVE_CAT_SET_RPT_SHIFT_MINUS, /* RPT SHIFT */ - FT_847_NATIVE_CAT_SET_RPT_SHIFT_PLUS, - FT_847_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, + FT_847_NATIVE_CAT_SET_RPT_SHIFT_MINUS, /* RPT SHIFT */ + FT_847_NATIVE_CAT_SET_RPT_SHIFT_PLUS, + FT_847_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, - FT_847_NATIVE_CAT_SET_RPT_OFFSET, /* RPT Offset frequency */ + FT_847_NATIVE_CAT_SET_RPT_OFFSET, /* RPT Offset frequency */ - /* Get info from the rig */ + /* Get info from the rig */ - FT_847_NATIVE_CAT_GET_RX_STATUS, - FT_847_NATIVE_CAT_GET_TX_STATUS, + FT_847_NATIVE_CAT_GET_RX_STATUS, + FT_847_NATIVE_CAT_GET_TX_STATUS, - FT_847_NATIVE_CAT_GET_FREQ_MODE_STATUS_MAIN, - FT_847_NATIVE_CAT_GET_FREQ_MODE_STATUS_SAT_RX, - FT_847_NATIVE_CAT_GET_FREQ_MODE_STATUS_SAT_TX, + FT_847_NATIVE_CAT_GET_FREQ_MODE_STATUS_MAIN, + FT_847_NATIVE_CAT_GET_FREQ_MODE_STATUS_SAT_RX, + FT_847_NATIVE_CAT_GET_FREQ_MODE_STATUS_SAT_TX, - FT_847_NATIVE_SIZE /* end marker, value indicates number of */ - /* native cmd entries */ + FT_847_NATIVE_SIZE /* end marker, value indicates number of */ + /* native cmd entries */ }; @@ -175,30 +176,36 @@ static int ft847_close(RIG *rig); static int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int ft847_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); -static int ft847_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); /* select mode */ -static int ft847_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); /* get mode */ +static int ft847_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, + pbwidth_t width); /* select mode */ +static int ft847_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); /* get mode */ -static int ft847_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); -static int ft847_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); +static int ft847_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int ft847_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); static int ft847_set_split_freq(RIG *rig, vfo_t vfo, freq_t freq); static int ft847_get_split_freq(RIG *rig, vfo_t vfo, freq_t *freq); -static int ft847_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); -static int ft847_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int ft847_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode, + pbwidth_t width); +static int ft847_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); static int ft847_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int ft847_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); static int ft847_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd); -static int ft847_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t * val); +static int ft847_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); static int ft847_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); -static int ft847_set_ctcss_tone (RIG *rig, vfo_t vfo, tone_t tone); -static int ft847_set_ctcss_sql (RIG *rig, vfo_t vfo, tone_t tone); -static int ft847_set_dcs_sql (RIG *rig, vfo_t vfo, tone_t code); -static int ft847_set_rptr_shift (RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift); -static int ft847_set_rptr_offs (RIG *rig, vfo_t vfo, shortfreq_t rptr_offs); +static int ft847_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone); +static int ft847_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone); +static int ft847_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code); +static int ft847_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift); +static int ft847_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t rptr_offs); /* * ft847 instance - private data @@ -942,7 +949,8 @@ static int ft847_send_priv_cmd(RIG *rig, int cmd_index) return -RIG_EINVAL; } - return write_block(&rig->state.rigport, (char *) ncmd[cmd_index].nseq, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) ncmd[cmd_index].nseq, + YAESU_CMD_LENGTH); } @@ -1335,7 +1343,8 @@ static int ft847_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) return ret; } -static int ft847_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) +static int ft847_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo) { struct ft847_priv_data *priv = (struct ft847_priv_data *)rig->state.priv; @@ -1361,12 +1370,14 @@ static int ft847_get_split_freq(RIG *rig, vfo_t vfo, freq_t *freq) return ft847_get_freq(rig, RIG_VFO_TX, freq); } -static int ft847_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) +static int ft847_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode, + pbwidth_t width) { return ft847_set_mode(rig, RIG_VFO_TX, mode, width); } -static int ft847_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) +static int ft847_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width) { return ft847_get_mode(rig, RIG_VFO_TX, mode, width); } diff --git a/rigs/yaesu/ft857.c b/rigs/yaesu/ft857.c index f1a681467..2d13caee4 100644 --- a/rigs/yaesu/ft857.c +++ b/rigs/yaesu/ft857.c @@ -75,48 +75,49 @@ #include "tones.h" #include "bandplan.h" -enum ft857_native_cmd_e { - FT857_NATIVE_CAT_LOCK_ON = 0, - FT857_NATIVE_CAT_LOCK_OFF, - FT857_NATIVE_CAT_PTT_ON, - FT857_NATIVE_CAT_PTT_OFF, - FT857_NATIVE_CAT_SET_FREQ, - FT857_NATIVE_CAT_SET_MODE_LSB, - FT857_NATIVE_CAT_SET_MODE_USB, - FT857_NATIVE_CAT_SET_MODE_CW, - FT857_NATIVE_CAT_SET_MODE_CWR, - FT857_NATIVE_CAT_SET_MODE_AM, - FT857_NATIVE_CAT_SET_MODE_FM, - FT857_NATIVE_CAT_SET_MODE_FM_N, - FT857_NATIVE_CAT_SET_MODE_DIG, - FT857_NATIVE_CAT_SET_MODE_PKT, - FT857_NATIVE_CAT_CLAR_ON, - FT857_NATIVE_CAT_CLAR_OFF, - FT857_NATIVE_CAT_SET_CLAR_FREQ, - FT857_NATIVE_CAT_SET_VFOAB, - FT857_NATIVE_CAT_SPLIT_ON, - FT857_NATIVE_CAT_SPLIT_OFF, - FT857_NATIVE_CAT_SET_RPT_SHIFT_MINUS, - FT857_NATIVE_CAT_SET_RPT_SHIFT_PLUS, - FT857_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, - FT857_NATIVE_CAT_SET_RPT_OFFSET, - FT857_NATIVE_CAT_SET_DCS_ON, - FT857_NATIVE_CAT_SET_DCS_DEC_ON, - FT857_NATIVE_CAT_SET_DCS_ENC_ON, - FT857_NATIVE_CAT_SET_CTCSS_ON, - FT857_NATIVE_CAT_SET_CTCSS_DEC_ON, - FT857_NATIVE_CAT_SET_CTCSS_ENC_ON, - FT857_NATIVE_CAT_SET_CTCSS_DCS_OFF, - FT857_NATIVE_CAT_SET_CTCSS_FREQ, - FT857_NATIVE_CAT_SET_DCS_CODE, - FT857_NATIVE_CAT_GET_RX_STATUS, - FT857_NATIVE_CAT_GET_TX_STATUS, - FT857_NATIVE_CAT_GET_FREQ_MODE_STATUS, - FT857_NATIVE_CAT_PWR_WAKE, - FT857_NATIVE_CAT_PWR_ON, - FT857_NATIVE_CAT_PWR_OFF, - FT857_NATIVE_CAT_EEPROM_READ, - FT857_NATIVE_SIZE /* end marker */ +enum ft857_native_cmd_e +{ + FT857_NATIVE_CAT_LOCK_ON = 0, + FT857_NATIVE_CAT_LOCK_OFF, + FT857_NATIVE_CAT_PTT_ON, + FT857_NATIVE_CAT_PTT_OFF, + FT857_NATIVE_CAT_SET_FREQ, + FT857_NATIVE_CAT_SET_MODE_LSB, + FT857_NATIVE_CAT_SET_MODE_USB, + FT857_NATIVE_CAT_SET_MODE_CW, + FT857_NATIVE_CAT_SET_MODE_CWR, + FT857_NATIVE_CAT_SET_MODE_AM, + FT857_NATIVE_CAT_SET_MODE_FM, + FT857_NATIVE_CAT_SET_MODE_FM_N, + FT857_NATIVE_CAT_SET_MODE_DIG, + FT857_NATIVE_CAT_SET_MODE_PKT, + FT857_NATIVE_CAT_CLAR_ON, + FT857_NATIVE_CAT_CLAR_OFF, + FT857_NATIVE_CAT_SET_CLAR_FREQ, + FT857_NATIVE_CAT_SET_VFOAB, + FT857_NATIVE_CAT_SPLIT_ON, + FT857_NATIVE_CAT_SPLIT_OFF, + FT857_NATIVE_CAT_SET_RPT_SHIFT_MINUS, + FT857_NATIVE_CAT_SET_RPT_SHIFT_PLUS, + FT857_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, + FT857_NATIVE_CAT_SET_RPT_OFFSET, + FT857_NATIVE_CAT_SET_DCS_ON, + FT857_NATIVE_CAT_SET_DCS_DEC_ON, + FT857_NATIVE_CAT_SET_DCS_ENC_ON, + FT857_NATIVE_CAT_SET_CTCSS_ON, + FT857_NATIVE_CAT_SET_CTCSS_DEC_ON, + FT857_NATIVE_CAT_SET_CTCSS_ENC_ON, + FT857_NATIVE_CAT_SET_CTCSS_DCS_OFF, + FT857_NATIVE_CAT_SET_CTCSS_FREQ, + FT857_NATIVE_CAT_SET_DCS_CODE, + FT857_NATIVE_CAT_GET_RX_STATUS, + FT857_NATIVE_CAT_GET_TX_STATUS, + FT857_NATIVE_CAT_GET_FREQ_MODE_STATUS, + FT857_NATIVE_CAT_PWR_WAKE, + FT857_NATIVE_CAT_PWR_ON, + FT857_NATIVE_CAT_PWR_OFF, + FT857_NATIVE_CAT_EEPROM_READ, + FT857_NATIVE_SIZE /* end marker */ }; static int ft857_init(RIG *rig); @@ -127,10 +128,14 @@ static int ft857_set_freq(RIG *rig, vfo_t vfo, freq_t freq); static int ft857_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); static int ft857_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); static int ft857_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); -static int ft857_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq, rmode_t mode, pbwidth_t width); -static int ft857_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *freq, rmode_t *mode, pbwidth_t *width); -static int ft857_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); -static int ft857_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); +static int ft857_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t freq, + rmode_t mode, pbwidth_t width); +static int ft857_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *freq, + rmode_t *mode, pbwidth_t *width); +static int ft857_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int ft857_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); // static int ft857_set_vfo(RIG *rig, vfo_t vfo); // static int ft857_get_vfo(RIG *rig, vfo_t *vfo); static int ft857_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); diff --git a/rigs/yaesu/ft890.c b/rigs/yaesu/ft890.c index 9bef6f9e3..3f890d7ab 100644 --- a/rigs/yaesu/ft890.c +++ b/rigs/yaesu/ft890.c @@ -75,31 +75,32 @@ * */ -enum ft890_native_cmd_e { - FT890_NATIVE_SPLIT_OFF = 0, - FT890_NATIVE_SPLIT_ON, - FT890_NATIVE_RECALL_MEM, - FT890_NATIVE_VFO_TO_MEM, - FT890_NATIVE_VFO_A, - FT890_NATIVE_VFO_B, - FT890_NATIVE_MEM_TO_VFO, - FT890_NATIVE_CLARIFIER_OPS, - FT890_NATIVE_FREQ_SET, - FT890_NATIVE_MODE_SET, - FT890_NATIVE_PACING, - FT890_NATIVE_PTT_OFF, - FT890_NATIVE_PTT_ON, - FT890_NATIVE_MEM_CHNL, - FT890_NATIVE_OP_DATA, - FT890_NATIVE_VFO_DATA, - FT890_NATIVE_MEM_CHNL_DATA, - FT890_NATIVE_TUNER_OFF, - FT890_NATIVE_TUNER_ON, - FT890_NATIVE_TUNER_START, - FT890_NATIVE_READ_METER, - FT890_NATIVE_READ_FLAGS, - FT890_NATIVE_SIZE /* end marker, value indicates number of */ - /* native cmd entries */ +enum ft890_native_cmd_e +{ + FT890_NATIVE_SPLIT_OFF = 0, + FT890_NATIVE_SPLIT_ON, + FT890_NATIVE_RECALL_MEM, + FT890_NATIVE_VFO_TO_MEM, + FT890_NATIVE_VFO_A, + FT890_NATIVE_VFO_B, + FT890_NATIVE_MEM_TO_VFO, + FT890_NATIVE_CLARIFIER_OPS, + FT890_NATIVE_FREQ_SET, + FT890_NATIVE_MODE_SET, + FT890_NATIVE_PACING, + FT890_NATIVE_PTT_OFF, + FT890_NATIVE_PTT_ON, + FT890_NATIVE_MEM_CHNL, + FT890_NATIVE_OP_DATA, + FT890_NATIVE_VFO_DATA, + FT890_NATIVE_MEM_CHNL_DATA, + FT890_NATIVE_TUNER_OFF, + FT890_NATIVE_TUNER_ON, + FT890_NATIVE_TUNER_START, + FT890_NATIVE_READ_METER, + FT890_NATIVE_READ_FLAGS, + FT890_NATIVE_SIZE /* end marker, value indicates number of */ + /* native cmd entries */ }; typedef enum ft890_native_cmd_e ft890_native_cmd_t; @@ -302,8 +303,10 @@ static int ft890_get_vfo(RIG *rig, vfo_t *vfo); static int ft890_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int ft890_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); -static int ft890_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); -static int ft890_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); +static int ft890_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int ft890_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); static int ft890_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int ft890_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit); diff --git a/rigs/yaesu/ft891.c b/rigs/yaesu/ft891.c index 0517a2c80..c004cd632 100644 --- a/rigs/yaesu/ft891.c +++ b/rigs/yaesu/ft891.c @@ -44,11 +44,15 @@ /* Prototypes */ static int ft891_init(RIG *rig); -static int ft891_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); -static int ft891_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_width); -static int ft891_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width); +static int ft891_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); +static int ft891_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, + pbwidth_t *tx_width); +static int ft891_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, + pbwidth_t tx_width); static int ft891_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); -static int ft891_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); +static int ft891_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); const struct confparams ft891_ext_levels[] = { @@ -131,7 +135,7 @@ const struct rig_caps ft891_caps = RIG_MODEL(RIG_MODEL_FT891), .model_name = "FT-891", .mfg_name = "Yaesu", - .version = NEWCAT_VER ".4", + .version = NEWCAT_VER ".5", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -316,6 +320,8 @@ const struct rig_caps ft891_caps = .set_ext_level = newcat_set_ext_level, .get_ext_level = newcat_get_ext_level, .send_morse = newcat_send_morse, + .set_clock = newcat_set_clock, + .get_clock = newcat_get_clock }; /* @@ -408,7 +414,8 @@ static int ft891_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) * * Comments: The passed value for the vfo is ignored since can only split one way */ -static int ft891_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) +static int ft891_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo) { struct newcat_priv_data *priv; int err; @@ -467,7 +474,7 @@ static int ft891_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vf */ static int ft891_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, - pbwidth_t *tx_width) + pbwidth_t *tx_width) { struct newcat_priv_data *priv; int err; @@ -514,7 +521,7 @@ static int ft891_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, */ static int ft891_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, - pbwidth_t tx_width) + pbwidth_t tx_width) { struct newcat_priv_data *priv; struct rig_state *state; diff --git a/rigs/yaesu/ft897.c b/rigs/yaesu/ft897.c index c1577cc70..5c9bf1e87 100644 --- a/rigs/yaesu/ft897.c +++ b/rigs/yaesu/ft897.c @@ -81,48 +81,49 @@ #include "tones.h" #include "bandplan.h" -enum ft897_native_cmd_e { - FT897_NATIVE_CAT_LOCK_ON = 0, - FT897_NATIVE_CAT_LOCK_OFF, - FT897_NATIVE_CAT_PTT_ON, - FT897_NATIVE_CAT_PTT_OFF, - FT897_NATIVE_CAT_SET_FREQ, - FT897_NATIVE_CAT_SET_MODE_LSB, - FT897_NATIVE_CAT_SET_MODE_USB, - FT897_NATIVE_CAT_SET_MODE_CW, - FT897_NATIVE_CAT_SET_MODE_CWR, - FT897_NATIVE_CAT_SET_MODE_AM, - FT897_NATIVE_CAT_SET_MODE_FM, - FT897_NATIVE_CAT_SET_MODE_FM_N, - FT897_NATIVE_CAT_SET_MODE_DIG, - FT897_NATIVE_CAT_SET_MODE_PKT, - FT897_NATIVE_CAT_CLAR_ON, - FT897_NATIVE_CAT_CLAR_OFF, - FT897_NATIVE_CAT_SET_CLAR_FREQ, - FT897_NATIVE_CAT_SET_VFOAB, - FT897_NATIVE_CAT_SPLIT_ON, - FT897_NATIVE_CAT_SPLIT_OFF, - FT897_NATIVE_CAT_SET_RPT_SHIFT_MINUS, - FT897_NATIVE_CAT_SET_RPT_SHIFT_PLUS, - FT897_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, - FT897_NATIVE_CAT_SET_RPT_OFFSET, - FT897_NATIVE_CAT_SET_DCS_ON, - FT897_NATIVE_CAT_SET_DCS_DEC_ON, - FT897_NATIVE_CAT_SET_DCS_ENC_ON, - FT897_NATIVE_CAT_SET_CTCSS_ON, - FT897_NATIVE_CAT_SET_CTCSS_DEC_ON, - FT897_NATIVE_CAT_SET_CTCSS_ENC_ON, - FT897_NATIVE_CAT_SET_CTCSS_DCS_OFF, - FT897_NATIVE_CAT_SET_CTCSS_FREQ, - FT897_NATIVE_CAT_SET_DCS_CODE, - FT897_NATIVE_CAT_GET_RX_STATUS, - FT897_NATIVE_CAT_GET_TX_STATUS, - FT897_NATIVE_CAT_GET_FREQ_MODE_STATUS, - FT897_NATIVE_CAT_PWR_WAKE, - FT897_NATIVE_CAT_PWR_ON, - FT897_NATIVE_CAT_PWR_OFF, - FT897_NATIVE_CAT_EEPROM_READ, - FT897_NATIVE_SIZE /* end marker */ +enum ft897_native_cmd_e +{ + FT897_NATIVE_CAT_LOCK_ON = 0, + FT897_NATIVE_CAT_LOCK_OFF, + FT897_NATIVE_CAT_PTT_ON, + FT897_NATIVE_CAT_PTT_OFF, + FT897_NATIVE_CAT_SET_FREQ, + FT897_NATIVE_CAT_SET_MODE_LSB, + FT897_NATIVE_CAT_SET_MODE_USB, + FT897_NATIVE_CAT_SET_MODE_CW, + FT897_NATIVE_CAT_SET_MODE_CWR, + FT897_NATIVE_CAT_SET_MODE_AM, + FT897_NATIVE_CAT_SET_MODE_FM, + FT897_NATIVE_CAT_SET_MODE_FM_N, + FT897_NATIVE_CAT_SET_MODE_DIG, + FT897_NATIVE_CAT_SET_MODE_PKT, + FT897_NATIVE_CAT_CLAR_ON, + FT897_NATIVE_CAT_CLAR_OFF, + FT897_NATIVE_CAT_SET_CLAR_FREQ, + FT897_NATIVE_CAT_SET_VFOAB, + FT897_NATIVE_CAT_SPLIT_ON, + FT897_NATIVE_CAT_SPLIT_OFF, + FT897_NATIVE_CAT_SET_RPT_SHIFT_MINUS, + FT897_NATIVE_CAT_SET_RPT_SHIFT_PLUS, + FT897_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, + FT897_NATIVE_CAT_SET_RPT_OFFSET, + FT897_NATIVE_CAT_SET_DCS_ON, + FT897_NATIVE_CAT_SET_DCS_DEC_ON, + FT897_NATIVE_CAT_SET_DCS_ENC_ON, + FT897_NATIVE_CAT_SET_CTCSS_ON, + FT897_NATIVE_CAT_SET_CTCSS_DEC_ON, + FT897_NATIVE_CAT_SET_CTCSS_ENC_ON, + FT897_NATIVE_CAT_SET_CTCSS_DCS_OFF, + FT897_NATIVE_CAT_SET_CTCSS_FREQ, + FT897_NATIVE_CAT_SET_DCS_CODE, + FT897_NATIVE_CAT_GET_RX_STATUS, + FT897_NATIVE_CAT_GET_TX_STATUS, + FT897_NATIVE_CAT_GET_FREQ_MODE_STATUS, + FT897_NATIVE_CAT_PWR_WAKE, + FT897_NATIVE_CAT_PWR_ON, + FT897_NATIVE_CAT_PWR_OFF, + FT897_NATIVE_CAT_EEPROM_READ, + FT897_NATIVE_SIZE /* end marker */ }; struct ft897_priv_data diff --git a/rigs/yaesu/ft900.c b/rigs/yaesu/ft900.c index a393281e5..58bf96bd9 100644 --- a/rigs/yaesu/ft900.c +++ b/rigs/yaesu/ft900.c @@ -76,31 +76,32 @@ * */ -enum ft900_native_cmd_e { - FT900_NATIVE_SPLIT_OFF = 0, - FT900_NATIVE_SPLIT_ON, - FT900_NATIVE_RECALL_MEM, - FT900_NATIVE_VFO_TO_MEM, - FT900_NATIVE_VFO_A, - FT900_NATIVE_VFO_B, - FT900_NATIVE_MEM_TO_VFO, - FT900_NATIVE_CLARIFIER_OPS, - FT900_NATIVE_FREQ_SET, - FT900_NATIVE_MODE_SET, - FT900_NATIVE_PACING, - FT900_NATIVE_PTT_OFF, - FT900_NATIVE_PTT_ON, - FT900_NATIVE_MEM_CHNL, - FT900_NATIVE_OP_DATA, - FT900_NATIVE_VFO_DATA, - FT900_NATIVE_MEM_CHNL_DATA, - FT900_NATIVE_TUNER_OFF, - FT900_NATIVE_TUNER_ON, - FT900_NATIVE_TUNER_START, - FT900_NATIVE_READ_METER, - FT900_NATIVE_READ_FLAGS, - FT900_NATIVE_SIZE /* end marker, value indicates number of */ - /* native cmd entries */ +enum ft900_native_cmd_e +{ + FT900_NATIVE_SPLIT_OFF = 0, + FT900_NATIVE_SPLIT_ON, + FT900_NATIVE_RECALL_MEM, + FT900_NATIVE_VFO_TO_MEM, + FT900_NATIVE_VFO_A, + FT900_NATIVE_VFO_B, + FT900_NATIVE_MEM_TO_VFO, + FT900_NATIVE_CLARIFIER_OPS, + FT900_NATIVE_FREQ_SET, + FT900_NATIVE_MODE_SET, + FT900_NATIVE_PACING, + FT900_NATIVE_PTT_OFF, + FT900_NATIVE_PTT_ON, + FT900_NATIVE_MEM_CHNL, + FT900_NATIVE_OP_DATA, + FT900_NATIVE_VFO_DATA, + FT900_NATIVE_MEM_CHNL_DATA, + FT900_NATIVE_TUNER_OFF, + FT900_NATIVE_TUNER_ON, + FT900_NATIVE_TUNER_START, + FT900_NATIVE_READ_METER, + FT900_NATIVE_READ_FLAGS, + FT900_NATIVE_SIZE /* end marker, value indicates number of */ + /* native cmd entries */ }; typedef enum ft900_native_cmd_e ft900_native_cmd_t; @@ -322,8 +323,10 @@ static int ft900_get_vfo(RIG *rig, vfo_t *vfo); static int ft900_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int ft900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); -static int ft900_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); -static int ft900_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); +static int ft900_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int ft900_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); static int ft900_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int ft900_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit); diff --git a/rigs/yaesu/ft920.c b/rigs/yaesu/ft920.c index 175baa965..15812bebd 100644 --- a/rigs/yaesu/ft920.c +++ b/rigs/yaesu/ft920.c @@ -71,7 +71,8 @@ * */ -enum ft920_native_cmd_e { +enum ft920_native_cmd_e +{ FT920_NATIVE_SPLIT_OFF = 0, FT920_NATIVE_SPLIT_ON, FT920_NATIVE_RECALL_MEM, @@ -99,7 +100,7 @@ enum ft920_native_cmd_e { FT920_NATIVE_VFO_B_PASSBAND_NAR, FT920_NATIVE_STATUS_FLAGS, FT920_NATIVE_SIZE /* end marker, value indicates number of */ - /* native cmd entries */ + /* native cmd entries */ }; /* @@ -302,14 +303,18 @@ static int ft920_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); static int ft920_set_vfo(RIG *rig, vfo_t vfo); static int ft920_get_vfo(RIG *rig, vfo_t *vfo); -static int ft920_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); -static int ft920_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); +static int ft920_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int ft920_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); static int ft920_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq); static int ft920_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq); -static int ft920_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width); -static int ft920_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, pbwidth_t *tx_width); +static int ft920_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, + pbwidth_t tx_width); +static int ft920_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, + pbwidth_t *tx_width); static int ft920_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int ft920_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit); diff --git a/rigs/yaesu/ft990.c b/rigs/yaesu/ft990.c index e661301b8..4ad1e559a 100644 --- a/rigs/yaesu/ft990.c +++ b/rigs/yaesu/ft990.c @@ -48,61 +48,62 @@ #include "ft990.h" // FT990 native commands -enum ft990_native_cmd_e { - FT990_NATIVE_SPLIT_OFF = 0, - FT990_NATIVE_SPLIT_ON, - FT990_NATIVE_RECALL_MEM, - FT990_NATIVE_VFO_TO_MEM, - FT990_NATIVE_LOCK_OFF, - FT990_NATIVE_LOCK_ON, - FT990_NATIVE_VFO_A, - FT990_NATIVE_VFO_B, - FT990_NATIVE_MEM_TO_VFO, - FT990_NATIVE_VFO_STEP_UP, - FT990_NATIVE_VFO_STEP_UP_FAST, - FT990_NATIVE_VFO_STEP_DOWN, - FT990_NATIVE_VFO_STEP_DOWN_FAST, - FT990_NATIVE_RX_CLARIFIER_OFF, - FT990_NATIVE_RX_CLARIFIER_ON, - FT990_NATIVE_TX_CLARIFIER_OFF, - FT990_NATIVE_TX_CLARIFIER_ON, - FT990_NATIVE_CLEAR_CLARIFIER_OFFSET, - FT990_NATIVE_CLARIFIER_OPS, - FT990_NATIVE_FREQ_SET, - FT990_NATIVE_MODE_SET_LSB, - FT990_NATIVE_MODE_SET_USB, - FT990_NATIVE_MODE_SET_CW_W, - FT990_NATIVE_MODE_SET_CW_N, - FT990_NATIVE_MODE_SET_AM_W, - FT990_NATIVE_MODE_SET_AM_N, - FT990_NATIVE_MODE_SET_FM, - FT990_NATIVE_MODE_SET_RTTY_LSB, - FT990_NATIVE_MODE_SET_RTTY_USB, - FT990_NATIVE_MODE_SET_PKT_LSB, - FT990_NATIVE_MODE_SET_PKT_FM, - FT990_NATIVE_PACING, - FT990_NATIVE_PTT_OFF, - FT990_NATIVE_PTT_ON, - FT990_NATIVE_UPDATE_ALL_DATA, - FT990_NATIVE_UPDATE_MEM_CHNL, - FT990_NATIVE_UPDATE_OP_DATA, - FT990_NATIVE_UPDATE_VFO_DATA, - FT990_NATIVE_UPDATE_MEM_CHNL_DATA, - FT990_NATIVE_TUNER_OFF, - FT990_NATIVE_TUNER_ON, - FT990_NATIVE_TUNER_START, - FT990_NATIVE_RPTR_SHIFT_NONE, - FT990_NATIVE_RPTR_SHIFT_MINUS, - FT990_NATIVE_RPTR_SHIFT_PLUS, - FT990_NATIVE_VFO_TO_VFO, - FT990_NATIVE_BANDWIDTH, - FT990_NATIVE_OP_FREQ_STEP_UP, - FT990_NATIVE_OP_FREQ_STEP_DOWN, - FT990_NATIVE_READ_METER, - FT990_NATIVE_DIM_LEVEL, - FT990_NATIVE_RPTR_OFFSET, - FT990_NATIVE_READ_FLAGS, - FT990_NATIVE_SIZE +enum ft990_native_cmd_e +{ + FT990_NATIVE_SPLIT_OFF = 0, + FT990_NATIVE_SPLIT_ON, + FT990_NATIVE_RECALL_MEM, + FT990_NATIVE_VFO_TO_MEM, + FT990_NATIVE_LOCK_OFF, + FT990_NATIVE_LOCK_ON, + FT990_NATIVE_VFO_A, + FT990_NATIVE_VFO_B, + FT990_NATIVE_MEM_TO_VFO, + FT990_NATIVE_VFO_STEP_UP, + FT990_NATIVE_VFO_STEP_UP_FAST, + FT990_NATIVE_VFO_STEP_DOWN, + FT990_NATIVE_VFO_STEP_DOWN_FAST, + FT990_NATIVE_RX_CLARIFIER_OFF, + FT990_NATIVE_RX_CLARIFIER_ON, + FT990_NATIVE_TX_CLARIFIER_OFF, + FT990_NATIVE_TX_CLARIFIER_ON, + FT990_NATIVE_CLEAR_CLARIFIER_OFFSET, + FT990_NATIVE_CLARIFIER_OPS, + FT990_NATIVE_FREQ_SET, + FT990_NATIVE_MODE_SET_LSB, + FT990_NATIVE_MODE_SET_USB, + FT990_NATIVE_MODE_SET_CW_W, + FT990_NATIVE_MODE_SET_CW_N, + FT990_NATIVE_MODE_SET_AM_W, + FT990_NATIVE_MODE_SET_AM_N, + FT990_NATIVE_MODE_SET_FM, + FT990_NATIVE_MODE_SET_RTTY_LSB, + FT990_NATIVE_MODE_SET_RTTY_USB, + FT990_NATIVE_MODE_SET_PKT_LSB, + FT990_NATIVE_MODE_SET_PKT_FM, + FT990_NATIVE_PACING, + FT990_NATIVE_PTT_OFF, + FT990_NATIVE_PTT_ON, + FT990_NATIVE_UPDATE_ALL_DATA, + FT990_NATIVE_UPDATE_MEM_CHNL, + FT990_NATIVE_UPDATE_OP_DATA, + FT990_NATIVE_UPDATE_VFO_DATA, + FT990_NATIVE_UPDATE_MEM_CHNL_DATA, + FT990_NATIVE_TUNER_OFF, + FT990_NATIVE_TUNER_ON, + FT990_NATIVE_TUNER_START, + FT990_NATIVE_RPTR_SHIFT_NONE, + FT990_NATIVE_RPTR_SHIFT_MINUS, + FT990_NATIVE_RPTR_SHIFT_PLUS, + FT990_NATIVE_VFO_TO_VFO, + FT990_NATIVE_BANDWIDTH, + FT990_NATIVE_OP_FREQ_STEP_UP, + FT990_NATIVE_OP_FREQ_STEP_DOWN, + FT990_NATIVE_READ_METER, + FT990_NATIVE_DIM_LEVEL, + FT990_NATIVE_RPTR_OFFSET, + FT990_NATIVE_READ_FLAGS, + FT990_NATIVE_SIZE }; @@ -122,8 +123,10 @@ static int ft990_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); static int ft990_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift); static int ft990_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *rptr_shift); static int ft990_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs); -static int ft990_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); -static int ft990_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); +static int ft990_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int ft990_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); static int ft990_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int ft990_get_rit(RIG *rig, vfo_t vfo, shortfreq_t *rit); static int ft990_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); @@ -135,8 +138,9 @@ static int ft990_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); static int ft990_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); static int ft990_set_mem(RIG *rig, vfo_t vfo, int ch); static int ft990_get_mem(RIG *rig, vfo_t vfo, int *ch); -static int ft990_set_channel (RIG *rig, vfo_t vfo, const channel_t *chan); -static int ft990_get_channel (RIG *rig, vfo_t vfo, channel_t *chan, int read_only); +static int ft990_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan); +static int ft990_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, + int read_only); diff --git a/rigs/yaesu/ft991.c b/rigs/yaesu/ft991.c index c5c615da7..c59f5f40a 100644 --- a/rigs/yaesu/ft991.c +++ b/rigs/yaesu/ft991.c @@ -143,7 +143,7 @@ const struct rig_caps ft991_caps = RIG_MODEL(RIG_MODEL_FT991), .model_name = "FT-991", .mfg_name = "Yaesu", - .version = NEWCAT_VER ".7", + .version = NEWCAT_VER ".8", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -329,6 +329,8 @@ const struct rig_caps ft991_caps = .get_ext_level = newcat_get_ext_level, .send_morse = newcat_send_morse, .send_voice_mem = newcat_send_voice_mem, + .set_clock = newcat_set_clock, + .get_clock = newcat_get_clock }; @@ -452,7 +454,7 @@ ft991_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) */ static int ft991_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, - pbwidth_t *tx_width) + pbwidth_t *tx_width) { struct newcat_priv_data *priv; int err; @@ -538,7 +540,7 @@ static void debug_ft991info_data(const ft991info *rdata) */ static int ft991_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, - pbwidth_t tx_width) + pbwidth_t tx_width) { struct newcat_priv_data *priv; struct rig_state *state; diff --git a/rigs/yaesu/ftdx10.c b/rigs/yaesu/ftdx10.c index bc3d6542f..41738e4cb 100644 --- a/rigs/yaesu/ftdx10.c +++ b/rigs/yaesu/ftdx10.c @@ -139,7 +139,7 @@ const struct rig_caps ftdx10_caps = RIG_MODEL(RIG_MODEL_FTDX10), .model_name = "FTDX-10", .mfg_name = "Yaesu", - .version = NEWCAT_VER ".0", + .version = NEWCAT_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -308,4 +308,6 @@ const struct rig_caps ftdx10_caps = .set_ext_level = newcat_set_ext_level, .get_ext_level = newcat_get_ext_level, .send_morse = newcat_send_morse, + .set_clock = newcat_set_clock, + .get_clock = newcat_get_clock }; diff --git a/rigs/yaesu/ftdx101.c b/rigs/yaesu/ftdx101.c index db9fdd7aa..00ca222ff 100644 --- a/rigs/yaesu/ftdx101.c +++ b/rigs/yaesu/ftdx101.c @@ -139,7 +139,7 @@ const struct rig_caps ftdx101d_caps = RIG_MODEL(RIG_MODEL_FTDX101D), .model_name = "FTDX-101D", .mfg_name = "Yaesu", - .version = NEWCAT_VER ".12", + .version = NEWCAT_VER ".13", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -309,4 +309,6 @@ const struct rig_caps ftdx101d_caps = .set_ext_level = newcat_set_ext_level, .get_ext_level = newcat_get_ext_level, .send_morse = newcat_send_morse, + .set_clock = newcat_set_clock, + .get_clock = newcat_get_clock }; diff --git a/rigs/yaesu/ftdx101mp.c b/rigs/yaesu/ftdx101mp.c index a1157b5a7..4fbcebfb1 100644 --- a/rigs/yaesu/ftdx101mp.c +++ b/rigs/yaesu/ftdx101mp.c @@ -77,7 +77,7 @@ const struct rig_caps ftdx101mp_caps = RIG_MODEL(RIG_MODEL_FTDX101MP), .model_name = "FTDX-101MP", .mfg_name = "Yaesu", - .version = NEWCAT_VER ".3", + .version = NEWCAT_VER ".4", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -247,4 +247,6 @@ const struct rig_caps ftdx101mp_caps = .set_ext_level = newcat_set_ext_level, .get_ext_level = newcat_get_ext_level, .send_morse = newcat_send_morse, + .set_clock = newcat_set_clock, + .get_clock = newcat_get_clock }; diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 87090d94c..85d6ad2cc 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -932,6 +932,7 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq) && rig->caps->set_vfo != NULL) // gotta' have get_vfo too { TRACE; + if (rig->state.current_vfo != vfo) { int vfo1 = 1, vfo2 = 0; @@ -1245,9 +1246,13 @@ int newcat_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (vfo == RIG_VFO_B || vfo == RIG_VFO_SUB) { rig_get_mode(rig, vfo, &tmode, &twidth); + if (mode == tmode && (twidth == width || twidth == RIG_PASSBAND_NOCHANGE)) + { RETURNFUNC(RIG_OK); + } } + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "MD0x%c", cat_term); priv->cmd_str[3] = newcat_modechar(mode); @@ -2312,7 +2317,8 @@ int newcat_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) vfo_t rx_vfo = RIG_VFO_NONE; //ENTERFUNC; - rig_debug(RIG_DEBUG_TRACE, "%s: entered, rxvfo=%s, txvfo=%s, split=%d\n", __func__, rig_strvfo(vfo), rig_strvfo(tx_vfo), split); + rig_debug(RIG_DEBUG_TRACE, "%s: entered, rxvfo=%s, txvfo=%s, split=%d\n", + __func__, rig_strvfo(vfo), rig_strvfo(tx_vfo), split); err = newcat_set_vfo_from_alias(rig, &vfo); @@ -3697,6 +3703,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { RETURNFUNC(-RIG_ENAVAIL); } + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "KS%03d%c", val.i, cat_term); break; @@ -4618,6 +4625,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { RETURNFUNC(-RIG_ENAVAIL); } + if (is_ftdx9000) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM06%c", cat_term); @@ -4626,6 +4634,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM3%c", cat_term); } + break; case RIG_LEVEL_VD_METER: @@ -4633,6 +4642,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { RETURNFUNC(-RIG_ENAVAIL); } + if (is_ftdx9000) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM11%c", cat_term); @@ -4641,6 +4651,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM8%c", cat_term); } + break; case RIG_LEVEL_ID_METER: @@ -4648,6 +4659,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { RETURNFUNC(-RIG_ENAVAIL); } + if (is_ftdx9000) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM10%c", cat_term); @@ -4656,6 +4668,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RM7%c", cat_term); } + break; case RIG_LEVEL_ANTIVOX: @@ -5067,14 +5080,17 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) case RIG_LEVEL_RAWSTR: case RIG_LEVEL_KEYSPD: - if (rig->caps->rig_model == RIG_MODEL_TS570D || rig->caps->rig_model == RIG_MODEL_TS570S) - { // TS570 uses 010-~060 scale according to manual - val->i = atoi(retlvl)/2 + 10; + if (rig->caps->rig_model == RIG_MODEL_TS570D + || rig->caps->rig_model == RIG_MODEL_TS570S) + { + // TS570 uses 010-~060 scale according to manual + val->i = atoi(retlvl) / 2 + 10; } else { val->i = atoi(retlvl); } + break; case RIG_LEVEL_IF: @@ -5594,15 +5610,28 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) } - if (is_ftdx101d || is_ftdx101mp) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c2%04d%c", main_sub_vfo, status ? 1 : 0, cat_term); - } else if (is_ftdx10 || is_ft991 || is_ft891) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO02%04d%c", status ? 1 : 0, cat_term); - } else if (is_ftdx5000) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%02d%c", main_sub_vfo, status ? 2 : 0, cat_term); - } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%02d%c", status ? 2 : 0, cat_term); - } else { + if (is_ftdx101d || is_ftdx101mp) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c2%04d%c", main_sub_vfo, + status ? 1 : 0, cat_term); + } + else if (is_ftdx10 || is_ft991 || is_ft891) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO02%04d%c", status ? 1 : 0, + cat_term); + } + else if (is_ftdx5000) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%02d%c", main_sub_vfo, + status ? 2 : 0, cat_term); + } + else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%02d%c", status ? 2 : 0, + cat_term); + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -5835,19 +5864,31 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c2%c", main_sub_vfo, cat_term); - } else if (is_ftdx10 || is_ft991 || is_ft891) { + if (is_ftdx101d || is_ftdx101mp) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c2%c", main_sub_vfo, + cat_term); + } + else if (is_ftdx10 || is_ft991 || is_ft891) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO02%c", cat_term); - } else if (is_ftdx5000) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%c", main_sub_vfo, cat_term); - } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + } + else if (is_ftdx5000) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%c", main_sub_vfo, + cat_term); + } + else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%c", cat_term); - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } break; + default: RETURNFUNC(-RIG_EINVAL); } @@ -5930,15 +5971,24 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) break; case RIG_FUNC_APF: - if (is_ftdx101d || is_ftdx101mp) { + if (is_ftdx101d || is_ftdx101mp) + { *status = (retfunc[last_char_index] == '1') ? 1 : 0; - } else if (is_ftdx10 || is_ft991 || is_ft891) { + } + else if (is_ftdx10 || is_ft991 || is_ft891) + { *status = (retfunc[last_char_index] == '1') ? 1 : 0; - } else if (is_ftdx5000) { + } + else if (is_ftdx5000) + { *status = (retfunc[last_char_index] == '2') ? 1 : 0; - } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + } + else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) + { *status = (retfunc[last_char_index] == '2') ? 1 : 0; - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -5986,7 +6036,7 @@ int newcat_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val) } snprintf(priv->cmd_str, sizeof(priv->cmd_str), "KR%d%c", val.i ? 1 : 0, - cat_term); + cat_term); RETURNFUNC(newcat_set_cmd(rig)); @@ -6176,6 +6226,7 @@ int newcat_send_morse(RIG *rig, vfo_t vfo, const char *msg) int rc; char *s = strdup(msg); ENTERFUNC; + if (newcat_is_rig(rig, RIG_MODEL_FT450)) { // 450 manual says 1/2/3 playback needs P1=6/7/8 @@ -6185,6 +6236,7 @@ int newcat_send_morse(RIG *rig, vfo_t vfo, const char *msg) { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "KY%c%c", s[0], cat_term); } + rc = newcat_set_cmd(rig); free(s); RETURNFUNC(rc); @@ -9851,7 +9903,7 @@ int newcat_get_cmd(RIG *rig) /* read the reply */ if ((rc = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data), - &cat_term, sizeof(cat_term), 0)) <= 0) + &cat_term, sizeof(cat_term), 0, 1)) <= 0) { continue; /* usually a timeout - retry */ } @@ -10051,7 +10103,7 @@ int newcat_set_cmd_validate(RIG *rig) if (strlen(valcmd) == 0) { RETURNFUNC(RIG_OK); } bytes = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data), - &cat_term, sizeof(cat_term), 0); + &cat_term, sizeof(cat_term), 0, 1); // FA and FB success is now verified in rig.c with a followup query // so no validation is needed @@ -10179,7 +10231,7 @@ int newcat_set_cmd(RIG *rig) /* read the reply */ if ((rc = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data), - &cat_term, sizeof(cat_term), 0)) <= 0) + &cat_term, sizeof(cat_term), 0, 1)) <= 0) { continue; /* usually a timeout - retry */ } @@ -10249,7 +10301,7 @@ int newcat_set_cmd(RIG *rig) /* read/flush the verify command reply which should still be there */ if ((rc = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data), - &cat_term, sizeof(cat_term), 0)) > 0) + &cat_term, sizeof(cat_term), 0, 1)) > 0) { rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s\n", __func__, rc, priv->ret_data); @@ -10394,10 +10446,12 @@ int newcat_send_voice_mem(RIG *rig, vfo_t vfo, int ch) { char *p1 = "0"; // newer rigs have 2 bytes where is fixed at zero e.g. FT991 struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + if (!newcat_valid_command(rig, "PB")) { RETURNFUNC(-RIG_ENAVAIL); } + // we don't do any channel checking -- varies by rig -- could do it but not critical snprintf(priv->cmd_str, sizeof(priv->cmd_str), "PB%s%d%c", p1, ch, cat_term); @@ -10415,13 +10469,23 @@ static int newcat_set_apf_frequency(RIG *rig, vfo_t vfo, int freq) } // Range seems to be -250..250 Hz in 10 Hz steps - if (is_ftdx101d || is_ftdx101mp) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c3%04d%c", main_sub_vfo, (freq + 250) / 10, cat_term); - } else if (is_ftdx10 || is_ft991 || is_ft891) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO03%04d%c", (freq + 250) / 10, cat_term); - } else if (is_ftdx3000 || is_ftdx1200) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO02%02d%c", (freq + 250) / 10, cat_term); - } else { + if (is_ftdx101d || is_ftdx101mp) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c3%04d%c", main_sub_vfo, + (freq + 250) / 10, cat_term); + } + else if (is_ftdx10 || is_ft991 || is_ft891) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO03%04d%c", (freq + 250) / 10, + cat_term); + } + else if (is_ftdx3000 || is_ftdx1200) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO02%02d%c", (freq + 250) / 10, + cat_term); + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10441,13 +10505,21 @@ static int newcat_get_apf_frequency(RIG *rig, vfo_t vfo, int *freq) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c3%c", main_sub_vfo, cat_term); - } else if (is_ftdx10 || is_ft991 || is_ft891) { + if (is_ftdx101d || is_ftdx101mp) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c3%c", main_sub_vfo, + cat_term); + } + else if (is_ftdx10 || is_ft991 || is_ft891) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO03%c", cat_term); - } else if (is_ftdx3000 || is_ftdx1200) { + } + else if (is_ftdx3000 || is_ftdx1200) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO02%c", cat_term); - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10481,17 +10553,29 @@ static int newcat_set_apf_width(RIG *rig, vfo_t vfo, int choice) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030201%d%c", choice, cat_term); - } else if (is_ft991) { + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030201%d%c", choice, + cat_term); + } + else if (is_ft991) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX111%d%c", choice, cat_term); - } else if (is_ft891) { + } + else if (is_ft891) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1201%d%c", choice, cat_term); - } else if (is_ftdx5000) { + } + else if (is_ftdx5000) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX112%d%c", choice, cat_term); - } else if (is_ftdx3000 || is_ftdx1200) { + } + else if (is_ftdx3000 || is_ftdx1200) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX107%d%c", choice, cat_term); - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10510,17 +10594,28 @@ static int newcat_get_apf_width(RIG *rig, vfo_t vfo, int *choice) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030201%c", cat_term); - } else if (is_ft991) { + } + else if (is_ft991) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX111%c", cat_term); - } else if (is_ft891) { + } + else if (is_ft891) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1201%c", cat_term); - } else if (is_ftdx5000) { + } + else if (is_ftdx5000) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX112%c", cat_term); - } else if (is_ftdx3000 || is_ftdx1200) { + } + else if (is_ftdx3000 || is_ftdx1200) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX107%c", cat_term); - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10552,15 +10647,28 @@ static int newcat_set_contour(RIG *rig, vfo_t vfo, int status) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%04d%c", main_sub_vfo, status ? 1 : 0, cat_term); - } else if (is_ftdx10 || is_ft991 || is_ft891) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%04d%c", status ? 1 : 0, cat_term); - } else if (is_ftdx5000) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%02d%c", main_sub_vfo, status ? 1 : 0, cat_term); - } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%02d%c", status ? 1 : 0, cat_term); - } else { + if (is_ftdx101d || is_ftdx101mp) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%04d%c", main_sub_vfo, + status ? 1 : 0, cat_term); + } + else if (is_ftdx10 || is_ft991 || is_ft891) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%04d%c", status ? 1 : 0, + cat_term); + } + else if (is_ftdx5000) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%02d%c", main_sub_vfo, + status ? 1 : 0, cat_term); + } + else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%02d%c", status ? 1 : 0, + cat_term); + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10581,15 +10689,26 @@ static int newcat_get_contour(RIG *rig, vfo_t vfo, int *status) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%c", main_sub_vfo, cat_term); - } else if (is_ftdx10 || is_ft991 || is_ft891) { + if (is_ftdx101d || is_ftdx101mp) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%c", main_sub_vfo, + cat_term); + } + else if (is_ftdx10 || is_ft991 || is_ft891) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%c", cat_term); - } else if (is_ftdx5000) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%c", main_sub_vfo, cat_term); - } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + } + else if (is_ftdx5000) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c0%c", main_sub_vfo, + cat_term); + } + else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO00%c", cat_term); - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10623,19 +10742,31 @@ static int newcat_set_contour_frequency(RIG *rig, vfo_t vfo, int freq) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp) { + if (is_ftdx101d || is_ftdx101mp) + { // Range is 10..3200 Hz - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%04d%c", main_sub_vfo, freq, cat_term); - } else if (is_ftdx10 || is_ft991 || is_ft891) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%04d%c", main_sub_vfo, + freq, cat_term); + } + else if (is_ftdx10 || is_ft991 || is_ft891) + { // Range is 10..3200 Hz snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO01%04d%c", freq, cat_term); - } else if (is_ftdx5000) { + } + else if (is_ftdx5000) + { // Range is 100..4000 Hz in 100 Hz steps - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%01d%c", main_sub_vfo, freq / 100, cat_term); - } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%01d%c", main_sub_vfo, + freq / 100, cat_term); + } + else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) + { // Range is 100..4000 Hz in 100 Hz steps - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO01%02d%c", freq / 100, cat_term); - } else { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO01%02d%c", freq / 100, + cat_term); + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10655,15 +10786,26 @@ static int newcat_get_contour_frequency(RIG *rig, vfo_t vfo, int *freq) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%c", main_sub_vfo, cat_term); - } else if (is_ftdx10 || is_ft991 || is_ft891) { + if (is_ftdx101d || is_ftdx101mp) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%c", main_sub_vfo, + cat_term); + } + else if (is_ftdx10 || is_ft991 || is_ft891) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO01%c", cat_term); - } else if (is_ftdx5000) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%c", main_sub_vfo, cat_term); - } else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) { + } + else if (is_ftdx5000) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO%c1%c", main_sub_vfo, + cat_term); + } + else if (is_ftdx3000 || is_ftdx1200 || is_ft2000) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "CO01%c", cat_term); - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10682,11 +10824,16 @@ static int newcat_get_contour_frequency(RIG *rig, vfo_t vfo, int *freq) int raw_value = atoi(ret_data); - if (is_ftdx101d || is_ftdx101mp || is_ftdx10 || is_ft991 || is_ft891) { + if (is_ftdx101d || is_ftdx101mp || is_ftdx10 || is_ft991 || is_ft891) + { *freq = raw_value; - } else if (is_ftdx5000 || is_ftdx3000 || is_ftdx1200 || is_ft2000) { + } + else if (is_ftdx5000 || is_ftdx3000 || is_ftdx1200 || is_ft2000) + { *freq = raw_value * 100; - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10702,17 +10849,30 @@ static int newcat_set_contour_level(RIG *rig, vfo_t vfo, int level) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030202%+03d%c", level, cat_term); - } else if (is_ft991) { + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030202%+03d%c", level, + cat_term); + } + else if (is_ft991) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX112%+03d%c", level, cat_term); - } else if (is_ft891) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1202%+03d%c", level, cat_term); - } else if (is_ftdx5000) { + } + else if (is_ft891) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1202%+03d%c", level, + cat_term); + } + else if (is_ftdx5000) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX113%+03d%c", level, cat_term); - } else if (is_ftdx3000 || is_ftdx1200) { + } + else if (is_ftdx3000 || is_ftdx1200) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX108%+03d%c", level, cat_term); - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10731,17 +10891,28 @@ static int newcat_get_contour_level(RIG *rig, vfo_t vfo, int *level) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030202%c", cat_term); - } else if (is_ft991) { + } + else if (is_ft991) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX112%c", cat_term); - } else if (is_ft891) { + } + else if (is_ft891) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1202%c", cat_term); - } else if (is_ftdx5000) { + } + else if (is_ftdx5000) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX113%c", cat_term); - } else if (is_ftdx3000 || is_ftdx1200) { + } + else if (is_ftdx3000 || is_ftdx1200) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX108%c", cat_term); - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10772,17 +10943,29 @@ static int newcat_set_contour_width(RIG *rig, vfo_t vfo, int width) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { - snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030203%02d%c", width, cat_term); - } else if (is_ft991) { + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) + { + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030203%02d%c", width, + cat_term); + } + else if (is_ft991) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX113%02d%c", width, cat_term); - } else if (is_ft891) { + } + else if (is_ft891) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1203%02d%c", width, cat_term); - } else if (is_ftdx5000) { + } + else if (is_ftdx5000) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX114%02d%c", width, cat_term); - } else if (is_ftdx3000 || is_ftdx1200) { + } + else if (is_ftdx3000 || is_ftdx1200) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX109%02d%c", width, cat_term); - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10801,17 +10984,28 @@ static int newcat_get_contour_width(RIG *rig, vfo_t vfo, int *width) RETURNFUNC(-RIG_ENAVAIL); } - if (is_ftdx101d || is_ftdx101mp || is_ftdx10) { + if (is_ftdx101d || is_ftdx101mp || is_ftdx10) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX030203%c", cat_term); - } else if (is_ft991) { + } + else if (is_ft991) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX113%c", cat_term); - } else if (is_ft891) { + } + else if (is_ft891) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX1203%c", cat_term); - } else if (is_ftdx5000) { + } + else if (is_ftdx5000) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX114%c", cat_term); - } else if (is_ftdx3000 || is_ftdx1200) { + } + else if (is_ftdx3000 || is_ftdx1200) + { snprintf(priv->cmd_str, sizeof(priv->cmd_str), "EX109%c", cat_term); - } else { + } + else + { RETURNFUNC(-RIG_ENIMPL); } @@ -10832,3 +11026,112 @@ static int newcat_get_contour_width(RIG *rig, vfo_t vfo, int *width) RETURNFUNC(RIG_OK); } + +int newcat_set_clock(RIG *rig, int year, int month, int day, int hour, int min, + int sec, double msec, int utc_offset) +{ + int retval = RIG_OK; + int err; + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + + if (!newcat_valid_command(rig, "DT")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT0%04d%02d%02d%c", year, month, + day, cat_term); + + if (RIG_OK != (err = newcat_set_cmd(rig))) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s:%d command err = %d\n", __func__, __LINE__, + err); + RETURNFUNC(err); + } + + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT1%02d%02d%02d%c", hour, min, sec, cat_term); + + if (RIG_OK != (err = newcat_set_cmd(rig))) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s:%d command err = %d\n", __func__, __LINE__, + err); + RETURNFUNC(err); + } + + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT2%c%04d%c", utc_offset>=0?'+':'-', utc_offset, cat_term); + + if (RIG_OK != (err = newcat_set_cmd(rig))) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s:%d command err = %d\n", __func__, __LINE__, + err); + RETURNFUNC(err); + } + + RETURNFUNC(retval); +} + +int newcat_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, + int *min, int *sec, double *msec, int *utc_offset) +{ + int retval = RIG_OK; + int err; + int n; + struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv; + + if (!newcat_valid_command(rig, "DT")) + { + RETURNFUNC(-RIG_ENAVAIL); + } + + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT0%c", cat_term); + + if ((err = newcat_get_cmd(rig)) != RIG_OK) + { + RETURNFUNC(err); + } + + n = sscanf(priv->ret_data, "DT0%04d%02d%02d", year, month, day); + + if (n != 3) + { + rig_debug(RIG_DEBUG_ERR, "%s: DT0 unable to parse '%s'\n", __func__, + priv->ret_data); + RETURNFUNC(-RIG_EPROTO); + } + + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT1%c", cat_term); + + if ((err = newcat_get_cmd(rig)) != RIG_OK) + { + RETURNFUNC(err); + } + + n = sscanf(priv->ret_data, "DT1%02d%02d%02d", hour, min, sec); + + if (n != 3) + { + rig_debug(RIG_DEBUG_ERR, "%s: DT1 unable to parse '%s'\n", __func__, + priv->ret_data); + RETURNFUNC(-RIG_EPROTO); + } + + snprintf(priv->cmd_str, sizeof(priv->cmd_str), "DT2%c", cat_term); + + if ((err = newcat_get_cmd(rig)) != RIG_OK) + { + RETURNFUNC(err); + } + + // we keep utc_offset in HHMM format rather than converting + n = sscanf(priv->ret_data, "DT2%d", utc_offset); + + if (n != 1) + { + rig_debug(RIG_DEBUG_ERR, "%s: DT2 unable to parse '%s'\n", __func__, + priv->ret_data); + RETURNFUNC(-RIG_EPROTO); + } + + RETURNFUNC(retval); +} + diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 7daac8806..89108f4bd 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20211114" +#define NEWCAT_VER "20211202" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 @@ -222,6 +222,11 @@ int newcat_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val); int newcat_send_morse(RIG *rig, vfo_t vfo, const char *msg); int newcat_send_voice_mem(RIG *rig, vfo_t vfo, int ch); +int newcat_set_clock(RIG *rig, int year, int month, int day, int hour, int min, + int sec, double msec, int utc_offset); +int newcat_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, + int *min, int *sec, double *msec, int *utc_offset); + #define TOKEN_BACKEND(t) (t) diff --git a/rigs/yaesu/vx1700.c b/rigs/yaesu/vx1700.c index dcd6d9648..691229e58 100644 --- a/rigs/yaesu/vx1700.c +++ b/rigs/yaesu/vx1700.c @@ -46,100 +46,101 @@ #include "vx1700.h" // VX-1700 native commands -typedef enum vx1700_native_cmd_e { - VX1700_NATIVE_RECALL_MEM = 0, /* 0x02, p1=ch */ - VX1700_NATIVE_VFO_TO_MEM, /* 0x03, p1=ch, p2=0 */ - VX1700_NATIVE_MEM_HIDE, /* 0x03, p1=ch, p2=1 */ - VX1700_NATIVE_VFO_A, /* 0x05 */ - VX1700_NATIVE_FREQ_SET, /* 0x0a, p1:4=freq */ - VX1700_NATIVE_MODE_SET_LSB, /* 0x0c, p1=0x00 */ - VX1700_NATIVE_MODE_SET_USB, /* 0x0c, p1=0x01 */ - VX1700_NATIVE_MODE_SET_CW_W, /* 0x0c, p1=0x02 */ - VX1700_NATIVE_MODE_SET_CW_N, /* 0x0c, p1=0x03 */ - VX1700_NATIVE_MODE_SET_AM, /* 0x0c, p1=0x04 */ - VX1700_NATIVE_MODE_SET_RTTY_LSB_W, /* 0x0c, p1=0x08 */ - VX1700_NATIVE_MODE_SET_RTTY_USB_W, /* 0x0c, p1=0x09 */ - VX1700_NATIVE_MODE_SET_H3E, /* 0x0c, p1=0x0d */ - VX1700_NATIVE_MODE_SET_RTTY_LSB_N, /* 0x0c, p1=0x0e */ - VX1700_NATIVE_MODE_SET_RTTY_USB_N, /* 0x0c, p1=0x0f */ - VX1700_NATIVE_PTT_OFF, /* 0x0f, p1=0 */ - VX1700_NATIVE_PTT_ON, /* 0x0f, p1=1 */ - VX1700_NATIVE_UPDATE_MEM_CHNL, /* 0x10, p1=1 */ - VX1700_NATIVE_UPDATE_OP_DATA, /* 0x10, p1=2 */ - VX1700_NATIVE_UPDATE_VFO_DATA, /* 0x10, p1=3 */ - VX1700_NATIVE_TX_POWER_LOW, /* 0x18 */ - VX1700_NATIVE_TX_POWER_MID, /* 0x28 */ - VX1700_NATIVE_TX_POWER_HI, /* 0x48 */ - VX1700_NATIVE_CPY_RX_TO_TX, /* 0x85 */ - VX1700_NATIVE_TX_FREQ_SET, /* 0x8a, p1:4=freq */ - VX1700_NATIVE_OP_FREQ_STEP_UP, /* 0x8e, p1=0 */ - VX1700_NATIVE_OP_FREQ_STEP_DOWN, /* 0x8e, p1=1 */ - VX1700_NATIVE_READ_METER, /* 0xf7 */ - VX1700_NATIVE_READ_FLAGS, /* 0xfa */ +typedef enum vx1700_native_cmd_e +{ + VX1700_NATIVE_RECALL_MEM = 0, /* 0x02, p1=ch */ + VX1700_NATIVE_VFO_TO_MEM, /* 0x03, p1=ch, p2=0 */ + VX1700_NATIVE_MEM_HIDE, /* 0x03, p1=ch, p2=1 */ + VX1700_NATIVE_VFO_A, /* 0x05 */ + VX1700_NATIVE_FREQ_SET, /* 0x0a, p1:4=freq */ + VX1700_NATIVE_MODE_SET_LSB, /* 0x0c, p1=0x00 */ + VX1700_NATIVE_MODE_SET_USB, /* 0x0c, p1=0x01 */ + VX1700_NATIVE_MODE_SET_CW_W, /* 0x0c, p1=0x02 */ + VX1700_NATIVE_MODE_SET_CW_N, /* 0x0c, p1=0x03 */ + VX1700_NATIVE_MODE_SET_AM, /* 0x0c, p1=0x04 */ + VX1700_NATIVE_MODE_SET_RTTY_LSB_W, /* 0x0c, p1=0x08 */ + VX1700_NATIVE_MODE_SET_RTTY_USB_W, /* 0x0c, p1=0x09 */ + VX1700_NATIVE_MODE_SET_H3E, /* 0x0c, p1=0x0d */ + VX1700_NATIVE_MODE_SET_RTTY_LSB_N, /* 0x0c, p1=0x0e */ + VX1700_NATIVE_MODE_SET_RTTY_USB_N, /* 0x0c, p1=0x0f */ + VX1700_NATIVE_PTT_OFF, /* 0x0f, p1=0 */ + VX1700_NATIVE_PTT_ON, /* 0x0f, p1=1 */ + VX1700_NATIVE_UPDATE_MEM_CHNL, /* 0x10, p1=1 */ + VX1700_NATIVE_UPDATE_OP_DATA, /* 0x10, p1=2 */ + VX1700_NATIVE_UPDATE_VFO_DATA, /* 0x10, p1=3 */ + VX1700_NATIVE_TX_POWER_LOW, /* 0x18 */ + VX1700_NATIVE_TX_POWER_MID, /* 0x28 */ + VX1700_NATIVE_TX_POWER_HI, /* 0x48 */ + VX1700_NATIVE_CPY_RX_TO_TX, /* 0x85 */ + VX1700_NATIVE_TX_FREQ_SET, /* 0x8a, p1:4=freq */ + VX1700_NATIVE_OP_FREQ_STEP_UP, /* 0x8e, p1=0 */ + VX1700_NATIVE_OP_FREQ_STEP_DOWN, /* 0x8e, p1=1 */ + VX1700_NATIVE_READ_METER, /* 0xf7 */ + VX1700_NATIVE_READ_FLAGS, /* 0xfa */ VX1700_NATIVE_SIZE } vx1700_native_cmd_t; // OpCode Declarations -#define VX1700_CMD_RECALLMEM 0x02 -#define VX1700_CMD_VFO2MEM 0x03 -#define VX1700_CMD_SEL_VFOA 0x05 -#define VX1700_CMD_SET_VFOA 0x0a -#define VX1700_CMD_SEL_OP_MODE 0x0c -#define VX1700_CMD_PTT 0x0f -#define VX1700_CMD_UPDATE 0x10 -#define VX1700_CMD_RX2TX 0x85 -#define VX1700_CMD_STEP_VFO 0x8e -#define VX1700_CMD_RD_METER 0xf7 -#define VX1700_CMD_RD_FLAGS 0xfa +#define VX1700_CMD_RECALLMEM 0x02 +#define VX1700_CMD_VFO2MEM 0x03 +#define VX1700_CMD_SEL_VFOA 0x05 +#define VX1700_CMD_SET_VFOA 0x0a +#define VX1700_CMD_SEL_OP_MODE 0x0c +#define VX1700_CMD_PTT 0x0f +#define VX1700_CMD_UPDATE 0x10 +#define VX1700_CMD_RX2TX 0x85 +#define VX1700_CMD_STEP_VFO 0x8e +#define VX1700_CMD_RD_METER 0xf7 +#define VX1700_CMD_RD_FLAGS 0xfa // Return codes -#define VX1700_CMD_RETCODE_OK 0x00 -#define VX1700_CMD_RETCODE_ERROR 0xF0 +#define VX1700_CMD_RETCODE_OK 0x00 +#define VX1700_CMD_RETCODE_ERROR 0xF0 // Operating Mode Status -#define VX1700_MODE_LSB 0x00 -#define VX1700_MODE_USB 0x01 -#define VX1700_MODE_CW_W 0x02 -#define VX1700_MODE_CW_N 0x03 -#define VX1700_MODE_AM 0x04 -#define VX1700_MODE_RTTY 0x05 +#define VX1700_MODE_LSB 0x00 +#define VX1700_MODE_USB 0x01 +#define VX1700_MODE_CW_W 0x02 +#define VX1700_MODE_CW_N 0x03 +#define VX1700_MODE_AM 0x04 +#define VX1700_MODE_RTTY 0x05 // Operation Mode Selection -#define VX1700_OP_MODE_LSB 0x00 -#define VX1700_OP_MODE_USB 0x01 -#define VX1700_OP_MODE_CW_W 0x02 -#define VX1700_OP_MODE_CW_N 0x03 -#define VX1700_OP_MODE_AM 0x04 -#define VX1700_OP_MODE_RTTY_LSB_W 0x08 -#define VX1700_OP_MODE_RTTY_USB_W 0x09 -#define VX1700_OP_MODE_H3E 0x0d -#define VX1700_OP_MODE_RTTY_LSB_N 0x0e -#define VX1700_OP_MODE_RTTY_USB_N 0x0f +#define VX1700_OP_MODE_LSB 0x00 +#define VX1700_OP_MODE_USB 0x01 +#define VX1700_OP_MODE_CW_W 0x02 +#define VX1700_OP_MODE_CW_N 0x03 +#define VX1700_OP_MODE_AM 0x04 +#define VX1700_OP_MODE_RTTY_LSB_W 0x08 +#define VX1700_OP_MODE_RTTY_USB_W 0x09 +#define VX1700_OP_MODE_H3E 0x0d +#define VX1700_OP_MODE_RTTY_LSB_N 0x0e +#define VX1700_OP_MODE_RTTY_USB_N 0x0f // Status Flag 1 Masks -#define VX1700_SF_LOCKED 0x01 /* LOCK is activated */ -#define VX1700_SF_MEM 0x20 /* Memory Mode */ -#define VX1700_SF_VFO 0x80 /* VFO Mode */ +#define VX1700_SF_LOCKED 0x01 /* LOCK is activated */ +#define VX1700_SF_MEM 0x20 /* Memory Mode */ +#define VX1700_SF_VFO 0x80 /* VFO Mode */ // Status Flag 2 Masks -#define VX1700_SF_PTT_BY_CAT 0x01 /* PTT closed by CAT */ -#define VX1700_SF_MEM_SCAN_PAUSE 0x02 /* Scanning paused */ -#define VX1700_SF_MEM_SCAN 0x04 /* Scanning enabled */ -#define VX1700_SF_RTTY_FILTER_NARROW 0x08 /* Narrow RTTY filter selected */ -#define VX1700_SF_CW_FILTER_NARROW 0x10 /* Narrow CW filter selected */ -#define VX1700_SF_RTTY_USB 0x20 /* USB selected for RTTY */ +#define VX1700_SF_PTT_BY_CAT 0x01 /* PTT closed by CAT */ +#define VX1700_SF_MEM_SCAN_PAUSE 0x02 /* Scanning paused */ +#define VX1700_SF_MEM_SCAN 0x04 /* Scanning enabled */ +#define VX1700_SF_RTTY_FILTER_NARROW 0x08 /* Narrow RTTY filter selected */ +#define VX1700_SF_CW_FILTER_NARROW 0x10 /* Narrow CW filter selected */ +#define VX1700_SF_RTTY_USB 0x20 /* USB selected for RTTY */ // Status Flag 3 Masks -#define VX1700_SF_10W_TX 0x20 /* 10 Watt TX output selected */ -#define VX1700_SF_TUNER_ON 0x20 /* Antenna Tuner working */ -#define VX1700_SF_TRANSMISSION_ON 0x80 /* Transmission in progress */ +#define VX1700_SF_10W_TX 0x20 /* 10 Watt TX output selected */ +#define VX1700_SF_TUNER_ON 0x20 /* Antenna Tuner working */ +#define VX1700_SF_TRANSMISSION_ON 0x80 /* Transmission in progress */ /* HAMLIB API implementation */ static int vx1700_init(RIG *rig); static int vx1700_open(RIG *rig); static int vx1700_cleanup(RIG *rig); -static const char * vx1700_get_info(RIG *rig); +static const char *vx1700_get_info(RIG *rig); static int vx1700_set_vfo(RIG *rig, vfo_t vfo); static int vx1700_get_vfo(RIG *rig, vfo_t *vfo); @@ -148,7 +149,8 @@ static int vx1700_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); static int vx1700_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq); static int vx1700_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq); static int vx1700_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); -static int vx1700_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int vx1700_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); static int vx1700_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); static int vx1700_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); static int vx1700_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); diff --git a/rotators/celestron/celestron.c b/rotators/celestron/celestron.c index 390006e7a..056c4ad51 100644 --- a/rotators/celestron/celestron.c +++ b/rotators/celestron/celestron.c @@ -92,7 +92,7 @@ transaction_write: /* the answer */ memset(data, 0, data_len); - retval = read_string(&rs->rotport, data, data_len, ACK, strlen(ACK), 0); + retval = read_string(&rs->rotport, data, data_len, ACK, strlen(ACK), 0, 1); if (retval < 0) { diff --git a/rotators/easycomm/easycomm.c b/rotators/easycomm/easycomm.c index 8facdefd8..e524e69b3 100644 --- a/rotators/easycomm/easycomm.c +++ b/rotators/easycomm/easycomm.c @@ -79,7 +79,7 @@ easycomm_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len) return RIG_OK; /* don't want a reply */ } - retval = read_string(&rs->rotport, data, data_len, "\n", 1, 0); + retval = read_string(&rs->rotport, data, data_len, "\n", 1, 0, 1); if (retval < 0) { diff --git a/rotators/ether6/ether6.c b/rotators/ether6/ether6.c index 77583f462..93af20b7b 100644 --- a/rotators/ether6/ether6.c +++ b/rotators/ether6/ether6.c @@ -60,7 +60,7 @@ static int ether_transaction(ROT *rot, char *cmd, int len, char *buf) return ret; } - ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0); + ret = read_string(&rot->state.rotport, buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); rig_debug(RIG_DEBUG_VERBOSE, "function %s(2): ret=%d || receive=%s\n", __func__, ret, buf); diff --git a/rotators/gs232a/gs232.c b/rotators/gs232a/gs232.c index 8cd946ce3..88a486def 100644 --- a/rotators/gs232a/gs232.c +++ b/rotators/gs232a/gs232.c @@ -94,7 +94,7 @@ transaction_write: memset(data, 0, data_len); retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, - strlen(REPLY_EOM), 0); + strlen(REPLY_EOM), 0, 1); if (retval < 0) { diff --git a/rotators/gs232a/gs232a.c b/rotators/gs232a/gs232a.c index 6def6bb32..783184007 100644 --- a/rotators/gs232a/gs232a.c +++ b/rotators/gs232a/gs232a.c @@ -104,7 +104,7 @@ transaction_write: { memset(data, 0, data_len); retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, - strlen(REPLY_EOM), 0); + strlen(REPLY_EOM), 0, 1); if (strncmp(data, "\r\n", 2) == 0 || strchr(data, '>')) diff --git a/rotators/gs232a/gs232b.c b/rotators/gs232a/gs232b.c index 38002c88e..b8ecf6b7e 100644 --- a/rotators/gs232a/gs232b.c +++ b/rotators/gs232a/gs232b.c @@ -104,7 +104,7 @@ transaction_write: memset(data, 0, data_len); retval = read_string(&rs->rotport, data, data_len, REPLY_EOM, - strlen(REPLY_EOM), 0); + strlen(REPLY_EOM), 0, 1); if (strncmp(data, "\r\n", 2) == 0 || strchr(data, '>')) { diff --git a/rotators/ioptron/rot_ioptron.c b/rotators/ioptron/rot_ioptron.c index d28c3f0ba..12fa96f12 100644 --- a/rotators/ioptron/rot_ioptron.c +++ b/rotators/ioptron/rot_ioptron.c @@ -108,7 +108,7 @@ transaction_write: /** the answer */ memset(data, 0, data_len); - retval = read_string(&rs->rotport, data, data_len, ACK, strlen(ACK), 0); + retval = read_string(&rs->rotport, data, data_len, ACK, strlen(ACK), 0, 1); if (retval < 0) { diff --git a/rotators/m2/rc2800.c b/rotators/m2/rc2800.c index 9f82705d9..ea39f8f49 100644 --- a/rotators/m2/rc2800.c +++ b/rotators/m2/rc2800.c @@ -204,13 +204,13 @@ transaction_write: /* then comes the answer */ memset(data, 0, data_len); - retval = read_string(&rs->rotport, data, data_len, CR, strlen(CR), 0); + retval = read_string(&rs->rotport, data, data_len, CR, strlen(CR), 0, 1); // some models seem to echo -- so we'll check and read again if echoed if (cmdstr && strcmp(data, cmdstr) == 0) { memset(data, 0, data_len); - retval = read_string(&rs->rotport, data, data_len, CR, strlen(CR), 0); + retval = read_string(&rs->rotport, data, data_len, CR, strlen(CR), 0, 1); } if (retval < 0) diff --git a/rotators/meade/meade.c b/rotators/meade/meade.c index ab740b4f3..c05dc1c90 100644 --- a/rotators/meade/meade.c +++ b/rotators/meade/meade.c @@ -129,7 +129,7 @@ transaction: if (data != NULL) { return_value = read_string(&rs->rotport, data, expected_return_length + 1, - "\r\n", strlen("\r\n"), 0); + "\r\n", strlen("\r\n"), 0, 1); if (return_value > 0) { diff --git a/rotators/prosistel/prosistel.c b/rotators/prosistel/prosistel.c index 02bd414c6..74bbac099 100644 --- a/rotators/prosistel/prosistel.c +++ b/rotators/prosistel/prosistel.c @@ -98,7 +98,7 @@ transaction_write: } // Remember to check for STXA,G,R or STXA,?,XXX,R 10 bytes - retval = read_string(&rs->rotport, data, 20, CR, strlen(CR), 0); + retval = read_string(&rs->rotport, data, 20, CR, strlen(CR), 0, 1); if (retval < 0) { diff --git a/rotators/radant/radant.c b/rotators/radant/radant.c index ca7e4bc2d..c37ec48b2 100644 --- a/rotators/radant/radant.c +++ b/rotators/radant/radant.c @@ -79,7 +79,7 @@ radant_transaction(ROT *rot, const char *cmdstr, char *data, size_t data_len) return RIG_OK; /* don't want a reply */ } - retval = read_string(&rs->rotport, data, data_len, "\n", 1, 0); + retval = read_string(&rs->rotport, data, data_len, "\n", 1, 0, 1); if (retval < 0) { diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c index 5de52b704..5666d920a 100644 --- a/rotators/rotorez/rotorez.c +++ b/rotators/rotorez/rotorez.c @@ -763,7 +763,7 @@ static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth, rs = &rot->state; - err = read_string(&rs->rotport, az, RT21_AZ_LEN + 1, ";", strlen(";"), 0); + err = read_string(&rs->rotport, az, RT21_AZ_LEN + 1, ";", strlen(";"), 0, 1); if (err < 0) /* read_string returns negative on error. */ { diff --git a/rotators/satel/satel.c b/rotators/satel/satel.c index fdd009050..d5231c960 100644 --- a/rotators/satel/satel.c +++ b/rotators/satel/satel.c @@ -137,7 +137,7 @@ static int satel_cmd(ROT *rot, char *cmd, int cmdlen, char *res, int reslen) if (reslen > 0 && res != NULL) { - ret = read_string(&rs->rotport, res, reslen, "\n", 1, 0); + ret = read_string(&rs->rotport, res, reslen, "\n", 1, 0, 1); if (ret < 0) { @@ -163,7 +163,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat) // read motion state - ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0); + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1); if (ret < 0) { @@ -173,7 +173,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat) stat->motion_enabled = strcmp(resbuf, "Motion ENABLED") == 0 ? true : false; // XXX skip mode - ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0); + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1); if (ret < 0) { @@ -181,7 +181,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat) } // XXX skip time - ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0); + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1); if (ret < 0) { @@ -189,7 +189,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat) } // read azimuth line - ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0); + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1); if (ret < 0) { @@ -201,7 +201,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat) stat->az = (int)strtof(p, NULL); // read elevation line - ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0); + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1); if (ret < 0) { @@ -213,7 +213,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat) stat->el = (int)strtof(p, NULL); // skip blank line - ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0); + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1); if (ret < 0) { @@ -221,7 +221,7 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat) } // XXX skip stored position count - ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0); + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1, 0, 1); if (ret < 0) { diff --git a/simulators/simft991.c b/simulators/simft991.c new file mode 100644 index 000000000..0417247cb --- /dev/null +++ b/simulators/simft991.c @@ -0,0 +1,207 @@ +// can run this using rigctl/rigctld and socat pty devices +// gcc -o simyaesu simyaesu.c +#define _XOPEN_SOURCE 600 +#include +#include +#include +#include +#include + +#define BUFSIZE 256 + +float freqA = 14074000; +float freqB = 14074500; + +// ID 0310 == 310, Must drop leading zero +typedef enum nc_rigid_e +{ + NC_RIGID_NONE = 0, + NC_RIGID_FT450 = 241, + NC_RIGID_FT450D = 244, + NC_RIGID_FT950 = 310, + NC_RIGID_FT891 = 135, + NC_RIGID_FT991 = 135, + NC_RIGID_FT2000 = 251, + NC_RIGID_FT2000D = 252, + NC_RIGID_FTDX1200 = 583, + NC_RIGID_FTDX9000D = 101, + NC_RIGID_FTDX9000Contest = 102, + NC_RIGID_FTDX9000MP = 103, + NC_RIGID_FTDX5000 = 362, + NC_RIGID_FTDX3000 = 460, + NC_RIGID_FTDX101D = 681, + NC_RIGID_FTDX101MP = 682 +} nc_rigid_t; + +int +getmyline(int fd, char *buf) +{ + char c; + int i = 0; + memset(buf, 0, BUFSIZE); + + while (read(fd, &c, 1) > 0) + { + buf[i++] = c; + + if (c == ';') { return strlen(buf); } + } + + return strlen(buf); +} + +#if defined(WIN32) || defined(_WIN32) +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd; + fd = open(comport, O_RDWR); + + if (fd < 0) + { + perror(comport); + } + + return fd; +} + +#else +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd = posix_openpt(O_RDWR); + char *name = ptsname(fd); + + if (name == NULL) + { + perror("pstname"); + return -1; + } + + printf("name=%s\n", name); + + if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) + { + perror("posix_openpt"); + return -1; + } + + return fd; +} +#endif + + + +int main(int argc, char *argv[]) +{ + char buf[256]; + char *pbuf; + int n; + int fd = openPort(argv[1]); + + while (1) + { + if (getmyline(fd, buf)) + { + printf("Cmd:%s\n", buf); + } + else { return 0; } + + if (strcmp(buf, "RM5;") == 0) + { + printf("%s\n", buf); + usleep(50 * 1000); + pbuf = "RM5100000;"; + n = write(fd, pbuf, strlen(pbuf)); + printf("n=%d\n", n); + + if (n <= 0) { perror("RM5"); } + } + + if (strcmp(buf, "AN0;") == 0) + { + printf("%s\n", buf); + usleep(50 * 1000); + pbuf = "AN030;"; + n = write(fd, pbuf, strlen(pbuf)); + printf("n=%d\n", n); + + if (n <= 0) { perror("AN"); } + } + else if (strcmp(buf, "IF;") == 0) + { + printf("%s\n", buf); + usleep(50 * 1000); + pbuf = "IF059014200000+000000700000;"; + n = write(fd, pbuf, strlen(pbuf)); + printf("n=%d\n", n); + + if (n <= 0) { perror("IF"); } + } + else if (strcmp(buf, "ID;") == 0) + { + printf("%s\n", buf); + usleep(50 * 1000); + int id = NC_RIGID_FTDX3000; + snprintf(buf, sizeof(buf), "ID%03d;", id); + n = write(fd, buf, strlen(buf)); + printf("n=%d\n", n); + + if (n <= 0) { perror("ID"); } + } + else if (strcmp(buf, "AI;") == 0) + { + printf("%s\n", buf); + usleep(50 * 1000); + snprintf(buf, sizeof(buf), "AI0;"); + n = write(fd, buf, strlen(buf)); + printf("n=%d\n", n); + + if (n <= 0) { perror("ID"); } + } + +#if 0 + else if (strncmp(buf, "AI", 2) == 0) + { + if (strcmp(buf, "AI;")) + { + printf("%s\n", buf); + usleep(50 * 1000); + n = fprintf(fp, "%s", "AI0;"); + printf("n=%d\n", n); + + if (n <= 0) { perror("AI"); } + } + } + +#endif + else if (strcmp(buf, "VS;") == 0) + { + printf("%s\n", buf); + usleep(50 * 1000); + pbuf = "VS0;"; + n = write(fd, pbuf, strlen(pbuf)); + printf("n=%d\n", n); + + if (n < 0) { perror("VS"); } + } + else if (strcmp(buf, "EX032;") == 0) + { + static int ant = 0; + ant = (ant + 1) % 3; + printf("%s\n", buf); + usleep(50 * 1000); + snprintf(buf, sizeof(buf), "EX032%1d;", ant); + n = write(fd, buf, strlen(buf)); + printf("n=%d\n", n); + + if (n < 0) { perror("EX032"); } + } + + else if (strlen(buf) > 0) + { + fprintf(stderr, "Unknown command: %s\n", buf); + } + + } + + return 0; +} diff --git a/simulators/simicom.c b/simulators/simicom.c index 23acb6df3..a134c9b69 100644 --- a/simulators/simicom.c +++ b/simulators/simicom.c @@ -194,6 +194,7 @@ void frameParse(int fd, unsigned char *frame, int len) frame[7] = 0xfd; write(fd, frame, 8); break; + case 0x07: // satmode frame[6] = 0; frame[7] = 0xfd; @@ -237,6 +238,7 @@ void frameParse(int fd, unsigned char *frame, int len) break; #else + case 0x25: frame[4] = 0xfa; frame[5] = 0xfd; diff --git a/simulators/simkenwood.c b/simulators/simkenwood.c index 1879bfb05..d8b80e3f7 100644 --- a/simulators/simkenwood.c +++ b/simulators/simkenwood.c @@ -11,6 +11,7 @@ float freqA = 14074000; float freqB = 14074500; +int filternum = 7; // ID 0310 == 310, Must drop leading zero typedef enum nc_rigid_e @@ -97,6 +98,7 @@ int main(int argc, char *argv[]) int n; int fd = openPort(argv[1]); int freqa = 14074000, freqb = 140735000; + int modeA = 0; // , modeB = 0; while (1) { @@ -203,11 +205,35 @@ int main(int argc, char *argv[]) { sscanf(buf, "FB%d", &freqb); } - else if (strncmp(buf, "AI;", 2) == 0) + else if (strncmp(buf, "AI;", 3) == 0) { sprintf(buf, "AI0;"); write(fd, buf, strlen(buf)); } + else if (strncmp(buf, "SA;", 3) == 0) + { + sprintf(buf, "SA0;"); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "MD;", 3) == 0) + { + sprintf(buf, "MD%d;", modeA); // not worried about modeB yet for simulator + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "MD", 2) == 0) + { + sscanf(buf, "MD%d", &modeA); // not worried about modeB yet for simulator + } + else if (strncmp(buf, "FL;", 3) == 0) + { + sprintf(buf, "FL%03d;", filternum); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "FL", 2) == 0) + { + sscanf(buf, "FL%d", &filternum); + } + else if (strlen(buf) > 0) diff --git a/simulators/simyaesu.c b/simulators/simyaesu.c index 7622c407c..bdb6e5cd1 100644 --- a/simulators/simyaesu.c +++ b/simulators/simyaesu.c @@ -130,23 +130,23 @@ int main(int argc, char *argv[]) } else if (strcmp(buf, "FA;") == 0) { - pbuf=strdup("FA3456789012;"); - sprintf(pbuf,"FA%010.0f", freqA); + pbuf = strdup("FA3456789012;"); + sprintf(pbuf, "FA%010.0f", freqA); free(pbuf); } - else if (strncmp(buf, "FA",2)==0) + else if (strncmp(buf, "FA", 2) == 0) { - sscanf(buf,"FA%f",&freqA); + sscanf(buf, "FA%f", &freqA); } else if (strcmp(buf, "FB;") == 0) { - pbuf=strdup("FB3456789012;"); - sprintf(pbuf,"FB%010.0f", freqB); + pbuf = strdup("FB3456789012;"); + sprintf(pbuf, "FB%010.0f", freqB); free(pbuf); } - else if (strncmp(buf, "FB",2)==0) + else if (strncmp(buf, "FB", 2) == 0) { - sscanf(buf,"FB%f",&freqB); + sscanf(buf, "FB%f", &freqB); } else if (strcmp(buf, "IF;") == 0) { @@ -205,20 +205,22 @@ int main(int argc, char *argv[]) if (n < 0) { perror("VS"); } } - else if (strcmp(buf, "FT;")==0) + else if (strcmp(buf, "FT;") == 0) { - usleep(50*1000); + usleep(50 * 1000); pbuf = strdup("FTx;"); pbuf[2] = tx_vfo; n = write(fd, pbuf, strlen(pbuf)); free(pbuf); + if (n < 0) { perror("FT"); } } else if (strncmp(buf, "FT", 2) == 0) { tx_vfo = buf[2]; - if (tx_vfo == '3') tx_vfo = '1'; - else if (tx_vfo == '2') tx_vfo = '0'; + + if (tx_vfo == '3') { tx_vfo = '1'; } + else if (tx_vfo == '2') { tx_vfo = '0'; } else { perror("Expected 2 or 3"); } } else if (strcmp(buf, "EX032;") == 0) diff --git a/src/cache.c b/src/cache.c index c359b4734..4ae32fed1 100644 --- a/src/cache.c +++ b/src/cache.c @@ -49,50 +49,50 @@ int rig_set_cache_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) switch (vfo) { - case RIG_VFO_ALL: // we'll use NONE to reset all VFO caches - elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE); - break; + case RIG_VFO_ALL: // we'll use NONE to reset all VFO caches + elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE); + break; - case RIG_VFO_A: - case RIG_VFO_MAIN: - case RIG_VFO_MAIN_A: - rig->state.cache.modeMainA = mode; + case RIG_VFO_A: + case RIG_VFO_MAIN: + case RIG_VFO_MAIN_A: + rig->state.cache.modeMainA = mode; - if (width > 0) { rig->state.cache.widthMainA = width; } + if (width > 0) { rig->state.cache.widthMainA = width; } - elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_SET); - elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_SET); - break; + elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_SET); + elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_SET); + break; - case RIG_VFO_B: - case RIG_VFO_SUB: - case RIG_VFO_MAIN_B: - rig->state.cache.modeMainB = mode; + case RIG_VFO_B: + case RIG_VFO_SUB: + case RIG_VFO_MAIN_B: + rig->state.cache.modeMainB = mode; - if (width > 0) { rig->state.cache.widthMainB = width; } + if (width > 0) { rig->state.cache.widthMainB = width; } - elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_SET); - elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_SET); - break; + elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_SET); + elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_SET); + break; - case RIG_VFO_C: - case RIG_VFO_MAIN_C: - rig->state.cache.modeMainC = mode; + case RIG_VFO_C: + case RIG_VFO_MAIN_C: + rig->state.cache.modeMainC = mode; - if (width > 0) { rig->state.cache.widthMainC = width; } + if (width > 0) { rig->state.cache.widthMainC = width; } - elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_SET); - elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_SET); - break; + elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_SET); + elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_SET); + break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=%s\n", __func__, rig_strvfo(vfo)); - RETURNFUNC(-RIG_EINTERNAL); + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=%s\n", __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINTERNAL); } rig_cache_show(rig, __func__, __LINE__); @@ -110,7 +110,7 @@ int rig_set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq) } rig_debug(RIG_DEBUG_CACHE, "%s: vfo=%s, current_vfo=%s\n", __func__, - rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); + rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); if (vfo == RIG_VFO_CURR) { @@ -129,74 +129,74 @@ int rig_set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq) if (rig_need_debug(RIG_DEBUG_CACHE)) { rig_debug(RIG_DEBUG_CACHE, "%s: set vfo=%s to freq=%.0f\n", __func__, - rig_strvfo(vfo), freq); + rig_strvfo(vfo), freq); } switch (vfo) { - case RIG_VFO_ALL: // we'll use NONE to reset all VFO caches - elapsed_ms(&rig->state.cache.time_freqMainA, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_freqMainB, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_freqMainC, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_freqSubA, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_freqSubB, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_freqSubC, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_freqMem, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_vfo, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_INVALIDATE); - elapsed_ms(&rig->state.cache.time_split, HAMLIB_ELAPSED_INVALIDATE); - break; + case RIG_VFO_ALL: // we'll use NONE to reset all VFO caches + elapsed_ms(&rig->state.cache.time_freqMainA, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_freqMainB, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_freqMainC, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_freqSubA, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_freqSubB, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_freqSubC, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_freqMem, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_vfo, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_modeMainA, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_modeMainB, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_modeMainC, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_widthMainA, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_widthMainB, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_INVALIDATE); + elapsed_ms(&rig->state.cache.time_split, HAMLIB_ELAPSED_INVALIDATE); + break; - case RIG_VFO_A: - case RIG_VFO_MAIN: - case RIG_VFO_MAIN_A: - rig->state.cache.freqMainA = freq; - elapsed_ms(&rig->state.cache.time_freqMainA, flag); - break; + case RIG_VFO_A: + case RIG_VFO_MAIN: + case RIG_VFO_MAIN_A: + rig->state.cache.freqMainA = freq; + elapsed_ms(&rig->state.cache.time_freqMainA, flag); + break; - case RIG_VFO_B: - case RIG_VFO_MAIN_B: - case RIG_VFO_SUB: - rig->state.cache.freqMainB = freq; - elapsed_ms(&rig->state.cache.time_freqMainB, flag); - break; + case RIG_VFO_B: + case RIG_VFO_MAIN_B: + case RIG_VFO_SUB: + rig->state.cache.freqMainB = freq; + elapsed_ms(&rig->state.cache.time_freqMainB, flag); + break; - case RIG_VFO_C: - case RIG_VFO_MAIN_C: - rig->state.cache.freqMainC = freq; - elapsed_ms(&rig->state.cache.time_freqMainC, flag); - break; + case RIG_VFO_C: + case RIG_VFO_MAIN_C: + rig->state.cache.freqMainC = freq; + elapsed_ms(&rig->state.cache.time_freqMainC, flag); + break; - case RIG_VFO_SUB_A: - rig->state.cache.freqSubA = freq; - elapsed_ms(&rig->state.cache.time_freqSubA, flag); - break; + case RIG_VFO_SUB_A: + rig->state.cache.freqSubA = freq; + elapsed_ms(&rig->state.cache.time_freqSubA, flag); + break; - case RIG_VFO_SUB_B: - rig->state.cache.freqSubB = freq; - elapsed_ms(&rig->state.cache.time_freqSubB, flag); - break; + case RIG_VFO_SUB_B: + rig->state.cache.freqSubB = freq; + elapsed_ms(&rig->state.cache.time_freqSubB, flag); + break; - case RIG_VFO_SUB_C: - rig->state.cache.freqSubC = freq; - elapsed_ms(&rig->state.cache.time_freqSubC, flag); - break; + case RIG_VFO_SUB_C: + rig->state.cache.freqSubC = freq; + elapsed_ms(&rig->state.cache.time_freqSubC, flag); + break; - case RIG_VFO_MEM: - rig->state.cache.freqMem = freq; - elapsed_ms(&rig->state.cache.time_freqMem, flag); - break; + case RIG_VFO_MEM: + rig->state.cache.freqMem = freq; + elapsed_ms(&rig->state.cache.time_freqMem, flag); + break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo?, vfo=%s\n", __func__, - rig_strvfo(vfo)); - RETURNFUNC(-RIG_EINVAL); + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo?, vfo=%s\n", __func__, + rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); } if (rig_need_debug(RIG_DEBUG_CACHE)) @@ -205,7 +205,7 @@ int rig_set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq) RETURNFUNC(RIG_OK); } - return RIG_OK; + RETURNFUNC(RIG_OK); } /** @@ -230,10 +230,10 @@ int rig_set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq) * */ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq, - rmode_t *mode, int *cache_ms_mode, pbwidth_t *width, int *cache_ms_width) + rmode_t *mode, int *cache_ms_mode, pbwidth_t *width, int *cache_ms_width) { if (CHECK_RIG_ARG(rig) || !freq || !cache_ms_freq || - !mode || !cache_ms_mode || !width || !cache_ms_width) + !mode || !cache_ms_mode || !width || !cache_ms_width) { RETURNFUNC(-RIG_EINVAL); } @@ -244,7 +244,7 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq, } rig_debug(RIG_DEBUG_CACHE, "%s: vfo=%s, current_vfo=%s\n", __func__, - rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); + rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); if (vfo == RIG_VFO_CURR) { @@ -252,32 +252,40 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq, } else if (vfo == RIG_VFO_OTHER) { - switch (vfo) + switch (rig->state.current_vfo) { case RIG_VFO_OTHER: vfo = RIG_VFO_OTHER; break; + case RIG_VFO_A: vfo = RIG_VFO_B; break; + case RIG_VFO_MAIN_A: vfo = RIG_VFO_MAIN_B; break; + case RIG_VFO_MAIN: vfo = RIG_VFO_SUB; break; + case RIG_VFO_B: vfo = RIG_VFO_A; break; + case RIG_VFO_MAIN_B: vfo = RIG_VFO_MAIN_A; break; + case RIG_VFO_SUB_A: vfo = RIG_VFO_SUB_B; break; + case RIG_VFO_SUB_B: vfo = RIG_VFO_SUB_A; break; + default: rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo=%s\n", __func__, rig_strvfo(vfo)); } @@ -291,123 +299,126 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq, switch (vfo) { - case RIG_VFO_CURR: - *freq = rig->state.cache.freqCurr; - *mode = rig->state.cache.modeCurr; - *width = rig->state.cache.widthCurr; - *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqCurr, - HAMLIB_ELAPSED_GET); - *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeCurr, - HAMLIB_ELAPSED_GET); - *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthCurr, - HAMLIB_ELAPSED_GET); - break; - case RIG_VFO_OTHER: - *freq = rig->state.cache.freqOther; - *mode = rig->state.cache.modeOther; - *width = rig->state.cache.widthOther; - *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqOther, - HAMLIB_ELAPSED_GET); - *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeOther, - HAMLIB_ELAPSED_GET); - *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthOther, - HAMLIB_ELAPSED_GET); - break; - case RIG_VFO_A: - case RIG_VFO_MAIN: - case RIG_VFO_MAIN_A: - *freq = rig->state.cache.freqMainA; - *mode = rig->state.cache.modeMainA; - *width = rig->state.cache.widthMainA; - *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainA, - HAMLIB_ELAPSED_GET); - *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainA, - HAMLIB_ELAPSED_GET); - *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainA, - HAMLIB_ELAPSED_GET); - break; + case RIG_VFO_CURR: + *freq = rig->state.cache.freqCurr; + *mode = rig->state.cache.modeCurr; + *width = rig->state.cache.widthCurr; + *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqCurr, + HAMLIB_ELAPSED_GET); + *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeCurr, + HAMLIB_ELAPSED_GET); + *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthCurr, + HAMLIB_ELAPSED_GET); + break; - case RIG_VFO_B: - case RIG_VFO_SUB: - case RIG_VFO_MAIN_B: - *freq = rig->state.cache.freqMainB; - *mode = rig->state.cache.modeMainB; - *width = rig->state.cache.widthMainB; - *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainB, - HAMLIB_ELAPSED_GET); - *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainB, - HAMLIB_ELAPSED_GET); - *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainB, - HAMLIB_ELAPSED_GET); - break; + case RIG_VFO_OTHER: + *freq = rig->state.cache.freqOther; + *mode = rig->state.cache.modeOther; + *width = rig->state.cache.widthOther; + *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqOther, + HAMLIB_ELAPSED_GET); + *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeOther, + HAMLIB_ELAPSED_GET); + *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthOther, + HAMLIB_ELAPSED_GET); + break; - case RIG_VFO_SUB_A: - *freq = rig->state.cache.freqSubA; - *mode = rig->state.cache.modeSubA; - *width = rig->state.cache.widthSubA; - *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubA, - HAMLIB_ELAPSED_GET); - *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubA, - HAMLIB_ELAPSED_GET); - *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubA, - HAMLIB_ELAPSED_GET); - break; + case RIG_VFO_A: + case RIG_VFO_MAIN: + case RIG_VFO_MAIN_A: + *freq = rig->state.cache.freqMainA; + *mode = rig->state.cache.modeMainA; + *width = rig->state.cache.widthMainA; + *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainA, + HAMLIB_ELAPSED_GET); + *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainA, + HAMLIB_ELAPSED_GET); + *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainA, + HAMLIB_ELAPSED_GET); + break; - case RIG_VFO_SUB_B: - *freq = rig->state.cache.freqSubB; - *mode = rig->state.cache.modeSubB; - *width = rig->state.cache.widthSubB; - *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubB, - HAMLIB_ELAPSED_GET); - *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubB, - HAMLIB_ELAPSED_GET); - *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubB, - HAMLIB_ELAPSED_GET); - break; + case RIG_VFO_B: + case RIG_VFO_SUB: + case RIG_VFO_MAIN_B: + *freq = rig->state.cache.freqMainB; + *mode = rig->state.cache.modeMainB; + *width = rig->state.cache.widthMainB; + *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainB, + HAMLIB_ELAPSED_GET); + *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainB, + HAMLIB_ELAPSED_GET); + *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainB, + HAMLIB_ELAPSED_GET); + break; - case RIG_VFO_C: - //case RIG_VFO_MAINC: // not used by any rig yet - *freq = rig->state.cache.freqMainC; - *mode = rig->state.cache.modeMainC; - *width = rig->state.cache.widthMainC; - *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainC, - HAMLIB_ELAPSED_GET); - *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainC, - HAMLIB_ELAPSED_GET); - *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainC, - HAMLIB_ELAPSED_GET); - break; + case RIG_VFO_SUB_A: + *freq = rig->state.cache.freqSubA; + *mode = rig->state.cache.modeSubA; + *width = rig->state.cache.widthSubA; + *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubA, + HAMLIB_ELAPSED_GET); + *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubA, + HAMLIB_ELAPSED_GET); + *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubA, + HAMLIB_ELAPSED_GET); + break; - case RIG_VFO_SUB_C: - *freq = rig->state.cache.freqSubC; - *mode = rig->state.cache.modeSubC; - *width = rig->state.cache.widthSubC; - *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubC, - HAMLIB_ELAPSED_GET); - *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubC, - HAMLIB_ELAPSED_GET); - *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubC, - HAMLIB_ELAPSED_GET); - break; + case RIG_VFO_SUB_B: + *freq = rig->state.cache.freqSubB; + *mode = rig->state.cache.modeSubB; + *width = rig->state.cache.widthSubB; + *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubB, + HAMLIB_ELAPSED_GET); + *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubB, + HAMLIB_ELAPSED_GET); + *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubB, + HAMLIB_ELAPSED_GET); + break; - case RIG_VFO_MEM: - *freq = rig->state.cache.freqMem; - *mode = rig->state.cache.modeMem; - *width = rig->state.cache.widthMem; - *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMem, HAMLIB_ELAPSED_GET); - *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMem, HAMLIB_ELAPSED_GET); - *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMem, - HAMLIB_ELAPSED_GET); - break; + case RIG_VFO_C: + //case RIG_VFO_MAINC: // not used by any rig yet + *freq = rig->state.cache.freqMainC; + *mode = rig->state.cache.modeMainC; + *width = rig->state.cache.widthMainC; + *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMainC, + HAMLIB_ELAPSED_GET); + *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMainC, + HAMLIB_ELAPSED_GET); + *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMainC, + HAMLIB_ELAPSED_GET); + break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo?, vfo=%s\n", __func__, - rig_strvfo(vfo)); - RETURNFUNC(-RIG_EINVAL); + case RIG_VFO_SUB_C: + *freq = rig->state.cache.freqSubC; + *mode = rig->state.cache.modeSubC; + *width = rig->state.cache.widthSubC; + *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqSubC, + HAMLIB_ELAPSED_GET); + *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeSubC, + HAMLIB_ELAPSED_GET); + *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthSubC, + HAMLIB_ELAPSED_GET); + break; + + case RIG_VFO_MEM: + *freq = rig->state.cache.freqMem; + *mode = rig->state.cache.modeMem; + *width = rig->state.cache.widthMem; + *cache_ms_freq = elapsed_ms(&rig->state.cache.time_freqMem, HAMLIB_ELAPSED_GET); + *cache_ms_mode = elapsed_ms(&rig->state.cache.time_modeMem, HAMLIB_ELAPSED_GET); + *cache_ms_width = elapsed_ms(&rig->state.cache.time_widthMem, + HAMLIB_ELAPSED_GET); + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown vfo?, vfo=%s\n", __func__, + rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); } - rig_debug(RIG_DEBUG_CACHE, "%s: vfo=%s, freq=%.0f, mode=%s, width=%d\n", __func__, rig_strvfo(vfo), - (double)*freq, rig_strrmode(*mode), (int)*width); + rig_debug(RIG_DEBUG_CACHE, "%s: vfo=%s, freq=%.0f, mode=%s, width=%d\n", + __func__, rig_strvfo(vfo), + (double)*freq, rig_strrmode(*mode), (int)*width); if (rig_need_debug(RIG_DEBUG_CACHE)) { diff --git a/src/debug.c b/src/debug.c index 0606ecc42..74e776d21 100644 --- a/src/debug.c +++ b/src/debug.c @@ -226,7 +226,7 @@ void HAMLIB_API rig_debug(enum rig_debug_level_e debug_level, if (rig_debug_time_stamp) { char buf[256]; - fprintf(rig_debug_stream, "%s: ", date_strget(buf, sizeof(buf))); + fprintf(rig_debug_stream, "%s: ", date_strget(buf, sizeof(buf), 1)); } vfprintf(rig_debug_stream, fmt, ap); diff --git a/src/iofunc.c b/src/iofunc.c index e8d2ad1a1..8481058cd 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -806,6 +806,7 @@ static int read_string_generic(hamlib_port_t *p, const char *stopset, int stopset_len, int flush_flag, + int expected_len, int direct) { fd_set rfds, efds; @@ -813,6 +814,7 @@ static int read_string_generic(hamlib_port_t *p, struct timeval tv, tv_timeout, start_time, end_time, elapsed_time; int total_count = 0; int i = 0; + static ssize_t minlen = 1; // dynamic minimum length of rig response data if (!p->async && !direct) { @@ -851,7 +853,7 @@ static int read_string_generic(hamlib_port_t *p, while (total_count < rxmax - 1) // allow 1 byte for end-of-string { - ssize_t rd_count; + ssize_t rd_count = 0; int retval; tv = tv_timeout; /* select may have updated it */ @@ -879,12 +881,12 @@ static int read_string_generic(hamlib_port_t *p, dump_hex((unsigned char *) rxbuffer, total_count); } if (!flush_flag) { - rig_debug(RIG_DEBUG_WARN, - "%s(): Timed out %d.%03d seconds after %d chars\n", - __func__, - (int)elapsed_time.tv_sec, - (int)elapsed_time.tv_usec / 1000, - total_count); + rig_debug(RIG_DEBUG_WARN, + "%s(): Timed out %d.%03d seconds after %d chars\n", + __func__, + (int)elapsed_time.tv_sec, + (int)elapsed_time.tv_usec / 1000, + total_count); } return -RIG_ETIMEOUT; @@ -938,15 +940,17 @@ static int read_string_generic(hamlib_port_t *p, * read 1 character from the rig, (check if in stop set) * The file descriptor must have been set up non blocking. */ - do + do { - rd_count = port_read_generic(p, &rxbuffer[total_count], 1, direct); + rd_count = port_read_generic(p, &rxbuffer[total_count], expected_len == 1 ? 1 : minlen, direct); + minlen -= rd_count; if (errno == EAGAIN) { - hl_usleep(5*1000); + hl_usleep(5 * 1000); rig_debug(RIG_DEBUG_WARN, "%s: port_read is busy?\n", __func__); } - } while( ++i < 10 && errno == EBUSY); // 50ms should be enough + } + while (++i < 10 && errno == EBUSY); // 50ms should be enough /* if we get 0 bytes or an error something is wrong */ if (rd_count <= 0) @@ -970,6 +974,14 @@ static int read_string_generic(hamlib_port_t *p, if (stopset && memchr(stopset, rxbuffer[total_count - 1], stopset_len)) { + if (minlen == 1) { minlen = total_count; } + + if (minlen < total_count) + { + minlen = total_count; + rig_debug(RIG_DEBUG_VERBOSE, "%s: minlen now %ld\n", __func__, minlen); + } + break; } } @@ -1024,9 +1036,10 @@ int HAMLIB_API read_string(hamlib_port_t *p, size_t rxmax, const char *stopset, int stopset_len, - int flush_flag) + int flush_flag, + int expected_len) { - return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, !p->async); + return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, !p->async); } @@ -1061,9 +1074,10 @@ int HAMLIB_API read_string_direct(hamlib_port_t *p, size_t rxmax, const char *stopset, int stopset_len, - int flush_flag) + int flush_flag, + int expected_len) { - return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, 1); + return read_string_generic(p, rxbuffer, rxmax, stopset, stopset_len, flush_flag, expected_len, 1); } /** @} */ diff --git a/src/iofunc.h b/src/iofunc.h index 1be0fccee..77b9df5b5 100644 --- a/src/iofunc.h +++ b/src/iofunc.h @@ -54,13 +54,15 @@ extern HAMLIB_EXPORT(int) read_string(hamlib_port_t *p, size_t rxmax, const char *stopset, int stopset_len, - int flush_flag); + int flush_flag, + int expected_len); extern HAMLIB_EXPORT(int) read_string_direct(hamlib_port_t *p, unsigned char *rxbuffer, size_t rxmax, const char *stopset, int stopset_len, - int flush_flag); + int flush_flag, + int expected_len); #endif /* _IOFUNC_H */ diff --git a/src/mem.c b/src/mem.c index 678607b97..6e6efcd3d 100644 --- a/src/mem.c +++ b/src/mem.c @@ -1181,6 +1181,7 @@ int HAMLIB_API rig_set_chan_all(RIG *rig, vfo_t vfo, const channel_t chans[]) } rc = rig->caps; + memset(&map_arg,0,sizeof(map_arg)); map_arg.chans = (channel_t *) chans; if (rc->set_chan_all_cb) @@ -1223,6 +1224,7 @@ int HAMLIB_API rig_get_chan_all(RIG *rig, vfo_t vfo, channel_t chans[]) } rc = rig->caps; + memset(&map_arg,0,sizeof(map_arg)); map_arg.chans = chans; if (rc->get_chan_all_cb) diff --git a/src/misc.c b/src/misc.c index c3447dc26..fda00c223 100644 --- a/src/misc.c +++ b/src/misc.c @@ -613,7 +613,7 @@ static const struct { RIG_VFO_SUB_C, "SubC" }, { RIG_VFO_NONE, "None" }, { RIG_VFO_OTHER, "otherVFO" }, - { 0xffffff, "" }, + { 0xffffffff, "" }, }; @@ -634,10 +634,14 @@ vfo_t HAMLIB_API rig_parse_vfo(const char *s) { if (!strcmp(s, vfo_str[i].str)) { + rig_debug(RIG_DEBUG_CACHE, "%s: str='%s' vfo='%s'\n", __func__, vfo_str[i].str, + rig_strvfo(vfo_str[i].vfo)); return vfo_str[i].vfo; } } + rig_debug(RIG_DEBUG_ERR, "%s: '%s' not found so vfo='%s'\n", __func__, s, + rig_strvfo(RIG_VFO_NONE)); return RIG_VFO_NONE; } @@ -1763,11 +1767,12 @@ static char *funcname = "Unknown"; static int linenum = 0; #undef vfo_fixup -vfo_t HAMLIB_API vfo_fixup2a(RIG *rig, vfo_t vfo, split_t split, const char *func, int line) +vfo_t HAMLIB_API vfo_fixup2a(RIG *rig, vfo_t vfo, split_t split, + const char *func, int line) { - funcname = (char*)func; + funcname = (char *)func; linenum = (int)line; - return vfo_fixup(rig,vfo,split); + return vfo_fixup(rig, vfo, split); } // we're mappping our VFO here to work with either VFO A/B rigs or Main/Sub @@ -1775,7 +1780,8 @@ vfo_t HAMLIB_API vfo_fixup2a(RIG *rig, vfo_t vfo, split_t split, const char *fun // So we map these to Main/Sub as required vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split) { - rig_debug(RIG_DEBUG_TRACE, "%s:(from %s:%d) vfo=%s, vfo_curr=%s, split=%d\n", __func__, funcname, linenum, + rig_debug(RIG_DEBUG_TRACE, "%s:(from %s:%d) vfo=%s, vfo_curr=%s, split=%d\n", + __func__, funcname, linenum, rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo), split); if (vfo == RIG_VFO_CURR) @@ -1783,22 +1789,28 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split) rig_debug(RIG_DEBUG_TRACE, "%s: Leaving currVFO alone\n", __func__); return vfo; // don't modify vfo for RIG_VFO_CURR } + if (vfo == RIG_VFO_OTHER) { - switch(rig->state.current_vfo) + switch (rig->state.current_vfo) { - case RIG_VFO_A: - return RIG_VFO_B; - case RIG_VFO_MAIN: - return RIG_VFO_SUB; - case RIG_VFO_B: - return RIG_VFO_A; - case RIG_VFO_SUB: - return RIG_VFO_MAIN; - case RIG_VFO_SUB_A: - return RIG_VFO_SUB_B; - case RIG_VFO_SUB_B: - return RIG_VFO_SUB_A; + case RIG_VFO_A: + return RIG_VFO_B; + + case RIG_VFO_MAIN: + return RIG_VFO_SUB; + + case RIG_VFO_B: + return RIG_VFO_A; + + case RIG_VFO_SUB: + return RIG_VFO_MAIN; + + case RIG_VFO_SUB_A: + return RIG_VFO_SUB_B; + + case RIG_VFO_SUB_B: + return RIG_VFO_SUB_A; } } @@ -1836,6 +1848,9 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split) int satmode = rig->state.cache.satmode; + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): split=%d, vfo==%s tx_vfo=%s\n", __func__, + __LINE__, split, rig_strvfo(vfo), rig_strvfo(rig->state.tx_vfo)); + if (split && vfo == RIG_VFO_TX) { vfo = rig->state.tx_vfo; } if (VFO_HAS_MAIN_SUB_ONLY && !split && !satmode && vfo != RIG_VFO_B) { vfo = RIG_VFO_MAIN; } @@ -2444,19 +2459,34 @@ static struct tm *gmtime_r(const time_t *t, struct tm *r) #endif // _WIN32 //! @cond Doxygen_Suppress -char *date_strget(char *buf, int buflen) +char *date_strget(char *buf, int buflen, int localtime) { - char tmp[16]; + char tmpbuf[64]; struct tm *mytm; time_t t; struct timeval tv; struct tm result; + int mytimezone; + t = time(NULL); - mytm = gmtime_r(&t, &result); - strftime(buf, buflen, "%Y-%m-%d:%H:%M:%S.", mytm); + + if (localtime) + { + mytm = localtime_r(&t, &result); + mytimezone = timezone; + } + else + { + mytm = gmtime_r(&t, &result); + mytimezone = 0; + } + + strftime(buf, buflen, "%Y-%m-%dT%H:%M:%S.", mytm); gettimeofday(&tv, NULL); - sprintf(tmp, "%06ld", (long)tv.tv_usec); - strcat(buf, tmp); + snprintf(tmpbuf, sizeof(tmpbuf), "%06ld", (long)tv.tv_usec); + strcat(buf, tmpbuf); + snprintf(tmpbuf, sizeof(tmpbuf), "%s%04d", mytimezone >=0? "-":"+", ((int)abs(mytimezone)/3600)*100); + strcat(buf, tmpbuf); return buf; } diff --git a/src/misc.h b/src/misc.h index 24cfd1cd0..27d618b37 100644 --- a/src/misc.h +++ b/src/misc.h @@ -119,7 +119,7 @@ extern HAMLIB_EXPORT(int) parse_hoststr(char *hoststr, char host[256], char port extern HAMLIB_EXPORT(uint32_t) CRC32_function(uint8_t *buf, uint32_t len); -extern char *date_strget(char *buf, int buflen); +extern char *date_strget(char *buf, int buflen, int localtime); #ifdef PRId64 /** \brief printf(3) format to be used for long long (64bits) type */ diff --git a/src/network.c b/src/network.c index cc9a4ac97..ae572c206 100644 --- a/src/network.c +++ b/src/network.c @@ -205,6 +205,7 @@ int network_open(hamlib_port_t *rp, int default_port) status = network_init(); if (status != RIG_OK) { RETURNFUNC(status); } + #endif if (!rp) @@ -392,9 +393,10 @@ void network_flush(hamlib_port_t *rp) } rig_debug(RIG_DEBUG_WARN, - "%s: network data cleared: ret=%d, len_read=%d/0x%x, '%s'\n", + "%s: network data cleared: ret=%d, len_read=%d/0x%x\n", __func__, - ret, len_read, len_read, buffer); + ret, len_read, len_read); + dump_hex((unsigned char *)buffer, len_read); } else { diff --git a/src/rig.c b/src/rig.c index fa563857b..6f3004595 100644 --- a/src/rig.c +++ b/src/rig.c @@ -158,9 +158,6 @@ const char hamlib_copyright[231] = /* hamlib 1.2 ABI specifies 231 bytes */ #define CHECK_RIG_ARG(r) (!(r) || !(r)->caps || !(r)->state.comm_state) -#define ELAPSED1 struct timespec __begin; elapsed_ms(&__begin, HAMLIB_ELAPSED_SET); -#define ELAPSED2 rig_debug(RIG_DEBUG_TRACE, "%s: elapsed=%.0lfms\n", __func__, elapsed_ms(&__begin, HAMLIB_ELAPSED_GET)); - #define LOCK \ /* @@ -204,31 +201,6 @@ static const char *const rigerror_table[] = #define ERROR_TBL_SZ (sizeof(rigerror_table)/sizeof(char *)) -#ifdef HAVE_PTHREAD -// Any call to rig_set or rig_get functions will lock the rig -// for non-targetable rigs this will still be problematic for rigctld -// in non-vfo mode as a transaction may be set_vfo/set_x/set_vfo -// this would require the client to request a lock -static pthread_mutex_t rig_lock_mutex = PTHREAD_MUTEX_INITIALIZER; -void rig_lock() -{ -#ifdef HAVE_PTHREAD - pthread_mutex_lock(&rig_lock_mutex); - rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__); -#endif -} -void rig_unlock() -{ -#ifdef HAVE_PTHREAD - pthread_mutex_unlock(&rig_lock_mutex); - rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__); -#endif -} -#else -void rig_lock() {}; -void rig_unlock() {}; -#endif - #ifdef HAVE_PTHREAD typedef struct async_data_handler_args_s { @@ -400,7 +372,7 @@ static int rig_check_rig_caps() &caps_test.macro_name); } - return rc; + RETURNFUNC(rc); } /** @@ -1087,9 +1059,12 @@ int HAMLIB_API rig_open(RIG *rig) { //int backend_num = RIG_BACKEND_NUM(rig->caps->rig_model); rs->tx_vfo = RIG_VFO_TX; + // If we haven't gotten the vfo by now we will default to VFO_CURR - if (rs->current_vfo == RIG_VFO_NONE) rs->current_vfo = RIG_VFO_CURR; - rig_debug(RIG_DEBUG_TRACE, "%s: vfo_curr=%s, tx_vfo=%s\n", __func__, rig_strvfo(rs->current_vfo), rig_strvfo(rs->tx_vfo)); + if (rs->current_vfo == RIG_VFO_NONE) { rs->current_vfo = RIG_VFO_CURR; } + + rig_debug(RIG_DEBUG_TRACE, "%s: vfo_curr=%s, tx_vfo=%s\n", __func__, + rig_strvfo(rs->current_vfo), rig_strvfo(rs->tx_vfo)); #if 0 // done in the back end @@ -1537,7 +1512,8 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) RIG_OK); // would be better as error but other software won't handle errors } - rig_debug(RIG_DEBUG_TRACE, "%s: TARGETABLE_FREQ vfo=%s\n", __func__, rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: TARGETABLE_FREQ vfo=%s\n", __func__, + rig_strvfo(vfo)); int retry = 3; freq_t tfreq = 0; @@ -1586,7 +1562,8 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq) } else { - rig_debug(RIG_DEBUG_TRACE, "%s: not a TARGETABLE_FREQ vfo=%s\n", __func__, rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: not a TARGETABLE_FREQ vfo=%s\n", __func__, + rig_strvfo(vfo)); if (!caps->set_vfo) { @@ -1773,7 +1750,8 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) rig_cache_show(rig, __func__, __LINE__); - if (*freq != 0 && cache_ms_freq < rig->state.cache.timeout_ms) + if (*freq != 0 && (cache_ms_freq < rig->state.cache.timeout_ms + || rig->state.cache.timeout_ms == HAMLIB_CACHE_ALWAYS)) { rig_debug(RIG_DEBUG_TRACE, "%s: %s cache hit age=%dms, freq=%.0f\n", __func__, rig_strvfo(vfo), cache_ms_freq, *freq); @@ -1795,6 +1773,9 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) RETURNFUNC(-RIG_ENAVAIL); } + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo_opt=%d, model=%d\n", __func__, + __LINE__, rig->state.vfo_opt, rig->caps->rig_model); + // If we're in vfo_mode then rigctld will do any VFO swapping we need if ((caps->targetable_vfo & RIG_TARGETABLE_FREQ) || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo @@ -1910,7 +1891,7 @@ int HAMLIB_API rig_get_freqs(RIG *rig, freq_t *freqA, freq_t freqB) { // we will attempt to avoid vfo swapping in this routine - return -RIG_ENIMPL; + RETURNFUNC(-RIG_ENIMPL); } @@ -1941,8 +1922,10 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) ELAPSED1; - rig_debug(RIG_DEBUG_VERBOSE, "%s called, vfo=%s, mode=%s, width=%d\n", __func__, - rig_strvfo(vfo), rig_strrmode(mode), (int)width); + rig_debug(RIG_DEBUG_VERBOSE, + "%s called, vfo=%s, mode=%s, width=%dm, curr_vfo=%s\n", __func__, + rig_strvfo(vfo), rig_strrmode(mode), (int)width, + rig_strvfo(rig->state.current_vfo)); if (CHECK_RIG_ARG(rig)) { @@ -1979,6 +1962,14 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) int rc2; vfo_t curr_vfo; + // if not a targetable rig we will only set mode on VFOB if it is changing + if (rig->state.cache.modeMainB == mode) + { + rig_debug(RIG_DEBUG_TRACE, "%s: VFOB mode not changing so ignoring\n", + __func__); + return (RIG_OK); + } + rig_debug(RIG_DEBUG_TRACE, "%s: not targetable need vfo swap\n", __func__); if (!caps->set_vfo) @@ -2075,6 +2066,15 @@ int HAMLIB_API rig_get_mode(RIG *rig, rig_cache_show(rig, __func__, __LINE__); + if (rig->state.cache.timeout_ms == HAMLIB_CACHE_ALWAYS) + { + rig_debug(RIG_DEBUG_TRACE, "%s: cache hit age mode=%dms, width=%dms\n", + __func__, cache_ms_mode, cache_ms_width); + + ELAPSED2; + RETURNFUNC(RIG_OK); + } + if ((*mode != RIG_MODE_NONE && cache_ms_mode < rig->state.cache.timeout_ms) && cache_ms_width < rig->state.cache.timeout_ms) { @@ -3538,6 +3538,7 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) freq_t tfreq = 0; ELAPSED1; + if (CHECK_RIG_ARG(rig)) { RETURNFUNC(-RIG_EINVAL); @@ -3559,7 +3560,7 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) tx_vfo = vfo; } - rig_get_freq(rig, tx_vfo, &tfreq); + rig_get_freq(rig, tx_vfo, &tfreq); if (tfreq == tx_freq) { @@ -3876,7 +3877,8 @@ int HAMLIB_API rig_set_split_mode(RIG *rig, if (caps->set_split_mode && (vfo == RIG_VFO_CURR || vfo == RIG_VFO_TX - || vfo == rig->state.current_vfo)) + || vfo == rig->state.current_vfo + || rig->caps->rig_model == RIG_MODEL_NETRIGCTL)) { TRACE; retcode = caps->set_split_mode(rig, vfo, tx_mode, tx_width); @@ -3888,7 +3890,8 @@ int HAMLIB_API rig_set_split_mode(RIG *rig, curr_vfo = rig->state.current_vfo; /* Use previously setup TxVFO */ - if (vfo == RIG_VFO_CURR || vfo == RIG_VFO_TX) + if (vfo == RIG_VFO_CURR || vfo == RIG_VFO_TX + || rig->state.tx_vfo != RIG_VFO_NONE) { TRACE; tx_vfo = rig->state.tx_vfo; @@ -3898,9 +3901,12 @@ int HAMLIB_API rig_set_split_mode(RIG *rig, TRACE; tx_vfo = vfo; } - rig_debug(RIG_DEBUG_VERBOSE, "%s: curr_vfo=%s, tx_vfo=%s\n", __func__, rig_strvfo(curr_vfo), rig_strvfo(tx_vfo)); - if (caps->set_mode && (caps->targetable_vfo & RIG_TARGETABLE_MODE)) + rig_debug(RIG_DEBUG_VERBOSE, "%s: curr_vfo=%s, tx_vfo=%s\n", __func__, + rig_strvfo(curr_vfo), rig_strvfo(tx_vfo)); + + if (caps->set_mode && ((caps->targetable_vfo & RIG_TARGETABLE_MODE) + || (rig->caps->rig_model == RIG_MODEL_NETRIGCTL))) { TRACE; retcode = caps->set_mode(rig, tx_vfo, tx_mode, tx_width); @@ -3911,12 +3917,46 @@ int HAMLIB_API rig_set_split_mode(RIG *rig, // some rigs exhibit undesirable flashing when swapping vfos in split // so we turn it off, do our thing, and turn split back on rx_vfo = RIG_VFO_A; - if (vfo == RIG_VFO_CURR && tx_vfo == RIG_VFO_B) rx_vfo = RIG_VFO_A; - else if (vfo == RIG_VFO_CURR && tx_vfo == RIG_VFO_A) rx_vfo = RIG_VFO_B; - else if (vfo == RIG_VFO_CURR && tx_vfo == RIG_VFO_MAIN) rx_vfo = RIG_VFO_SUB; - else if (vfo == RIG_VFO_CURR && tx_vfo == RIG_VFO_SUB) rx_vfo = RIG_VFO_MAIN; - rig_debug(RIG_DEBUG_VERBOSE, "%s: rx_vfo=%s, tx_vfo=%s\n", __func__, rig_strvfo(rx_vfo), rig_strvfo(tx_vfo)); - rig_set_split_vfo(rig,rx_vfo, RIG_SPLIT_OFF, rx_vfo); + + if (vfo == RIG_VFO_CURR && tx_vfo == RIG_VFO_B) { rx_vfo = RIG_VFO_A; } + else if (vfo == RIG_VFO_CURR && tx_vfo == RIG_VFO_A) { rx_vfo = RIG_VFO_B; } + else if (vfo == RIG_VFO_CURR && tx_vfo == RIG_VFO_MAIN) { rx_vfo = RIG_VFO_SUB; } + else if (vfo == RIG_VFO_CURR && tx_vfo == RIG_VFO_SUB) { rx_vfo = RIG_VFO_MAIN; } + + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): rx_vfo=%s, tx_vfo=%s\n", __func__, + __LINE__, rig_strvfo(rx_vfo), rig_strvfo(tx_vfo)); + + // we will reuse cached mode instead of trying to set mode again + if ((tx_vfo & (RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_MAIN_A | RIG_VFO_SUB_A)) + && (tx_mode == rig->state.cache.modeMainA)) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): VFOA mode=%s already set...ignoring\n", + __func__, __LINE__, rig_strrmode(tx_mode)); + ELAPSED2; + RETURNFUNC(RIG_OK); + } + else if ((tx_vfo & (RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_MAIN_B | RIG_VFO_SUB_B)) + && (tx_mode == rig->state.cache.modeMainB)) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): VFOB mode=%s already set...ignoring\n", + __func__, __LINE__, rig_strrmode(tx_mode)); + ELAPSED2; + RETURNFUNC(RIG_OK); + } + + rig_debug(RIG_DEBUG_WARN, "%s(%d): Unhandled TXVFO=%s, tx_mode=%s\n", __func__, + __LINE__, rig_strvfo(tx_vfo), rig_strrmode(tx_mode)); + + // code below here should be dead code now -- but maybe we have VFO situatiuon we need to handle + if (caps->rig_model == RIG_MODEL_NETRIGCTL) + { + // special handlingt for netrigctl to avoid set_vfo + retcode = caps->set_split_mode(rig, vfo, tx_mode, tx_width); + RETURNFUNC(retcode); + } + + rig_set_split_vfo(rig, rx_vfo, RIG_SPLIT_OFF, rx_vfo); + if (caps->set_vfo) { TRACE; @@ -3968,7 +4008,8 @@ int HAMLIB_API rig_set_split_mode(RIG *rig, /* return the first error code */ retcode = rc2; } - rig_set_split_vfo(rig,rx_vfo, RIG_SPLIT_ON, tx_vfo); + + rig_set_split_vfo(rig, rx_vfo, RIG_SPLIT_ON, tx_vfo); ELAPSED2; RETURNFUNC(retcode); @@ -4274,10 +4315,9 @@ int HAMLIB_API rig_get_split_freq_mode(RIG *rig, if (caps->get_split_freq_mode) { - TRACE; retcode = caps->get_split_freq_mode(rig, vfo, tx_freq, tx_mode, tx_width); ELAPSED2; - return retcode; + RETURNFUNC(retcode); } TRACE; @@ -4334,13 +4374,13 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, { RETURNFUNC(-RIG_ENAVAIL); } - - if (rig->state.cache.ptt) - { - rig_debug(RIG_DEBUG_WARN, "%s: cannot execute when PTT is on\n", __func__); - ELAPSED2; - return RIG_OK; - } + + if (rig->state.cache.ptt) + { + rig_debug(RIG_DEBUG_WARN, "%s: cannot execute when PTT is on\n", __func__); + ELAPSED2; + return RIG_OK; + } // We fix up vfos for non-satmode rigs only if (rig->caps->has_get_func & RIG_FUNC_SATMODE) @@ -4350,23 +4390,26 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, } else { + switch (tx_vfo) + { + case RIG_VFO_A: rx_vfo = split == 1 ? RIG_VFO_B : RIG_VFO_A; break; + + case RIG_VFO_B: rx_vfo = split == 1 ? RIG_VFO_A : RIG_VFO_B; break; + } + rx_vfo = vfo_fixup(rig, rx_vfo, split); tx_vfo = vfo_fixup(rig, tx_vfo, split); - if (rx_vfo == RIG_VFO_CURR) - { - rx_vfo = rig->state.current_vfo; - } - if (tx_vfo == RIG_VFO_CURR) - { - tx_vfo = rig->state.tx_vfo; - } - rig_debug(RIG_DEBUG_VERBOSE, "%s: final rxvfo=%s, txvfo=%s\n", __func__, rig_strvfo(rx_vfo), rig_strvfo(tx_vfo)); + rig->state.rx_vfo = rx_vfo; + rig->state.tx_vfo = tx_vfo; + rig_debug(RIG_DEBUG_VERBOSE, "%s: final rxvfo=%s, txvfo=%s\n", __func__, + rig_strvfo(rx_vfo), rig_strvfo(tx_vfo)); } // set rig to the the requested RX VFO TRACE; - if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) + if ((!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) + && (!(rig->caps->rig_model == RIG_MODEL_NETRIGCTL))) #if BUILTINFUNC rig_set_vfo(rig, rx_vfo == RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A, __builtin_FUNCTION()); @@ -4378,6 +4421,14 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, if (rx_vfo == RIG_VFO_CURR || rx_vfo == rig->state.current_vfo) { + // for non-targetable VFOs we will not set split again + if (rig->state.cache.split == split && rig->state.cache.split_vfo == tx_vfo) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): split already set...ignoring\n", __func__, + __LINE__); + RETURNFUNC(RIG_OK); + } + TRACE; retcode = caps->set_split_vfo(rig, rx_vfo, split, tx_vfo); @@ -4506,7 +4557,8 @@ int HAMLIB_API rig_get_split_vfo(RIG *rig, { *split = rig->state.cache.split; *tx_vfo = rig->state.cache.split_vfo; - rig_debug(RIG_DEBUG_TRACE, "%s: cache hit age=%dms, split=%d, tx_vfo=%s\n", __func__, cache_ms, *split, rig_strvfo(*tx_vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: cache hit age=%dms, split=%d, tx_vfo=%s\n", + __func__, cache_ms, *split, rig_strvfo(*tx_vfo)); ELAPSED2; RETURNFUNC(RIG_OK); } @@ -5276,12 +5328,12 @@ int HAMLIB_API rig_mW2power(RIG *rig, if (!rig || !rig->caps || !power || mwpower == 0) { - return (-RIG_EINVAL); + RETURNFUNC(-RIG_EINVAL); } if (rig->caps->mW2power != NULL) { - return (rig->caps->mW2power(rig, power, mwpower, freq, mode)); + RETURNFUNC(rig->caps->mW2power(rig, power, mwpower, freq, mode)); } txrange = rig_get_range(rig->state.tx_range_list, freq, mode); @@ -5291,13 +5343,13 @@ int HAMLIB_API rig_mW2power(RIG *rig, /* * freq is not on the tx range! */ - return (-RIG_EINVAL); /* could be RIG_EINVAL ? */ + RETURNFUNC(-RIG_EINVAL); /* could be RIG_EINVAL ? */ } if (txrange->high_power == 0) { *power = 0.0; - return (RIG_OK); + RETURNFUNC(RIG_OK); } *power = (float)mwpower / txrange->high_power; @@ -5307,7 +5359,7 @@ int HAMLIB_API rig_mW2power(RIG *rig, *power = 1.0; } - return (mwpower > txrange->high_power ? RIG_OK : -RIG_ETRUNC); + RETURNFUNC(mwpower > txrange->high_power ? RIG_OK : -RIG_ETRUNC); } @@ -6220,7 +6272,7 @@ const freq_range_t *HAMLIB_API rig_get_range(const freq_range_t *range_list, if (!range_list) { - return NULL; + return (NULL); } for (i = 0; i < HAMLIB_FRQRANGESIZ; i++) @@ -6525,6 +6577,42 @@ int HAMLIB_API rig_get_vfo_list(RIG *rig, char *buf, int buflen) RETURNFUNC(RIG_OK); } +/** + * \brief set the rig's clock + * + */ +int HAMLIB_API rig_set_clock(RIG *rig, int year, int month, int day, int hour, + int min, int sec, double msec, int utc_offset) +{ + if (rig->caps->set_clock == NULL) + { + return -RIG_ENIMPL; + } + + RETURNFUNC(rig->caps->set_clock(rig, year, month, day, hour, min, sec, + msec, utc_offset)); +} + +/** + * \brief get the rig's clock + * + */ +int HAMLIB_API rig_get_clock(RIG *rig, int *year, int *month, int *day, + int *hour, + int *min, int *sec, double *msec, int *utc_offset) +{ + int retval; + + if (rig->caps->get_clock == NULL) + { + return -RIG_ENIMPL; + } + + retval = rig->caps->get_clock(rig, year, month, day, hour, min, sec, + msec, utc_offset); + RETURNFUNC(retval); +} + /** * \brief get the Hamlib license * @@ -6689,7 +6777,7 @@ int HAMLIB_API rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie, __FILE__, __LINE__, cookie_save, time_curr - time_last_used); } - date_strget(cookie, cookie_len); + date_strget(cookie, cookie_len, 0); size_t len = strlen(cookie); // add on our random number to ensure uniqueness // The cookie should never be longer then HAMLIB_COOKIE_SIZE diff --git a/src/serial.c b/src/serial.c index 9af2624d9..3eb2dbc76 100644 --- a/src/serial.c +++ b/src/serial.c @@ -674,23 +674,29 @@ int HAMLIB_API serial_flush(hamlib_port_t *p) timeout_save = p->timeout; p->timeout = 1; + do { // we pass an empty stopset so read_string can determine // the appropriate stopset for async data char stopset[1]; - len = read_string(p, (char*)buf, sizeof(buf)-1, stopset, 0, 1); - if (len > 0) + len = read_string(p, (char *)buf, sizeof(buf) - 1, stopset, 0, 1, 1); + + if (len > 0) { - int i, binary=0; - for(i=0;i 0); + } + while (len > 0); + p->timeout = timeout_save; //rig_debug(RIG_DEBUG_VERBOSE, "tcflush%s\n", ""); //tcflush(p->fd, TCIFLUSH); diff --git a/tests/ampctl_parse.c b/tests/ampctl_parse.c index db8d0c55e..f0052cf21 100644 --- a/tests/ampctl_parse.c +++ b/tests/ampctl_parse.c @@ -1957,7 +1957,7 @@ declare_proto_amp(send_cmd) * assumes CR or LF is end of line char * for all ascii protocols */ - retval = read_string(&rs->ampport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0); + retval = read_string(&rs->ampport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1); if (retval < 0) { diff --git a/tests/ampctld.c b/tests/ampctld.c index 208d0b5f4..045a3d8a7 100644 --- a/tests/ampctld.c +++ b/tests/ampctld.c @@ -568,7 +568,7 @@ int main(int argc, char *argv[]) sizeof(host), serv, sizeof(serv), - NI_NUMERICHOST|NI_NUMERICSERV)) + NI_NUMERICHOST | NI_NUMERICSERV)) < 0) { @@ -674,7 +674,7 @@ void *handle_socket(void *arg) sizeof(host), serv, sizeof(serv), - NI_NUMERICHOST|NI_NUMERICSERV)) + NI_NUMERICHOST | NI_NUMERICSERV)) < 0) { diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 35c7c1289..0875ac531 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -244,6 +244,8 @@ declare_proto_rig(halt); declare_proto_rig(pause); declare_proto_rig(password); declare_proto_rig(set_password); +declare_proto_rig(set_clock); +declare_proto_rig(get_clock); /* @@ -344,11 +346,14 @@ static struct test_table test_list[] = { 0xf5, "get_rig_info", ACTION(get_rig_info), ARG_NOVFO | ARG_OUT, "RigInfo" }, /* get several vfo parameters at once */ { 0xf4, "get_vfo_list", ACTION(get_vfo_list), ARG_OUT | ARG_NOVFO, "VFOs" }, { 0xf6, "get_modes", ACTION(get_modes), ARG_OUT | ARG_NOVFO, "Modes" }, - { 0xf7, "get_mode_bandwidths", ACTION(get_mode_bandwidths), ARG_IN | ARG_NOVFO, "Mode" }, +// { 0xf9, "get_clock", ACTION(get_clock), ARG_IN | ARG_NOVFO, "local/utc" }, + { 0xf9, "get_clock", ACTION(get_clock), ARG_NOVFO }, + { 0xf8, "set_clock", ACTION(set_clock), ARG_IN | ARG_NOVFO, "YYYYMMDDHHMMSS.sss+ZZ" }, { 0xf1, "halt", ACTION(halt), ARG_NOVFO }, /* rigctld only--halt the daemon */ { 0x8c, "pause", ACTION(pause), ARG_IN, "Seconds" }, { 0x98, "password", ACTION(password), ARG_IN, "Password" }, { 0x99, "set_password", ACTION(set_password), ARG_IN, "Password" }, + { 0xf7, "get_mode_bandwidths", ACTION(get_mode_bandwidths), ARG_IN | ARG_NOVFO, "Mode" }, { 0x00, "", NULL }, }; @@ -2257,6 +2262,7 @@ declare_proto_rig(get_vfo_info) int retval; ENTERFUNC; + ELAPSED1; if (!strcmp(arg1, "?")) { @@ -2296,6 +2302,7 @@ declare_proto_rig(get_vfo_info) fprintf(fout, "%.0f\n%s\n%d\n", freq, modestr, (int)width); } + ELAPSED2; RETURNFUNC(retval); } @@ -2798,7 +2805,7 @@ declare_proto_rig(set_split_mode) } // mode could be RIG_MODE_NONE here - // we treat it as non-fatal + // we treat it as non-fatal // rig_parse_mode will spit out error msg mode = rig_parse_mode(arg1); CHKSCN1ARG(sscanf(arg2, "%d", &width)); @@ -3633,6 +3640,8 @@ declare_proto_rig(vfo_op) if (RIG_OP_NONE == op) { + rig_debug(RIG_DEBUG_ERR, "%s: rig_parse_vfo failed with '%s'\n", __func__, + arg1); RETURNFUNC(-RIG_EINVAL); } @@ -4766,7 +4775,7 @@ declare_proto_rig(send_cmd) /* Assumes CR or LF is end of line char for all ASCII protocols. */ retval = read_string(&rs->rigport, buf, rxbytes, eom_buf, - strlen(eom_buf), 0); + strlen(eom_buf), 0, 1); if (retval < 0) { @@ -4905,13 +4914,18 @@ char rig_passwd[256]; declare_proto_rig(password) { const char *passwd = arg1; - if (strcmp(passwd,rig_passwd)==0) { - rig_debug(RIG_DEBUG_ERR, "%s: #1 password OK\n", __func__); - return(RIG_EINVAL); + + if (strcmp(passwd, rig_passwd) == 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: #1 password OK\n", __func__); + return (RIG_EINVAL); } - else{ - rig_debug(RIG_DEBUG_ERR, "%s: #2 password error, '%s'!='%s'\n", __func__,passwd,rig_passwd); + else + { + rig_debug(RIG_DEBUG_ERR, "%s: #2 password error, '%s'!='%s'\n", __func__, + passwd, rig_passwd); } + RETURNFUNC(RIG_OK); } @@ -4919,7 +4933,7 @@ declare_proto_rig(password) declare_proto_rig(set_password) { const char *passwd = arg1; - strncpy(rig_passwd, passwd, sizeof(passwd)-1); + strncpy(rig_passwd, passwd, sizeof(passwd) - 1); rig_debug(RIG_DEBUG_ERR, "%s: set_password %s\n", __func__, rig_passwd); fprintf(fout, "set_password %s\n", rig_passwd); RETURNFUNC(RIG_OK); @@ -5007,3 +5021,73 @@ declare_proto_rig(get_cache) RETURNFUNC(RIG_OK); } + +/* '0xf8' */ +declare_proto_rig(set_clock) +{ + int year, mon, day, hour = -1, min = -1, sec = -1; + double msec; + int utc_offset = 0; + int n; + char timebuf[64]; + + ENTERFUNC; + + if (arg1 && strcasecmp(arg1, "local") == 0) + { + date_strget(timebuf, sizeof(timebuf), 1); + rig_debug(RIG_DEBUG_VERBOSE, "%s: local time set = %s\n", __func__, timebuf); + n = sscanf(timebuf, "%04d-%02d-%02dT%02d:%02d:%02d%lf%d", &year, &mon, &day, + &hour, + &min, &sec, &msec, &utc_offset); + } + else if (arg1 && strcasecmp(arg1, "utc") == 0) + { + date_strget(timebuf, sizeof(timebuf), 0); + rig_debug(RIG_DEBUG_VERBOSE, "%s: utc time set = %s\n", __func__, timebuf); + n = sscanf(timebuf, "%04d-%02d-%02dT%02d:%02d:%02d%lf%d", &year, &mon, &day, + &hour, + &min, &sec, &msec, &utc_offset); + } + else + { + n = sscanf(arg1, "%04d-%02d-%02dT%02d:%02d:%02d%lf%d", &year, &mon, &day, &hour, + &min, &sec, &msec, &utc_offset); + } + + rig_debug(RIG_DEBUG_VERBOSE, + "%s: n=%d, %04d-%02d-%02dT%02d:%02d:%02d.%0.3f%s%02d\n", + __func__, n, year, mon, day, hour, min, sec, msec, utc_offset >= 0 ? "+" : "-", + (unsigned)abs(utc_offset)); + + rig_debug(RIG_DEBUG_ERR, "%s: utc_offset=%d\n", __func__, utc_offset); + + if (utc_offset < 24) { utc_offset *= 100; } // allow for minutes offset too + + rig_debug(RIG_DEBUG_ERR, "%s: utc_offset=%d\n", __func__, utc_offset); + + RETURNFUNC(rig_set_clock(rig, year, mon, day, hour, min, sec, msec, + utc_offset)); +} + +/* '0xf9' */ +declare_proto_rig(get_clock) +{ + //char option[64]; + int year, month, day, hour, min, sec, utc_offset, aoffset; + int retval; + double msec; + + ENTERFUNC; + + //CHKSCN1ARG(sscanf(arg1, "%63s", option)); + + retval = rig_get_clock(rig, &year, &month, &day, &hour, &min, &sec, &msec, + &utc_offset); + aoffset = abs(utc_offset); + fprintf(fout, "%04d-%02d-%02dT%02d:%02d:%06.3f%s%02d:%02d\n", year, month, day, + hour, min, sec + msec / 1000, utc_offset >= 0 ? "+" : "-", + aoffset / 100, aoffset % 100); + + return retval; +} diff --git a/tests/rigctlcom.c b/tests/rigctlcom.c index 5a3a5119a..fdfff6c5f 100644 --- a/tests/rigctlcom.c +++ b/tests/rigctlcom.c @@ -626,7 +626,8 @@ int main(int argc, char *argv[]) sizeof(ts2000), stop_set, strlen(stop_set), - 0); + 0, + 1); rig_debug(RIG_DEBUG_TRACE, "%s: status=%d\n", __func__, status); diff --git a/tests/rigctld.c b/tests/rigctld.c index 8b9fd5f64..1a8737223 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -86,7 +86,7 @@ * keep up to date SHORT_OPTIONS, usage()'s output and man page. thanks. * TODO: add an option to read from a file */ -#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:T:t:C:W:x:z:lLuovhVZM" +#define SHORT_OPTIONS "m:r:p:d:P:D:s:c:T:t:C:W:x:z:lLuovhVZM:" static struct option long_options[] = { {"model", 1, 0, 'm'}, @@ -978,7 +978,7 @@ int main(int argc, char *argv[]) sizeof(host), serv, sizeof(serv), - NI_NUMERICHOST|NI_NUMERICSERV)) + NI_NUMERICHOST | NI_NUMERICSERV)) < 0) { rig_debug(RIG_DEBUG_WARN, @@ -1218,7 +1218,7 @@ void *handle_socket(void *arg) sizeof(host), serv, sizeof(serv), - NI_NUMERICHOST|NI_NUMERICSERV)) + NI_NUMERICHOST | NI_NUMERICSERV)) < 0) { diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index b9e5e3069..eff5c7c3c 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -2499,7 +2499,7 @@ declare_proto_rot(send_cmd) * assumes CR or LF is end of line char * for all ascii protocols */ - retval = read_string(&rs->rotport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0); + retval = read_string(&rs->rotport, buf, BUFSZ, eom_buf, strlen(eom_buf), 0, 1); if (retval < 0) { diff --git a/tests/rotctld.c b/tests/rotctld.c index ecbca0e6a..bd10c976b 100644 --- a/tests/rotctld.c +++ b/tests/rotctld.c @@ -598,7 +598,7 @@ int main(int argc, char *argv[]) sizeof(host), serv, sizeof(serv), - NI_NUMERICHOST|NI_NUMERICSERV)) + NI_NUMERICHOST | NI_NUMERICSERV)) < 0) { @@ -711,7 +711,7 @@ void *handle_socket(void *arg) sizeof(host), serv, sizeof(serv), - NI_NUMERICHOST|NI_NUMERICSERV)) + NI_NUMERICHOST | NI_NUMERICSERV)) < 0) { diff --git a/tests/testcookie.c b/tests/testcookie.c index 94c5fa653..5081a4c1b 100644 --- a/tests/testcookie.c +++ b/tests/testcookie.c @@ -77,6 +77,7 @@ static int test2() if (retcode == RIG_OK) { printf("Test#2e OK\n"); } else {printf("Test#2e Failed\n"); return 1;} + return 0; } @@ -85,21 +86,25 @@ static int test3_invalid_input() { int retcode; char cookie[HAMLIB_COOKIE_SIZE]; + /* Make sure any value smaller then HAMLIB_COOKIE_SIZE is rejected */ - for(unsigned int i = 0; i < HAMLIB_COOKIE_SIZE; i++) + for (unsigned int i = 0; i < HAMLIB_COOKIE_SIZE; i++) { retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie, i); + if (retcode == -RIG_EINVAL) { printf("Test#3a OK\n"); } else {printf("Test#3a Failed\n"); return 1;} } /* Make sure a NULL cookie is ignored */ retcode = rig_cookie(NULL, RIG_COOKIE_GET, NULL, sizeof(cookie)); + if (retcode == -RIG_EINVAL) { printf("Test#3b OK\n"); } else {printf("Test#3b Failed\n"); return 1;} /* Make sure an invalid command is dropped with proto error */ retcode = rig_cookie(NULL, RIG_COOKIE_RENEW + 1, cookie, sizeof(cookie)); + if (retcode == -RIG_EPROTO) { printf("Test#3c OK\n"); } else {printf("Test#3c Failed\n"); return 1;} @@ -113,6 +118,7 @@ static int test4_large_cookie_size() /* Using a larger cookie should also work */ retcode = rig_cookie(NULL, RIG_COOKIE_GET, cookie, sizeof(cookie)); + if (retcode == RIG_OK) { printf("Test#4a OK\n"); } else {printf("Test#4a Failed\n"); return 1;} @@ -122,6 +128,7 @@ static int test4_large_cookie_size() /* Release the cookie again to clean up */ retcode = rig_cookie(NULL, RIG_COOKIE_RELEASE, cookie, sizeof(cookie)); + if (retcode == RIG_OK) { printf("Test#4c OK\n"); } else {printf("Test#4c Failed\n"); return 1;}