From c5bc57b719d01734525e198b0a424ed479301af4 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Fri, 13 Aug 2021 11:56:04 -0500 Subject: [PATCH 01/97] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 000000000..8469eb624 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,71 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '39 20 * * 6' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp', 'csharp', 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From c95adac2b1f3d7404cd4d2c551440b32333609e9 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 14 Aug 2021 10:39:00 -0500 Subject: [PATCH 02/97] Adding testlibusb.c --- tests/testlibusb.c | 316 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100755 tests/testlibusb.c diff --git a/tests/testlibusb.c b/tests/testlibusb.c new file mode 100755 index 000000000..5213055d3 --- /dev/null +++ b/tests/testlibusb.c @@ -0,0 +1,316 @@ +/* +* To compile on linux ensure you have libusb-1.0 installed +* e.g. apt install libusb-1.0-0-dev +* Also works on MinGW with both static build and DLLs from MSVC builds +* gcc -o testlibusb testlibusb.c -lusb-1.0 +* +* Test suite program based of libusb-0.1-compat testlibusb +* Copyright (c) 2013 Nathan Hjelm +* +* 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 +*/ + +#include +#include +#include + +int verbose = 0; + +static void print_endpoint_comp(const struct libusb_ss_endpoint_companion_descriptor *ep_comp) +{ + printf(" USB 3.0 Endpoint Companion:\n"); + printf(" bMaxBurst: %u\n", ep_comp->bMaxBurst); + printf(" bmAttributes: %02xh\n", ep_comp->bmAttributes); + printf(" wBytesPerInterval: %u\n", ep_comp->wBytesPerInterval); +} + +static void print_endpoint(const struct libusb_endpoint_descriptor *endpoint) +{ + int i, ret; + + printf(" Endpoint:\n"); + printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress); + printf(" bmAttributes: %02xh\n", endpoint->bmAttributes); + printf(" wMaxPacketSize: %u\n", endpoint->wMaxPacketSize); + printf(" bInterval: %u\n", endpoint->bInterval); + printf(" bRefresh: %u\n", endpoint->bRefresh); + printf(" bSynchAddress: %u\n", endpoint->bSynchAddress); + + for (i = 0; i < endpoint->extra_length;) { + if (LIBUSB_DT_SS_ENDPOINT_COMPANION == endpoint->extra[i + 1]) { + struct libusb_ss_endpoint_companion_descriptor *ep_comp; + + ret = libusb_get_ss_endpoint_companion_descriptor(NULL, endpoint, &ep_comp); + if (LIBUSB_SUCCESS != ret) + continue; + + print_endpoint_comp(ep_comp); + + libusb_free_ss_endpoint_companion_descriptor(ep_comp); + } + + i += endpoint->extra[i]; + } +} + +static void print_altsetting(const struct libusb_interface_descriptor *interface) +{ + uint8_t i; + + printf(" Interface:\n"); + printf(" bInterfaceNumber: %u\n", interface->bInterfaceNumber); + printf(" bAlternateSetting: %u\n", interface->bAlternateSetting); + printf(" bNumEndpoints: %u\n", interface->bNumEndpoints); + printf(" bInterfaceClass: %u\n", interface->bInterfaceClass); + printf(" bInterfaceSubClass: %u\n", interface->bInterfaceSubClass); + printf(" bInterfaceProtocol: %u\n", interface->bInterfaceProtocol); + printf(" iInterface: %u\n", interface->iInterface); + + for (i = 0; i < interface->bNumEndpoints; i++) + print_endpoint(&interface->endpoint[i]); +} + +static void print_2_0_ext_cap(struct libusb_usb_2_0_extension_descriptor *usb_2_0_ext_cap) +{ + printf(" USB 2.0 Extension Capabilities:\n"); + printf(" bDevCapabilityType: %u\n", usb_2_0_ext_cap->bDevCapabilityType); + printf(" bmAttributes: %08xh\n", usb_2_0_ext_cap->bmAttributes); +} + +static void print_ss_usb_cap(struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap) +{ + printf(" USB 3.0 Capabilities:\n"); + printf(" bDevCapabilityType: %u\n", ss_usb_cap->bDevCapabilityType); + printf(" bmAttributes: %02xh\n", ss_usb_cap->bmAttributes); + printf(" wSpeedSupported: %u\n", ss_usb_cap->wSpeedSupported); + printf(" bFunctionalitySupport: %u\n", ss_usb_cap->bFunctionalitySupport); + printf(" bU1devExitLat: %u\n", ss_usb_cap->bU1DevExitLat); + printf(" bU2devExitLat: %u\n", ss_usb_cap->bU2DevExitLat); +} + +static void print_bos(libusb_device_handle *handle) +{ + struct libusb_bos_descriptor *bos; + uint8_t i; + int ret; + + ret = libusb_get_bos_descriptor(handle, &bos); + if (ret < 0) + return; + + printf(" Binary Object Store (BOS):\n"); + printf(" wTotalLength: %u\n", bos->wTotalLength); + printf(" bNumDeviceCaps: %u\n", bos->bNumDeviceCaps); + + for (i = 0; i < bos->bNumDeviceCaps; i++) { + struct libusb_bos_dev_capability_descriptor *dev_cap = bos->dev_capability[i]; + + if (dev_cap->bDevCapabilityType == LIBUSB_BT_USB_2_0_EXTENSION) { + struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension; + + ret = libusb_get_usb_2_0_extension_descriptor(NULL, dev_cap, &usb_2_0_extension); + if (ret < 0) + return; + + print_2_0_ext_cap(usb_2_0_extension); + libusb_free_usb_2_0_extension_descriptor(usb_2_0_extension); + } else if (dev_cap->bDevCapabilityType == LIBUSB_BT_SS_USB_DEVICE_CAPABILITY) { + struct libusb_ss_usb_device_capability_descriptor *ss_dev_cap; + + ret = libusb_get_ss_usb_device_capability_descriptor(NULL, dev_cap, &ss_dev_cap); + if (ret < 0) + return; + + print_ss_usb_cap(ss_dev_cap); + libusb_free_ss_usb_device_capability_descriptor(ss_dev_cap); + } + } + + libusb_free_bos_descriptor(bos); +} + +static void print_interface(const struct libusb_interface *interface) +{ + int i; + + for (i = 0; i < interface->num_altsetting; i++) + print_altsetting(&interface->altsetting[i]); +} + +static void print_configuration(struct libusb_config_descriptor *config) +{ + uint8_t i; + + printf(" Configuration:\n"); + printf(" wTotalLength: %u\n", config->wTotalLength); + printf(" bNumInterfaces: %u\n", config->bNumInterfaces); + printf(" bConfigurationValue: %u\n", config->bConfigurationValue); + printf(" iConfiguration: %u\n", config->iConfiguration); + printf(" bmAttributes: %02xh\n", config->bmAttributes); + printf(" MaxPower: %u\n", config->MaxPower); + + for (i = 0; i < config->bNumInterfaces; i++) + print_interface(&config->interface[i]); +} + +static void print_device(libusb_device *dev, libusb_device_handle *handle) +{ + struct libusb_device_descriptor desc; + unsigned char string[256]; + const char *speed; + int ret; + uint8_t i; + + switch (libusb_get_device_speed(dev)) { + case LIBUSB_SPEED_LOW: speed = "1.5M"; break; + case LIBUSB_SPEED_FULL: speed = "12M"; break; + case LIBUSB_SPEED_HIGH: speed = "480M"; break; + case LIBUSB_SPEED_SUPER: speed = "5G"; break; + case LIBUSB_SPEED_SUPER_PLUS: speed = "10G"; break; + default: speed = "Unknown"; + } + + ret = libusb_get_device_descriptor(dev, &desc); + if (ret < 0) { + fprintf(stderr, "failed to get device descriptor"); + return; + } + + printf("Dev (bus %u, device %u): %04X - %04X speed: %s\n", + libusb_get_bus_number(dev), libusb_get_device_address(dev), + desc.idVendor, desc.idProduct, speed); + + if (!handle) + libusb_open(dev, &handle); + + if (handle) { + if (desc.iManufacturer) { + ret = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, string, sizeof(string)); + if (ret > 0) + printf(" Manufacturer: %s\n", (char *)string); + } + + if (desc.iProduct) { + ret = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, sizeof(string)); + if (ret > 0) + printf(" Product: %s\n", (char *)string); + } + + if (desc.iSerialNumber && verbose) { + ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string, sizeof(string)); + if (ret > 0) + printf(" Serial Number: %s\n", (char *)string); + } + } + + if (verbose) { + for (i = 0; i < desc.bNumConfigurations; i++) { + struct libusb_config_descriptor *config; + + ret = libusb_get_config_descriptor(dev, i, &config); + if (LIBUSB_SUCCESS != ret) { + printf(" Couldn't retrieve descriptors\n"); + continue; + } + + print_configuration(config); + + libusb_free_config_descriptor(config); + } + + if (handle && desc.bcdUSB >= 0x0201) + print_bos(handle); + } + + if (handle) + libusb_close(handle); +} + +#ifdef __linux__ +#include +#include +#include + +static int test_wrapped_device(const char *device_name) +{ + libusb_device_handle *handle; + int r, fd; + + fd = open(device_name, O_RDWR); + if (fd < 0) { + printf("Error could not open %s: %s\n", device_name, strerror(errno)); + return 1; + } + r = libusb_wrap_sys_device(NULL, fd, &handle); + if (r) { + printf("Error wrapping device: %s: %s\n", device_name, libusb_strerror(r)); + close(fd); + return 1; + } + print_device(libusb_get_device(handle), handle); + close(fd); + return 0; +} +#else +static int test_wrapped_device(const char *device_name) +{ + (void)device_name; + printf("Testing wrapped devices is not supported on your platform\n"); + return 1; +} +#endif + +int main(int argc, char *argv[]) +{ + const char *device_name = NULL; + libusb_device **devs; + ssize_t cnt; + int r, i; + + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "-v")) { + verbose = 1; + } else if (!strcmp(argv[i], "-d") && (i + 1) < argc) { + i++; + device_name = argv[i]; + } else { + printf("Usage %s [-v] [-d ]\n", argv[0]); + printf("Note use -d to test libusb_wrap_sys_device()\n"); + return 1; + } + } + + r = libusb_init(NULL); + if (r < 0) + return r; + + if (device_name) { + r = test_wrapped_device(device_name); + } else { + cnt = libusb_get_device_list(NULL, &devs); + if (cnt < 0) { + libusb_exit(NULL); + return 1; + } + + for (i = 0; devs[i]; i++) + print_device(devs[i], NULL); + + libusb_free_device_list(devs, 1); + } + + libusb_exit(NULL); + return r; +} From 12b4dda856217cc60c6b392d4c5274a91e398198 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 14 Aug 2021 17:56:32 -0500 Subject: [PATCH 03/97] Add a check in flrig to protect strdup from a NULL pointer https://github.com/Hamlib/Hamlib/issues/765 --- rigs/dummy/flrig.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index c4ea99fdf..14e1a3279 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 = "202100721", + .version = "202100814", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1414,7 +1414,13 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) } // Set the mode - ttmode = strdup(modeMapGetFLRig(mode)); + if (modeMapGetFLRig(mode)) { + ttmode = strdup(modeMapGetFLRig(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); From 06327322efe20e47730357a00e53f4ca769539c5 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 14 Aug 2021 22:36:33 -0500 Subject: [PATCH 04/97] For Elecraft add a set split after DT$ command in set_split_mode On the K4 the setting of VFOA was turning split off https://github.com/Hamlib/Hamlib/issues/748 --- rigs/kenwood/k3.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rigs/kenwood/k3.c b/rigs/kenwood/k3.c index ae4584e21..4fb288afb 100644 --- a/rigs/kenwood/k3.c +++ b/rigs/kenwood/k3.c @@ -183,7 +183,7 @@ const struct rig_caps k3_caps = RIG_MODEL(RIG_MODEL_K3), .model_name = "K3", .mfg_name = "Elecraft", - .version = BACKEND_VER ".15", + .version = BACKEND_VER ".16", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -334,7 +334,7 @@ const struct rig_caps k3s_caps = RIG_MODEL(RIG_MODEL_K3S), .model_name = "K3S", .mfg_name = "Elecraft", - .version = BACKEND_VER ".13", + .version = BACKEND_VER ".14", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -484,7 +484,7 @@ const struct rig_caps k4_caps = RIG_MODEL(RIG_MODEL_K4), .model_name = "K4", .mfg_name = "Elecraft", - .version = BACKEND_VER ".13", + .version = BACKEND_VER ".14", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -633,7 +633,7 @@ const struct rig_caps kx3_caps = RIG_MODEL(RIG_MODEL_KX3), .model_name = "KX3", .mfg_name = "Elecraft", - .version = BACKEND_VER ".13", + .version = BACKEND_VER ".14", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -782,7 +782,7 @@ const struct rig_caps kx2_caps = RIG_MODEL(RIG_MODEL_KX2), .model_name = "KX2", .mfg_name = "Elecraft", - .version = BACKEND_VER ".13", + .version = BACKEND_VER ".14", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1479,7 +1479,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) snprintf(cmd_m, sizeof(cmd_m), "DT0;"); /* DATA A mode - DATA-R LSB, suppressed carrier */ if (priv->is_k4d || priv->is_k4hd) { - strcat(cmd_m, "DT$0;"); + strcat(cmd_m, "DT$0;FT1;"); } break; @@ -1488,7 +1488,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) snprintf(cmd_m, sizeof(cmd_m), "DT0;"); /* DATA A mode - DATA on USB, suppressed carrier */ if (priv->is_k4d || priv->is_k4hd) { - strcat(cmd_m, "DT$0;"); + strcat(cmd_m, "DT$0;FT1;"); } break; @@ -1497,7 +1497,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) snprintf(cmd_m, sizeof(cmd_m), "DT2;"); /* FSK D mode - direct FSK on LSB optimized for RTTY, VFO dial is MARK */ if (priv->is_k4d || priv->is_k4hd) { - strcat(cmd_m, "DT$2;"); + strcat(cmd_m, "DT$2;FT1;"); } break; @@ -1506,16 +1506,16 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) snprintf(cmd_m, sizeof(cmd_m), "DT1;"); /* FSK D mode - direct FSK on USB optimized for RTTY, VFO dial is MARK */ if (priv->is_k4d || priv->is_k4hd) { - strcat(cmd_m, "DT$1;"); + strcat(cmd_m, "DT$1;FT1;"); } break; case RIG_MODE_PSK: tx_mode = RIG_MODE_PSK; snprintf(cmd_m, sizeof(cmd_m), - "DT3;"); /* PSK D Mode - direct PSK keying, USB is "normal", VFO dial is MARK */ + "DT3;FT1;"); /* PSK D Mode - direct PSK keying, USB is "normal", VFO dial is MARK */ if (priv->is_k4d || priv->is_k4hd) { - strcat(cmd_m, "DT$3;"); + strcat(cmd_m, "DT$3;FT1;"); } break; From e0f468d2c61bffb3adbdc641a020a95abc0c3e38 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 14 Aug 2021 23:45:59 -0500 Subject: [PATCH 05/97] Move FT1 command to K4 rig only --- rigs/kenwood/k3.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rigs/kenwood/k3.c b/rigs/kenwood/k3.c index 4fb288afb..9cbcae647 100644 --- a/rigs/kenwood/k3.c +++ b/rigs/kenwood/k3.c @@ -1479,7 +1479,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) snprintf(cmd_m, sizeof(cmd_m), "DT0;"); /* DATA A mode - DATA-R LSB, suppressed carrier */ if (priv->is_k4d || priv->is_k4hd) { - strcat(cmd_m, "DT$0;FT1;"); + strcat(cmd_m, "DT$0;"); } break; @@ -1488,7 +1488,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) snprintf(cmd_m, sizeof(cmd_m), "DT0;"); /* DATA A mode - DATA on USB, suppressed carrier */ if (priv->is_k4d || priv->is_k4hd) { - strcat(cmd_m, "DT$0;FT1;"); + strcat(cmd_m, "DT$0;"); } break; @@ -1497,7 +1497,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) snprintf(cmd_m, sizeof(cmd_m), "DT2;"); /* FSK D mode - direct FSK on LSB optimized for RTTY, VFO dial is MARK */ if (priv->is_k4d || priv->is_k4hd) { - strcat(cmd_m, "DT$2;FT1;"); + strcat(cmd_m, "DT$2;"); } break; @@ -1506,7 +1506,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) snprintf(cmd_m, sizeof(cmd_m), "DT1;"); /* FSK D mode - direct FSK on USB optimized for RTTY, VFO dial is MARK */ if (priv->is_k4d || priv->is_k4hd) { - strcat(cmd_m, "DT$1;FT1;"); + strcat(cmd_m, "DT$1;"); } break; @@ -1515,7 +1515,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) snprintf(cmd_m, sizeof(cmd_m), "DT3;FT1;"); /* PSK D Mode - direct PSK keying, USB is "normal", VFO dial is MARK */ if (priv->is_k4d || priv->is_k4hd) { - strcat(cmd_m, "DT$3;FT1;"); + strcat(cmd_m, "DT$3;"); } break; @@ -1527,6 +1527,10 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) #if 1 if (priv->is_k4d || priv->is_k4hd) { + // split can get turned off when modes are changing + // so if the rig did this independtly of us we turn it back on + // even if the rig changes the split status should be the last thing we did + if (priv->split) strcat(cmd_m, "FT1;"); /* Set data sub-mode. K3 needs to be in a DATA mode before setting * the sub-mode or switching to VFOB so we do this before the MD$ command. */ From 72de08b3e074f971d4c7ff439c8d62e6f0464bac Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 15 Aug 2021 12:24:28 -0500 Subject: [PATCH 06/97] Add msys-2.0.dll to jtsdk build for libusb support https://github.com/Hamlib/Hamlib/issues/763 --- scripts/build-w64-jtsdk.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/build-w64-jtsdk.sh b/scripts/build-w64-jtsdk.sh index ddef2ea5a..29486937c 100755 --- a/scripts/build-w64-jtsdk.sh +++ b/scripts/build-w64-jtsdk.sh @@ -289,6 +289,13 @@ then cp -a ${FILE} ${ZIP_DIR}/bin/. fi +# Copy over the main MSYS2 Runtime DLL (v2.0 at time of development) +FILE="${QTD_F}/msys-2.0.dll" +if test -f "$FILE" +then + cp -a ${FILE} ${ZIP_DIR}/bin/. +fi + # Required for MinGW with GCC 6.3 (Debian 9) FILE="/usr/lib/gcc/i686-w64-mingw32/6.3-posix/libgcc_s_sjlj-1.dll" if test -f "$FILE" From d59d75c20a4ca851d50d1d879640867ec03fbdc7 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 15 Aug 2021 22:49:06 -0500 Subject: [PATCH 07/97] Another fix for build-w64-jtsdk.sh https://github.com/Hamlib/Hamlib/issues/763 --- scripts/build-w64-jtsdk.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/build-w64-jtsdk.sh b/scripts/build-w64-jtsdk.sh index 29486937c..9b07c0f74 100755 --- a/scripts/build-w64-jtsdk.sh +++ b/scripts/build-w64-jtsdk.sh @@ -290,7 +290,8 @@ then fi # Copy over the main MSYS2 Runtime DLL (v2.0 at time of development) -FILE="${QTD_F}/msys-2.0.dll" +# This is dirty +FILE="/usr/bin/msys-2.0.dll" if test -f "$FILE" then cp -a ${FILE} ${ZIP_DIR}/bin/. From 67597b50c7949ad7f013e8d4d994715391500ef0 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 15 Aug 2021 23:46:27 -0500 Subject: [PATCH 08/97] Add testlibusb to Makefile.am in tests https://github.com/Hamlib/Hamlib/issues/763 --- tests/Makefile.am | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index e8aa5cf1d..6132163ab 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -6,7 +6,7 @@ DISTCLEANFILES = rigctl.log rigctl.sum testbcd.log testbcd.sum -bin_PROGRAMS = rigctl rigctld rigmem rigsmtr rigswr rotctl rotctld rigctlcom ampctl ampctld +bin_PROGRAMS = rigctl rigctld rigmem rigsmtr rigswr rotctl rotctld rigctlcom ampctl ampctld testlibusb check_PROGRAMS = dumpmem testrig testrigopen testrigcaps testtrn testbcd testfreq listrigs testloc rig_bench testcache cachetest cachetest2 testcookie @@ -24,6 +24,7 @@ ampctld_SOURCES = ampctld.c $(AMPCOMMONSRC) rigswr_SOURCES = rigswr.c rigsmtr_SOURCES = rigsmtr.c rigmem_SOURCES = rigmem.c memsave.c memload.c memcsv.c +testlibusb_SOURCES = testlibusb.c # include generated include files ahead of any in sources rigctl_CPPFLAGS = -I$(top_builddir)/tests -I$(top_builddir)/src -I$(srcdir) $(AM_CPPFLAGS) @@ -38,6 +39,7 @@ rotctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I$(top_builddir)/src ampctl_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I$(top_builddir)/src ampctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I$(top_builddir)/src rigctlcom_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) +testlibusb_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) rigctl_LDADD = $(PTHREAD_LIBS) $(READLINE_LIBS) $(LDADD) rigctld_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) @@ -47,6 +49,7 @@ ampctl_LDADD = $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) ampctld_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) rigmem_LDADD = $(LIBXML2_LIBS) $(LDADD) rigctlcom_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) +testlibusb_LDADD = -L/c/JTSDK64-Tools/tools/libusb/1.0.24/VS2019/MS64/dll -lusb-1.0 # Linker options rigctl_LDFLAGS = $(WINEXELDFLAGS) @@ -59,6 +62,7 @@ rigctld_LDFLAGS = $(WINEXELDFLAGS) rotctld_LDFLAGS = $(WINEXELDFLAGS) ampctld_LDFLAGS = $(WINEXELDFLAGS) rigctlcom_LDFLAGS = $(WINEXELDFLAGS) +testlibusb_LDFLAGS = $(WINEXELDFLAGS) if HTML_MATRIX @@ -109,4 +113,4 @@ testcookie.sh: echo './testcookie 1' > testcookie.sh chmod +x ./testcookie.sh -CLEANFILES = testrig.sh testfreq.sh testbcd.sh testloc.sh testrigcaps.sh testcache.sh testcookie.sh +CLEANFILES = testrig.sh testfreq.sh testbcd.sh testloc.sh testrigcaps.sh testcache.sh testcookie.sh testlibusb From 9c75ab3d40a9a4677e0d15b24acce28af2fb9b31 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 16 Aug 2021 07:02:09 -0500 Subject: [PATCH 09/97] Attempt to fix c-cpp.yml for libusb dependency --- .github/workflows/c-cpp.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 3109a5604..7be3eb9d9 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -13,6 +13,8 @@ jobs: steps: - uses: actions/checkout@v2 + - name: packages + - run: sudo apt install libusb-1.0-0-dev - name: bootstrap run: ./bootstrap - name: configure From 2e48c2470b28abb105f2cf9a38fc230c15f98982 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 16 Aug 2021 07:05:32 -0500 Subject: [PATCH 10/97] Fixing c-cpp.yml for libusb --- .github/workflows/c-cpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 7be3eb9d9..1bc344daa 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: packages - - run: sudo apt install libusb-1.0-0-dev + run: sudo apt install libusb-1.0-0-dev - name: bootstrap run: ./bootstrap - name: configure From 6cb90f5260de62234a6e4358d256120113b110dd Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 16 Aug 2021 07:23:39 -0500 Subject: [PATCH 11/97] Fixing c-cpp.yml for libusb --- .github/workflows/c-cpp.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 1bc344daa..519c232f4 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -13,10 +13,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: packages - run: sudo apt install libusb-1.0-0-dev - name: bootstrap - run: ./bootstrap + run: | + sudo apt install libusb-1.0-0-dev + ./bootstrap - name: configure run: ./configure - name: make From 67181bf7c9fa942ae2c5dd61810b2f6584328349 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 16 Aug 2021 07:35:10 -0500 Subject: [PATCH 12/97] Fixing codesql-analysis.yml --- .github/workflows/codeql-analysis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8469eb624..8c456cb9c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -63,7 +63,8 @@ jobs: # and modify them (or add more) to build your code if your project # uses a compiled language - #- run: | + - run: | + sudo apt install libusb-1.0-0-dev # make bootstrap # make release From 356f23b0fbe2c996738cd0cc641133a7324d1e74 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 16 Aug 2021 09:03:08 -0500 Subject: [PATCH 13/97] Fixing codesql-analysis.yml --- .github/workflows/codeql-analysis.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 8c456cb9c..242a4472f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -53,8 +53,8 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 + #- name: Autobuild + # uses: github/codeql-action/autobuild@v1 # â„šī¸ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -64,9 +64,10 @@ jobs: # uses a compiled language - run: | - sudo apt install libusb-1.0-0-dev - # make bootstrap - # make release + sudo apt install libusb-1.0-0-dev + ./bootstrap + ./configure + make - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 From 908b18246e5a0020ca49717f2887e28c616b72bd Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 16 Aug 2021 22:24:51 -0500 Subject: [PATCH 14/97] Hopefully portable detection of libusb.h in testlibusb.c https://github.com/Hamlib/Hamlib/issues/763 --- tests/testlibusb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/testlibusb.c b/tests/testlibusb.c index 5213055d3..83c5f62ac 100755 --- a/tests/testlibusb.c +++ b/tests/testlibusb.c @@ -24,7 +24,11 @@ #include #include +#if __has_include("libusb.h") +#include "libusb.h" +#else #include +#endif int verbose = 0; From 724891246af901b76adca5b84a6a21b849754a29 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 16 Aug 2021 22:39:57 -0500 Subject: [PATCH 15/97] Remove csharp from codeql-analysis --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 242a4472f..4cac2720d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -32,7 +32,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'cpp', 'csharp', 'python' ] + language: [ 'cpp', 'python' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] # Learn more: # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed From 181571a9709475b7be4f37160c67a5f23da1bddb Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 16 Aug 2021 22:49:36 -0500 Subject: [PATCH 16/97] Add fallback serial open logic to hopefully cure serial port open error with K4 https://github.com/Hamlib/Hamlib/issues/768 --- src/serial.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/serial.c b/src/serial.c index af7aa518f..dca8c78c8 100644 --- a/src/serial.c +++ b/src/serial.c @@ -225,6 +225,21 @@ int HAMLIB_API serial_open(hamlib_port_t *rp) * Open in Non-blocking mode. Watch for EAGAIN errors! */ fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); + if (fd == -1) + { + rig_debug(RIG_DEBUG_WARN, "%s: open failed...trying withoud O_NOCTTY\n", __func__); + fd = OPEN(rp->pathname, O_RDWR | O_NDELAY); + } + if (fd == -1) + { + rig_debug(RIG_DEBUG_WARN, "%s: open failed...trying withoud O_NDELAY\n", __func__); + fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY ); + } + if (fd == -1) + { + rig_debug(RIG_DEBUG_WARN, "%s: open failed...trying withoud O_NDELAY and O_NOCTTY\n", __func__); + fd = OPEN(rp->pathname, O_RDWR); + } if (fd == -1) { From 36b42332778ef3398dd08a6c237544c1ff385480 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 17 Aug 2021 08:12:16 -0500 Subject: [PATCH 17/97] Change tests/Makefile.am testlibusb to use LIBUSB_CFLAGS and LIBUSB_LIBS --- tests/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 6132163ab..aa6eae034 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -39,7 +39,7 @@ rotctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I$(top_builddir)/src ampctl_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I$(top_builddir)/src ampctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I$(top_builddir)/src rigctlcom_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -testlibusb_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) +testlibusb_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(LIBUSB_CFLAGS) rigctl_LDADD = $(PTHREAD_LIBS) $(READLINE_LIBS) $(LDADD) rigctld_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) @@ -49,7 +49,7 @@ ampctl_LDADD = $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) ampctld_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) rigmem_LDADD = $(LIBXML2_LIBS) $(LDADD) rigctlcom_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) -testlibusb_LDADD = -L/c/JTSDK64-Tools/tools/libusb/1.0.24/VS2019/MS64/dll -lusb-1.0 +testlibusb_LDADD = $(LIBUSB_LIBS) # Linker options rigctl_LDFLAGS = $(WINEXELDFLAGS) From b2560982fe8ccfeefe656773d62df7863440b560 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 17 Aug 2021 09:17:20 -0500 Subject: [PATCH 18/97] Add LIBUSB flags to hamlib.m4 https://github.com/Hamlib/Hamlib/issues/763 --- hamlib.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hamlib.m4 b/hamlib.m4 index bf65f1774..302974b51 100644 --- a/hamlib.m4 +++ b/hamlib.m4 @@ -38,7 +38,7 @@ dnl Add any special include directories AC_MSG_CHECKING(for HAMLIB CFLAGS) if test "$hamlib_inc_prefix" != "" ; then HAMLIB_CFLAGS="$HAMLIB_CFLAGS -I$hamlib_inc_prefix" - CFLAGS="$CFLAGS -I$hamlib_inc_prefix" + CFLAGS="$CFLAGS -I$hamlib_inc_prefix $LIBUSB_CFLAGS" fi AC_MSG_RESULT($HAMLIB_CFLAGS) @@ -46,7 +46,7 @@ dnl add any special lib dirs AC_MSG_CHECKING(for HAMLIB LDFLAGS) if test "$hamlib_prefix" != "" ; then HAMLIB_LIBS="$HAMLIB_LIBS -L$hamlib_prefix -Wl,--rpath -Wl,$hamlib_prefix" - LDFLAGS="$LDFLAGS $HAMLIB_LIBS" + LDFLAGS="$LDFLAGS $HAMLIB_LIBS $LIBUSB_LDFLAGS" fi dnl add the hamlib library From 3fabc0b50384c17ce56f2662e4c2587aca5ed7a2 Mon Sep 17 00:00:00 2001 From: Wouter Date: Tue, 17 Aug 2021 22:08:17 +0200 Subject: [PATCH 19/97] README: current version is 4 --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 2d31051ff..09e5372e7 100644 --- a/README +++ b/README @@ -124,14 +124,14 @@ Major.minor.incremental Where -Major: Currently at 3, but can be advanced when changes to the API require +Major: Currently at 4, but can be advanced when changes to the API require client programs to be rewritten to take advantage of new features of Hamlib. This number has advanced a couple of times throughout the life of Hamlib. Advancement of the major number is only for frontend API changes that require modification of client source. ABI compatibility is presently maintained to prior releases so that a program linked to an earlier 1.2.Y.[Z] release will work with a later 3.Y[.Z] release without -recompiling. Itis our intention to maintain such ABI compatibility as long +recompiling. It is our intention to maintain such ABI compatibility as long as practical. Minor: This number advances when either new backend(s) or new rig From cb9ea39c660d8a9c5a74f389ba252976dcc7d5c6 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Tue, 17 Aug 2021 20:23:03 +0200 Subject: [PATCH 20/97] Move private data structs of ft100, ft600, ft817, ft857, ft897 to the C file. Note that is already so for all other Yaesu device. Leave private data in newcat; it is used by multiple rigs. --- rigs/yaesu/ft100.c | 7 +++++++ rigs/yaesu/ft100.h | 7 ------- rigs/yaesu/ft600.c | 8 ++++++++ rigs/yaesu/ft600.h | 8 -------- rigs/yaesu/ft817.c | 16 ++++++++++++++++ rigs/yaesu/ft817.h | 17 ----------------- rigs/yaesu/ft847.c | 20 +++++++++++++++++++- rigs/yaesu/ft847.h | 20 -------------------- rigs/yaesu/ft857.c | 18 ++++++++++++++++++ rigs/yaesu/ft857.h | 17 ----------------- rigs/yaesu/ft897.c | 17 +++++++++++++++++ rigs/yaesu/ft897.h | 18 ------------------ 12 files changed, 85 insertions(+), 88 deletions(-) diff --git a/rigs/yaesu/ft100.c b/rigs/yaesu/ft100.c index 52b18a8bb..fd7e9601d 100644 --- a/rigs/yaesu/ft100.c +++ b/rigs/yaesu/ft100.c @@ -41,6 +41,13 @@ #include "misc.h" #include "bandplan.h" +struct ft100_priv_data { + /* TODO: make use of cached data */ + FT100_STATUS_INFO status; + FT100_FLAG_INFO flags; +}; + + /* prototypes */ static int ft100_send_priv_cmd(RIG *rig, unsigned char cmd_index); diff --git a/rigs/yaesu/ft100.h b/rigs/yaesu/ft100.h index 64c2dc582..bb8c8fbf2 100644 --- a/rigs/yaesu/ft100.h +++ b/rigs/yaesu/ft100.h @@ -127,13 +127,6 @@ typedef struct FT100_FLAG_INFO; -struct ft100_priv_data { - /* TODO: make use of cached data */ - FT100_STATUS_INFO status; - FT100_FLAG_INFO flags; -}; - - static int ft100_init(RIG *rig); static int ft100_open(RIG *rig); static int ft100_cleanup(RIG *rig); diff --git a/rigs/yaesu/ft600.c b/rigs/yaesu/ft600.c index ab4838cb8..c0f353a1e 100644 --- a/rigs/yaesu/ft600.c +++ b/rigs/yaesu/ft600.c @@ -41,6 +41,14 @@ #include "misc.h" #include "bandplan.h" +struct ft600_priv_data { + FT600_STATUS_INFO status; + FT600_FLAG_INFO flags; + unsigned char s_meter; + +}; + + /* prototypes */ static int ft600_send_priv_cmd(RIG *rig, unsigned char cmd_index); diff --git a/rigs/yaesu/ft600.h b/rigs/yaesu/ft600.h index 22963d472..002554d16 100644 --- a/rigs/yaesu/ft600.h +++ b/rigs/yaesu/ft600.h @@ -112,14 +112,6 @@ typedef struct FT600_FLAG_INFO; -struct ft600_priv_data { - FT600_STATUS_INFO status; - FT600_FLAG_INFO flags; - unsigned char s_meter; - -}; - - static int ft600_init(RIG *rig); static int ft600_open(RIG *rig); static int ft600_cleanup(RIG *rig); diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index a9d12590c..dc7b9f480 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -71,6 +71,22 @@ #include "bandplan.h" #include "cal.h" +struct ft817_priv_data +{ + yaesu_cmd_set_t pcs[FT817_NATIVE_SIZE]; /* TODO: why? */ + + /* rx status */ + struct timeval rx_status_tv; + unsigned char rx_status; + + /* tx status */ + struct timeval tx_status_tv; + unsigned char tx_status; + + /* freq & mode status */ + struct timeval fm_status_tv; + unsigned char fm_status[YAESU_CMD_LENGTH + 1]; +}; /* Native ft817 cmd set prototypes. These are READ ONLY as each */ /* rig instance will copy from these and modify if required . */ diff --git a/rigs/yaesu/ft817.h b/rigs/yaesu/ft817.h index d6fe017a5..97532dc07 100644 --- a/rigs/yaesu/ft817.h +++ b/rigs/yaesu/ft817.h @@ -122,23 +122,6 @@ enum ft817_native_cmd_e typedef enum ft817_native_cmd_e ft817_native_cmd_t; -struct ft817_priv_data -{ - yaesu_cmd_set_t pcs[FT817_NATIVE_SIZE]; /* TODO: why? */ - - /* rx status */ - struct timeval rx_status_tv; - unsigned char rx_status; - - /* tx status */ - struct timeval tx_status_tv; - unsigned char tx_status; - - /* freq & mode status */ - struct timeval fm_status_tv; - unsigned char fm_status[YAESU_CMD_LENGTH + 1]; -}; - /* fixme: why declare static? it has no effect */ static int ft817_init(RIG *rig); static int ft817_open(RIG *rig); diff --git a/rigs/yaesu/ft847.c b/rigs/yaesu/ft847.c index da42a36d1..8699780fa 100644 --- a/rigs/yaesu/ft847.c +++ b/rigs/yaesu/ft847.c @@ -60,8 +60,26 @@ #include "bandplan.h" #include "tones.h" -/* prototypes */ +/* + * ft847 instance - private data + * + */ +struct ft847_priv_data { + split_t sat_mode; + + unsigned char rx_status; /* tx returned data */ + unsigned char tx_status; /* rx returned data */ + /* for early ft847's we keep our own memory items */ + /* Early rigs are one-way com to the rig */ + freq_t freqA,freqB; + mode_t mode; + pbwidth_t width; + ptt_t ptt; +}; + + +/* prototypes */ static int ft847_send_priv_cmd(RIG *rig, int cmd_index); diff --git a/rigs/yaesu/ft847.h b/rigs/yaesu/ft847.h index 694697879..9c20fc23b 100644 --- a/rigs/yaesu/ft847.h +++ b/rigs/yaesu/ft847.h @@ -144,26 +144,6 @@ typedef enum ft847_native_cmd_e ft847_native_cmd_t; -/* - * ft847 instance - private data - * - */ - -struct ft847_priv_data { - split_t sat_mode; - - unsigned char rx_status; /* tx returned data */ - unsigned char tx_status; /* rx returned data */ - /* for early ft847's we keep our own memory items */ - /* Early rigs are one-way com to the rig */ - freq_t freqA,freqB; - mode_t mode; - pbwidth_t width; - ptt_t ptt; -}; - - - /* * API local implementation */ diff --git a/rigs/yaesu/ft857.c b/rigs/yaesu/ft857.c index 12df2a91c..33f7a27b8 100644 --- a/rigs/yaesu/ft857.c +++ b/rigs/yaesu/ft857.c @@ -74,6 +74,24 @@ #include "tones.h" #include "bandplan.h" +struct ft857_priv_data { + yaesu_cmd_set_t pcs[FT857_NATIVE_SIZE]; /* TODO: why? */ + + /* rx status */ + struct timeval rx_status_tv; + unsigned char rx_status; + + /* tx status */ + struct timeval tx_status_tv; + unsigned char tx_status; + + /* freq & mode status */ + struct timeval fm_status_tv; + unsigned char fm_status[YAESU_CMD_LENGTH+1]; +}; + + + /* Native ft857 cmd set prototypes. These are READ ONLY as each */ /* rig instance will copy from these and modify if required . */ /* Complete sequences (1) can be read and used directly as a cmd sequence . */ diff --git a/rigs/yaesu/ft857.h b/rigs/yaesu/ft857.h index 6634ce1a4..2f1699ae1 100644 --- a/rigs/yaesu/ft857.h +++ b/rigs/yaesu/ft857.h @@ -118,23 +118,6 @@ enum ft857_native_cmd_e { typedef enum ft857_native_cmd_e ft857_native_cmd_t; -struct ft857_priv_data { - yaesu_cmd_set_t pcs[FT857_NATIVE_SIZE]; /* TODO: why? */ - - /* rx status */ - struct timeval rx_status_tv; - unsigned char rx_status; - - /* tx status */ - struct timeval tx_status_tv; - unsigned char tx_status; - - /* freq & mode status */ - struct timeval fm_status_tv; - unsigned char fm_status[YAESU_CMD_LENGTH+1]; -}; - - static int ft857_init(RIG *rig); static int ft857_open(RIG *rig); static int ft857_cleanup(RIG *rig); diff --git a/rigs/yaesu/ft897.c b/rigs/yaesu/ft897.c index ccc40395e..d8963abcf 100644 --- a/rigs/yaesu/ft897.c +++ b/rigs/yaesu/ft897.c @@ -79,6 +79,23 @@ #include "tones.h" #include "bandplan.h" +struct ft897_priv_data { + yaesu_cmd_set_t pcs[FT897_NATIVE_SIZE]; /* TODO: why? */ + + /* rx status */ + struct timeval rx_status_tv; + unsigned char rx_status; + + /* tx status */ + struct timeval tx_status_tv; + unsigned char tx_status; + + /* freq & mode status */ + struct timeval fm_status_tv; + unsigned char fm_status[YAESU_CMD_LENGTH+1]; +}; + + static int ft897_init(RIG *rig); static int ft897_open(RIG *rig); diff --git a/rigs/yaesu/ft897.h b/rigs/yaesu/ft897.h index 9e8c62ed6..a879e4923 100644 --- a/rigs/yaesu/ft897.h +++ b/rigs/yaesu/ft897.h @@ -115,22 +115,4 @@ enum ft897_native_cmd_e { typedef enum ft897_native_cmd_e ft897_native_cmd_t; - -struct ft897_priv_data { - yaesu_cmd_set_t pcs[FT897_NATIVE_SIZE]; /* TODO: why? */ - - /* rx status */ - struct timeval rx_status_tv; - unsigned char rx_status; - - /* tx status */ - struct timeval tx_status_tv; - unsigned char tx_status; - - /* freq & mode status */ - struct timeval fm_status_tv; - unsigned char fm_status[YAESU_CMD_LENGTH+1]; -}; - - #endif /* _FT897_H */ From 9849a1bcaf438c08ac0ea31cad825b9157f80f0c Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Tue, 17 Aug 2021 21:48:25 +0200 Subject: [PATCH 21/97] Implement get_vfo/set_vfo for FT817/FT818. Read the eeprom to get VFO and toggle VFO if not the desired VFO is selected. This code is the ft857 implementation, but EEPROM address 0x55 instead of 0x68. --- rigs/yaesu/ft817.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index dc7b9f480..394e54de9 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -88,6 +88,9 @@ struct ft817_priv_data unsigned char fm_status[YAESU_CMD_LENGTH + 1]; }; +static int ft817_get_vfo(RIG *rig, vfo_t *vfo); +static int ft817_set_vfo(RIG *rig, vfo_t vfo); + /* Native ft817 cmd set prototypes. These are READ ONLY as each */ /* rig instance will copy from these and modify if required . */ /* Complete sequences (1) can be read and used directly as a cmd sequence . */ @@ -324,6 +327,8 @@ const struct rig_caps ft817_caps = .rig_cleanup = ft817_cleanup, .rig_open = ft817_open, .rig_close = ft817_close, + .get_vfo = ft817_get_vfo, + .set_vfo = ft817_set_vfo, .set_freq = ft817_set_freq, .get_freq = ft817_get_freq, .set_mode = ft817_set_mode, @@ -462,6 +467,8 @@ const struct rig_caps ft818_caps = .rig_cleanup = ft817_cleanup, .rig_open = ft817_open, .rig_close = ft817_close, + .get_vfo = ft817_get_vfo, + .set_vfo = ft817_set_vfo, .set_freq = ft817_set_freq, .get_freq = ft817_get_freq, .set_mode = ft817_set_mode, @@ -1114,6 +1121,48 @@ static int ft817_send_icmd(RIG *rig, int index, unsigned char *data) } /* ---------------------------------------------------------------------- */ +static int ft817_get_vfo(RIG *rig, vfo_t *vfo) +{ + unsigned char c; + *vfo = RIG_VFO_B; + + rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); + + if (ft817_read_eeprom(rig, 0x55, &c) < 0) /* get vfo status */ + { + return -RIG_EPROTO; + } + + if ((c & 0x1) == 0) { *vfo = RIG_VFO_A; } + + return RIG_OK; +} + +static int ft817_set_vfo(RIG *rig, vfo_t vfo) +{ + vfo_t curvfo; + int retval; + + rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); + + retval = ft817_get_vfo(rig, &curvfo); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: error get_vfo '%s'\n", __func__, + rigerror(retval)); + return retval; + } + + if (curvfo == vfo) + { + return RIG_OK; + } + + return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_VFOAB); +} + + int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { From 78160a1bf6d9d0493514dc9092e2dd0859740f6f Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Tue, 17 Aug 2021 22:02:45 +0200 Subject: [PATCH 22/97] FT817/FT818 Drop pcs and use ncmd direct --- rigs/yaesu/ft817.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 394e54de9..64f3903ff 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -73,8 +73,6 @@ struct ft817_priv_data { - yaesu_cmd_set_t pcs[FT817_NATIVE_SIZE]; /* TODO: why? */ - /* rx status */ struct timeval rx_status_tv; unsigned char rx_status; @@ -497,8 +495,6 @@ const struct rig_caps ft818_caps = int ft817_init(RIG *rig) { - struct ft817_priv_data *priv; - rig_debug(RIG_DEBUG_VERBOSE, "%s: called, version %s\n", __func__, rig->caps->version); @@ -509,9 +505,6 @@ int ft817_init(RIG *rig) priv = rig->state.priv; - /* Copy complete native cmd set to private cmd storage area */ - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - return RIG_OK; } @@ -582,12 +575,11 @@ static int check_cache_timeout(struct timeval *tv) static int ft817_read_eeprom(RIG *rig, unsigned short addr, unsigned char *out) { - struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; unsigned char data[YAESU_CMD_LENGTH]; int n; rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - memcpy(data, (char *)p->pcs[FT817_NATIVE_CAT_EEPROM_READ].nseq, + memcpy(data, ncmd[FT817_NATIVE_CAT_EEPROM_READ].nseq, YAESU_CMD_LENGTH); data[0] = addr >> 8; @@ -649,7 +641,7 @@ static int ft817_get_status(RIG *rig, int status) do { rig_flush(&rig->state.rigport); - write_block(&rig->state.rigport, (char *) p->pcs[status].nseq, + write_block(&rig->state.rigport, (char *) ncmd[status].nseq, YAESU_CMD_LENGTH); n = read_block(&rig->state.rigport, (char *) data, len); } @@ -1082,18 +1074,16 @@ int ft817_read_ack(RIG *rig) */ static int ft817_send_cmd(RIG *rig, int index) { - struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; - rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - if (p->pcs[index].ncomp == 0) + if (ncmd[index].ncomp == 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: Incomplete sequence\n", __func__); return -RIG_EINTERNAL; } rig_flush(&rig->state.rigport); - write_block(&rig->state.rigport, (char *) p->pcs[index].nseq, YAESU_CMD_LENGTH); + write_block(&rig->state.rigport, (char *) ncmd[index].nseq, YAESU_CMD_LENGTH); return ft817_read_ack(rig); } @@ -1102,18 +1092,17 @@ static int ft817_send_cmd(RIG *rig, int index) */ static int ft817_send_icmd(RIG *rig, int index, unsigned char *data) { - struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; unsigned char cmd[YAESU_CMD_LENGTH]; rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - if (p->pcs[index].ncomp == 1) + if (ncmd[index].ncomp == 1) { rig_debug(RIG_DEBUG_VERBOSE, "%s: Complete sequence\n", __func__); return -RIG_EINTERNAL; } - cmd[YAESU_CMD_LENGTH - 1] = p->pcs[index].nseq[YAESU_CMD_LENGTH - 1]; + cmd[YAESU_CMD_LENGTH - 1] = ncmd[index].nseq[YAESU_CMD_LENGTH - 1]; memcpy(cmd, data, YAESU_CMD_LENGTH - 1); write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH); @@ -1512,8 +1501,6 @@ int ft817_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit) int ft817_set_powerstat(RIG *rig, powerstat_t status) { - struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; - rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); switch (status) @@ -1524,9 +1511,9 @@ int ft817_set_powerstat(RIG *rig, powerstat_t status) case RIG_POWER_ON: // send 5 bytes first, snooze a bit, then PWR_ON write_block(&rig->state.rigport, - (char *) p->pcs[FT817_NATIVE_CAT_PWR_WAKE].nseq, YAESU_CMD_LENGTH); + (char *) ncmd[FT817_NATIVE_CAT_PWR_WAKE].nseq, YAESU_CMD_LENGTH); hl_usleep(200 * 1000); - write_block(&rig->state.rigport, (char *) p->pcs[FT817_NATIVE_CAT_PWR_ON].nseq, + write_block(&rig->state.rigport, (char *) ncmd[FT817_NATIVE_CAT_PWR_ON].nseq, YAESU_CMD_LENGTH); return RIG_OK; From 5ece51ef2f30bebf9c1f40e2303a190a04c1ee5f Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 17 Aug 2021 15:43:21 -0500 Subject: [PATCH 23/97] Remove priv statement --- rigs/yaesu/ft817.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 64f3903ff..73d67fd1c 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -503,8 +503,6 @@ int ft817_init(RIG *rig) return -RIG_ENOMEM; } - priv = rig->state.priv; - return RIG_OK; } From 012b939a197eda184beae6b6ba93fdbdeda3f69a Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 17 Aug 2021 17:53:14 -0500 Subject: [PATCH 24/97] Fix without-libusb build to not build testlibusb --- configure.ac | 1 + tests/Makefile.am | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index d9d3d187e..2ff5cbdb8 100644 --- a/configure.ac +++ b/configure.ac @@ -315,6 +315,7 @@ AC_ARG_WITH([libusb], ) AC_MSG_RESULT([$cf_with_libusb]) +AM_CONDITIONAL([HAVE_LIBUSB], [test x"${cf_with_libusb}" = "xyes"]) LIBUSB="" AC_ARG_VAR([LIBUSB_CFLAGS], [C compiler flags for libusb, overriding configure defaults]) diff --git a/tests/Makefile.am b/tests/Makefile.am index aa6eae034..3fac3cf77 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,9 +4,15 @@ # AUTOMAKE_OPTIONS = dejagnu # DEJATOOL = testfreq testbcd testloc rigctl +if HAVE_LIBUSB + TESTLIBUSB = testlibusb +else + TESTLIBUSB = +endif + DISTCLEANFILES = rigctl.log rigctl.sum testbcd.log testbcd.sum -bin_PROGRAMS = rigctl rigctld rigmem rigsmtr rigswr rotctl rotctld rigctlcom ampctl ampctld testlibusb +bin_PROGRAMS = rigctl rigctld rigmem rigsmtr rigswr rotctl rotctld rigctlcom ampctl ampctld $(TESTLIBUSB) check_PROGRAMS = dumpmem testrig testrigopen testrigcaps testtrn testbcd testfreq listrigs testloc rig_bench testcache cachetest cachetest2 testcookie @@ -24,7 +30,9 @@ ampctld_SOURCES = ampctld.c $(AMPCOMMONSRC) rigswr_SOURCES = rigswr.c rigsmtr_SOURCES = rigsmtr.c rigmem_SOURCES = rigmem.c memsave.c memload.c memcsv.c -testlibusb_SOURCES = testlibusb.c +if HAVE_LIBUSB + testlibusb_SOURCES = testlibusb.c +endif # include generated include files ahead of any in sources rigctl_CPPFLAGS = -I$(top_builddir)/tests -I$(top_builddir)/src -I$(srcdir) $(AM_CPPFLAGS) @@ -39,7 +47,9 @@ rotctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I$(top_builddir)/src ampctl_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I$(top_builddir)/src ampctld_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -I$(top_builddir)/src rigctlcom_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) -testlibusb_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(LIBUSB_CFLAGS) +if HAVE_LIBUSB + testlibusb_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(LIBUSB_CFLAGS) +endif rigctl_LDADD = $(PTHREAD_LIBS) $(READLINE_LIBS) $(LDADD) rigctld_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) @@ -49,7 +59,9 @@ ampctl_LDADD = $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) ampctld_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) rigmem_LDADD = $(LIBXML2_LIBS) $(LDADD) rigctlcom_LDADD = $(NET_LIBS) $(PTHREAD_LIBS) $(LDADD) $(READLINE_LIBS) -testlibusb_LDADD = $(LIBUSB_LIBS) +if HAVE_LIBUSB + testlibusb_LDADD = $(LIBUSB_LIBS) +endif # Linker options rigctl_LDFLAGS = $(WINEXELDFLAGS) @@ -62,7 +74,9 @@ rigctld_LDFLAGS = $(WINEXELDFLAGS) rotctld_LDFLAGS = $(WINEXELDFLAGS) ampctld_LDFLAGS = $(WINEXELDFLAGS) rigctlcom_LDFLAGS = $(WINEXELDFLAGS) -testlibusb_LDFLAGS = $(WINEXELDFLAGS) +if HAVE_LIBUSB + testlibusb_LDFLAGS = $(WINEXELDFLAGS) +endif if HTML_MATRIX From d97eba3c7046ce743ae61965c49c3b26fb6fc676 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 18 Aug 2021 17:41:12 -0500 Subject: [PATCH 25/97] Update NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 64cbdfe0f..1cc539b33 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net Version 4.3 * 2021-??-?? + * libusb-1.0.23 or greater is now required or use --without-libusb * Generating documentation now requires GNU source-highlighter. * Added IC-575 * Overhaul of rig split -- reverse split (VFOA=RX VFOB=TX) should work for rigs capable of it From 61020e950cc3b979630dca8be4bab4ca8003a3da Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 20 Aug 2021 10:21:10 -0500 Subject: [PATCH 26/97] Allow testlibusb to compile on < libusb-1.0.23 Generate warning for libusb-1.0.23 future requirement https://github.com/Hamlib/Hamlib/issues/763 --- tests/testlibusb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/testlibusb.c b/tests/testlibusb.c index 83c5f62ac..fefb80477 100755 --- a/tests/testlibusb.c +++ b/tests/testlibusb.c @@ -242,7 +242,8 @@ static void print_device(libusb_device *dev, libusb_device_handle *handle) libusb_close(handle); } -#ifdef __linux__ +#if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000107) + #include #include #include @@ -268,6 +269,7 @@ static int test_wrapped_device(const char *device_name) return 0; } #else +#warning LIBUSB-1.0.23 will be required in Hamlib > 4.3 static int test_wrapped_device(const char *device_name) { (void)device_name; From 18bbd6b7a790d595760706749ed6c326b57cba0d Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 20 Aug 2021 22:29:12 -0500 Subject: [PATCH 27/97] Add additional attempts to open serial port K4 was failing on 1st open for some unknown reason but succeeds on 2nd try https://github.com/Hamlib/Hamlib/issues/768 --- src/serial.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/serial.c b/src/serial.c index dca8c78c8..ec28a7966 100644 --- a/src/serial.c +++ b/src/serial.c @@ -225,20 +225,23 @@ int HAMLIB_API serial_open(hamlib_port_t *rp) * Open in Non-blocking mode. Watch for EAGAIN errors! */ fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); - if (fd == -1) - { - rig_debug(RIG_DEBUG_WARN, "%s: open failed...trying withoud O_NOCTTY\n", __func__); - fd = OPEN(rp->pathname, O_RDWR | O_NDELAY); + if (fd == -1) // some serial ports fail to open 1st time for some unknown reason + { + rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#1\n", __func__, __LINE__); + hl_usleep(500*1000); + fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); } if (fd == -1) { - rig_debug(RIG_DEBUG_WARN, "%s: open failed...trying withoud O_NDELAY\n", __func__); - fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY ); + rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#2\n", __func__, __LINE__); + hl_usleep(500*1000); + fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); } if (fd == -1) { - rig_debug(RIG_DEBUG_WARN, "%s: open failed...trying withoud O_NDELAY and O_NOCTTY\n", __func__); - fd = OPEN(rp->pathname, O_RDWR); + rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#3\n", __func__, __LINE__); + hl_usleep(500*1000); + fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); } if (fd == -1) @@ -717,6 +720,12 @@ int ser_open(hamlib_port_t *p) * pathname is not uh_rig or uh_ptt: simply open() */ ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY); + if (ret == 1) // some serial ports fail to open 1st time + { + rig_debug(RIG_DEBUG_WARN, "%s(d): open failed#1\n", __func__, ___LINE__); + hl_usleep(500*1000); + ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY); + } } } From 9311519461aeb32f6ea6526d8ec2c7edcb2eb3bd Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 20 Aug 2021 22:31:11 -0500 Subject: [PATCH 28/97] Fix error in serial.c https://github.com/Hamlib/Hamlib/issues/768 --- src/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serial.c b/src/serial.c index ec28a7966..871a2a712 100644 --- a/src/serial.c +++ b/src/serial.c @@ -722,7 +722,7 @@ int ser_open(hamlib_port_t *p) ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY); if (ret == 1) // some serial ports fail to open 1st time { - rig_debug(RIG_DEBUG_WARN, "%s(d): open failed#1\n", __func__, ___LINE__); + rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#1\n", __func__, __LINE__); hl_usleep(500*1000); ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY); } From 4c371ca40acffa8cc7df498cac870fcd1d983d09 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 21 Aug 2021 07:41:48 -0500 Subject: [PATCH 29/97] Fix typo in serial.c https://github.com/Hamlib/Hamlib/issues/768 --- src/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serial.c b/src/serial.c index 871a2a712..57d6eff7b 100644 --- a/src/serial.c +++ b/src/serial.c @@ -720,7 +720,7 @@ int ser_open(hamlib_port_t *p) * pathname is not uh_rig or uh_ptt: simply open() */ ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY); - if (ret == 1) // some serial ports fail to open 1st time + if (ret == -1) // some serial ports fail to open 1st time { rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#1\n", __func__, __LINE__); hl_usleep(500*1000); From 447fda06813e82db5549018e286fb9da2d62c8ca Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sat, 21 Aug 2021 20:30:03 +0200 Subject: [PATCH 30/97] newcat.c: Drop width check; the only call site (get_mode) uses it before the call. Besides most other rigs assume it is != NULL. So having width == NULL would cause a crash for all other rigs. --- rigs/yaesu/newcat.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index bc63e96c5..851f70b5a 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -10080,16 +10080,13 @@ rmode_t newcat_rmode_width(RIG *rig, vfo_t vfo, char mode, pbwidth_t *width) ENTERFUNC; - if (width != NULL) - { - *width = RIG_PASSBAND_NORMAL; - } + *width = RIG_PASSBAND_NORMAL; for (i = 0; i < sizeof(newcat_mode_conv) / sizeof(newcat_mode_conv[0]); i++) { if (newcat_mode_conv[i].modechar == mode) { - if (newcat_mode_conv[i].chk_width == TRUE && width != NULL) + if (newcat_mode_conv[i].chk_width == TRUE) { if (newcat_is_rig(rig, RIG_MODEL_FT991) && mode == 'E') // crude fix because 991 hangs on NA0; command while in C4FM From bfd08203626fd6af5f42e22c1533a47a55697c07 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sat, 21 Aug 2021 20:36:10 +0200 Subject: [PATCH 31/97] icom.c: Drop width check. Other code assumes != NULL. I am not sure if the intention was to check for width == default. But that never worked, so for now do not change behaviour. --- rigs/icom/icom.c | 107 +++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 55 deletions(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index ea506028e..e6120c3ec 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -1742,7 +1742,7 @@ static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, int datamode, in buf[1] = datamode; // filter fixed to filter 1 due to IC7300 bug defaulting to filter 2 on mode changed -- yuck!! // buf[2] = filter // if Icom ever fixed this - buf[2] = 1; + buf[2] = 1; retval = icom_transaction(rig, cmd2, subcmd2, buf, 3, NULL, NULL); @@ -1820,7 +1820,7 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, unsigned char datamode[2]; unsigned char mode_icom; // Not used, we only need the width signed char width_icom; - + TRACE; switch (mode) { @@ -1844,7 +1844,7 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, { TRACE; if (datamode[0] == 0) datamode[1]=0; // the only good combo possible according to manual - + rig_debug(RIG_DEBUG_TRACE, "%s(%d) mode_icom=%d, datamode[0]=%d, filter=%d\n", __func__, __LINE__, mode_icom, datamode[0], datamode[1]); retval = icom_set_mode_x26(rig, vfo, mode_icom, datamode[0], datamode[1]); if (retval != RIG_OK) @@ -2220,64 +2220,61 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) // if we already set width we won't update with except during set_vfo or set_mode // reason is we can't get width without swapping vfos -- yuck!! - if (width != NULL) + if (vfo & (RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_SUB_A | RIG_VFO_MAIN_A | + RIG_VFO_CURR)) { - if (vfo & (RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_SUB_A | RIG_VFO_MAIN_A | - RIG_VFO_CURR)) + // then we get what was asked for + if (vfo == RIG_VFO_NONE && rig->state.current_vfo == RIG_VFO_NONE) { - // then we get what was asked for - if (vfo == RIG_VFO_NONE && rig->state.current_vfo == RIG_VFO_NONE) - { - rig_debug(RIG_DEBUG_TRACE, "%s(%d): forcing default VFO_A\n", __func__, - __LINE__); - TRACE; - rig_set_vfo(rig, RIG_VFO_A); // force VFOA - } + rig_debug(RIG_DEBUG_TRACE, "%s(%d): forcing default VFO_A\n", __func__, + __LINE__); + TRACE; + rig_set_vfo(rig, RIG_VFO_A); // force VFOA + } + retval = icom_get_dsp_flt(rig, *mode); + *width = retval; + + if (retval == 0) + { + rig_debug(RIG_DEBUG_TRACE, + "%s: vfo=%s returning mode=%s, width not available\n", __func__, + rig_strvfo(vfo), rig_strrmode(*mode)); + } + } + else if (rig->state.cache.widthMainB == 0) + { + // we need to swap vfos to get the bandwidth -- yuck + // so we read it once and will let set_mode and transceive capability (4.3 hamlib) update it + vfo_t vfosave = rig->state.current_vfo; + + if (vfosave != vfo) + { + // right now forcing VFOA/B arrangement -- reverse not supported yet + // If VFOB width is ever different than VFOA + // we need to figure out how to read VFOB without swapping VFOs + //TRACE; + //rig_set_vfo(rig, RIG_VFO_B); retval = icom_get_dsp_flt(rig, *mode); *width = retval; - if (retval == 0) - { - rig_debug(RIG_DEBUG_TRACE, - "%s: vfo=%s returning mode=%s, width not available\n", __func__, - rig_strvfo(vfo), rig_strrmode(*mode)); - } + if (*width == 0) { *width = rig->state.cache.widthMainA; } // we'll use VFOA's width + + // dont' really care about cache time here + // this is just to prevent vfo swapping while getting width + rig->state.cache.widthMainB = retval; + rig_debug(RIG_DEBUG_TRACE, "%s(%d): vfosave=%s, currvfo=%s\n", __func__, + __LINE__, rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); + //TRACE; + //rig_set_vfo(rig, RIG_VFO_A); + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s returning mode=%s, width=%d\n", __func__, + rig_strvfo(vfo), rig_strrmode(*mode), (int)*width); } - else if (rig->state.cache.widthMainB == 0) + else { - // we need to swap vfos to get the bandwidth -- yuck - // so we read it once and will let set_mode and transceive capability (4.3 hamlib) update it - vfo_t vfosave = rig->state.current_vfo; - - if (vfosave != vfo) - { - // right now forcing VFOA/B arrangement -- reverse not supported yet - // If VFOB width is ever different than VFOA - // we need to figure out how to read VFOB without swapping VFOs - //TRACE; - //rig_set_vfo(rig, RIG_VFO_B); - retval = icom_get_dsp_flt(rig, *mode); - *width = retval; - - if (*width == 0) { *width = rig->state.cache.widthMainA; } // we'll use VFOA's width - - // dont' really care about cache time here - // this is just to prevent vfo swapping while getting width - rig->state.cache.widthMainB = retval; - rig_debug(RIG_DEBUG_TRACE, "%s(%d): vfosave=%s, currvfo=%s\n", __func__, - __LINE__, rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); - //TRACE; - //rig_set_vfo(rig, RIG_VFO_A); - rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s returning mode=%s, width=%d\n", __func__, - rig_strvfo(vfo), rig_strrmode(*mode), (int)*width); - } - else - { - rig_debug(RIG_DEBUG_WARN, - "%s: vfo arrangement not supported yet, vfo=%s, currvfo=%s\n", __func__, - rig_strvfo(vfo), rig_strvfo(vfosave)); - } + rig_debug(RIG_DEBUG_WARN, + "%s: vfo arrangement not supported yet, vfo=%s, currvfo=%s\n", __func__, + rig_strvfo(vfo), rig_strvfo(vfosave)); } } @@ -5016,7 +5013,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) { RETURNFUNC(retval); } - + TRACE; if (VFO_HAS_MAIN_SUB_A_B_ONLY) { @@ -7864,7 +7861,7 @@ int icom_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch) scan_sc = S_SCAN_STOP; break; - case RIG_SCAN_MEM: + case RIG_SCAN_MEM: TRACE; retval = rig_set_vfo(rig, RIG_VFO_MEM); From a305b4f205f6a33f36d0b5f518351d60d881ddd2 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sat, 21 Aug 2021 20:45:43 +0200 Subject: [PATCH 32/97] ft600.c: Drop width check, code below has no check. The lower code would have crashed if width was NULL, so 'width == NULL' never happens. --- rigs/yaesu/ft600.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rigs/yaesu/ft600.c b/rigs/yaesu/ft600.c index c0f353a1e..e471075ac 100644 --- a/rigs/yaesu/ft600.c +++ b/rigs/yaesu/ft600.c @@ -467,10 +467,7 @@ int ft600_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return -RIG_EINVAL; } - if (width != NULL) - { - *width = RIG_PASSBAND_NORMAL; - } + *width = RIG_PASSBAND_NORMAL; ret = ft600_read_status(rig); From f85cb7cb809d1b337ee2728832da0a7a9b12d06f Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sat, 21 Aug 2021 21:59:02 +0200 Subject: [PATCH 33/97] src/rig.c: Add comments to clarify both mode and width must be supplied --- src/rig.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rig.c b/src/rig.c index 28043dd93..979b5dff4 100644 --- a/src/rig.c +++ b/src/rig.c @@ -2297,6 +2297,9 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) * The value stored at \a mode location equals RIG_MODE_NONE when the current * mode of the VFO is not defined (e.g. blank memory). * + * Note that if either \a mode or \a width is NULL, -RIG_EINVAL is returned. + * Both must be given even if only one is actually wanted. + * * \RETURNFUNC(RIG_OK) if the operation has been successful, otherwise * a negative value if an error occurred (in which case, cause is * set appropriately). From c9860abe9f59b3a541cd3bb50693260c02332586 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sat, 21 Aug 2021 22:26:59 +0200 Subject: [PATCH 34/97] rig.c: Constify rigerror_table --- src/rig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rig.c b/src/rig.c index 979b5dff4..87bbc65f8 100644 --- a/src/rig.c +++ b/src/rig.c @@ -173,7 +173,7 @@ static struct opened_rig_l *opened_rig_list = { NULL }; * Careful, the order must be the same as their RIG_E* counterpart! * TODO: localise the messages.. */ -static const char *rigerror_table[] = +static const char * const rigerror_table[] = { "Command completed successfully", "Invalid parameter", From 617a38ff45c160950491ca3cc7ba5ff8a3a3b3b6 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sat, 21 Aug 2021 22:48:02 +0200 Subject: [PATCH 35/97] src/misc.c: Constify some tables --- src/misc.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/misc.c b/src/misc.c index ad9b9694c..d7abf173f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -413,7 +413,7 @@ const char *HAMLIB_API rig_strstatus(enum rig_status_e status) } -static struct +static const struct { rmode_t mode; const char *str; @@ -553,7 +553,7 @@ int HAMLIB_API rig_strrmodes(rmode_t modes, char *buf, int buflen) } -static struct +static const struct { vfo_t vfo; const char *str; @@ -632,7 +632,7 @@ const char *HAMLIB_API rig_strvfo(vfo_t vfo) } -static struct +static const struct { setting_t func; const char *str; @@ -686,7 +686,7 @@ static struct }; -static struct +static const struct { setting_t func; const char *str; @@ -817,7 +817,7 @@ const char *HAMLIB_API rot_strfunc(setting_t func) } -static struct +static const struct { setting_t level; const char *str; @@ -874,7 +874,7 @@ static struct }; -static struct +static const struct { setting_t level; const char *str; @@ -885,7 +885,7 @@ static struct }; -static struct +static const struct { setting_t level; const char *str; @@ -1074,7 +1074,7 @@ const char *HAMLIB_API amp_strlevel(setting_t level) } -static struct +static const struct { setting_t parm; const char *str; @@ -1092,7 +1092,7 @@ static struct }; -static struct +static const struct { setting_t parm; const char *str; @@ -1211,7 +1211,7 @@ const char *HAMLIB_API rot_strparm(setting_t parm) return ""; } -static struct +static const struct { enum agc_level_e level; const char *str; @@ -1253,7 +1253,7 @@ const char *HAMLIB_API rig_stragclevel(enum agc_level_e level) } -static struct +static const struct { vfo_op_t vfo_op; const char *str; @@ -1327,7 +1327,7 @@ const char *HAMLIB_API rig_strvfop(vfo_op_t op) } -static struct +static const struct { scan_t rscan; const char *str; @@ -1451,7 +1451,7 @@ rptr_shift_t HAMLIB_API rig_parse_rptr_shift(const char *s) } -static struct +static const struct { chan_type_t mtype; const char *str; @@ -1522,7 +1522,7 @@ const char *HAMLIB_API rig_strmtype(chan_type_t mtype) return ""; } -static struct +static const struct { enum rig_spectrum_mode_e mode; const char *str; @@ -1937,7 +1937,7 @@ int HAMLIB_API rig_flush(hamlib_port_t *port) } -static struct +static const struct { rot_status_t status; const char *str; From 2fb5343cc17c1354e77fe6b6ca1fee953471abda Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 21 Aug 2021 22:31:15 -0500 Subject: [PATCH 36/97] Add more retries to PTT serial port open https://github.com/Hamlib/Hamlib/issues/768 --- src/serial.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/serial.c b/src/serial.c index 57d6eff7b..1d8520513 100644 --- a/src/serial.c +++ b/src/serial.c @@ -224,25 +224,16 @@ int HAMLIB_API serial_open(hamlib_port_t *rp) /* * Open in Non-blocking mode. Watch for EAGAIN errors! */ - fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); - if (fd == -1) // some serial ports fail to open 1st time for some unknown reason - { - rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#1\n", __func__, __LINE__); - hl_usleep(500*1000); + int i=1; + do { // some serial ports fail to open 1st time for some unknown reason fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); - } - if (fd == -1) - { - rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#2\n", __func__, __LINE__); - hl_usleep(500*1000); - fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); - } - if (fd == -1) - { - rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#3\n", __func__, __LINE__); - hl_usleep(500*1000); - fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); - } + if (fd == -1) // some serial ports fail to open 1st time for some unknown reason + { + rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#%d\n", __func__, __LINE__, i); + hl_usleep(500*1000); + fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); + } + } while(++i <= 4 && fd == -1); if (fd == -1) { @@ -719,13 +710,17 @@ int ser_open(hamlib_port_t *p) /* * pathname is not uh_rig or uh_ptt: simply open() */ - ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY); - if (ret == -1) // some serial ports fail to open 1st time + int i=1; + do // some serial ports fail to open 1st time { - rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#1\n", __func__, __LINE__); - hl_usleep(500*1000); ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY); - } + if (ret == -1) // some serial ports fail to open 1st time + { + rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#%d\n", __func__, __LINE__, i); + hl_usleep(500*1000); + ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY); + } + } while(++i <= 4 && ret == -1); } } From 82b0a8a84ebcbd3d5c5b0acd29d0cc9e252ef839 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 21 Aug 2021 22:38:44 -0500 Subject: [PATCH 37/97] Improve debug in ser_open --- src/serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serial.c b/src/serial.c index 1d8520513..caa313cae 100644 --- a/src/serial.c +++ b/src/serial.c @@ -680,7 +680,7 @@ int ser_open(hamlib_port_t *p) { int ret; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s called port=%s\n", __func__, p->pathname); if (!strncmp(p->pathname, "uh-rig", 6)) { From 19c5e3e0a73c761e3bdd4f2009354661876ea67d Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 22 Aug 2021 16:40:48 -0500 Subject: [PATCH 38/97] Fix ANT get/set for IC756Pro series https://github.com/Hamlib/Hamlib/issues/774 --- rigs/icom/ic756.c | 10 +++++----- rigs/icom/icom.c | 4 ++-- rigs/icom/icom.h | 2 +- tests/simicom.c | 23 ++++++++++++++++++++++- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/rigs/icom/ic756.c b/rigs/icom/ic756.c index bcdb0baaf..64e8243f8 100644 --- a/rigs/icom/ic756.c +++ b/rigs/icom/ic756.c @@ -127,7 +127,7 @@ static const struct icom_priv_caps ic756_priv_caps = 0, /* 731 mode */ 0, /* no XCHG */ ic756_ts_sc_list, - .antack_len = 2, + .antack_len = 3, .ant_count = 2, .r2i_mode = r2i_mode, .agc_levels_present = 1, @@ -291,7 +291,7 @@ static const struct icom_priv_caps ic756pro_priv_caps = 0, /* 731 mode */ 0, /* no XCHG */ ic756pro_ts_sc_list, - .antack_len = 2, + .antack_len = 3, .ant_count = 2, .agc_levels_present = 1, .agc_levels = { @@ -461,7 +461,7 @@ static const struct icom_priv_caps ic756pro2_priv_caps = 0, /* 731 mode */ 0, /* no XCHG */ ic756pro_ts_sc_list, - .antack_len = 2, + .antack_len = 3, .ant_count = 2, .agc_levels_present = 1, .agc_levels = { @@ -890,7 +890,7 @@ static const struct icom_priv_caps ic756pro3_priv_caps = 0, /* 731 mode */ 0, /* no XCHG */ ic756pro_ts_sc_list, - .antack_len = 2, + .antack_len = 3, .ant_count = 2, .agc_levels_present = 1, .agc_levels = { @@ -976,7 +976,7 @@ const struct rig_caps ic756pro3_caps = RIG_MODEL(RIG_MODEL_IC756PROIII), .model_name = "IC-756PROIII", .mfg_name = "Icom", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index e6120c3ec..ba3607cea 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -7601,7 +7601,6 @@ int icom_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) RETURNFUNC(retval); } - antopt_len = 0; rig_debug(RIG_DEBUG_TRACE, "%s: antack_len=%d so antopt_len=%d, antopt=0x%02x\n", __func__, priv_caps->antack_len, antopt_len, antopt[0]); @@ -7729,13 +7728,14 @@ int icom_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, rig_debug(RIG_DEBUG_ERR, "%s: ackbuf= 0x%02x 0x%02x 0x%02x\n", __func__, ackbuf[0], ackbuf[1], ackbuf[2]); - *ant_curr = rig_idx2setting(ackbuf[1]); + *ant_curr = *ant_tx = *ant_rx = rig_idx2setting(ackbuf[1]); // Note: with IC756/IC-756Pro/IC-7800 and more, ackbuf[2] deals with [RX ANT] // Hopefully any ack_len=3 can fit in the option field if (ack_len == 3) { option->i = ackbuf[2]; + *ant_rx = rig_idx2setting(ackbuf[2]); } RETURNFUNC(RIG_OK); diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 606e271c9..c937844c1 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "20210812" +#define BACKEND_VER "20210822" #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/tests/simicom.c b/tests/simicom.c index 509fc54b1..7e7be7134 100644 --- a/tests/simicom.c +++ b/tests/simicom.c @@ -27,6 +27,8 @@ mode_t modeA = RIG_MODE_CW; mode_t modeB = RIG_MODE_USB; pbwidth_t widthA = 0; pbwidth_t widthB = 1; +ant_t ant_curr = 0; +int ant_option = 0; void dumphex(unsigned char *buf, int n) { @@ -159,6 +161,25 @@ void frameParse(int fd, unsigned char *frame, int len) write(fd, frame, 6); break; + case 0x12: // we're simulating the 3-byte version -- not the 2-byte + if (frame[5] != 0xfd) + { + printf("Set ant %d\n", -1); + ant_curr = frame[5]; + ant_option = frame[6]; + dump_hex(frame,8); + } + else { + printf("Get ant\n"); + } + frame[5] = ant_curr; + frame[6] = ant_option; + frame[7]=0xfd; + printf("write 8 bytes\n"); + dump_hex(frame,8); + write(fd, frame, 8); + break; + case 0x1a: // miscellaneous things switch (frame[5]) { @@ -173,7 +194,7 @@ void frameParse(int fd, unsigned char *frame, int len) break; -#if 0 +#if 1 case 0x25: if (frame[6] == 0xfd) { From dd6224bc5b322592d6db4551523b972b3861d801 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 22 Aug 2021 16:47:29 -0500 Subject: [PATCH 39/97] Fix Kenwood rigs that turn split off during FR command by turning split back on if needed https://github.com/Hamlib/Hamlib/issues/746 --- rigs/kenwood/kenwood.c | 6 ++++++ rigs/kenwood/kenwood.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index f6681ee99..efe6ade9a 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1115,6 +1115,9 @@ int kenwood_set_vfo(RIG *rig, vfo_t 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 + if (priv->split) strcat(cmdbuf,"FT1;"); if (RIG_IS_TS50 || RIG_IS_TS940) { @@ -1251,6 +1254,9 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) /* 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 + if (priv->split) strcat(cmdbuf,"FT1;"); retval = kenwood_transaction(rig, cmdbuf, NULL, 0); if (retval != RIG_OK) diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index f00b156f9..17f64d544 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -28,7 +28,7 @@ #include "token.h" #include "misc.h" -#define BACKEND_VER "20210809" +#define BACKEND_VER "20210822" #define EOM_KEN ';' #define EOM_TH '\r' From 5a2cbdda219107e97971fdc21297005e34ce0f1c Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 23 Aug 2021 23:19:12 -0500 Subject: [PATCH 40/97] Fix lack of error for some bad rig numbers. e.g. rigctl -m 228 produced hash collision error instead of unknown rig https://github.com/Hamlib/Hamlib/issues/735 --- src/register.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/register.c b/src/register.c index ff4ef5e28..0d3895aca 100644 --- a/src/register.c +++ b/src/register.c @@ -284,6 +284,7 @@ int HAMLIB_API rig_check_backend(rig_model_t rig_model) const struct rig_caps *caps; int be_idx; int retval; + int i,n; /* already loaded ? */ caps = rig_get_caps(rig_model); @@ -293,6 +294,17 @@ int HAMLIB_API rig_check_backend(rig_model_t rig_model) return RIG_OK; } + // hmmm...no caps so did we already load the rigs? + for(n=0, i=0; i< RIGLSTHASHSZ; i++) + { + if (rig_hash_table[i]) ++n; + } + if (n > 1) + { + rig_debug(RIG_DEBUG_ERR, "%s: rig model %d not found and rig count=%d\n", __func__, rig_model, n); + return -RIG_ENAVAIL; + } + be_idx = rig_lookup_backend(rig_model); /* From 49240c9846c9d4c730e9cbe154ec07a496c4ec7d Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Wed, 25 Aug 2021 22:13:21 +0200 Subject: [PATCH 41/97] Simplify get_ant by having setting to unknown by default. Drop setting to default in rigs. Add some more documentation on get_ant. --- rigs/drake/drake.c | 3 --- rigs/dummy/dummy.c | 4 +--- rigs/dummy/netrigctl.c | 6 ++---- rigs/icom/icom.c | 2 -- rigs/kenwood/ic10.c | 1 - rigs/kenwood/kenwood.c | 6 ++---- rigs/kenwood/th.c | 2 -- rigs/racal/ra37xx.c | 2 -- rigs/tentec/orion.c | 2 -- rigs/yaesu/newcat.c | 3 --- src/rig.c | 16 +++++++++++----- 11 files changed, 16 insertions(+), 31 deletions(-) diff --git a/rigs/drake/drake.c b/rigs/drake/drake.c index ad817591e..493a72e1b 100644 --- a/rigs/drake/drake.c +++ b/rigs/drake/drake.c @@ -512,8 +512,6 @@ int drake_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, char mdbuf[BUFSZ]; char cant; - *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; - retval = drake_transaction(rig, "RM" EOM, 3, mdbuf, &mdbuf_len); if (retval != RIG_OK) @@ -542,7 +540,6 @@ int drake_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, rig_debug(RIG_DEBUG_ERR, "drake_get_ant: unsupported antenna %c\n", cant); - *ant_curr = RIG_ANT_UNKNOWN; return -RIG_EINVAL; } diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c index f2c45f52d..6372f17bf 100644 --- a/rigs/dummy/dummy.c +++ b/rigs/dummy/dummy.c @@ -482,7 +482,7 @@ static int dummy_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) case RIG_VFO_SUB: case RIG_VFO_B: *freq = priv->vfo_b.freq; break; - case RIG_VFO_SUB_A: *freq = priv->vfo_suba.freq;break; + case RIG_VFO_SUB_A: *freq = priv->vfo_suba.freq;break; case RIG_VFO_SUB_B: *freq = priv->vfo_subb.freq;break; case RIG_VFO_C: *freq = priv->vfo_c.freq; break; @@ -1671,8 +1671,6 @@ static int dummy_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x\n", __func__, ant); - *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; - switch (ant) { case RIG_ANT_CURR: diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c index 3dd9a987f..fd69cb9a5 100644 --- a/rigs/dummy/netrigctl.c +++ b/rigs/dummy/netrigctl.c @@ -673,7 +673,7 @@ static int netrigctl_open(RIG *rig) // setting targetable_vfo this way breaks WSJTX in rig split with rigctld // Ends up putting VFOB freq on VFOA // Have to figure out why but disabling this fixes it for now -#if 0 +#if 0 else if (strcmp(setting, "targetable_vfo") == 0) { rig->caps->targetable_vfo = strtol(value, NULL, 0); @@ -2111,8 +2111,6 @@ static int netrigctl_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; - ret = netrigctl_vfostr(rig, vfostr, sizeof(vfostr), vfo); if (ret != RIG_OK) { return ret; } @@ -2557,7 +2555,7 @@ struct rig_caps netrigctl_caps = .dcd_type = RIG_DCD_RIG, .port_type = RIG_PORT_NETWORK, .timeout = 10000, /* enough for the worst rig we have */ - .retry = 5, + .retry = 5, /* following fields updated in rig_state at opening time */ .has_get_func = RIG_FUNC_NONE, diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index ba3607cea..a1ef70942 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -7663,8 +7663,6 @@ int icom_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, rig_debug(RIG_DEBUG_VERBOSE, "%s called, ant=0x%02x\n", __func__, ant); - *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; - if (ant != RIG_ANT_CURR) { ant = rig_setting2idx(ant); diff --git a/rigs/kenwood/ic10.c b/rigs/kenwood/ic10.c index 07a10d19e..db9196286 100644 --- a/rigs/kenwood/ic10.c +++ b/rigs/kenwood/ic10.c @@ -505,7 +505,6 @@ int ic10_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, char infobuf[50]; int info_len, retval; - *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; info_len = 4; retval = ic10_transaction(rig, "AN;", 3, infobuf, &info_len); diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index efe6ade9a..64eb64d81 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1299,8 +1299,8 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) priv->tx_vfo = txvfo; /* do not attempt redundant split change commands on Elecraft as - they impact output power when transmitting - and all other rigs don't need to set it if it's already set correctly + they impact output power when transmitting + and all other rigs don't need to set it if it's already set correctly */ if (RIG_OK == (retval = kenwood_safe_transaction(rig, "FT", cmdbuf, sizeof(cmdbuf), 3))) @@ -4188,8 +4188,6 @@ int kenwood_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; - if (!ant_curr) { RETURNFUNC(-RIG_EINVAL); diff --git a/rigs/kenwood/th.c b/rigs/kenwood/th.c index 7fd89979b..b08567b2c 100644 --- a/rigs/kenwood/th.c +++ b/rigs/kenwood/th.c @@ -2532,8 +2532,6 @@ int th_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__); - *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; - retval = kenwood_safe_transaction(rig, "ANT", buf, sizeof(buf), 5); if (retval != RIG_OK) diff --git a/rigs/racal/ra37xx.c b/rigs/racal/ra37xx.c index ca09bf1ed..6d1866219 100644 --- a/rigs/racal/ra37xx.c +++ b/rigs/racal/ra37xx.c @@ -760,8 +760,6 @@ int ra37xx_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, char buf[BUFSZ]; int retval, buflen, ra_ant; - *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; - retval = ra37xx_transaction(rig, "QANT", buf, &buflen); if (retval != RIG_OK) diff --git a/rigs/tentec/orion.c b/rigs/tentec/orion.c index 41a6d9242..b80ae7062 100644 --- a/rigs/tentec/orion.c +++ b/rigs/tentec/orion.c @@ -2125,8 +2125,6 @@ int tt565_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, char respbuf[TT565_BUFSIZE]; int resp_len, retval; - *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; - resp_len = sizeof(respbuf); retval = tt565_transaction(rig, "?KA" EOM, 4, respbuf, &resp_len); diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 851f70b5a..3ca0a62b7 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -3383,8 +3383,6 @@ int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, ENTERFUNC; - option->i = 0; // default to no options - if (!newcat_valid_command(rig, command)) { RETURNFUNC(-RIG_ENAVAIL); @@ -3437,7 +3435,6 @@ int newcat_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, break; default: - *ant_curr = RIG_ANT_UNKNOWN; RETURNFUNC(-RIG_EPROTO); } diff --git a/src/rig.c b/src/rig.c index 87bbc65f8..c67b6d017 100644 --- a/src/rig.c +++ b/src/rig.c @@ -5188,15 +5188,18 @@ int HAMLIB_API rig_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) * \brief get the current antenna * \param rig The rig handle * \param vfo The target VFO - * \param ant The location where to store the current antenna - * \param option The option value for the antenna + * \param ant The antenna to query option for + * \param option The option value for the antenna, rig specific. * \param ant_curr The currently selected antenna * \param ant_tx The currently selected TX antenna * \param ant_rx The currently selected RX antenna * * Retrieves the current antenna. * - * \RETURNFUNC(RIG_OK) if the operation has been successful, otherwise + * If \a ant_tx and/or \a ant_rx are unused by the rig they will be set to + * RIG_ANT_UNKNOWN and only \a ant_curr will be set. + * + * \return RIG_OK if the operation has been successful, otherwise * a negative value if an error occurred (in which case, cause is * set appropriately). * @@ -5224,8 +5227,6 @@ int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, RETURNFUNC(-RIG_EINVAL); } - *ant_tx = *ant_rx = RIG_ANT_UNKNOWN; - caps = rig->caps; if (caps->get_ant == NULL) @@ -5233,6 +5234,11 @@ int HAMLIB_API rig_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, RETURNFUNC(-RIG_ENAVAIL); } + /* Set antenna default to unknown and clear option. + * So we have sane defaults for all backends */ + *ant_tx = *ant_rx = *ant_curr = RIG_ANT_UNKNOWN; + option->i = 0; + if ((caps->targetable_vfo & RIG_TARGETABLE_ANT) || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) From 49c7e09142db692693f68d2d959465a8d3a438d8 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 26 Aug 2021 06:47:14 -0500 Subject: [PATCH 42/97] Put simulators in their own directory...this is an ongoing project to make these more robust. Simulators are currently used to debug things and need to improved to allow model selection and all the complexities of simulating multiple models --- {tests => simulators}/simelecraft.c | 0 {tests => simulators}/simicom.c | 0 {tests => simulators}/simkenwood.c | 0 {tests => simulators}/simyaesu.c | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {tests => simulators}/simelecraft.c (100%) rename {tests => simulators}/simicom.c (100%) rename {tests => simulators}/simkenwood.c (100%) rename {tests => simulators}/simyaesu.c (100%) diff --git a/tests/simelecraft.c b/simulators/simelecraft.c similarity index 100% rename from tests/simelecraft.c rename to simulators/simelecraft.c diff --git a/tests/simicom.c b/simulators/simicom.c similarity index 100% rename from tests/simicom.c rename to simulators/simicom.c diff --git a/tests/simkenwood.c b/simulators/simkenwood.c similarity index 100% rename from tests/simkenwood.c rename to simulators/simkenwood.c diff --git a/tests/simyaesu.c b/simulators/simyaesu.c similarity index 100% rename from tests/simyaesu.c rename to simulators/simyaesu.c From c823564a2af6755f5a524003a0786442878451af Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 26 Aug 2021 06:49:24 -0500 Subject: [PATCH 43/97] astyle all files preparing for 4.3 release --- rigs/dummy/dummy.c | 49 ++-- rigs/dummy/flrig.c | 17 +- rigs/dummy/netrigctl.c | 2 + rigs/icom/frame.c | 6 +- rigs/icom/icom.c | 444 ++++++++++++++++++++++------------ rigs/kenwood/flex6xxx.c | 2 +- rigs/kenwood/k3.c | 58 +++-- rigs/kenwood/kenwood.c | 18 +- rigs/kenwood/ts890s.c | 5 +- rigs/kit/rs_hfiq.c | 164 +++++++------ rigs/yaesu/ft100.c | 9 +- rigs/yaesu/ft600.c | 9 +- rigs/yaesu/ft847.c | 21 +- rigs/yaesu/ft857.c | 23 +- rigs/yaesu/ft897.c | 23 +- rigs/yaesu/newcat.c | 13 +- rotators/rotorez/rotorez.c | 6 +- simulators/simelecraft.c | 41 ++-- simulators/simicom.c | 15 +- simulators/simkenwood.c | 23 +- simulators/simyaesu.c | 10 +- src/event.c | 9 +- src/iofunc.c | 3 +- src/misc.c | 1 + src/network.c | 5 +- src/register.c | 13 +- src/rig.c | 97 +++++--- src/serial.c | 23 +- src/sprintflst.c | 21 +- tests/dumpcaps.c | 12 +- tests/rigctl.c | 8 +- tests/rigctl_parse.c | 23 +- tests/rigctlcom.c | 52 ++-- tests/rigctld.c | 10 +- tests/testcache.c | 4 +- tests/testcookie.c | 1 + tests/testlibusb.c | 481 ++++++++++++++++++++++--------------- tests/testrig.c | 5 +- 38 files changed, 1078 insertions(+), 648 deletions(-) mode change 100755 => 100644 tests/testlibusb.c diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c index 6372f17bf..5ae37a6b0 100644 --- a/rigs/dummy/dummy.c +++ b/rigs/dummy/dummy.c @@ -155,25 +155,31 @@ static void init_chan(RIG *rig, vfo_t vfo, channel_t *chan) chan->vfo = vfo; strcpy(chan->channel_desc, rig_strvfo(vfo)); - switch(vfo) + switch (vfo) { - case RIG_VFO_A: - case RIG_VFO_MAIN_A: + case RIG_VFO_A: + case RIG_VFO_MAIN_A: chan->freq = MHz(145); break; - case RIG_VFO_B: - case RIG_VFO_MAIN_B: + + case RIG_VFO_B: + case RIG_VFO_MAIN_B: chan->freq = MHz(146); break; - case RIG_VFO_SUB_A: + + case RIG_VFO_SUB_A: chan->freq = MHz(147); break; - case RIG_VFO_SUB_B: + + case RIG_VFO_SUB_B: chan->freq = MHz(148); break; - default: - rig_debug(RIG_DEBUG_ERR, "%s(%d) unknown vfo=%s\n", __FILE__, __LINE__, rig_strvfo(vfo)); + + default: + rig_debug(RIG_DEBUG_ERR, "%s(%d) unknown vfo=%s\n", __FILE__, __LINE__, + rig_strvfo(vfo)); } + chan->mode = RIG_MODE_FM; chan->width = rig_passband_normal(rig, RIG_MODE_FM); chan->tx_freq = chan->freq; @@ -420,7 +426,7 @@ static int dummy_set_freq(RIG *rig, vfo_t vfo, freq_t freq) // if needed for testing enable this to emulate a rig with 100hz resolution #if 0 // we emulate a rig with 100Hz set freq interval limits -- truncation - freq = freq - fmod(freq,100); + freq = freq - fmod(freq, 100); #endif usleep(CMDSLEEP); sprintf_freq(fstr, sizeof(fstr), freq); @@ -431,12 +437,16 @@ static int dummy_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { case RIG_VFO_MAIN: case RIG_VFO_A: priv->vfo_a.freq = freq; break; + case RIG_VFO_MAIN_A: priv->vfo_maina.freq = freq; break; + case RIG_VFO_MAIN_B: priv->vfo_mainb.freq = freq; break; case RIG_VFO_SUB: case RIG_VFO_B: priv->vfo_b.freq = freq; break; + case RIG_VFO_SUB_A: priv->vfo_suba.freq = freq; break; + case RIG_VFO_SUB_B: priv->vfo_subb.freq = freq; break; case RIG_VFO_C: priv->vfo_c.freq = freq; break; @@ -477,13 +487,17 @@ static int dummy_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { case RIG_VFO_MAIN: case RIG_VFO_A: *freq = priv->vfo_a.freq; break; - case RIG_VFO_MAIN_A: *freq = priv->vfo_maina.freq;break; - case RIG_VFO_MAIN_B: *freq = priv->vfo_mainb.freq;break; + + case RIG_VFO_MAIN_A: *freq = priv->vfo_maina.freq; break; + + case RIG_VFO_MAIN_B: *freq = priv->vfo_mainb.freq; break; case RIG_VFO_SUB: case RIG_VFO_B: *freq = priv->vfo_b.freq; break; - case RIG_VFO_SUB_A: *freq = priv->vfo_suba.freq;break; - case RIG_VFO_SUB_B: *freq = priv->vfo_subb.freq;break; + + case RIG_VFO_SUB_A: *freq = priv->vfo_suba.freq; break; + + case RIG_VFO_SUB_B: *freq = priv->vfo_subb.freq; break; case RIG_VFO_C: *freq = priv->vfo_c.freq; break; @@ -508,6 +522,7 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) rig_strvfo(vfo), rig_strrmode(mode), buf); vfo = vfo_fixup(rig, vfo, rig->state.cache.split); + switch (vfo) { case RIG_VFO_MAIN: @@ -517,6 +532,7 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) case RIG_VFO_B: priv->vfo_b.mode = mode; priv->vfo_b.width = width; break; case RIG_VFO_C: priv->vfo_c.mode = mode; priv->vfo_c.width = width; break; + default: rig_debug(RIG_DEBUG_ERR, "%s: unknown VFO=%s\n", __func__, rig_strvfo(vfo)); RETURNFUNC(-RIG_EINVAL); @@ -589,13 +605,17 @@ static int dummy_set_vfo(RIG *rig, vfo_t vfo) case RIG_VFO_RX: case RIG_VFO_MAIN: priv->curr = &priv->vfo_a; break; + case RIG_VFO_MAIN_A: priv->curr = &priv->vfo_maina; break; + case RIG_VFO_MAIN_B: priv->curr = &priv->vfo_mainb; break; case RIG_VFO_A: priv->curr = &priv->vfo_a; break; case RIG_VFO_SUB: priv->curr = &priv->vfo_b; break; + case RIG_VFO_SUB_A: priv->curr = &priv->vfo_suba; break; + case RIG_VFO_SUB_B: priv->curr = &priv->vfo_subb; break; case RIG_VFO_B: priv->curr = &priv->vfo_b; break; @@ -622,6 +642,7 @@ static int dummy_set_vfo(RIG *rig, vfo_t vfo) rig_strvfo(vfo)); RETURNFUNC(-RIG_EINVAL); } + rig->state.current_vfo = vfo; RETURNFUNC(RIG_OK); diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index 14e1a3279..49cd998fd 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -272,7 +272,8 @@ static int check_vfo(vfo_t vfo) * So we'll hand craft them * xml_build takes a value and return an xml string for FLRig */ -static char *xml_build(RIG *rig, char *cmd, char *value, char *xmlbuf, int xmlbuflen) +static char *xml_build(RIG *rig, char *cmd, char *value, char *xmlbuf, + int xmlbuflen) { char xml[4096]; // we shouldn't need more the 4096 bytes for this char tmp[32]; @@ -297,7 +298,9 @@ static char *xml_build(RIG *rig, char *cmd, char *value, char *xmlbuf, int xmlbu __func__, (int)strlen(header), n); } - n = snprintf(xml, sizeof(xml), "\r\n\r\n", rig->state.rigport.client_port); + n = snprintf(xml, sizeof(xml), + "\r\n\r\n", + rig->state.rigport.client_port); if (n != strlen(xml)) { @@ -1414,13 +1417,17 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) } // Set the mode - if (modeMapGetFLRig(mode)) { + if (modeMapGetFLRig(mode)) + { ttmode = strdup(modeMapGetFLRig(mode)); } - else { - rig_debug(RIG_DEBUG_ERR, "%s: modeMapGetFlRig failed on mode=%d\n", __func__, (int)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); diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c index fd69cb9a5..672c5f7bc 100644 --- a/rigs/dummy/netrigctl.c +++ b/rigs/dummy/netrigctl.c @@ -670,6 +670,7 @@ static int netrigctl_open(RIG *rig) rig->caps->ptt_type = temp; } } + // setting targetable_vfo this way breaks WSJTX in rig split with rigctld // Ends up putting VFOB freq on VFOA // Have to figure out why but disabling this fixes it for now @@ -680,6 +681,7 @@ static int netrigctl_open(RIG *rig) rig_debug(RIG_DEBUG_ERR, "%s: targetable_vfo=0x%2x\n", __func__, rig->caps->targetable_vfo); } + #endif else if (strcmp(setting, "has_set_vfo") == 0) { diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c index 65997f093..6880df8a8 100644 --- a/rigs/icom/frame.c +++ b/rigs/icom/frame.c @@ -101,7 +101,8 @@ int icom_frame_fix_preamble(int frame_len, unsigned char *frame) } else { - rig_debug(RIG_DEBUG_WARN, "%s: invalid Icom CI-V frame, no preamble found\n", __func__); + rig_debug(RIG_DEBUG_WARN, "%s: invalid Icom CI-V frame, no preamble found\n", + __func__); RETURNFUNC(-RIG_EPROTO); } @@ -284,6 +285,7 @@ read_another_frame: } retval = icom_frame_fix_preamble(frm_len, buf); + if (retval < 0) { Unhold_Decode(rig); @@ -355,7 +357,7 @@ read_another_frame: gettimeofday(¤t_time, NULL); timersub(¤t_time, &start_time, &elapsed_time); - elapsed_ms = (int) (elapsed_time.tv_sec * 1000 + elapsed_time.tv_usec / 1000); + elapsed_ms = (int)(elapsed_time.tv_sec * 1000 + elapsed_time.tv_usec / 1000); if (elapsed_ms > rs->rigport.timeout) { diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index a1ef70942..0ce03fda5 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -47,7 +47,8 @@ static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo); static int icom_set_default_vfo(RIG *rig); static int icom_get_spectrum_vfo(RIG *rig, vfo_t vfo); -static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, int *range_id); +static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, + int *range_id); const cal_table_float_t icom_default_swr_cal = { @@ -634,17 +635,21 @@ int icom_init(RIG *rig) priv = rig->state.priv; priv->spectrum_scope_count = 0; + for (i = 0; caps->spectrum_scopes[i].name != NULL; i++) { priv->spectrum_scope_cache[i].spectrum_data = NULL; if (priv_caps->spectrum_scope_caps.spectrum_line_length < 1) { - rig_debug(RIG_DEBUG_ERR, "%s: no spectrum scope line length defined\n", __func__); + rig_debug(RIG_DEBUG_ERR, "%s: no spectrum scope line length defined\n", + __func__); RETURNFUNC(-RIG_ECONF); } - priv->spectrum_scope_cache[i].spectrum_data = calloc(1, priv_caps->spectrum_scope_caps.spectrum_line_length); + priv->spectrum_scope_cache[i].spectrum_data = calloc(1, + priv_caps->spectrum_scope_caps.spectrum_line_length); + if (!priv->spectrum_scope_cache[i].spectrum_data) { RETURNFUNC(-RIG_ENOMEM); @@ -902,7 +907,7 @@ static int icom_set_default_vfo(RIG *rig) { rig_debug(RIG_DEBUG_TRACE, "%s: setting default as MAIN/VFOA\n", __func__); - TRACE; + TRACE; retval = rig_set_vfo(rig, RIG_VFO_MAIN); // we'll default to Main in this case if (retval != RIG_OK) @@ -926,7 +931,7 @@ static int icom_set_default_vfo(RIG *rig) { rig_debug(RIG_DEBUG_TRACE, "%s: setting default as MAIN\n", __func__); - TRACE; + TRACE; retval = rig_set_vfo(rig, RIG_VFO_MAIN); // we'll default to Main in this case rig->state.current_vfo = RIG_VFO_MAIN; } @@ -936,11 +941,12 @@ static int icom_set_default_vfo(RIG *rig) __func__); TRACE; retval = RIG_OK; + if (rig->state.current_vfo != RIG_VFO_A) { - retval = rig_set_vfo(rig, - RIG_VFO_A); // we'll default to VFOA for all others - rig->state.current_vfo = RIG_VFO_A; + retval = rig_set_vfo(rig, + RIG_VFO_A); // we'll default to VFOA for all others + rig->state.current_vfo = RIG_VFO_A; } } else @@ -1032,7 +1038,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { TRACE; rig_debug(RIG_DEBUG_TRACE, "%s: set_vfo_curr=%s\n", __func__, - rig_strvfo(rig->state.current_vfo)); + rig_strvfo(rig->state.current_vfo)); retval = set_vfo_curr(rig, vfo, rig->state.current_vfo); if (retval != RIG_OK) @@ -1058,6 +1064,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) if (rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ) { vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B; + // if we are on the "other" vfo already then we have to allow for that if (rig->state.current_vfo & vfo_unselected) { @@ -1065,8 +1072,10 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) vfo_unselected = RIG_VFO_A | RIG_VFO_MAIN | RIG_VFO_SUB_A | RIG_VFO_MAIN_A; } - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo=%s, currvfo=%s\n", __func__, __LINE__, rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): vfo=%s, currvfo=%s\n", __func__, __LINE__, + rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); subcmd = 0x00; + // if we ask for unselected but we're not on unselected subcmd2 changes if ((vfo & vfo_unselected) && !(rig->state.current_vfo & vfo_unselected)) { @@ -1076,15 +1085,16 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) cmd = 0x25; retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf, - &ack_len); + &ack_len); } else { cmd = C_SET_FREQ; subcmd = -1; retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf, - &ack_len); + &ack_len); } + hl_usleep(50 * 1000); // pause for transceive message and we'll flush it if (retval != RIG_OK) @@ -1155,11 +1165,15 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq) switch (vfo) { case RIG_VFO_A: priv->vfoa_freq = freq; break; + case RIG_VFO_MAIN_A: priv->maina_freq = freq; break; + case RIG_VFO_SUB_A: priv->suba_freq = freq; break; case RIG_VFO_B: priv->vfob_freq = freq; break; + case RIG_VFO_MAIN_B: priv->mainb_freq = freq; + case RIG_VFO_SUB_B: priv->subb_freq = freq; case RIG_VFO_MAIN: priv->main_freq = freq; break; @@ -1313,6 +1327,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int cmd2 = 0x25; int subcmd2 = 0x00; vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B; + // if we are on the "other" vfo already then we have to allow for that if (rig->state.current_vfo & vfo_unselected) { @@ -1416,11 +1431,15 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) switch (vfo) { case RIG_VFO_A: priv->vfoa_freq = *freq; break; + case RIG_VFO_MAIN_A: priv->maina_freq = *freq; break; + case RIG_VFO_SUB_A: priv->suba_freq = *freq; break; case RIG_VFO_B: priv->vfob_freq = *freq; break; + case RIG_VFO_MAIN_B: priv->mainb_freq = *freq; break; + case RIG_VFO_SUB_B: priv->subb_freq = *freq; break; case RIG_VFO_MAIN: priv->main_freq = *freq; break; @@ -1715,18 +1734,21 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width) RETURNFUNC(RIG_OK); } -static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, int datamode, int filter) +static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, int datamode, + int filter) { struct icom_priv_data *priv = rig->state.priv; int retval; unsigned char buf[3]; ENTERFUNC; - if (priv->x26cmdfails) RETURNFUNC(-RIG_ENAVAIL); + + if (priv->x26cmdfails) { RETURNFUNC(-RIG_ENAVAIL); } int cmd2 = 0x26; int subcmd2 = 0x00; vfo_t vfo_unselected = RIG_VFO_B | RIG_VFO_SUB | RIG_VFO_SUB_B | RIG_VFO_MAIN_B; + // if we are on the "other" vfo already then we have to allow for that if (rig->state.current_vfo & vfo_unselected) { @@ -1738,6 +1760,7 @@ static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, int datamode, in { subcmd2 = 0x01; // get unselected VFO } + buf[0] = mode; buf[1] = datamode; // filter fixed to filter 1 due to IC7300 bug defaulting to filter 2 on mode changed -- yuck!! @@ -1809,7 +1832,8 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, break; } - rig_debug(RIG_DEBUG_VERBOSE, "%s mode=%d, width=%d, curr_vfo=%s\n", __func__, (int)icom_mode, + rig_debug(RIG_DEBUG_VERBOSE, "%s mode=%d, width=%d, curr_vfo=%s\n", __func__, + (int)icom_mode, (int)width, rig_strvfo(rig->state.current_vfo)); retval = icom_set_mode(rig, vfo, icom_mode, width); @@ -1822,6 +1846,7 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, signed char width_icom; TRACE; + switch (mode) { case RIG_MODE_PKTUSB: @@ -1843,19 +1868,22 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, if (filter_byte) // then we need the filter width byte too { TRACE; - if (datamode[0] == 0) datamode[1]=0; // the only good combo possible according to manual - rig_debug(RIG_DEBUG_TRACE, "%s(%d) mode_icom=%d, datamode[0]=%d, filter=%d\n", __func__, __LINE__, mode_icom, datamode[0], datamode[1]); + if (datamode[0] == 0) { datamode[1] = 0; } // the only good combo possible according to manual + + rig_debug(RIG_DEBUG_TRACE, "%s(%d) mode_icom=%d, datamode[0]=%d, filter=%d\n", + __func__, __LINE__, mode_icom, datamode[0], datamode[1]); retval = icom_set_mode_x26(rig, vfo, mode_icom, datamode[0], datamode[1]); + if (retval != RIG_OK) { retval = - icom_transaction(rig, C_CTL_MEM, dm_sub_cmd, datamode, 2, ackbuf, &ack_len); + icom_transaction(rig, C_CTL_MEM, dm_sub_cmd, datamode, 2, ackbuf, &ack_len); } } else { - TRACE; + TRACE; retval = icom_transaction(rig, C_CTL_MEM, dm_sub_cmd, datamode, 1, ackbuf, &ack_len); } @@ -1895,8 +1923,10 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) int ack_len = sizeof(ackbuf), retval, err; int swapvfos = 0; - rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, mode=%s, width=%d, current_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, current_vfo=%s\n", __func__, + rig_strvfo(vfo), rig_strrmode(mode), (int)width, + rig_strvfo(rig->state.current_vfo)); rs = &rig->state; priv = (struct icom_priv_data *) rs->priv; @@ -1937,11 +1967,14 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) // some Icom rigs have seperate modes for VFOB/Sub // switching to VFOB should not matter for the other rigs // This needs to be improved for RIG_TARGETABLE_MODE rigs - if ((vfo == RIG_VFO_B || vfo == RIG_VFO_SUB) && ((rig->state.current_vfo == RIG_VFO_A || rig->state.current_vfo == RIG_VFO_MAIN) || rig->state.current_vfo == RIG_VFO_CURR)) + if ((vfo == RIG_VFO_B || vfo == RIG_VFO_SUB) + && ((rig->state.current_vfo == RIG_VFO_A + || rig->state.current_vfo == RIG_VFO_MAIN) + || rig->state.current_vfo == RIG_VFO_CURR)) { TRACE; swapvfos = 1; - rig_set_vfo(rig,RIG_VFO_B); + rig_set_vfo(rig, RIG_VFO_B); } rig_debug(RIG_DEBUG_VERBOSE, "%s: #2 icmode=%d, icmode_ext=%d\n", __func__, @@ -1953,7 +1986,7 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) if (swapvfos) { TRACE; - rig_set_vfo(rig,RIG_VFO_A); + rig_set_vfo(rig, RIG_VFO_A); } if (retval != RIG_OK) @@ -2124,7 +2157,7 @@ int icom_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) // IC7800 can set but not read with 0x26 if ((rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) - && rig->caps->rig_model != RIG_MODEL_IC7800) + && rig->caps->rig_model != RIG_MODEL_IC7800) { int vfosel = 0x00; @@ -2565,9 +2598,10 @@ int icom_set_vfo(RIG *rig, vfo_t vfo) ackbuf[0], ack_len); RETURNFUNC(-RIG_ERJCTED); } + // If SUB_A then we'll assume we're done and probably not in sat mode // If rig has SUB_B active this may be a problem - if (vfo == RIG_VFO_SUB_A) return RIG_OK; + if (vfo == RIG_VFO_SUB_A) { return RIG_OK; } icvfo = vfo == RIG_VFO_SUB_A ? S_VFOA : S_VFOB; @@ -3109,15 +3143,19 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) case RIG_SPECTRUM_MODE_CENTER: icom_val = SCOPE_MODE_CENTER; break; + case RIG_SPECTRUM_MODE_FIXED: icom_val = SCOPE_MODE_FIXED; break; + case RIG_SPECTRUM_MODE_CENTER_SCROLL: icom_val = SCOPE_MODE_SCROLL_C; break; + case RIG_SPECTRUM_MODE_FIXED_SCROLL: icom_val = SCOPE_MODE_SCROLL_F; break; + default: rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum mode %d\n", __func__, val.i); RETURNFUNC(-RIG_EINVAL); @@ -3156,9 +3194,11 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) case 0: icom_val = SCOPE_SPEED_SLOW; break; + case 1: icom_val = SCOPE_SPEED_MID; break; + case 2: icom_val = SCOPE_SPEED_FAST; break; @@ -3168,7 +3208,8 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) cmdbuf[1] = icom_val; break; - case RIG_LEVEL_SPECTRUM_REF: { + case RIG_LEVEL_SPECTRUM_REF: + { float icom_db = (roundf(val.f * 2.0f) / 2.0f) * 100.0f; lvl_cn = C_CTL_SCP; @@ -3186,13 +3227,14 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } case RIG_LEVEL_SPECTRUM_EDGE_LOW: - case RIG_LEVEL_SPECTRUM_EDGE_HIGH: { + case RIG_LEVEL_SPECTRUM_EDGE_HIGH: + { int range_id; value_t edge_number_value; value_t opposite_edge_value; setting_t level_opposite_edge = - (level == RIG_LEVEL_SPECTRUM_EDGE_LOW) ? - RIG_LEVEL_SPECTRUM_EDGE_HIGH : RIG_LEVEL_SPECTRUM_EDGE_LOW; + (level == RIG_LEVEL_SPECTRUM_EDGE_LOW) ? + RIG_LEVEL_SPECTRUM_EDGE_HIGH : RIG_LEVEL_SPECTRUM_EDGE_LOW; lvl_cn = C_CTL_SCP; lvl_sc = S_SCP_FEF; @@ -3200,14 +3242,17 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) // Modify the frequency range currently active retval = icom_get_spectrum_edge_frequency_range(rig, vfo, &range_id); + if (retval != RIG_OK) { - rig_debug(RIG_DEBUG_ERR, "%s: error getting spectrum edge frequency range\n", __func__); + rig_debug(RIG_DEBUG_ERR, "%s: error getting spectrum edge frequency range\n", + __func__); RETURNFUNC(retval); } // Modify the edge number currently active retval = icom_get_ext_level(rig, vfo, TOK_SCOPE_EDG, &edge_number_value); + if (retval != RIG_OK) { RETURNFUNC(retval); @@ -3215,6 +3260,7 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) // Get the current opposite edge frequency retval = icom_get_level(rig, vfo, level_opposite_edge, &opposite_edge_value); + if (retval != RIG_OK) { RETURNFUNC(retval); @@ -3233,6 +3279,7 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) to_bcd(cmdbuf + 2, opposite_edge_value.i, 5 * 2); to_bcd(cmdbuf + 7, val.i, 5 * 2); } + break; } @@ -3249,7 +3296,8 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } } - if (val.i != 0 && (i == HAMLIB_MAXDBLSTSIZ || rig->caps->spectrum_attenuator[i] == 0)) + if (val.i != 0 && (i == HAMLIB_MAXDBLSTSIZ + || rig->caps->spectrum_attenuator[i] == 0)) { rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum attenuator level %ddB\n", __func__, val.i); @@ -3545,7 +3593,8 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) break; case RIG_LEVEL_SPECTRUM_EDGE_LOW: - case RIG_LEVEL_SPECTRUM_EDGE_HIGH: { + case RIG_LEVEL_SPECTRUM_EDGE_HIGH: + { int range_id; value_t edge_number_value; @@ -3555,14 +3604,17 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) // Get the frequency range currently active retval = icom_get_spectrum_edge_frequency_range(rig, vfo, &range_id); + if (retval != RIG_OK) { - rig_debug(RIG_DEBUG_ERR, "%s: error getting spectrum edge frequency range\n", __func__); + rig_debug(RIG_DEBUG_ERR, "%s: error getting spectrum edge frequency range\n", + __func__); RETURNFUNC(retval); } // Get the edge number currently active retval = icom_get_ext_level(rig, vfo, TOK_SCOPE_EDG, &edge_number_value); + if (retval != RIG_OK) { RETURNFUNC(retval); @@ -3588,7 +3640,8 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } /* use cmdbuf and cmd_len for 'set mode' subcommand */ - retval = icom_transaction(rig, lvl_cn, lvl_sc, cmdbuf, cmd_len, respbuf, &resp_len); + retval = icom_transaction(rig, lvl_cn, lvl_sc, cmdbuf, cmd_len, respbuf, + &resp_len); if (retval != RIG_OK) { @@ -3805,19 +3858,25 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) case SCOPE_MODE_CENTER: val->i = RIG_SPECTRUM_MODE_CENTER; break; + case SCOPE_MODE_FIXED: val->i = RIG_SPECTRUM_MODE_FIXED; break; + case SCOPE_MODE_SCROLL_C: val->i = RIG_SPECTRUM_MODE_CENTER_SCROLL; break; + case SCOPE_MODE_SCROLL_F: val->i = RIG_SPECTRUM_MODE_FIXED_SCROLL; break; + default: - rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum mode %d\n", __func__, icom_val); + rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum mode %d\n", __func__, + icom_val); RETURNFUNC(-RIG_EINVAL); } + break; case RIG_LEVEL_SPECTRUM_SPAN: @@ -3832,19 +3891,25 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) case SCOPE_SPEED_SLOW: val->i = 0; break; + case SCOPE_SPEED_MID: val->i = 1; break; + case SCOPE_SPEED_FAST: val->i = 2; break; + default: - rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum speed %d\n", __func__, icom_val); + rig_debug(RIG_DEBUG_ERR, "%s: unsupported spectrum speed %d\n", __func__, + icom_val); RETURNFUNC(-RIG_EINVAL); } + break; - case RIG_LEVEL_SPECTRUM_REF: { + case RIG_LEVEL_SPECTRUM_REF: + { unsigned char *icom_ref = respbuf + cmdhead; // Spectrum reference level is represented at 0.01dB accuracy, but is rounded to nearest 0.5dB @@ -3921,7 +3986,8 @@ int icom_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val) int lvl_cn, lvl_sc; /* Command Number, Subcommand */ int i, retval; - rig_debug(RIG_DEBUG_VERBOSE, "%s called: token=%ld int=%d float=%f\n", __func__, token, val.i, val.f); + rig_debug(RIG_DEBUG_VERBOSE, "%s called: token=%ld int=%d float=%f\n", __func__, + token, val.i, val.f); switch (token) { @@ -3950,6 +4016,7 @@ int icom_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val) break; case TOK_SCOPE_STX: + // TODO: Should be a func? if (val.i < 0 || val.i > 1) { @@ -4030,7 +4097,8 @@ int icom_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val) else { i++; } } - rig_debug(RIG_DEBUG_ERR, "%s: unsupported set_ext_level token: %ld\n", __func__, token); + rig_debug(RIG_DEBUG_ERR, "%s: unsupported set_ext_level token: %ld\n", __func__, + token); RETURNFUNC(-RIG_EINVAL); } @@ -4136,12 +4204,14 @@ int icom_get_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t *val) else { i++; } } - rig_debug(RIG_DEBUG_ERR, "%s: unsupported get_ext_level token: %ld\n", __func__, token); + rig_debug(RIG_DEBUG_ERR, "%s: unsupported get_ext_level token: %ld\n", __func__, + token); RETURNFUNC(-RIG_EINVAL); } /* use cmdbuf and cmd_len for 'set mode' subcommand */ - retval = icom_transaction(rig, lvl_cn, lvl_sc, cmdbuf, cmd_len, respbuf, &resp_len); + retval = icom_transaction(rig, lvl_cn, lvl_sc, cmdbuf, cmd_len, respbuf, + &resp_len); if (retval != RIG_OK) { @@ -4923,11 +4993,13 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) cmd = C_SEND_SEL_FREQ; subcmd = 0x01; // set the unselected vfo + // if we're already on the tx_vfo don't need the "other" vfo if (rig->state.current_vfo == rig->state.tx_vfo) { subcmd = 0x00; } + retval = icom_transaction(rig, cmd, subcmd, freqbuf, freq_len, ackbuf, &ack_len); @@ -5003,8 +5075,10 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) rig_debug(RIG_DEBUG_TRACE, "%s: rx_vfo=%s, tx_vfo=%s\n", __func__, rig_strvfo(rx_vfo), rig_strvfo(tx_vfo)); - TRACE; - if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ) && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) + TRACE; + + if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ) + && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) { RETURNFUNC(retval); } @@ -5015,6 +5089,7 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) } TRACE; + if (VFO_HAS_MAIN_SUB_A_B_ONLY) { // Then we return the VFO to the rx_vfo @@ -5022,15 +5097,17 @@ int icom_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) __func__, priv->split_on, rig_strvfo(rx_vfo)); - TRACE; - if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ) && RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) + TRACE; + + if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ) + && RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) { RETURNFUNC(retval); } } else if (RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) { - TRACE; + TRACE; RETURNFUNC(retval); } @@ -5230,6 +5307,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) } TRACE; + if (RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) { RETURNFUNC(retval); @@ -5241,13 +5319,15 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) } TRACE; + if (VFO_HAS_MAIN_SUB_A_B_ONLY) { // Then we return the VFO to where it was rig_debug(RIG_DEBUG_TRACE, "%s: SATMODE rig so returning vfo to %s\n", __func__, rig_strvfo(rx_vfo)); - TRACE; + TRACE; + if (RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) { RETURNFUNC(retval); @@ -5255,7 +5335,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) } else if (RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) { - TRACE; + TRACE; RETURNFUNC(retval); } @@ -5354,7 +5434,9 @@ int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, } TRACE; - if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) + + if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) + && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) { RETURNFUNC(retval); } @@ -5365,8 +5447,10 @@ int icom_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, RETURNFUNC(retval); } - TRACE; - if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) + TRACE; + + if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) + && RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) { RETURNFUNC(retval); } @@ -5466,6 +5550,7 @@ int icom_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, } TRACE; + if (RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) { RETURNFUNC(retval); @@ -5477,7 +5562,8 @@ int icom_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, RETURNFUNC(retval); } - TRACE; + TRACE; + if (RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) { RETURNFUNC(retval); @@ -5540,8 +5626,9 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, RETURNFUNC(retval); } - if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && RIG_OK != (retval = rig->caps->set_mode(rig, RIG_VFO_CURR, tx_mode, - tx_width))) + if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) + && RIG_OK != (retval = rig->caps->set_mode(rig, RIG_VFO_CURR, tx_mode, + tx_width))) { RETURNFUNC(retval); } @@ -5618,7 +5705,9 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, } TRACE; - if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ) && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) + + if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_FREQ) + && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) { RETURNFUNC(retval); } @@ -5628,8 +5717,10 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, RETURNFUNC(retval); } - TRACE; - if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) + TRACE; + + if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) + && RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) { RETURNFUNC(retval); } @@ -5640,8 +5731,10 @@ int icom_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, RETURNFUNC(retval); } - TRACE; - if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) && RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) + TRACE; + + if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE) + && RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) { RETURNFUNC(retval); } @@ -5746,6 +5839,7 @@ int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, } TRACE; + if (RIG_OK != (retval = rig_set_vfo(rig, tx_vfo))) { RETURNFUNC(retval); @@ -5762,7 +5856,8 @@ int icom_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, RETURNFUNC(retval); } - TRACE; + TRACE; + if (RIG_OK != (retval = rig_set_vfo(rig, rx_vfo))) { RETURNFUNC(retval); @@ -5879,6 +5974,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) case RIG_SPLIT_ON: split_sc = S_SPLT_ON; rig_debug(RIG_DEBUG_TRACE, "trace %s(%d)\n", __func__, __LINE__); + // the VFO adjusting here could probably be done in rig.c for all rigs /* If asking for Sub or Main on rig that doesn't have it map it */ if (VFO_HAS_A_B_ONLY && ((tx_vfo == RIG_VFO_MAIN || tx_vfo == RIG_VFO_SUB) @@ -5901,13 +5997,15 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) "%s: rx_vfo to VFO_A, tx_vfo to VFO_B because tx_vfo=%s\n", __func__, rig_strvfo(tx_vfo)); - if (tx_vfo == RIG_VFO_B) { - priv->tx_vfo = RIG_VFO_B; - priv->rx_vfo = vfo = RIG_VFO_A; + if (tx_vfo == RIG_VFO_B) + { + priv->tx_vfo = RIG_VFO_B; + priv->rx_vfo = vfo = RIG_VFO_A; } - else { - priv->tx_vfo = RIG_VFO_A; - priv->rx_vfo = vfo = RIG_VFO_B; + else + { + priv->tx_vfo = RIG_VFO_A; + priv->rx_vfo = vfo = RIG_VFO_B; } } else if (VFO_HAS_MAIN_SUB_A_B_ONLY && (tx_vfo == RIG_VFO_MAIN @@ -5927,12 +6025,14 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) // make sure we're on Main/VFOA TRACE; + if (RIG_OK != (retval = icom_set_vfo(rig, RIG_VFO_MAIN))) { RETURNFUNC(retval); } TRACE; + if (RIG_OK != (retval = icom_set_vfo(rig, RIG_VFO_A))) { RETURNFUNC(retval); @@ -5949,6 +6049,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) #if 0 // do we need this for satmode? TRACE; + if (RIG_OK != (retval = icom_set_vfo(rig, tx_vfo))) { RETURNFUNC(retval); @@ -5999,6 +6100,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) priv->split_on = RIG_SPLIT_ON == split; #if 0 // don't think we need this anymore -- 20210731 + if (vfo_final != RIG_VFO_NONE && vfo_final != rig->state.current_vfo) { rig_debug(RIG_DEBUG_TRACE, "%s: vfo_final set %s\n", __func__, @@ -6012,6 +6114,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) rigerror(retval)); } } + #endif rig_debug(RIG_DEBUG_VERBOSE, @@ -6083,9 +6186,11 @@ int icom_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) if (rig->caps->has_get_func & RIG_FUNC_SATMODE) { rig_get_func(rig, RIG_VFO_CURR, RIG_FUNC_SATMODE, &satmode); + if (satmode != rig->state.cache.satmode) { - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): satmode changed to reset x25cmdfails\n", __func__, __LINE__); + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): satmode changed to reset x25cmdfails\n", + __func__, __LINE__); priv->x25cmdfails = satmode; // reset this so it tries again } } @@ -6702,6 +6807,7 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) fct_cn = C_CTL_FUNC; fct_sc = S_MEM_SATMODE; } + break; default: @@ -6710,7 +6816,8 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) RETURNFUNC(-RIG_EINVAL); } - retval = icom_transaction(rig, fct_cn, fct_sc, fctbuf, fct_len, ackbuf, &ack_len); + retval = icom_transaction(rig, fct_cn, fct_sc, fctbuf, fct_len, ackbuf, + &ack_len); if (retval != RIG_OK) { @@ -8086,7 +8193,8 @@ int icom_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq, RETURNFUNC(RIG_OK); } -static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char *frame_data) +static int icom_parse_spectrum_frame(RIG *rig, int length, + const unsigned char *frame_data) { struct rig_caps *caps = rig->caps; struct icom_priv_caps *priv_caps = (struct icom_priv_caps *) caps->priv; @@ -8106,7 +8214,8 @@ static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char * if (spectrum_id < 0 || spectrum_id >= priv->spectrum_scope_count) { - rig_debug(RIG_DEBUG_ERR, "%s: invalid spectrum scope ID from CI-V frame: %d\n", __func__, spectrum_id); + rig_debug(RIG_DEBUG_ERR, "%s: invalid spectrum scope ID from CI-V frame: %d\n", + __func__, spectrum_id); RETURNFUNC(-RIG_EPROTO); } @@ -8121,46 +8230,60 @@ static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char * switch (spectrum_scope_mode) { - case SCOPE_MODE_CENTER: - cache->spectrum_mode = RIG_SPECTRUM_MODE_CENTER; - cache->spectrum_center_freq = (freq_t) from_bcd(frame_data + 4, 5 * 2); - cache->spectrum_span_freq = (freq_t) from_bcd(frame_data + 9, 5 * 2) * 2; - cache->spectrum_low_edge_freq = cache->spectrum_center_freq - cache->spectrum_span_freq / 2; - cache->spectrum_high_edge_freq = cache->spectrum_center_freq + cache->spectrum_span_freq / 2; - break; - case SCOPE_MODE_FIXED: - cache->spectrum_mode = RIG_SPECTRUM_MODE_FIXED; - case SCOPE_MODE_SCROLL_C: - if (cache->spectrum_mode == RIG_SPECTRUM_MODE_NONE) - { - cache->spectrum_mode = RIG_SPECTRUM_MODE_CENTER_SCROLL; - } - case SCOPE_MODE_SCROLL_F: - if (cache->spectrum_mode == RIG_SPECTRUM_MODE_NONE) - { - cache->spectrum_mode = RIG_SPECTRUM_MODE_FIXED_SCROLL; - } - cache->spectrum_low_edge_freq = (freq_t) from_bcd(frame_data + 4, 5 * 2); - cache->spectrum_high_edge_freq = (freq_t) from_bcd(frame_data + 9, 5 * 2); - cache->spectrum_span_freq = (cache->spectrum_high_edge_freq - cache->spectrum_low_edge_freq); - cache->spectrum_center_freq = cache->spectrum_high_edge_freq - cache->spectrum_span_freq / 2; - break; - default: - rig_debug(RIG_DEBUG_ERR, "%s: unknown Icom spectrum scope mode: %d\n", __func__, spectrum_scope_mode) - RETURNFUNC(-RIG_EPROTO); + case SCOPE_MODE_CENTER: + cache->spectrum_mode = RIG_SPECTRUM_MODE_CENTER; + cache->spectrum_center_freq = (freq_t) from_bcd(frame_data + 4, 5 * 2); + cache->spectrum_span_freq = (freq_t) from_bcd(frame_data + 9, 5 * 2) * 2; + cache->spectrum_low_edge_freq = cache->spectrum_center_freq - + cache->spectrum_span_freq / 2; + cache->spectrum_high_edge_freq = cache->spectrum_center_freq + + cache->spectrum_span_freq / 2; + break; + + case SCOPE_MODE_FIXED: + cache->spectrum_mode = RIG_SPECTRUM_MODE_FIXED; + + case SCOPE_MODE_SCROLL_C: + if (cache->spectrum_mode == RIG_SPECTRUM_MODE_NONE) + { + cache->spectrum_mode = RIG_SPECTRUM_MODE_CENTER_SCROLL; + } + + case SCOPE_MODE_SCROLL_F: + if (cache->spectrum_mode == RIG_SPECTRUM_MODE_NONE) + { + cache->spectrum_mode = RIG_SPECTRUM_MODE_FIXED_SCROLL; + } + + cache->spectrum_low_edge_freq = (freq_t) from_bcd(frame_data + 4, 5 * 2); + cache->spectrum_high_edge_freq = (freq_t) from_bcd(frame_data + 9, 5 * 2); + cache->spectrum_span_freq = (cache->spectrum_high_edge_freq - + cache->spectrum_low_edge_freq); + cache->spectrum_center_freq = cache->spectrum_high_edge_freq - + cache->spectrum_span_freq / 2; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown Icom spectrum scope mode: %d\n", __func__, + spectrum_scope_mode) + RETURNFUNC(-RIG_EPROTO); } spectrum_data_length_in_frame = length - 15; spectrum_data_start_in_frame = frame_data + 15; - memset(cache->spectrum_data, 0, priv_caps->spectrum_scope_caps.spectrum_line_length); + memset(cache->spectrum_data, 0, + priv_caps->spectrum_scope_caps.spectrum_line_length); cache->spectrum_data_length = 0; cache->spectrum_metadata_valid = 1; - rig_debug(RIG_DEBUG_TRACE, "%s: Spectrum line start: id=%d division=%d max_division=%d mode=%d center=%.0f span=%.0f low_edge=%.0f high_edge=%.0f oor=%d data_length=%d\n", - __func__, spectrum_id, division, max_division, spectrum_scope_mode, cache->spectrum_center_freq, cache->spectrum_span_freq, - cache->spectrum_low_edge_freq, cache->spectrum_high_edge_freq, out_of_range, spectrum_data_length_in_frame); + rig_debug(RIG_DEBUG_TRACE, + "%s: Spectrum line start: id=%d division=%d max_division=%d mode=%d center=%.0f span=%.0f low_edge=%.0f high_edge=%.0f oor=%d data_length=%d\n", + __func__, spectrum_id, division, max_division, spectrum_scope_mode, + cache->spectrum_center_freq, cache->spectrum_span_freq, + cache->spectrum_low_edge_freq, cache->spectrum_high_edge_freq, out_of_range, + spectrum_data_length_in_frame); } else { @@ -8174,20 +8297,25 @@ static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char * int data_frame_index = (max_division > 1) ? (division - 2) : (division - 1); int offset = data_frame_index * frame_length; - if (offset + spectrum_data_length_in_frame > priv_caps->spectrum_scope_caps.spectrum_line_length) + if (offset + spectrum_data_length_in_frame > + priv_caps->spectrum_scope_caps.spectrum_line_length) { - rig_debug(RIG_DEBUG_ERR, "%s: too much spectrum scope data received: %d bytes > %d bytes expected\n", - __func__, offset + spectrum_data_length_in_frame, priv_caps->spectrum_scope_caps.spectrum_line_length); + rig_debug(RIG_DEBUG_ERR, + "%s: too much spectrum scope data received: %d bytes > %d bytes expected\n", + __func__, offset + spectrum_data_length_in_frame, + priv_caps->spectrum_scope_caps.spectrum_line_length); RETURNFUNC(-RIG_EPROTO); } - memcpy(cache->spectrum_data + offset, spectrum_data_start_in_frame, spectrum_data_length_in_frame); + memcpy(cache->spectrum_data + offset, spectrum_data_start_in_frame, + spectrum_data_length_in_frame); cache->spectrum_data_length = offset + spectrum_data_length_in_frame; } if (cache->spectrum_metadata_valid && division == max_division) { - struct rig_spectrum_line spectrum_line = { + struct rig_spectrum_line spectrum_line = + { .data_level_min = priv_caps->spectrum_scope_caps.data_level_min, .data_level_max = priv_caps->spectrum_scope_caps.data_level_max, .signal_strength_min = priv_caps->spectrum_scope_caps.signal_strength_min, @@ -8220,10 +8348,12 @@ int icom_is_async_frame(RIG *rig, int frame_len, const unsigned char *frame) } /* Spectrum scope data is not CI-V transceive data, but handled the same way as it is pushed by the rig */ - return frame[2] == BCASTID || (frame[2] == CTRLID && frame[4] == C_CTL_SCP && frame[5] == S_SCP_DAT); + return frame[2] == BCASTID || (frame[2] == CTRLID && frame[4] == C_CTL_SCP + && frame[5] == S_SCP_DAT); } -int icom_process_async_frame(RIG *rig, int frame_len, const unsigned char *frame) +int icom_process_async_frame(RIG *rig, int frame_len, + const unsigned char *frame) { struct rig_state *rs = &rig->state; struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv; @@ -8242,50 +8372,52 @@ int icom_process_async_frame(RIG *rig, int frame_len, const unsigned char *frame */ switch (frame[4]) { - case C_SND_FREQ: - /* - * TODO: the freq length might be less than 4 or 5 bytes - * on older rigs! - */ - if (rig->callbacks.freq_event) - { - freq_t freq; - freq = from_bcd(frame + 5, (priv->civ_731_mode ? 4 : 5) * 2); - RETURNFUNC(rig->callbacks.freq_event(rig, RIG_VFO_CURR, freq, - rig->callbacks.freq_arg)); - } - else - { - RETURNFUNC(-RIG_ENAVAIL); - } + case C_SND_FREQ: - break; + /* + * TODO: the freq length might be less than 4 or 5 bytes + * on older rigs! + */ + if (rig->callbacks.freq_event) + { + freq_t freq; + freq = from_bcd(frame + 5, (priv->civ_731_mode ? 4 : 5) * 2); + RETURNFUNC(rig->callbacks.freq_event(rig, RIG_VFO_CURR, freq, + rig->callbacks.freq_arg)); + } + else + { + RETURNFUNC(-RIG_ENAVAIL); + } - case C_SND_MODE: - if (rig->callbacks.mode_event) - { - icom2rig_mode(rig, frame[5], frame[6], &mode, &width); - RETURNFUNC(rig->callbacks.mode_event(rig, RIG_VFO_CURR, - mode, width, rig->callbacks.mode_arg)); - } - else - { - RETURNFUNC(-RIG_ENAVAIL); - } + break; - break; + case C_SND_MODE: + if (rig->callbacks.mode_event) + { + icom2rig_mode(rig, frame[5], frame[6], &mode, &width); + RETURNFUNC(rig->callbacks.mode_event(rig, RIG_VFO_CURR, + mode, width, rig->callbacks.mode_arg)); + } + else + { + RETURNFUNC(-RIG_ENAVAIL); + } - case C_CTL_SCP: - if (frame[5] == S_SCP_DAT) - { - icom_parse_spectrum_frame(rig, frame_len - (6 + 1), frame + 6); - } - break; + break; - default: - rig_debug(RIG_DEBUG_VERBOSE, "%s: transceive cmd unsupported %#2.2x\n", - __func__, frame[4]); - RETURNFUNC(-RIG_ENIMPL); + case C_CTL_SCP: + if (frame[5] == S_SCP_DAT) + { + icom_parse_spectrum_frame(rig, frame_len - (6 + 1), frame + 6); + } + + break; + + default: + rig_debug(RIG_DEBUG_VERBOSE, "%s: transceive cmd unsupported %#2.2x\n", + __func__, frame[4]); + RETURNFUNC(-RIG_ENIMPL); } RETURNFUNC(RIG_OK); @@ -8321,6 +8453,7 @@ int icom_decode_event(RIG *rig) } retval = icom_frame_fix_preamble(frm_len, buf); + if (retval < 0) { RETURNFUNC(retval); @@ -8681,7 +8814,7 @@ static int set_vfo_curr(RIG *rig, vfo_t vfo, vfo_t curr_vfo) { rig_debug(RIG_DEBUG_TRACE, "%s: setting new vfo=%s\n", __func__, rig_strvfo(vfo)); - TRACE; + TRACE; retval = rig_set_vfo(rig, vfo); if (retval != RIG_OK) @@ -8709,7 +8842,8 @@ static int icom_get_spectrum_vfo(RIG *rig, vfo_t vfo) RETURNFUNC(0); } -static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, int *range_id) +static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, + int *range_id) { freq_t freq; rmode_t mode; @@ -8718,7 +8852,9 @@ static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, int *rang int i, retval; struct icom_priv_caps *priv_caps = (struct icom_priv_caps *) rig->caps->priv; - retval = rig_get_cache(rig, vfo, &freq, &cache_ms_freq, &mode, &cache_ms_mode, &width, &cache_ms_width); + retval = rig_get_cache(rig, vfo, &freq, &cache_ms_freq, &mode, &cache_ms_mode, + &width, &cache_ms_width); + if (retval != RIG_OK) { RETURNFUNC(retval); @@ -8728,6 +8864,7 @@ static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, int *rang if (freq == 0 || cache_ms_freq >= 1000) { retval = rig_get_freq(rig, vfo, &freq); + if (retval != RIG_OK) { RETURNFUNC(retval); @@ -8737,11 +8874,14 @@ static int icom_get_spectrum_edge_frequency_range(RIG *rig, vfo_t vfo, int *rang for (i = 0; i < ICOM_MAX_SPECTRUM_FREQ_RANGES; i++) { int id = priv_caps->spectrum_edge_frequency_ranges[i].range_id; + if (id < 1) { break; } - if (freq >= priv_caps->spectrum_edge_frequency_ranges[i].low_freq && freq < priv_caps->spectrum_edge_frequency_ranges[i].high_freq) + + if (freq >= priv_caps->spectrum_edge_frequency_ranges[i].low_freq + && freq < priv_caps->spectrum_edge_frequency_ranges[i].high_freq) { *range_id = id; RETURNFUNC(RIG_OK); diff --git a/rigs/kenwood/flex6xxx.c b/rigs/kenwood/flex6xxx.c index 1fcea3741..231ee1f94 100644 --- a/rigs/kenwood/flex6xxx.c +++ b/rigs/kenwood/flex6xxx.c @@ -631,7 +631,7 @@ int flex6k_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) if (ptt_cmd[4] != response[4]) { rig_debug(RIG_DEBUG_ERR, "%s: %s != %s\n", __func__, ptt_cmd, response); - hl_usleep(20*1000); // takes a bit to do PTT off + hl_usleep(20 * 1000); // takes a bit to do PTT off } } while (ptt_cmd[4] != response[4] && --retry); diff --git a/rigs/kenwood/k3.c b/rigs/kenwood/k3.c index 9cbcae647..a131de3ff 100644 --- a/rigs/kenwood/k3.c +++ b/rigs/kenwood/k3.c @@ -220,7 +220,7 @@ const struct rig_caps k3_caps = .max_xit = Hz(9990), .max_ifshift = Hz(0), .vfo_ops = K3_VFO_OP, - .targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE, + .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, .transceive = RIG_TRN_RIG, .bank_qty = 0, .chan_desc_sz = 0, @@ -370,7 +370,7 @@ const struct rig_caps k3s_caps = .max_xit = Hz(9990), .max_ifshift = Hz(0), .vfo_ops = K3_VFO_OP, - .targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE, + .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, .transceive = RIG_TRN_RIG, .bank_qty = 0, .chan_desc_sz = 0, @@ -520,7 +520,7 @@ const struct rig_caps k4_caps = .max_xit = Hz(9990), .max_ifshift = Hz(0), .vfo_ops = K3_VFO_OP, - .targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE, + .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, .transceive = RIG_TRN_RIG, .bank_qty = 0, .chan_desc_sz = 0, @@ -669,7 +669,7 @@ const struct rig_caps kx3_caps = .max_xit = Hz(9990), .max_ifshift = Hz(0), .vfo_ops = K3_VFO_OP, - .targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE, + .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, .transceive = RIG_TRN_RIG, .bank_qty = 0, .chan_desc_sz = 0, @@ -818,7 +818,7 @@ const struct rig_caps kx2_caps = .max_xit = Hz(9990), .max_ifshift = Hz(0), .vfo_ops = K3_VFO_OP, - .targetable_vfo = RIG_TARGETABLE_FREQ|RIG_TARGETABLE_MODE, + .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, .transceive = RIG_TRN_RIG, .bank_qty = 0, .chan_desc_sz = 0, @@ -1098,17 +1098,22 @@ int k3_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { vfo = rig->state.current_vfo; } + rmode_t tmode; pbwidth_t twidth; - err = k3_get_mode(rig,vfo,&tmode,&twidth); + err = k3_get_mode(rig, vfo, &tmode, &twidth); + if (err == RIG_OK && tmode == mode && width == RIG_PASSBAND_NOCHANGE) { - rig_debug(RIG_DEBUG_TRACE, "%s(%d): mode/width no change, skipping\n", __FILE__, __LINE__); + rig_debug(RIG_DEBUG_TRACE, "%s(%d): mode/width no change, skipping\n", __FILE__, + __LINE__); return RIG_OK; } else { - rig_debug(RIG_DEBUG_TRACE, "%s(%d): changing mode=%s, oldmode=%s, width=%ld, oldwidth=%ld\n", __FILE__, __LINE__, rig_strrmode(tmode), rig_strrmode(mode), twidth, width); + rig_debug(RIG_DEBUG_TRACE, + "%s(%d): changing mode=%s, oldmode=%s, width=%ld, oldwidth=%ld\n", __FILE__, + __LINE__, rig_strrmode(tmode), rig_strrmode(mode), twidth, width); } switch (mode) @@ -1478,45 +1483,60 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) tx_mode = RIG_MODE_RTTYR; // "DT0" RIG_MODE_RTTY = LSB snprintf(cmd_m, sizeof(cmd_m), "DT0;"); /* DATA A mode - DATA-R LSB, suppressed carrier */ - if (priv->is_k4d || priv->is_k4hd) { + + if (priv->is_k4d || priv->is_k4hd) + { strcat(cmd_m, "DT$0;"); } + break; case RIG_MODE_PKTUSB: tx_mode = RIG_MODE_RTTY; // "DT0" RIG_MODE_RTTYR = USB snprintf(cmd_m, sizeof(cmd_m), "DT0;"); /* DATA A mode - DATA on USB, suppressed carrier */ - if (priv->is_k4d || priv->is_k4hd) { + + if (priv->is_k4d || priv->is_k4hd) + { strcat(cmd_m, "DT$0;"); } + break; case RIG_MODE_RTTY: tx_mode = RIG_MODE_RTTY; // DT1" RIG_MODE_RTTY = LSB and RIG_MODE_RTTYR = USB snprintf(cmd_m, sizeof(cmd_m), "DT2;"); /* FSK D mode - direct FSK on LSB optimized for RTTY, VFO dial is MARK */ - if (priv->is_k4d || priv->is_k4hd) { + + if (priv->is_k4d || priv->is_k4hd) + { strcat(cmd_m, "DT$2;"); } + break; case RIG_MODE_RTTYR: tx_mode = RIG_MODE_RTTYR; // "DT2" RIG_MODE_RTTY = USB and RIG_MODE_RTTYR = USB snprintf(cmd_m, sizeof(cmd_m), "DT1;"); /* FSK D mode - direct FSK on USB optimized for RTTY, VFO dial is MARK */ - if (priv->is_k4d || priv->is_k4hd) { + + if (priv->is_k4d || priv->is_k4hd) + { strcat(cmd_m, "DT$1;"); } + break; case RIG_MODE_PSK: tx_mode = RIG_MODE_PSK; snprintf(cmd_m, sizeof(cmd_m), "DT3;FT1;"); /* PSK D Mode - direct PSK keying, USB is "normal", VFO dial is MARK */ - if (priv->is_k4d || priv->is_k4hd) { + + if (priv->is_k4d || priv->is_k4hd) + { strcat(cmd_m, "DT$3;"); } + break; default: @@ -1526,16 +1546,18 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) // Enabling this clause for just the K4 for now #if 1 - if (priv->is_k4d || priv->is_k4hd) { - // split can get turned off when modes are changing + if (priv->is_k4d || priv->is_k4hd) + { + // split can get turned off when modes are changing // so if the rig did this independtly of us we turn it back on // even if the rig changes the split status should be the last thing we did - if (priv->split) strcat(cmd_m, "FT1;"); + if (priv->split) { strcat(cmd_m, "FT1;"); } + /* Set data sub-mode. K3 needs to be in a DATA mode before setting * the sub-mode or switching to VFOB so we do this before the MD$ command. */ if (tx_mode == RIG_MODE_PKTLSB || tx_mode == RIG_MODE_PKTUSB - || tx_mode == RIG_MODE_RTTY || tx_mode == RIG_MODE_RTTYR) + || tx_mode == RIG_MODE_RTTY || tx_mode == RIG_MODE_RTTYR) { err = kenwood_transaction(rig, cmd_m, NULL, 0); @@ -1591,6 +1613,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) { tx_width = rig_passband_normal(rig, tx_mode); } + #if 0 else if (tx_width < pb_nar) { @@ -1600,6 +1623,7 @@ int k3_set_split_mode(RIG *rig, vfo_t vfo, rmode_t tx_mode, pbwidth_t tx_width) { tx_width = pb_wid; } + #endif snprintf(cmd_s, sizeof(cmd_s), "BW$%04ld", tx_width / 10); diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 64eb64d81..6a52d164a 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -762,10 +762,11 @@ int kenwood_open(RIG *rig) id[0] = 0; rig->state.rigport.retry = 0; err = kenwood_get_id(rig, id); + if (err != RIG_OK) { // TS450S is flaky on the 1st ID call so we'll try again - hl_usleep(200*1000); + hl_usleep(200 * 1000); err = kenwood_get_id(rig, id); } @@ -962,7 +963,8 @@ int kenwood_open(RIG *rig) rig->state.rigport.retry = retry_save; // Default to 1st VFO and split off - if (rig->caps->set_vfo) { + if (rig->caps->set_vfo) + { rig_set_vfo(rig, vfo_fixup(rig, RIG_VFO_A, 0)); } @@ -1115,9 +1117,10 @@ int kenwood_set_vfo(RIG *rig, vfo_t 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 - if (priv->split) strcat(cmdbuf,"FT1;"); + if (priv->split) { strcat(cmdbuf, "FT1;"); } if (RIG_IS_TS50 || RIG_IS_TS940) { @@ -1138,6 +1141,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) { RETURNFUNC(RIG_OK); } + // some rigs need split turned on after VFOA is set if (vfo == RIG_VFO_A && priv->split == RIG_SPLIT_ON) { @@ -1254,9 +1258,11 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) /* 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 - if (priv->split) strcat(cmdbuf,"FT1;"); + if (priv->split) { strcat(cmdbuf, "FT1;"); } + retval = kenwood_transaction(rig, cmdbuf, NULL, 0); if (retval != RIG_OK) @@ -2072,8 +2078,10 @@ int kenwood_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { pbwidth_t twidth; err = rig_get_mode(rig, vfo, &priv->curr_mode, &twidth); + // only change mode if needed - if (priv->curr_mode != mode) { + if (priv->curr_mode != mode) + { snprintf(buf, sizeof(buf), "MD%c", c); err = kenwood_transaction(rig, buf, NULL, 0); } diff --git a/rigs/kenwood/ts890s.c b/rigs/kenwood/ts890s.c index 4248604e0..1ee866271 100644 --- a/rigs/kenwood/ts890s.c +++ b/rigs/kenwood/ts890s.c @@ -120,12 +120,13 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) retval = kenwood_safe_transaction(rig, "VD0", ackbuf, sizeof(ackbuf), 6); if (retval != RIG_OK) - { + { return retval; } sscanf(ackbuf + 3, "%d", &levelint); - val->i = levelint * 3 / 2; /* 150ms units converted to 100ms units */ + val->i = levelint * 3 / + 2; /* 150ms units converted to 100ms units */ return RIG_OK; case RIG_LEVEL_RF: diff --git a/rigs/kit/rs_hfiq.c b/rigs/kit/rs_hfiq.c index b71fc8f74..53be48a6f 100644 --- a/rigs/kit/rs_hfiq.c +++ b/rigs/kit/rs_hfiq.c @@ -88,16 +88,20 @@ static int rshfiq_open(RIG *rig) //There is a delay between when the port is open and the RS-HFIQ can receive and respond. //Make a few attempts at getting the version string just in case the RS-HFIQ has to catch up first. retval = -RIG_ETIMEOUT; - for (int init_retry_count = 0; (init_retry_count < RSHFIQ_INIT_RETRY) && (retval == -RIG_ETIMEOUT); init_retry_count++) + + for (int init_retry_count = 0; (init_retry_count < RSHFIQ_INIT_RETRY) + && (retval == -RIG_ETIMEOUT); init_retry_count++) { rig_flush(&rig->state.rigport); snprintf(versionstr, sizeof(versionstr), "*w\r"); rig_debug(RIG_DEBUG_TRACE, "%s: cmdstr = %s\n", __func__, versionstr); retval = write_block(&rig->state.rigport, versionstr, strlen(versionstr)); + if (retval != RIG_OK) { return retval; } + retval = read_string(&rig->state.rigport, versionstr, 20, stopset, 2); } @@ -117,20 +121,27 @@ static int rshfiq_open(RIG *rig) return -RIG_ECONF; } - retval = sscanf(versionstr, "RS-HFIQ FW %d.%d", &rshfiq_version_major, &rshfiq_version_minor); + retval = sscanf(versionstr, "RS-HFIQ FW %d.%d", &rshfiq_version_major, + &rshfiq_version_minor); if (retval <= 0) { - rig_debug(RIG_DEBUG_WARN, "%s: Failed to parse RS-HFIQ firmware version string. Defaulting to 2.0.\n", __func__); + rig_debug(RIG_DEBUG_WARN, + "%s: Failed to parse RS-HFIQ firmware version string. Defaulting to 2.0.\n", + __func__); rshfiq_version_major = 2; rshfiq_version_minor = 0; } - rig_debug(RIG_DEBUG_VERBOSE, "RS-HFIQ returned firmware version major=%d minor=%d\n", rshfiq_version_major, rshfiq_version_minor); + rig_debug(RIG_DEBUG_VERBOSE, + "RS-HFIQ returned firmware version major=%d minor=%d\n", rshfiq_version_major, + rshfiq_version_minor); if (rshfiq_version_major < 4) { - rig_debug(RIG_DEBUG_WARN, "%s: RS-HFIQ firmware major version is less than 4. RFPOWER_METER support will be unavailable.\n", __func__); + rig_debug(RIG_DEBUG_WARN, + "%s: RS-HFIQ firmware major version is less than 4. RFPOWER_METER support will be unavailable.\n", + __func__); } return RIG_OK; @@ -227,7 +238,8 @@ static int rshfiq_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { - rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__, level); + rig_debug(RIG_DEBUG_VERBOSE, "%s called. level type =%"PRIll"\n", __func__, + level); char cmdstr[15]; char stopset[2]; @@ -238,90 +250,92 @@ static int rshfiq_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return -RIG_EINVAL; } - switch (level) + switch (level) + { + //Requires RS-HFIQ firmware version 4 or later + case RIG_LEVEL_RFPOWER_METER: + + if (rshfiq_version_major <= 3) { - //Requires RS-HFIQ firmware version 4 or later - case RIG_LEVEL_RFPOWER_METER: + return -RIG_ENAVAIL; + } - if (rshfiq_version_major <= 3) - { - return -RIG_ENAVAIL; - } + rig_flush(&rig->state.rigport); - rig_flush(&rig->state.rigport); + snprintf(cmdstr, sizeof(cmdstr), "*L\r"); - snprintf(cmdstr, sizeof(cmdstr), "*L\r"); + rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER command=%s\n", cmdstr); - rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER command=%s\n", cmdstr); + retval = write_block(&rig->state.rigport, cmdstr, strlen(cmdstr)); - retval = write_block(&rig->state.rigport, cmdstr, strlen(cmdstr)); + if (retval != RIG_OK) + { + return retval; + } - if (retval != RIG_OK) - { - return retval; - } + stopset[0] = '\r'; + stopset[1] = '\n'; - stopset[0] = '\r'; - stopset[1] = '\n'; + retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2); - retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2); + rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER reply=%s\n", cmdstr); - rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER reply=%s\n", cmdstr); + if (retval <= 0) + { + return retval; + } - if (retval <= 0) - { - return retval; - } + cmdstr[retval] = 0; - cmdstr[retval] = 0; + //Range is 0-110. Unit is percent + val->i = atoi(cmdstr); + val->f = (float)(val->i) / 100; - //Range is 0-110. Unit is percent - val->i = atoi(cmdstr); - val->f = (float)(val->i) / 100; + rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER val=%f\n", val->f); - rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_RFPOWER_METER val=%f\n", val->f); - - return RIG_OK; - break; - - case RIG_LEVEL_TEMP_METER: - - rig_flush(&rig->state.rigport); - - snprintf(cmdstr, sizeof(cmdstr), "*T\r"); - - rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER command=%s\n", cmdstr); - - retval = write_block(&rig->state.rigport, cmdstr, strlen(cmdstr)); - - if (retval != RIG_OK) - { - return retval; - } - - stopset[0] = '\r'; - stopset[1] = '\n'; - - retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2); - - rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER reply=%s\n", cmdstr); - - if (retval <= 0) - { - return retval; - } - - cmdstr[retval] = 0; - - sscanf(cmdstr, "%d.", &val->i); - - rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER val=%d\n", val->i); - - return RIG_OK; - break; + return RIG_OK; break; + + case RIG_LEVEL_TEMP_METER: + + rig_flush(&rig->state.rigport); + + snprintf(cmdstr, sizeof(cmdstr), "*T\r"); + + rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER command=%s\n", cmdstr); + + retval = write_block(&rig->state.rigport, cmdstr, strlen(cmdstr)); + + if (retval != RIG_OK) + { + return retval; + } + + stopset[0] = '\r'; + stopset[1] = '\n'; + + retval = read_string(&rig->state.rigport, cmdstr, 9, stopset, 2); + + rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER reply=%s\n", cmdstr); + + if (retval <= 0) + { + return retval; + } + + cmdstr[retval] = 0; + + sscanf(cmdstr, "%d.", &val->i); + + rig_debug(RIG_DEBUG_TRACE, "RIG_LEVEL_TEMP_METER val=%d\n", val->i); + + return RIG_OK; + break; + break; + default: - rig_debug(RIG_DEBUG_VERBOSE, "%s: Unrecognized RIG_LEVEL_* enum: %"PRIll"\n", __func__, level); + rig_debug(RIG_DEBUG_VERBOSE, "%s: Unrecognized RIG_LEVEL_* enum: %"PRIll"\n", + __func__, level); return -RIG_EDOM; break; } @@ -373,7 +387,7 @@ const struct rig_caps rshfiq_caps = .get_freq = rshfiq_get_freq, .set_freq = rshfiq_set_freq, .set_ptt = rshfiq_set_ptt, - .get_level= rshfiq_get_level, + .get_level = rshfiq_get_level, }; diff --git a/rigs/yaesu/ft100.c b/rigs/yaesu/ft100.c index fd7e9601d..98871fad5 100644 --- a/rigs/yaesu/ft100.c +++ b/rigs/yaesu/ft100.c @@ -41,10 +41,11 @@ #include "misc.h" #include "bandplan.h" -struct ft100_priv_data { - /* TODO: make use of cached data */ - FT100_STATUS_INFO status; - FT100_FLAG_INFO flags; +struct ft100_priv_data +{ + /* TODO: make use of cached data */ + FT100_STATUS_INFO status; + FT100_FLAG_INFO flags; }; diff --git a/rigs/yaesu/ft600.c b/rigs/yaesu/ft600.c index e471075ac..78dc78089 100644 --- a/rigs/yaesu/ft600.c +++ b/rigs/yaesu/ft600.c @@ -41,10 +41,11 @@ #include "misc.h" #include "bandplan.h" -struct ft600_priv_data { - FT600_STATUS_INFO status; - FT600_FLAG_INFO flags; - unsigned char s_meter; +struct ft600_priv_data +{ + FT600_STATUS_INFO status; + FT600_FLAG_INFO flags; + unsigned char s_meter; }; diff --git a/rigs/yaesu/ft847.c b/rigs/yaesu/ft847.c index 8699780fa..69242e705 100644 --- a/rigs/yaesu/ft847.c +++ b/rigs/yaesu/ft847.c @@ -65,17 +65,18 @@ * */ -struct ft847_priv_data { - split_t sat_mode; +struct ft847_priv_data +{ + split_t sat_mode; - unsigned char rx_status; /* tx returned data */ - unsigned char tx_status; /* rx returned data */ - /* for early ft847's we keep our own memory items */ - /* Early rigs are one-way com to the rig */ - freq_t freqA,freqB; - mode_t mode; - pbwidth_t width; - ptt_t ptt; + unsigned char rx_status; /* tx returned data */ + unsigned char tx_status; /* rx returned data */ + /* for early ft847's we keep our own memory items */ + /* Early rigs are one-way com to the rig */ + freq_t freqA, freqB; + mode_t mode; + pbwidth_t width; + ptt_t ptt; }; diff --git a/rigs/yaesu/ft857.c b/rigs/yaesu/ft857.c index 33f7a27b8..fc70327d6 100644 --- a/rigs/yaesu/ft857.c +++ b/rigs/yaesu/ft857.c @@ -74,20 +74,21 @@ #include "tones.h" #include "bandplan.h" -struct ft857_priv_data { - yaesu_cmd_set_t pcs[FT857_NATIVE_SIZE]; /* TODO: why? */ +struct ft857_priv_data +{ + yaesu_cmd_set_t pcs[FT857_NATIVE_SIZE]; /* TODO: why? */ - /* rx status */ - struct timeval rx_status_tv; - unsigned char rx_status; + /* rx status */ + struct timeval rx_status_tv; + unsigned char rx_status; - /* tx status */ - struct timeval tx_status_tv; - unsigned char tx_status; + /* tx status */ + struct timeval tx_status_tv; + unsigned char tx_status; - /* freq & mode status */ - struct timeval fm_status_tv; - unsigned char fm_status[YAESU_CMD_LENGTH+1]; + /* freq & mode status */ + struct timeval fm_status_tv; + unsigned char fm_status[YAESU_CMD_LENGTH + 1]; }; diff --git a/rigs/yaesu/ft897.c b/rigs/yaesu/ft897.c index d8963abcf..bf8e33a37 100644 --- a/rigs/yaesu/ft897.c +++ b/rigs/yaesu/ft897.c @@ -79,20 +79,21 @@ #include "tones.h" #include "bandplan.h" -struct ft897_priv_data { - yaesu_cmd_set_t pcs[FT897_NATIVE_SIZE]; /* TODO: why? */ +struct ft897_priv_data +{ + yaesu_cmd_set_t pcs[FT897_NATIVE_SIZE]; /* TODO: why? */ - /* rx status */ - struct timeval rx_status_tv; - unsigned char rx_status; + /* rx status */ + struct timeval rx_status_tv; + unsigned char rx_status; - /* tx status */ - struct timeval tx_status_tv; - unsigned char tx_status; + /* tx status */ + struct timeval tx_status_tv; + unsigned char tx_status; - /* freq & mode status */ - struct timeval fm_status_tv; - unsigned char fm_status[YAESU_CMD_LENGTH+1]; + /* freq & mode status */ + struct timeval fm_status_tv; + unsigned char fm_status[YAESU_CMD_LENGTH + 1]; }; diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 3ca0a62b7..c910ecd16 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -921,19 +921,24 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq) if (rig->state.current_vfo != vfo) { int vfo1 = 1, vfo2 = 0; - if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) { + + if (vfo == RIG_VFO_A || vfo == RIG_VFO_MAIN) + { vfo1 = 0; vfo2 = 1; } + // we need to change vfos, BS, and change back snprintf(priv->cmd_str, sizeof(priv->cmd_str), "VS%d;BS%02d", vfo1, newcat_band_index(freq)); + if (RIG_OK != (err = newcat_set_cmd(rig))) { rig_debug(RIG_DEBUG_ERR, "%s: Unexpected error with BS command#1=%s\n", - __func__, rigerror(err)); + __func__, rigerror(err)); } - hl_usleep(50*1000); // wait for BS to do it's thing and swap back + + hl_usleep(50 * 1000); // wait for BS to do it's thing and swap back snprintf(priv->cmd_str, sizeof(priv->cmd_str), "VS%d;", vfo2); } else @@ -4682,6 +4687,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } break; + case RIG_LEVEL_TEMP_METER: if (is_ftdx9000) { @@ -4695,6 +4701,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { RETURNFUNC(-RIG_EINVAL); } + break; default: diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c index e60a3cec1..76c3496f3 100644 --- a/rotators/rotorez/rotorez.c +++ b/rotators/rotorez/rotorez.c @@ -490,7 +490,11 @@ static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth, } if (rot->state.rotport2.pathname[0] != 0) - sprintf(cmdstr, "AP1%05.1f\r;", elevation); /* Total field width of 5 chars */ + { + sprintf(cmdstr, "AP1%05.1f\r;", + elevation); /* Total field width of 5 chars */ + } + err = rotorez_send_priv_cmd2(rot, cmdstr); if (err != RIG_OK) diff --git a/simulators/simelecraft.c b/simulators/simelecraft.c index 2a661ec37..2762c4eec 100644 --- a/simulators/simelecraft.c +++ b/simulators/simelecraft.c @@ -101,9 +101,10 @@ int main(int argc, char *argv[]) while (1) { - buf[0]=0; - if (getmyline(fd, buf) > 0) printf("Cmd:%s\n", buf); - else return 0; + buf[0] = 0; + + if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); } + else { return 0; } if (strcmp(buf, "RM5;") == 0) { @@ -141,7 +142,7 @@ int main(int argc, char *argv[]) printf("%s\n", buf); usleep(50 * 1000); int id = 24; - snprintf(buf,sizeof(buf),"ID%03d;", id); + snprintf(buf, sizeof(buf), "ID%03d;", id); n = snprintf(buf, sizeof(buf), "ID%03d;", id); n = write(fd, buf, strlen(buf)); printf("n=%d\n", n); @@ -186,7 +187,7 @@ int main(int argc, char *argv[]) if (n < 0) { perror("EX032"); } } - else if (strcmp(buf,"OM;") == 0) + else if (strcmp(buf, "OM;") == 0) { // KPA3 snprintf(buf, sizeof(buf), "OM AP----L-----;"); // K4+KPA3 @@ -196,55 +197,55 @@ int main(int argc, char *argv[]) if (n < 0) { perror("OM"); } } - else if (strcmp(buf,"K2;") == 0) + else if (strcmp(buf, "K2;") == 0) { write(fd, "K20;", 4); } - else if (strcmp(buf,"K3;") == 0) + else if (strcmp(buf, "K3;") == 0) { write(fd, "K30;", 4); } - else if (strcmp(buf,"RVM;") == 0) + else if (strcmp(buf, "RVM;") == 0) { write(fd, "RV02.37;", 8); } - else if (strcmp(buf,"AI;") == 0) + else if (strcmp(buf, "AI;") == 0) { write(fd, "AI0;", 4); } - else if (strcmp(buf,"MD;") == 0) + else if (strcmp(buf, "MD;") == 0) { snprintf(buf, sizeof(buf), "MD%d;", modea); write(fd, buf, strlen(buf)); } - else if (strcmp(buf,"MD$;") == 0) + else if (strcmp(buf, "MD$;") == 0) { snprintf(buf, sizeof(buf), "MD$%d;", modeb); write(fd, buf, strlen(buf)); } - else if (strncmp(buf,"MD", 2) == 0) + else if (strncmp(buf, "MD", 2) == 0) { - if (buf[2]=='$') sscanf(buf,"MD$%d;",&modeb); - else sscanf(buf,"MD%d;", &modea); + if (buf[2] == '$') { sscanf(buf, "MD$%d;", &modeb); } + else { sscanf(buf, "MD%d;", &modea); } } - else if (strcmp(buf,"FA;")==0) + else if (strcmp(buf, "FA;") == 0) { sprintf(buf, "FA%011d;", freqa); write(fd, buf, strlen(buf)); } - else if (strcmp(buf,"FB;")==0) + else if (strcmp(buf, "FB;") == 0) { sprintf(buf, "FB%011d;", freqb); write(fd, buf, strlen(buf)); } - else if (strncmp(buf,"FA",2)==0) + else if (strncmp(buf, "FA", 2) == 0) { - sscanf(buf,"FA%d",&freqa); + sscanf(buf, "FA%d", &freqa); } - else if (strncmp(buf,"FB",2)==0) + else if (strncmp(buf, "FB", 2) == 0) { - sscanf(buf,"FB%d",&freqb); + sscanf(buf, "FB%d", &freqb); } else if (strlen(buf) > 0) { diff --git a/simulators/simicom.c b/simulators/simicom.c index 7e7be7134..203e533dc 100644 --- a/simulators/simicom.c +++ b/simulators/simicom.c @@ -118,6 +118,7 @@ void frameParse(int fd, unsigned char *frame, int len) if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { freqA = freq; } else { freqB = freq; } + frame[4] = 0xfb; frame[5] = 0xfd; write(fd, frame, 6); @@ -126,6 +127,7 @@ void frameParse(int fd, unsigned char *frame, int len) case 0x06: if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { modeA = frame[6]; } else { modeB = frame[6]; } + frame[4] = 0xfb; frame[5] = 0xfd; write(fd, frame, 6); @@ -167,20 +169,22 @@ void frameParse(int fd, unsigned char *frame, int len) printf("Set ant %d\n", -1); ant_curr = frame[5]; ant_option = frame[6]; - dump_hex(frame,8); + dump_hex(frame, 8); } - else { + else + { printf("Get ant\n"); } + frame[5] = ant_curr; frame[6] = ant_option; - frame[7]=0xfd; + frame[7] = 0xfd; printf("write 8 bytes\n"); - dump_hex(frame,8); + dump_hex(frame, 8); write(fd, frame, 8); break; - case 0x1a: // miscellaneous things + case 0x1a: // miscellaneous things switch (frame[5]) { case 0x03: // width @@ -195,6 +199,7 @@ void frameParse(int fd, unsigned char *frame, int len) break; #if 1 + case 0x25: if (frame[6] == 0xfd) { diff --git a/simulators/simkenwood.c b/simulators/simkenwood.c index 99e7e9777..9343bb6e4 100644 --- a/simulators/simkenwood.c +++ b/simulators/simkenwood.c @@ -96,14 +96,15 @@ int main(int argc, char *argv[]) char *pbuf; int n; int fd = openPort(argv[1]); - int freqa=14074000, freqb=140735000; - int modea=0,modeb=0; + int freqa = 14074000, freqb = 140735000; + int modea = 0, modeb = 0; while (1) { - buf[0]=0; - if (getmyline(fd, buf) > 0) printf("Cmd:%s\n", buf); - else return 0; + buf[0] = 0; + + if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); } + else { return 0; } if (strcmp(buf, "RM5;") == 0) { @@ -141,7 +142,7 @@ int main(int argc, char *argv[]) printf("%s\n", buf); usleep(50 * 1000); int id = 24; - snprintf(buf,sizeof(buf),"ID%03d;", id); + snprintf(buf, sizeof(buf), "ID%03d;", id); n = snprintf(buf, sizeof(buf), "ID%03d;", id); n = write(fd, buf, strlen(buf)); printf("n=%d\n", n); @@ -196,15 +197,15 @@ int main(int argc, char *argv[]) sprintf(buf, "FA%011d;", freqa); write(fd, buf, strlen(buf)); } - else if (strncmp(buf,"FA",2)==0) + else if (strncmp(buf, "FA", 2) == 0) { - sscanf(buf,"FA%d",&freqa); + sscanf(buf, "FA%d", &freqa); } - else if (strncmp(buf,"FB",2)==0) + else if (strncmp(buf, "FB", 2) == 0) { - sscanf(buf,"FB%d",&freqb); + sscanf(buf, "FB%d", &freqb); } - else if (strncmp(buf,"AI;",2)==0) + else if (strncmp(buf, "AI;", 2) == 0) { sprintf(buf, "AI0;"); write(fd, buf, strlen(buf)); diff --git a/simulators/simyaesu.c b/simulators/simyaesu.c index ce39abd7f..ed0080c67 100644 --- a/simulators/simyaesu.c +++ b/simulators/simyaesu.c @@ -99,9 +99,11 @@ int main(int argc, char *argv[]) while (1) { - if(getmyline(fd, buf)) - printf("Cmd:%s\n", buf); - else return 0; + if (getmyline(fd, buf)) + { + printf("Cmd:%s\n", buf); + } + else { return 0; } if (strcmp(buf, "RM5;") == 0) { @@ -139,7 +141,7 @@ int main(int argc, char *argv[]) printf("%s\n", buf); usleep(50 * 1000); int id = NC_RIGID_FTDX3000; - snprintf(buf,sizeof(buf),"ID%03d;", id); + snprintf(buf, sizeof(buf), "ID%03d;", id); n = snprintf(buf, sizeof(buf), "ID%03d;", id); n = write(fd, buf, strlen(buf)); printf("n=%d\n", n); diff --git a/src/event.c b/src/event.c index e0e9cbf1c..188b1aaf2 100644 --- a/src/event.c +++ b/src/event.c @@ -323,7 +323,8 @@ static int search_rig_and_decode(RIG *rig, rig_ptr_t data) */ if (rig->state.hold_decode) { - rig_debug(RIG_DEBUG_TRACE, "%s: hold decode, backend is receiving data\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: hold decode, backend is receiving data\n", + __func__); RETURNFUNC(-1); } @@ -365,7 +366,8 @@ static int search_rig_and_decode(RIG *rig, rig_ptr_t data) */ if (rig->state.hold_decode) { - rig_debug(RIG_DEBUG_TRACE, "%s: hold decode, backend is receiving data\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: hold decode, backend is receiving data\n", + __func__); RETURNFUNC(-1); } @@ -724,7 +726,8 @@ int HAMLIB_API rig_set_pltune_callback(RIG *rig, pltune_cb_t cb, rig_ptr_t arg) * * \sa rig_set_trn() */ -int HAMLIB_API rig_set_spectrum_callback(RIG *rig, spectrum_cb_t cb, rig_ptr_t arg) +int HAMLIB_API rig_set_spectrum_callback(RIG *rig, spectrum_cb_t cb, + rig_ptr_t arg) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); diff --git a/src/iofunc.c b/src/iofunc.c index 582c7424e..6c4cc43a9 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -76,7 +76,8 @@ int HAMLIB_API port_open(hamlib_port_t *p) if (status < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: serial_open(%s) status=%d\n", __func__, p->pathname, status); + rig_debug(RIG_DEBUG_ERR, "%s: serial_open(%s) status=%d\n", __func__, + p->pathname, status); RETURNFUNC(status); } diff --git a/src/misc.c b/src/misc.c index d7abf173f..08f6d4130 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1761,6 +1761,7 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split) { split = rig->state.cache.split; } + #endif int satmode = rig->state.cache.satmode; diff --git a/src/network.c b/src/network.c index aa56f8ef6..591dd6350 100644 --- a/src/network.c +++ b/src/network.c @@ -556,9 +556,10 @@ int network_multicast_server(RIG *rig, const char *multicast_addr, rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):ADDR=%s, port=%d\n", __FILE__, __LINE__, multicast_addr, default_port); - if (strcmp(multicast_addr,"0.0.0.0")==0) + if (strcmp(multicast_addr, "0.0.0.0") == 0) { - rig_debug(RIG_DEBUG_TRACE, "%s(%d): not starting multicast\n", __FILE__, __LINE__); + rig_debug(RIG_DEBUG_TRACE, "%s(%d): not starting multicast\n", __FILE__, + __LINE__); return RIG_OK; // don't start it } diff --git a/src/register.c b/src/register.c index 0d3895aca..6d56b130a 100644 --- a/src/register.c +++ b/src/register.c @@ -261,7 +261,7 @@ static int rig_lookup_backend(rig_model_t rig_model) for (i = 0; i < RIG_BACKEND_MAX && rig_backend_list[i].be_name; i++) { if (RIG_BACKEND_NUM(rig_model) == - rig_backend_list[i].be_num) + rig_backend_list[i].be_num) { return i; @@ -284,7 +284,7 @@ int HAMLIB_API rig_check_backend(rig_model_t rig_model) const struct rig_caps *caps; int be_idx; int retval; - int i,n; + int i, n; /* already loaded ? */ caps = rig_get_caps(rig_model); @@ -295,13 +295,15 @@ int HAMLIB_API rig_check_backend(rig_model_t rig_model) } // hmmm...no caps so did we already load the rigs? - for(n=0, i=0; i< RIGLSTHASHSZ; i++) + for (n = 0, i = 0; i < RIGLSTHASHSZ; i++) { - if (rig_hash_table[i]) ++n; + if (rig_hash_table[i]) { ++n; } } + if (n > 1) { - rig_debug(RIG_DEBUG_ERR, "%s: rig model %d not found and rig count=%d\n", __func__, rig_model, n); + rig_debug(RIG_DEBUG_ERR, "%s: rig model %d not found and rig count=%d\n", + __func__, rig_model, n); return -RIG_ENAVAIL; } @@ -329,6 +331,7 @@ int HAMLIB_API rig_check_backend(rig_model_t rig_model) { retval = RIG_OK; } + #endif return retval; diff --git a/src/rig.c b/src/rig.c index c67b6d017..2c48b619f 100644 --- a/src/rig.c +++ b/src/rig.c @@ -173,7 +173,7 @@ static struct opened_rig_l *opened_rig_list = { NULL }; * Careful, the order must be the same as their RIG_E* counterpart! * TODO: localise the messages.. */ -static const char * const rigerror_table[] = +static const char *const rigerror_table[] = { "Command completed successfully", "Invalid parameter", @@ -365,15 +365,17 @@ static void cache_show(RIG *rig, const char *func, int line) "%s(%d): freqMainB=%.0f, modeMainB=%s, widthMainB=%d\n", func, line, rig->state.cache.freqMainB, rig_strrmode(rig->state.cache.modeMainB), (int)rig->state.cache.widthMainB); - if (rig->state.vfo_list & RIG_VFO_SUB_A) { - rig_debug(RIG_DEBUG_CACHE, - "%s(%d): freqSubA=%.0f, modeSubA=%s, widthSubA=%d\n", func, line, - rig->state.cache.freqSubA, rig_strrmode(rig->state.cache.modeSubA), - (int)rig->state.cache.widthSubA); - rig_debug(RIG_DEBUG_CACHE, - "%s(%d): freqSubB=%.0f, modeSubB=%s, widthSubB=%d\n", func, line, - rig->state.cache.freqSubB, rig_strrmode(rig->state.cache.modeSubB), - (int)rig->state.cache.widthSubB); + + if (rig->state.vfo_list & RIG_VFO_SUB_A) + { + rig_debug(RIG_DEBUG_CACHE, + "%s(%d): freqSubA=%.0f, modeSubA=%s, widthSubA=%d\n", func, line, + rig->state.cache.freqSubA, rig_strrmode(rig->state.cache.modeSubA), + (int)rig->state.cache.widthSubA); + rig_debug(RIG_DEBUG_CACHE, + "%s(%d): freqSubB=%.0f, modeSubB=%s, widthSubB=%d\n", func, line, + rig->state.cache.freqSubB, rig_strrmode(rig->state.cache.modeSubB), + (int)rig->state.cache.widthSubB); } } @@ -1041,6 +1043,7 @@ int HAMLIB_API rig_open(RIG *rig) rs->current_vfo = RIG_VFO_CURR; #if 0 // done in the back end + if (backend_num == RIG_ICOM) { TRACE; @@ -1048,7 +1051,9 @@ int HAMLIB_API rig_open(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s: Icom rig so default vfo = %s\n", __func__, rig_strvfo(rs->current_vfo)); } + #endif + if (rig->caps->set_vfo == NULL) { // for non-Icom rigs if there's no set_vfo then we need to set one @@ -1136,6 +1141,7 @@ int HAMLIB_API rig_close(RIG *rig) multicast_server_threadId = 0; } + #endif if (!rig || !rig->caps) @@ -1983,7 +1989,8 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) RETURNFUNC(-RIG_EINVAL); } - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) called vfo=%s\n", __func__, __LINE__, rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) called vfo=%s\n", __func__, __LINE__, + rig_strvfo(vfo)); cache_show(rig, __func__, __LINE__); @@ -1991,7 +1998,8 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) vfo = vfo_fixup(rig, vfo, rig->state.cache.split); - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) vfo=%s, curr_vfo=%s\n", __FILE__, __LINE__, rig_strvfo(vfo), rig_strvfo(curr_vfo)); + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) vfo=%s, curr_vfo=%s\n", __FILE__, __LINE__, + rig_strvfo(vfo), rig_strvfo(curr_vfo)); if (vfo == RIG_VFO_CURR) { vfo = curr_vfo; } @@ -2124,6 +2132,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) retcode = caps->get_freq(rig, vfo, freq); /* try and revert even if we had an error above */ rc2 = RIG_OK; + if (curr_vfo != RIG_VFO_NONE) { rc2 = caps->set_vfo(rig, curr_vfo); @@ -2605,7 +2614,8 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo) ENTERFUNC; #if BUILTINFUNC - rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, called from %s\n", __func__, rig_strvfo(vfo),func); + rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, called from %s\n", __func__, + rig_strvfo(vfo), func); #else rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo)); #endif @@ -2626,6 +2636,7 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo) if (vfo == RIG_VFO_CURR) { RETURNFUNC(RIG_OK); } #if 0 // removing this check 20210801 -- should be mapped already + // make sure we are asking for a VFO that the rig actually has if ((vfo == RIG_VFO_A || vfo == RIG_VFO_B) && !VFO_HAS_A_B) { @@ -2640,6 +2651,7 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo) rig_strvfo(vfo)); RETURNFUNC(-RIG_EINVAL); } + #endif vfo = vfo_fixup(rig, vfo, rig->state.cache.split); @@ -2661,7 +2673,9 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo) TRACE; vfo_t vfo_save = rig->state.current_vfo; - if (vfo != RIG_VFO_CURR) rig->state.current_vfo = vfo; + + if (vfo != RIG_VFO_CURR) { rig->state.current_vfo = vfo; } + retcode = caps->set_vfo(rig, vfo); if (retcode == RIG_OK) @@ -2707,7 +2721,8 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo) elapsed_ms(&rig->state.cache.time_widthMainC, HAMLIB_ELAPSED_INVALIDATE); #endif - rig_debug(RIG_DEBUG_TRACE, "%s: return %d, vfo=%s, curr_vfo=%s\n", __func__, retcode, + rig_debug(RIG_DEBUG_TRACE, "%s: return %d, vfo=%s, curr_vfo=%s\n", __func__, + retcode, rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); RETURNFUNC(retcode); } @@ -3797,8 +3812,11 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) { TRACE; retcode = RIG_OK; + if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) + { retcode = caps->set_vfo(rig, tx_vfo); + } } else if (rig_has_vfo_op(rig, RIG_OP_TOGGLE) && caps->vfo_op) { @@ -3842,8 +3860,11 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) { TRACE; rc2 = RIG_OK; + if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) + { rc2 = caps->set_vfo(rig, curr_vfo); + } } else { @@ -3962,7 +3983,8 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) else { TRACE; - retcode = caps->get_freq ? caps->get_freq(rig, RIG_VFO_CURR, tx_freq) :-RIG_ENIMPL; + retcode = caps->get_freq ? caps->get_freq(rig, RIG_VFO_CURR, + tx_freq) : -RIG_ENIMPL; } /* try and revert even if we had an error above */ @@ -4098,7 +4120,8 @@ int HAMLIB_API rig_set_split_mode(RIG *rig, else { TRACE; - retcode = caps->set_mode ? caps->set_mode(rig, RIG_VFO_CURR, tx_mode, tx_width) : -RIG_ENIMPL; + retcode = caps->set_mode ? caps->set_mode(rig, RIG_VFO_CURR, tx_mode, + tx_width) : -RIG_ENIMPL; } /* try and revert even if we had an error above */ @@ -4221,7 +4244,8 @@ int HAMLIB_API rig_get_split_mode(RIG *rig, vfo_t vfo, rmode_t *tx_mode, else { TRACE; - retcode = caps->get_mode ? caps->get_mode(rig, RIG_VFO_CURR, tx_mode, tx_width) : -RIG_ENIMPL; + retcode = caps->get_mode ? caps->get_mode(rig, RIG_VFO_CURR, tx_mode, + tx_width) : -RIG_ENIMPL; } /* try and revert even if we had an error above */ @@ -4461,15 +4485,20 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, if (vfo != RIG_VFO_A && vfo != RIG_VFO_B) { - rig_debug(RIG_DEBUG_ERR, "%s: expected VFOA/B but got %s\n", __func__, rig_strvfo(vfo)); + rig_debug(RIG_DEBUG_ERR, "%s: expected VFOA/B but got %s\n", __func__, + rig_strvfo(vfo)); } + // set rig to the the requested RX VFO TRACE; + if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) #if BUILTINFUNC - rig_set_vfo(rig, vfo == RIG_VFO_B?RIG_VFO_B:RIG_VFO_A, __builtin_FUNCTION()); + rig_set_vfo(rig, vfo == RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A, + __builtin_FUNCTION()); + #else - rig_set_vfo(rig, vfo == RIG_VFO_B?RIG_VFO_B:RIG_VFO_A); + rig_set_vfo(rig, vfo == RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A); #endif if (vfo == RIG_VFO_CURR @@ -4496,28 +4525,30 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, curr_vfo = rig->state.current_vfo; TRACE; + if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) { retcode = caps->set_vfo(rig, vfo); - if (retcode != RIG_OK) - { - RETURNFUNC(retcode); - } + if (retcode != RIG_OK) + { + RETURNFUNC(retcode); + } } TRACE; retcode = caps->set_split_vfo(rig, vfo, split, tx_vfo); /* try and revert even if we had an error above */ - if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) { + if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) + { rc2 = caps->set_vfo(rig, curr_vfo); - if (RIG_OK == retcode) - { - /* return the first error code */ - retcode = rc2; - } + if (RIG_OK == retcode) + { + /* return the first error code */ + retcode = rc2; + } } if (retcode == RIG_OK) @@ -4614,7 +4645,8 @@ int HAMLIB_API rig_get_split_vfo(RIG *rig, TRACE; retcode = RIG_OK; //if (rig->caps->rig_model != RIG_MODEL_NETRIGCTL) - { // rigctld doesn't like nested calls + { + // rigctld doesn't like nested calls retcode = caps->get_split_vfo(rig, vfo, split, tx_vfo); rig->state.cache.split = *split; rig->state.cache.split_vfo = *tx_vfo; @@ -6374,6 +6406,7 @@ void make_crc_table(unsigned long crcTable[]) remainder = b; unsigned long bit; + for (bit = 8; bit > 0; --bit) { if (remainder & 1) diff --git a/src/serial.c b/src/serial.c index caa313cae..a9e15a188 100644 --- a/src/serial.c +++ b/src/serial.c @@ -224,16 +224,20 @@ int HAMLIB_API serial_open(hamlib_port_t *rp) /* * Open in Non-blocking mode. Watch for EAGAIN errors! */ - int i=1; - do { // some serial ports fail to open 1st time for some unknown reason + int i = 1; + + do // some serial ports fail to open 1st time for some unknown reason + { fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); + if (fd == -1) // some serial ports fail to open 1st time for some unknown reason - { + { rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#%d\n", __func__, __LINE__, i); - hl_usleep(500*1000); + hl_usleep(500 * 1000); fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); } - } while(++i <= 4 && fd == -1); + } + while (++i <= 4 && fd == -1); if (fd == -1) { @@ -710,17 +714,20 @@ int ser_open(hamlib_port_t *p) /* * pathname is not uh_rig or uh_ptt: simply open() */ - int i=1; + int i = 1; + do // some serial ports fail to open 1st time { ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY); + if (ret == -1) // some serial ports fail to open 1st time { rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#%d\n", __func__, __LINE__, i); - hl_usleep(500*1000); + hl_usleep(500 * 1000); ret = OPEN(p->pathname, O_RDWR | O_NOCTTY | O_NDELAY); } - } while(++i <= 4 && ret == -1); + } + while (++i <= 4 && ret == -1); } } diff --git a/src/sprintflst.c b/src/sprintflst.c index 4f43ea192..faa5dea6a 100644 --- a/src/sprintflst.c +++ b/src/sprintflst.c @@ -727,7 +727,8 @@ int rot_sprintf_status(char *str, int nlen, rot_status_t status) return len; } -int rig_sprintf_spectrum_modes(char *str, int nlen, const enum rig_spectrum_mode_e *modes) +int rig_sprintf_spectrum_modes(char *str, int nlen, + const enum rig_spectrum_mode_e *modes) { int i, len = 0, lentmp; @@ -750,11 +751,13 @@ int rig_sprintf_spectrum_modes(char *str, int nlen, const enum rig_spectrum_mode } lentmp = snprintf(str + len, nlen - len, "%d=%s ", modes[i], sm); + if (len < 0 || lentmp >= nlen - len) { - rig_debug(RIG_DEBUG_ERR,"%s(%d): overflowed str buffer\n", __FILE__, __LINE__); + rig_debug(RIG_DEBUG_ERR, "%s(%d): overflowed str buffer\n", __FILE__, __LINE__); break; } + len += lentmp; } @@ -776,18 +779,21 @@ int rig_sprintf_spectrum_spans(char *str, int nlen, const freq_t *spans) } lentmp = snprintf(str + len, nlen - len, "%.0f ", spans[i]); + if (len < 0 || lentmp >= nlen - len) { - rig_debug(RIG_DEBUG_ERR,"%s(%d): overflowed str buffer\n", __FILE__, __LINE__); + rig_debug(RIG_DEBUG_ERR, "%s(%d): overflowed str buffer\n", __FILE__, __LINE__); break; } + len += lentmp; } return len; } -int rig_sprintf_spectrum_avg_modes(char *str, int nlen, const struct rig_spectrum_avg_mode *avg_modes) +int rig_sprintf_spectrum_avg_modes(char *str, int nlen, + const struct rig_spectrum_avg_mode *avg_modes) { int i, len = 0, lentmp; @@ -800,12 +806,15 @@ int rig_sprintf_spectrum_avg_modes(char *str, int nlen, const struct rig_spectru break; } - lentmp = snprintf(str + len, nlen - len, "%d=\"%s\" ", avg_modes[i].id, avg_modes[i].name); + lentmp = snprintf(str + len, nlen - len, "%d=\"%s\" ", avg_modes[i].id, + avg_modes[i].name); + if (len < 0 || lentmp >= nlen - len) { - rig_debug(RIG_DEBUG_ERR,"%s(%d): overflowed str buffer\n", __FILE__, __LINE__); + rig_debug(RIG_DEBUG_ERR, "%s(%d): overflowed str buffer\n", __FILE__, __LINE__); break; } + len += lentmp; } diff --git a/tests/dumpcaps.c b/tests/dumpcaps.c index 80d1ff2ce..f775b727b 100644 --- a/tests/dumpcaps.c +++ b/tests/dumpcaps.c @@ -297,7 +297,8 @@ int dumpcaps(RIG *rig, FILE *fout) for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && i < caps->agc_level_count; i++) { - fprintf(fout, " %d=%s", caps->agc_levels[i], rig_stragclevel(caps->agc_levels[i])); + fprintf(fout, " %d=%s", caps->agc_levels[i], + rig_stragclevel(caps->agc_levels[i])); } if (i == 0) @@ -700,9 +701,11 @@ int dumpcaps(RIG *rig, FILE *fout) fprintf(fout, "Spectrum scopes:"); - for (i = 0; i < HAMLIB_MAX_SPECTRUM_SCOPES && caps->spectrum_scopes[i].name != NULL; i++) + for (i = 0; i < HAMLIB_MAX_SPECTRUM_SCOPES + && caps->spectrum_scopes[i].name != NULL; i++) { - fprintf(fout, " %d=\"%s\"", caps->spectrum_scopes[i].id, caps->spectrum_scopes[i].name); + fprintf(fout, " %d=\"%s\"", caps->spectrum_scopes[i].id, + caps->spectrum_scopes[i].name); } if (i == 0) @@ -718,7 +721,8 @@ int dumpcaps(RIG *rig, FILE *fout) rig_sprintf_spectrum_spans(prntbuf, sizeof(prntbuf), caps->spectrum_spans); fprintf(fout, "Spectrum spans: %s\n", prntbuf); - rig_sprintf_spectrum_avg_modes(prntbuf, sizeof(prntbuf), caps->spectrum_avg_modes); + rig_sprintf_spectrum_avg_modes(prntbuf, sizeof(prntbuf), + caps->spectrum_avg_modes); fprintf(fout, "Spectrum averaging modes: %s\n", prntbuf); fprintf(fout, "Spectrum attenuator:"); diff --git a/tests/rigctl.c b/tests/rigctl.c index 3dd46854e..5286778c0 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -156,7 +156,9 @@ int main(int argc, char *argv[]) int i; rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) Startup:", __FILE__, __LINE__); - for(i=0;idata_level_max / 2; int aggregate_count = line->spectrum_data_length / 120; @@ -4081,7 +4085,9 @@ static int print_spectrum_line(char *str, size_t length, struct rig_spectrum_lin } int level = aggregate_value * 10 / data_level_max; - if (level >= 8) { + + if (level >= 8) + { strcpy(str + c, "█"); c += charlen; } @@ -4114,7 +4120,8 @@ static int print_spectrum_line(char *str, size_t length, struct rig_spectrum_lin } -static int myspectrum_event(RIG *rig, struct rig_spectrum_line *line, rig_ptr_t arg) +static int myspectrum_event(RIG *rig, struct rig_spectrum_line *line, + rig_ptr_t arg) { ENTERFUNC; @@ -4122,7 +4129,8 @@ static int myspectrum_event(RIG *rig, struct rig_spectrum_line *line, rig_ptr_t { char spectrum_debug[line->spectrum_data_length * 4]; print_spectrum_line(spectrum_debug, sizeof(spectrum_debug), line); - rig_debug(RIG_DEBUG_TRACE, "%s: ASCII Spectrum Scope: %s\n", __func__, spectrum_debug); + rig_debug(RIG_DEBUG_TRACE, "%s: ASCII Spectrum Scope: %s\n", __func__, + spectrum_debug); } // TODO: Push out spectrum data via multicast server once it is implemented @@ -4501,7 +4509,8 @@ declare_proto_rig(dump_state) if (chk_vfo_executed) // for 3.3 compatiblility { fprintf(fout, "vfo_ops=0x%x\n", rig->caps->vfo_ops); - fprintf(fout, "ptt_type=0x%x\n", rig->state.pttport.type.ptt==RIG_PTT_NONE?RIG_PTT_NONE:RIG_PTT_RIG); + fprintf(fout, "ptt_type=0x%x\n", + rig->state.pttport.type.ptt == RIG_PTT_NONE ? RIG_PTT_NONE : RIG_PTT_RIG); fprintf(fout, "targetable_vfo=0x%x\n", rig->caps->targetable_vfo); fprintf(fout, "has_set_vfo=%d\n", rig->caps->set_vfo != NULL); fprintf(fout, "has_get_vfo=%d\n", rig->caps->get_vfo != NULL); diff --git a/tests/rigctlcom.c b/tests/rigctlcom.c index 11d516293..2ba5d8ed6 100644 --- a/tests/rigctlcom.c +++ b/tests/rigctlcom.c @@ -653,7 +653,8 @@ static rmode_t ts2000_get_mode() { rmode_t mode; pbwidth_t width; - rig_get_mode(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), &mode, &width); + rig_get_mode(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), + &mode, &width); // Perhaps we should emulate a rig that has PKT modes instead?? switch (mode) @@ -740,7 +741,8 @@ static int handle_ts2000(void *arg) int p13 = 0; // P13 Tone dummy value for now int p14 = 0; // P14 Tone Freq dummy value for now int p15 = 0; // P15 Shift status dummy value for now - int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), &freq); + int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + my_rig->state.cache.split), &freq); char response[64]; char *fmt = // cppcheck-suppress * @@ -752,7 +754,8 @@ static int handle_ts2000(void *arg) } mode = ts2000_get_mode(); - retval = rig_get_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), &ptt); + retval = rig_get_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + my_rig->state.cache.split), &ptt); if (retval != RIG_OK) { @@ -834,7 +837,8 @@ static int handle_ts2000(void *arg) freq_t freq = 0; char response[32]; - int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), &freq); + int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + my_rig->state.cache.split), &freq); if (retval != RIG_OK) { @@ -850,7 +854,8 @@ static int handle_ts2000(void *arg) { char response[32]; freq_t freq = 0; - int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split), &freq); + int retval = rig_get_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B, + my_rig->state.cache.split), &freq); if (retval != RIG_OK) { @@ -904,7 +909,8 @@ static int handle_ts2000(void *arg) } else if (strcmp(arg, "TX;") == 0) { - return rig_set_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), 1); + return rig_set_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + my_rig->state.cache.split), 1); } else if (strcmp(arg, "AI0;") == 0) { @@ -918,11 +924,13 @@ static int handle_ts2000(void *arg) } else if (strcmp(arg, "FR0;") == 0) { - return rig_set_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split)); + return rig_set_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + my_rig->state.cache.split)); } else if (strcmp(arg, "FR1;") == 0) { - return rig_set_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split)); + return rig_set_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_B, + my_rig->state.cache.split)); } else if (strcmp(arg, "FR;") == 0) { @@ -1018,7 +1026,8 @@ static int handle_ts2000(void *arg) { char response[32]; int valA; - int retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), RIG_FUNC_AIP, + int retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + my_rig->state.cache.split), RIG_FUNC_AIP, &valA); int valB; @@ -1037,7 +1046,8 @@ static int handle_ts2000(void *arg) return retval; } - retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split), RIG_FUNC_AIP, + retval = rig_get_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B, + my_rig->state.cache.split), RIG_FUNC_AIP, &valB); if (retval != RIG_OK) @@ -1063,7 +1073,8 @@ static int handle_ts2000(void *arg) (char *)arg); } - retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), RIG_FUNC_AIP, valA); + retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + my_rig->state.cache.split), RIG_FUNC_AIP, valA); if (retval != RIG_OK) { @@ -1072,7 +1083,8 @@ static int handle_ts2000(void *arg) return retval; } - retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split), RIG_FUNC_AIP, valB); + retval = rig_set_func(my_rig, vfo_fixup(my_rig, RIG_VFO_B, + my_rig->state.cache.split), RIG_FUNC_AIP, valB); if (retval != RIG_OK) { @@ -1487,27 +1499,31 @@ static int handle_ts2000(void *arg) } else if (strcmp(arg, "FT0;") == 0) { - return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), vfo_fixup(my_rig, - RIG_VFO_A, my_rig->state.cache.split), 0); + return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + my_rig->state.cache.split), vfo_fixup(my_rig, + RIG_VFO_A, my_rig->state.cache.split), 0); } else if (strcmp(arg, "FT1;") == 0) { - return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split), vfo_fixup(my_rig, - RIG_VFO_B, my_rig->state.cache.split), 0); + return rig_set_split_vfo(my_rig, vfo_fixup(my_rig, RIG_VFO_B, + my_rig->state.cache.split), vfo_fixup(my_rig, + RIG_VFO_B, my_rig->state.cache.split), 0); } else if (strncmp(arg, "FA0", 3) == 0) { freq_t freq; sscanf((char *)arg + 2, "%"SCNfreq, &freq); - return rig_set_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, my_rig->state.cache.split), freq); + return rig_set_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_A, + my_rig->state.cache.split), freq); } else if (strncmp(arg, "FB0", 3) == 0) { freq_t freq; sscanf((char *)arg + 2, "%"SCNfreq, &freq); - return rig_set_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B, my_rig->state.cache.split), freq); + return rig_set_freq(my_rig, vfo_fixup(my_rig, RIG_VFO_B, + my_rig->state.cache.split), freq); } else if (strncmp(arg, "MD", 2) == 0) { diff --git a/tests/rigctld.c b/tests/rigctld.c index 3a748810e..64a29c7f7 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -270,7 +270,9 @@ int main(int argc, char *argv[]) int i; rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) Startup:", __FILE__, __LINE__); - for(i=0;ibMaxBurst); - printf(" bmAttributes: %02xh\n", ep_comp->bmAttributes); - printf(" wBytesPerInterval: %u\n", ep_comp->wBytesPerInterval); + printf(" USB 3.0 Endpoint Companion:\n"); + printf(" bMaxBurst: %u\n", ep_comp->bMaxBurst); + printf(" bmAttributes: %02xh\n", ep_comp->bmAttributes); + printf(" wBytesPerInterval: %u\n", ep_comp->wBytesPerInterval); } static void print_endpoint(const struct libusb_endpoint_descriptor *endpoint) { - int i, ret; + int i, ret; - printf(" Endpoint:\n"); - printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress); - printf(" bmAttributes: %02xh\n", endpoint->bmAttributes); - printf(" wMaxPacketSize: %u\n", endpoint->wMaxPacketSize); - printf(" bInterval: %u\n", endpoint->bInterval); - printf(" bRefresh: %u\n", endpoint->bRefresh); - printf(" bSynchAddress: %u\n", endpoint->bSynchAddress); + printf(" Endpoint:\n"); + printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress); + printf(" bmAttributes: %02xh\n", endpoint->bmAttributes); + printf(" wMaxPacketSize: %u\n", endpoint->wMaxPacketSize); + printf(" bInterval: %u\n", endpoint->bInterval); + printf(" bRefresh: %u\n", endpoint->bRefresh); + printf(" bSynchAddress: %u\n", endpoint->bSynchAddress); - for (i = 0; i < endpoint->extra_length;) { - if (LIBUSB_DT_SS_ENDPOINT_COMPANION == endpoint->extra[i + 1]) { - struct libusb_ss_endpoint_companion_descriptor *ep_comp; + for (i = 0; i < endpoint->extra_length;) + { + if (LIBUSB_DT_SS_ENDPOINT_COMPANION == endpoint->extra[i + 1]) + { + struct libusb_ss_endpoint_companion_descriptor *ep_comp; - ret = libusb_get_ss_endpoint_companion_descriptor(NULL, endpoint, &ep_comp); - if (LIBUSB_SUCCESS != ret) - continue; + ret = libusb_get_ss_endpoint_companion_descriptor(NULL, endpoint, &ep_comp); - print_endpoint_comp(ep_comp); + if (LIBUSB_SUCCESS != ret) + { + continue; + } - libusb_free_ss_endpoint_companion_descriptor(ep_comp); - } + print_endpoint_comp(ep_comp); - i += endpoint->extra[i]; - } + libusb_free_ss_endpoint_companion_descriptor(ep_comp); + } + + i += endpoint->extra[i]; + } } -static void print_altsetting(const struct libusb_interface_descriptor *interface) +static void print_altsetting(const struct libusb_interface_descriptor + *interface) { - uint8_t i; + uint8_t i; - printf(" Interface:\n"); - printf(" bInterfaceNumber: %u\n", interface->bInterfaceNumber); - printf(" bAlternateSetting: %u\n", interface->bAlternateSetting); - printf(" bNumEndpoints: %u\n", interface->bNumEndpoints); - printf(" bInterfaceClass: %u\n", interface->bInterfaceClass); - printf(" bInterfaceSubClass: %u\n", interface->bInterfaceSubClass); - printf(" bInterfaceProtocol: %u\n", interface->bInterfaceProtocol); - printf(" iInterface: %u\n", interface->iInterface); + printf(" Interface:\n"); + printf(" bInterfaceNumber: %u\n", interface->bInterfaceNumber); + printf(" bAlternateSetting: %u\n", interface->bAlternateSetting); + printf(" bNumEndpoints: %u\n", interface->bNumEndpoints); + printf(" bInterfaceClass: %u\n", interface->bInterfaceClass); + printf(" bInterfaceSubClass: %u\n", interface->bInterfaceSubClass); + printf(" bInterfaceProtocol: %u\n", interface->bInterfaceProtocol); + printf(" iInterface: %u\n", interface->iInterface); - for (i = 0; i < interface->bNumEndpoints; i++) - print_endpoint(&interface->endpoint[i]); + for (i = 0; i < interface->bNumEndpoints; i++) + { + print_endpoint(&interface->endpoint[i]); + } } -static void print_2_0_ext_cap(struct libusb_usb_2_0_extension_descriptor *usb_2_0_ext_cap) +static void print_2_0_ext_cap(struct libusb_usb_2_0_extension_descriptor + *usb_2_0_ext_cap) { - printf(" USB 2.0 Extension Capabilities:\n"); - printf(" bDevCapabilityType: %u\n", usb_2_0_ext_cap->bDevCapabilityType); - printf(" bmAttributes: %08xh\n", usb_2_0_ext_cap->bmAttributes); + printf(" USB 2.0 Extension Capabilities:\n"); + printf(" bDevCapabilityType: %u\n", + usb_2_0_ext_cap->bDevCapabilityType); + printf(" bmAttributes: %08xh\n", usb_2_0_ext_cap->bmAttributes); } -static void print_ss_usb_cap(struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap) +static void print_ss_usb_cap(struct libusb_ss_usb_device_capability_descriptor + *ss_usb_cap) { - printf(" USB 3.0 Capabilities:\n"); - printf(" bDevCapabilityType: %u\n", ss_usb_cap->bDevCapabilityType); - printf(" bmAttributes: %02xh\n", ss_usb_cap->bmAttributes); - printf(" wSpeedSupported: %u\n", ss_usb_cap->wSpeedSupported); - printf(" bFunctionalitySupport: %u\n", ss_usb_cap->bFunctionalitySupport); - printf(" bU1devExitLat: %u\n", ss_usb_cap->bU1DevExitLat); - printf(" bU2devExitLat: %u\n", ss_usb_cap->bU2DevExitLat); + printf(" USB 3.0 Capabilities:\n"); + printf(" bDevCapabilityType: %u\n", ss_usb_cap->bDevCapabilityType); + printf(" bmAttributes: %02xh\n", ss_usb_cap->bmAttributes); + printf(" wSpeedSupported: %u\n", ss_usb_cap->wSpeedSupported); + printf(" bFunctionalitySupport: %u\n", ss_usb_cap->bFunctionalitySupport); + printf(" bU1devExitLat: %u\n", ss_usb_cap->bU1DevExitLat); + printf(" bU2devExitLat: %u\n", ss_usb_cap->bU2DevExitLat); } static void print_bos(libusb_device_handle *handle) { - struct libusb_bos_descriptor *bos; - uint8_t i; - int ret; + struct libusb_bos_descriptor *bos; + uint8_t i; + int ret; - ret = libusb_get_bos_descriptor(handle, &bos); - if (ret < 0) - return; + ret = libusb_get_bos_descriptor(handle, &bos); - printf(" Binary Object Store (BOS):\n"); - printf(" wTotalLength: %u\n", bos->wTotalLength); - printf(" bNumDeviceCaps: %u\n", bos->bNumDeviceCaps); + if (ret < 0) + { + return; + } - for (i = 0; i < bos->bNumDeviceCaps; i++) { - struct libusb_bos_dev_capability_descriptor *dev_cap = bos->dev_capability[i]; + printf(" Binary Object Store (BOS):\n"); + printf(" wTotalLength: %u\n", bos->wTotalLength); + printf(" bNumDeviceCaps: %u\n", bos->bNumDeviceCaps); - if (dev_cap->bDevCapabilityType == LIBUSB_BT_USB_2_0_EXTENSION) { - struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension; + for (i = 0; i < bos->bNumDeviceCaps; i++) + { + struct libusb_bos_dev_capability_descriptor *dev_cap = bos->dev_capability[i]; - ret = libusb_get_usb_2_0_extension_descriptor(NULL, dev_cap, &usb_2_0_extension); - if (ret < 0) - return; + if (dev_cap->bDevCapabilityType == LIBUSB_BT_USB_2_0_EXTENSION) + { + struct libusb_usb_2_0_extension_descriptor *usb_2_0_extension; - print_2_0_ext_cap(usb_2_0_extension); - libusb_free_usb_2_0_extension_descriptor(usb_2_0_extension); - } else if (dev_cap->bDevCapabilityType == LIBUSB_BT_SS_USB_DEVICE_CAPABILITY) { - struct libusb_ss_usb_device_capability_descriptor *ss_dev_cap; + ret = libusb_get_usb_2_0_extension_descriptor(NULL, dev_cap, + &usb_2_0_extension); - ret = libusb_get_ss_usb_device_capability_descriptor(NULL, dev_cap, &ss_dev_cap); - if (ret < 0) - return; + if (ret < 0) + { + return; + } - print_ss_usb_cap(ss_dev_cap); - libusb_free_ss_usb_device_capability_descriptor(ss_dev_cap); - } - } + print_2_0_ext_cap(usb_2_0_extension); + libusb_free_usb_2_0_extension_descriptor(usb_2_0_extension); + } + else if (dev_cap->bDevCapabilityType == LIBUSB_BT_SS_USB_DEVICE_CAPABILITY) + { + struct libusb_ss_usb_device_capability_descriptor *ss_dev_cap; - libusb_free_bos_descriptor(bos); + ret = libusb_get_ss_usb_device_capability_descriptor(NULL, dev_cap, + &ss_dev_cap); + + if (ret < 0) + { + return; + } + + print_ss_usb_cap(ss_dev_cap); + libusb_free_ss_usb_device_capability_descriptor(ss_dev_cap); + } + } + + libusb_free_bos_descriptor(bos); } static void print_interface(const struct libusb_interface *interface) { - int i; + int i; - for (i = 0; i < interface->num_altsetting; i++) - print_altsetting(&interface->altsetting[i]); + for (i = 0; i < interface->num_altsetting; i++) + { + print_altsetting(&interface->altsetting[i]); + } } static void print_configuration(struct libusb_config_descriptor *config) { - uint8_t i; + uint8_t i; - printf(" Configuration:\n"); - printf(" wTotalLength: %u\n", config->wTotalLength); - printf(" bNumInterfaces: %u\n", config->bNumInterfaces); - printf(" bConfigurationValue: %u\n", config->bConfigurationValue); - printf(" iConfiguration: %u\n", config->iConfiguration); - printf(" bmAttributes: %02xh\n", config->bmAttributes); - printf(" MaxPower: %u\n", config->MaxPower); + printf(" Configuration:\n"); + printf(" wTotalLength: %u\n", config->wTotalLength); + printf(" bNumInterfaces: %u\n", config->bNumInterfaces); + printf(" bConfigurationValue: %u\n", config->bConfigurationValue); + printf(" iConfiguration: %u\n", config->iConfiguration); + printf(" bmAttributes: %02xh\n", config->bmAttributes); + printf(" MaxPower: %u\n", config->MaxPower); - for (i = 0; i < config->bNumInterfaces; i++) - print_interface(&config->interface[i]); + for (i = 0; i < config->bNumInterfaces; i++) + { + print_interface(&config->interface[i]); + } } static void print_device(libusb_device *dev, libusb_device_handle *handle) { - struct libusb_device_descriptor desc; - unsigned char string[256]; - const char *speed; - int ret; - uint8_t i; + struct libusb_device_descriptor desc; + unsigned char string[256]; + const char *speed; + int ret; + uint8_t i; - switch (libusb_get_device_speed(dev)) { - case LIBUSB_SPEED_LOW: speed = "1.5M"; break; - case LIBUSB_SPEED_FULL: speed = "12M"; break; - case LIBUSB_SPEED_HIGH: speed = "480M"; break; - case LIBUSB_SPEED_SUPER: speed = "5G"; break; - case LIBUSB_SPEED_SUPER_PLUS: speed = "10G"; break; - default: speed = "Unknown"; - } + switch (libusb_get_device_speed(dev)) + { + case LIBUSB_SPEED_LOW: speed = "1.5M"; break; - ret = libusb_get_device_descriptor(dev, &desc); - if (ret < 0) { - fprintf(stderr, "failed to get device descriptor"); - return; - } + case LIBUSB_SPEED_FULL: speed = "12M"; break; - printf("Dev (bus %u, device %u): %04X - %04X speed: %s\n", - libusb_get_bus_number(dev), libusb_get_device_address(dev), - desc.idVendor, desc.idProduct, speed); + case LIBUSB_SPEED_HIGH: speed = "480M"; break; - if (!handle) - libusb_open(dev, &handle); + case LIBUSB_SPEED_SUPER: speed = "5G"; break; - if (handle) { - if (desc.iManufacturer) { - ret = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, string, sizeof(string)); - if (ret > 0) - printf(" Manufacturer: %s\n", (char *)string); - } + case LIBUSB_SPEED_SUPER_PLUS: speed = "10G"; break; - if (desc.iProduct) { - ret = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, sizeof(string)); - if (ret > 0) - printf(" Product: %s\n", (char *)string); - } + default: speed = "Unknown"; + } - if (desc.iSerialNumber && verbose) { - ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string, sizeof(string)); - if (ret > 0) - printf(" Serial Number: %s\n", (char *)string); - } - } + ret = libusb_get_device_descriptor(dev, &desc); - if (verbose) { - for (i = 0; i < desc.bNumConfigurations; i++) { - struct libusb_config_descriptor *config; + if (ret < 0) + { + fprintf(stderr, "failed to get device descriptor"); + return; + } - ret = libusb_get_config_descriptor(dev, i, &config); - if (LIBUSB_SUCCESS != ret) { - printf(" Couldn't retrieve descriptors\n"); - continue; - } + printf("Dev (bus %u, device %u): %04X - %04X speed: %s\n", + libusb_get_bus_number(dev), libusb_get_device_address(dev), + desc.idVendor, desc.idProduct, speed); - print_configuration(config); + if (!handle) + { + libusb_open(dev, &handle); + } - libusb_free_config_descriptor(config); - } + if (handle) + { + if (desc.iManufacturer) + { + ret = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, string, + sizeof(string)); - if (handle && desc.bcdUSB >= 0x0201) - print_bos(handle); - } + if (ret > 0) + { + printf(" Manufacturer: %s\n", (char *)string); + } + } - if (handle) - libusb_close(handle); + if (desc.iProduct) + { + ret = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, + sizeof(string)); + + if (ret > 0) + { + printf(" Product: %s\n", (char *)string); + } + } + + if (desc.iSerialNumber && verbose) + { + ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string, + sizeof(string)); + + if (ret > 0) + { + printf(" Serial Number: %s\n", (char *)string); + } + } + } + + if (verbose) + { + for (i = 0; i < desc.bNumConfigurations; i++) + { + struct libusb_config_descriptor *config; + + ret = libusb_get_config_descriptor(dev, i, &config); + + if (LIBUSB_SUCCESS != ret) + { + printf(" Couldn't retrieve descriptors\n"); + continue; + } + + print_configuration(config); + + libusb_free_config_descriptor(config); + } + + if (handle && desc.bcdUSB >= 0x0201) + { + print_bos(handle); + } + } + + if (handle) + { + libusb_close(handle); + } } #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000107) @@ -250,73 +315,95 @@ static void print_device(libusb_device *dev, libusb_device_handle *handle) static int test_wrapped_device(const char *device_name) { - libusb_device_handle *handle; - int r, fd; + libusb_device_handle *handle; + int r, fd; - fd = open(device_name, O_RDWR); - if (fd < 0) { - printf("Error could not open %s: %s\n", device_name, strerror(errno)); - return 1; - } - r = libusb_wrap_sys_device(NULL, fd, &handle); - if (r) { - printf("Error wrapping device: %s: %s\n", device_name, libusb_strerror(r)); - close(fd); - return 1; - } - print_device(libusb_get_device(handle), handle); - close(fd); - return 0; + fd = open(device_name, O_RDWR); + + if (fd < 0) + { + printf("Error could not open %s: %s\n", device_name, strerror(errno)); + return 1; + } + + r = libusb_wrap_sys_device(NULL, fd, &handle); + + if (r) + { + printf("Error wrapping device: %s: %s\n", device_name, libusb_strerror(r)); + close(fd); + return 1; + } + + print_device(libusb_get_device(handle), handle); + close(fd); + return 0; } #else #warning LIBUSB-1.0.23 will be required in Hamlib > 4.3 static int test_wrapped_device(const char *device_name) { - (void)device_name; - printf("Testing wrapped devices is not supported on your platform\n"); - return 1; + (void)device_name; + printf("Testing wrapped devices is not supported on your platform\n"); + return 1; } #endif int main(int argc, char *argv[]) { - const char *device_name = NULL; - libusb_device **devs; - ssize_t cnt; - int r, i; + const char *device_name = NULL; + libusb_device **devs; + ssize_t cnt; + int r, i; - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-v")) { - verbose = 1; - } else if (!strcmp(argv[i], "-d") && (i + 1) < argc) { - i++; - device_name = argv[i]; - } else { - printf("Usage %s [-v] [-d ]\n", argv[0]); - printf("Note use -d to test libusb_wrap_sys_device()\n"); - return 1; - } - } + for (i = 1; i < argc; i++) + { + if (!strcmp(argv[i], "-v")) + { + verbose = 1; + } + else if (!strcmp(argv[i], "-d") && (i + 1) < argc) + { + i++; + device_name = argv[i]; + } + else + { + printf("Usage %s [-v] [-d ]\n", argv[0]); + printf("Note use -d to test libusb_wrap_sys_device()\n"); + return 1; + } + } - r = libusb_init(NULL); - if (r < 0) - return r; + r = libusb_init(NULL); - if (device_name) { - r = test_wrapped_device(device_name); - } else { - cnt = libusb_get_device_list(NULL, &devs); - if (cnt < 0) { - libusb_exit(NULL); - return 1; - } + if (r < 0) + { + return r; + } - for (i = 0; devs[i]; i++) - print_device(devs[i], NULL); + if (device_name) + { + r = test_wrapped_device(device_name); + } + else + { + cnt = libusb_get_device_list(NULL, &devs); - libusb_free_device_list(devs, 1); - } + if (cnt < 0) + { + libusb_exit(NULL); + return 1; + } - libusb_exit(NULL); - return r; + for (i = 0; devs[i]; i++) + { + print_device(devs[i], NULL); + } + + libusb_free_device_list(devs, 1); + } + + libusb_exit(NULL); + return r; } diff --git a/tests/testrig.c b/tests/testrig.c index 8410ade0a..d75f54b82 100644 --- a/tests/testrig.c +++ b/tests/testrig.c @@ -140,10 +140,13 @@ int main(int argc, char *argv[]) { printf("rig_set_freq: error exptect %.0f got %.0f\n", 296290000.0, freq); } + if (rmode != RIG_MODE_FM || width != rig_passband_narrow(my_rig, RIG_MODE_FM)) { - printf("rig_set_mode: error expected FM/%d, got %s/%d\n", (int)rig_passband_narrow(my_rig, RIG_MODE_FM), rig_strrmode(rmode), (int)width); + printf("rig_set_mode: error expected FM/%d, got %s/%d\n", + (int)rig_passband_narrow(my_rig, RIG_MODE_FM), rig_strrmode(rmode), (int)width); } + sleep(1); /* so you can see it -- FS */ /* 15m USB */ From 9c44e29ec697a62d52b70eeb8ebec8f4eb6f29b9 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 26 Aug 2021 07:22:52 -0500 Subject: [PATCH 44/97] Add ax_cxx_compile_stdcxx.m4 to macros/Makefile.am --- macros/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/macros/Makefile.am b/macros/Makefile.am index 3507bbcfa..5bbf29963 100644 --- a/macros/Makefile.am +++ b/macros/Makefile.am @@ -8,6 +8,7 @@ MACROS = \ ax_python_devel.m4 \ ax_lib_indi.m4 \ ax_lib_nova.m4 \ + ax_cxx_compile_stdcxx.m4 \ gr_doxygen.m4 \ gr_pwin32.m4 \ hl_getaddrinfo.m4 \ From 9b650f9dc533d90b39d5c4a6dc57cb58adbe68f4 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 26 Aug 2021 08:47:52 -0500 Subject: [PATCH 45/97] Add build script for jtsdk to Makefile.am --- scripts/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.am b/scripts/Makefile.am index b62041da0..1982b5e5e 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,2 +1,2 @@ -EXTRA_DIST = README.scripts build-w32.sh build-w64.sh README.build-Windows \ +EXTRA_DIST = README.scripts build-w32.sh build-w64.sh build-w64.jtsdk.sh README.build-Windows \ build-VB.NET.sh README.build-VB.NET astylerc From aedcc4191c56ae61c5f8f840accf2a8fb38aebfc Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 26 Aug 2021 08:53:44 -0500 Subject: [PATCH 46/97] Fix typo in scripts/Makefile.am --- scripts/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 1982b5e5e..0f9acc3af 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,2 +1,2 @@ -EXTRA_DIST = README.scripts build-w32.sh build-w64.sh build-w64.jtsdk.sh README.build-Windows \ +EXTRA_DIST = README.scripts build-w32.sh build-w64.sh build-w64-jtsdk.sh README.build-Windows \ build-VB.NET.sh README.build-VB.NET astylerc From a851da80e210564f077aa6366c07c2be760e5004 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 26 Aug 2021 16:31:37 -0500 Subject: [PATCH 47/97] Fix Kenwood FR/FT sequencing https://github.com/Hamlib/Hamlib/issues/746 --- rigs/kenwood/kenwood.c | 4 ++-- rigs/kenwood/kenwood.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 6a52d164a..62632779b 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1120,7 +1120,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) // FR can turn off split on some Kenwood rigs // So we'll turn it back on just in case - if (priv->split) { strcat(cmdbuf, "FT1;"); } + if (priv->split && vfo_function == '0') { strcat(cmdbuf, ";FT1"); } if (RIG_IS_TS50 || RIG_IS_TS940) { @@ -1261,7 +1261,7 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) // FR can turn off split on some Kenwood rigs // So we'll turn it back on just in case - if (priv->split) { strcat(cmdbuf, "FT1;"); } + if (priv->split && vfo_function=='0') { strcat(cmdbuf, ";FT1"); } retval = kenwood_transaction(rig, cmdbuf, NULL, 0); diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index 17f64d544..0781eea84 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -28,7 +28,7 @@ #include "token.h" #include "misc.h" -#define BACKEND_VER "20210822" +#define BACKEND_VER "20210826" #define EOM_KEN ';' #define EOM_TH '\r' From eecffd31be0b072a121f20aca9ea1d4bbc20866b Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 26 Aug 2021 22:49:41 -0500 Subject: [PATCH 48/97] Change kenwood set_split to check split instead of priv->split https://github.com/Hamlib/Hamlib/issues/746 --- rigs/kenwood/kenwood.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 62632779b..46774940e 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1261,7 +1261,7 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) // FR can turn off split on some Kenwood rigs // So we'll turn it back on just in case - if (priv->split && vfo_function=='0') { strcat(cmdbuf, ";FT1"); } + if (split && vfo_function=='0') { strcat(cmdbuf, ";FT1"); } retval = kenwood_transaction(rig, cmdbuf, NULL, 0); From 1c7b4ab80674ba981b56ea2d4d086fead1b1e1da Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 27 Aug 2021 12:04:16 -0500 Subject: [PATCH 49/97] Allow all Icom, Kenwood, Yaesu to avoid VFO swapping https://github.com/Hamlib/Hamlib/issues/762 https://github.com/Hamlib/Hamlib/issues/430 --- src/rig.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rig.c b/src/rig.c index 2c48b619f..aef85ab0d 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1098,6 +1098,18 @@ int HAMLIB_API rig_open(RIG *rig) // freq_t freq; // if (caps->get_freq) rig_get_freq(rig, RIG_VFO_A, &freq); // if (caps->get_freq) rig_get_freq(rig, RIG_VFO_B, &freq); + int backend_num = RIG_BACKEND_NUM(rig->caps->rig_model); + + switch (backend_num) + { + // most rigs have only one PTT VFO so we can set that flag here + case RIG_ICOM: + case RIG_KENWOOD: + case RIG_YAESU: + rig->caps->targetable_vfo |= RIG_TARGETABLE_PTT; + break; + } + RETURNFUNC(RIG_OK); } From 6a9432a0c7edc56aac7c7ccd11e10b7059a443a4 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 27 Aug 2021 12:16:35 -0500 Subject: [PATCH 50/97] Fix possilbe segfault last patch https://github.com/Hamlib/Hamlib/issues/762 https://github.com/Hamlib/Hamlib/issues/430 --- src/rig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rig.c b/src/rig.c index aef85ab0d..75b1613da 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1106,7 +1106,7 @@ int HAMLIB_API rig_open(RIG *rig) case RIG_ICOM: case RIG_KENWOOD: case RIG_YAESU: - rig->caps->targetable_vfo |= RIG_TARGETABLE_PTT; + if (rig->caps->targetable_vfo) rig->caps->targetable_vfo |= RIG_TARGETABLE_PTT; break; } From 3dde32f53499050486d44e1283d5ca8e36342ed6 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 27 Aug 2021 12:32:37 -0500 Subject: [PATCH 51/97] Move TARGETABLE_PTT logic to the set_ptt routine https://github.com/Hamlib/Hamlib/issues/762 https://github.com/Hamlib/Hamlib/issues/430 --- src/rig.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/rig.c b/src/rig.c index 75b1613da..bd88b0ed6 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1098,17 +1098,6 @@ int HAMLIB_API rig_open(RIG *rig) // freq_t freq; // if (caps->get_freq) rig_get_freq(rig, RIG_VFO_A, &freq); // if (caps->get_freq) rig_get_freq(rig, RIG_VFO_B, &freq); - int backend_num = RIG_BACKEND_NUM(rig->caps->rig_model); - - switch (backend_num) - { - // most rigs have only one PTT VFO so we can set that flag here - case RIG_ICOM: - case RIG_KENWOOD: - case RIG_YAESU: - if (rig->caps->targetable_vfo) rig->caps->targetable_vfo |= RIG_TARGETABLE_PTT; - break; - } RETURNFUNC(RIG_OK); } @@ -3105,6 +3094,8 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) int rc2, status; vfo_t curr_vfo; int cache_ms; + int targetable_ptt = 0; + int backend_num; ENTERFUNC; @@ -3143,10 +3134,21 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) *ptt = rs->transmit ? RIG_PTT_ON : RIG_PTT_OFF; RETURNFUNC(RIG_OK); } + backend_num = RIG_BACKEND_NUM(rig->caps->rig_model); + + switch (backend_num) + { + // most rigs have only one PTT VFO so we can set that flag here + case RIG_ICOM: + case RIG_KENWOOD: + case RIG_YAESU: + targetable_ptt = 1; + } if ((caps->targetable_vfo & RIG_TARGETABLE_PTT) || vfo == RIG_VFO_CURR - || vfo == rig->state.current_vfo) + || vfo == rig->state.current_vfo + || targetable_ptt) { TRACE; retcode = caps->get_ptt(rig, vfo, ptt); From fcdacb254037ec0423295fced437a8e4d1e5175b Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 27 Aug 2021 12:50:53 -0500 Subject: [PATCH 52/97] Finish up targetable_ptt logic Was causing unnecessary vfo swapping https://github.com/Hamlib/Hamlib/issues/762 https://github.com/Hamlib/Hamlib/issues/430 --- src/rig.c | 73 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/src/rig.c b/src/rig.c index bd88b0ed6..9e8288d1b 100644 --- a/src/rig.c +++ b/src/rig.c @@ -2896,6 +2896,8 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) else { vfo_t curr_vfo; + int backend_num; + int targetable_ptt; if (!caps->set_vfo) { @@ -2904,7 +2906,22 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) curr_vfo = rig->state.current_vfo; TRACE; - retcode = caps->set_vfo(rig, vfo); + backend_num = RIG_BACKEND_NUM(rig->caps->rig_model); + + switch (backend_num) + { + // most rigs have only one PTT VFO so we can set that flag here + case RIG_ICOM: + case RIG_KENWOOD: + case RIG_YAESU: + targetable_ptt = 1; + } + + + if (!targetable_ptt) + { + retcode = caps->set_vfo(rig, vfo); + } if (retcode == RIG_OK) { @@ -2932,7 +2949,11 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) /* try and revert even if we had an error above */ TRACE; - rc2 = caps->set_vfo(rig, curr_vfo); + + if (!targetable_ptt) + { + rc2 = caps->set_vfo(rig, curr_vfo); + } /* return the first error code */ if (RIG_OK == retcode) @@ -3134,21 +3155,10 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) *ptt = rs->transmit ? RIG_PTT_ON : RIG_PTT_OFF; RETURNFUNC(RIG_OK); } - backend_num = RIG_BACKEND_NUM(rig->caps->rig_model); - - switch (backend_num) - { - // most rigs have only one PTT VFO so we can set that flag here - case RIG_ICOM: - case RIG_KENWOOD: - case RIG_YAESU: - targetable_ptt = 1; - } if ((caps->targetable_vfo & RIG_TARGETABLE_PTT) || vfo == RIG_VFO_CURR - || vfo == rig->state.current_vfo - || targetable_ptt) + || vfo == rig->state.current_vfo) { TRACE; retcode = caps->get_ptt(rig, vfo, ptt); @@ -3169,7 +3179,22 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) curr_vfo = rig->state.current_vfo; TRACE; - retcode = caps->set_vfo(rig, vfo); + backend_num = RIG_BACKEND_NUM(rig->caps->rig_model); + + switch (backend_num) + { + // most rigs have only one PTT VFO so we can set that flag here + case RIG_ICOM: + case RIG_KENWOOD: + case RIG_YAESU: + targetable_ptt = 1; + } + + + if (!targetable_ptt) + { + retcode = caps->set_vfo(rig, vfo); + } if (retcode != RIG_OK) { @@ -3178,15 +3203,19 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) TRACE; retcode = caps->get_ptt(rig, vfo, ptt); - /* try and revert even if we had an error above */ - rc2 = caps->set_vfo(rig, curr_vfo); - if (RIG_OK == retcode) + /* try and revert even if we had an error above */ + if (!targetable_ptt) { - /* return the first error code */ - retcode = rc2; - rig->state.cache.ptt = *ptt; - elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_SET); + rc2 = caps->set_vfo(rig, curr_vfo); + + if (RIG_OK == retcode) + { + /* return the first error code */ + retcode = rc2; + rig->state.cache.ptt = *ptt; + elapsed_ms(&rig->state.cache.time_ptt, HAMLIB_ELAPSED_SET); + } } RETURNFUNC(retcode); From 31696351a9660899bb68311ad6602e64cfd1628c Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 27 Aug 2021 13:08:15 -0500 Subject: [PATCH 53/97] Add RX command to kenwood rigs hopefully setting VFO to VFOA after split set FT450 and others turn split off doing FR0 and FT1; leaves the rig on VFOB https://github.com/Hamlib/Hamlib/issues/746 --- rigs/kenwood/kenwood.c | 4 ++-- rigs/kenwood/kenwood.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 46774940e..7a3422cc4 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1120,7 +1120,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) // FR can turn off split on some Kenwood rigs // So we'll turn it back on just in case - if (priv->split && vfo_function == '0') { strcat(cmdbuf, ";FT1"); } + if (priv->split && vfo_function == '0') { strcat(cmdbuf, ";FT1;RX"); } if (RIG_IS_TS50 || RIG_IS_TS940) { @@ -1261,7 +1261,7 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) // 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 (split && vfo_function=='0') { strcat(cmdbuf, ";FT1;RX"); } retval = kenwood_transaction(rig, cmdbuf, NULL, 0); diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index 0781eea84..a5c0242a3 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -28,7 +28,7 @@ #include "token.h" #include "misc.h" -#define BACKEND_VER "20210826" +#define BACKEND_VER "20210827" #define EOM_KEN ';' #define EOM_TH '\r' From d5028e7ba4c346b41f41bf6e2c4b0546bf3339c6 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 27 Aug 2021 15:46:23 -0500 Subject: [PATCH 54/97] Fix some more unnecessary vfo swapping https://github.com/Hamlib/Hamlib/issues/762 https://github.com/Hamlib/Hamlib/issues/430 --- src/rig.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/rig.c b/src/rig.c index 9e8288d1b..c3a4e48a2 100644 --- a/src/rig.c +++ b/src/rig.c @@ -3815,7 +3815,8 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) if (caps->set_split_freq && (vfo == RIG_VFO_CURR || vfo == RIG_VFO_TX - || tx_vfo == rig->state.current_vfo)) + || tx_vfo == rig->state.current_vfo + || (caps->targetable_vfo & RIG_TARGETABLE_FREQ))) { TRACE; retcode = caps->set_split_freq(rig, vfo, tx_freq); @@ -3828,7 +3829,7 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) /* Assisted mode */ curr_vfo = rig->state.current_vfo; - if (caps->set_freq && (caps->targetable_vfo & RIG_TARGETABLE_FREQ)) + if (caps->set_freq) { int retry = 3; freq_t tfreq; @@ -3856,10 +3857,7 @@ int HAMLIB_API rig_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) TRACE; retcode = RIG_OK; - if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) - { - retcode = caps->set_vfo(rig, tx_vfo); - } + retcode = caps->set_vfo(rig, tx_vfo); } else if (rig_has_vfo_op(rig, RIG_OP_TOGGLE) && caps->vfo_op) { @@ -3994,7 +3992,8 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) if (caps->set_vfo) { // if the underlying rig has OP_XCHG we don't need to set VFO - if (!rig_has_vfo_op(rig, RIG_OP_XCHG)) + if (!rig_has_vfo_op(rig, RIG_OP_XCHG) + && !(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) { TRACE; retcode = caps->set_vfo(rig, tx_vfo); @@ -4040,7 +4039,16 @@ int HAMLIB_API rig_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) rig_debug(RIG_DEBUG_TRACE, "%s: restoring vfo=%s\n", __func__, rig_strvfo(save_vfo)); TRACE; - rc2 = caps->set_vfo(rig, save_vfo); + + if (!rig_has_vfo_op(rig, RIG_OP_XCHG) + && !(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) + { + rc2 = caps->set_vfo(rig, save_vfo); + } + else + { + rc2 = RIG_OK; + } } else { From 83590a0868e23cd3ba7f377fc26cd5ba7c97a44d Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 27 Aug 2021 15:51:02 -0500 Subject: [PATCH 55/97] Fix uninitialized warning in rig.c https://github.com/Hamlib/Hamlib/issues/762 https://github.com/Hamlib/Hamlib/issues/430 --- src/rig.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rig.c b/src/rig.c index c3a4e48a2..9241c90b7 100644 --- a/src/rig.c +++ b/src/rig.c @@ -2950,6 +2950,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) /* try and revert even if we had an error above */ TRACE; + rc2 = RIG_OK; if (!targetable_ptt) { rc2 = caps->set_vfo(rig, curr_vfo); From c04c4cbd2ae0b006b79b7fb84675807e0d173abf Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 27 Aug 2021 17:24:31 -0500 Subject: [PATCH 56/97] Remove another unneeded vfo swap from icom rigs https://github.com/Hamlib/Hamlib/issues/762 https://github.com/Hamlib/Hamlib/issues/430 --- rigs/icom/icom.c | 8 ++++++-- rigs/icom/icom.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 0ce03fda5..7880b04f5 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -1973,8 +1973,12 @@ int icom_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) || rig->state.current_vfo == RIG_VFO_CURR)) { TRACE; - swapvfos = 1; - rig_set_vfo(rig, RIG_VFO_B); + + if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE)) + { + swapvfos = 1; + rig_set_vfo(rig, RIG_VFO_B); + } } rig_debug(RIG_DEBUG_VERBOSE, "%s: #2 icmode=%d, icmode_ext=%d\n", __func__, diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index c937844c1..b765dcaf4 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "20210822" +#define BACKEND_VER "20210824" #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) From 124e2c30c7673a312fb60195f8d1dc806dee72e7 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 27 Aug 2021 18:00:11 -0500 Subject: [PATCH 57/97] Remove RX from kenwood.c -- did not put rig on VFOA https://github.com/Hamlib/Hamlib/issues/746 --- rigs/kenwood/kenwood.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 7a3422cc4..245325d24 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1118,10 +1118,6 @@ int kenwood_set_vfo(RIG *rig, vfo_t 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 - if (priv->split && vfo_function == '0') { strcat(cmdbuf, ";FT1;RX"); } - if (RIG_IS_TS50 || RIG_IS_TS940) { cmdbuf[1] = 'N'; @@ -1261,7 +1257,7 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) // 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;RX"); } + if (split && vfo_function=='0') { strcat(cmdbuf, ";FT1"); } retval = kenwood_transaction(rig, cmdbuf, NULL, 0); From fa4fa7a1d937efcaa8d7507d5955db5d7919313b Mon Sep 17 00:00:00 2001 From: kacomet Date: Fri, 27 Aug 2021 19:41:38 -0500 Subject: [PATCH 58/97] Corrected modes for FT-736R. The FT-736 supports SSB, CW, FM, FM-N (narrowband FM,) CW-N (narrowband CW.) Now, the FM-N and CW-N modes can be set from rigctl. Passbands have also been corrected to the values in the manual. --- include/hamlib/rig.h | 2 +- rigs/yaesu/ft736.c | 30 +++++++++++++++--------------- src/misc.c | 1 + 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index b5d8a891b..352d503ef 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -1224,7 +1224,7 @@ typedef uint64_t rmode_t; #define RIG_MODE_C4FM CONSTANT_64BIT_FLAG (33) /*!< \c Yaesu C4FM mode */ #define RIG_MODE_PKTFMN CONSTANT_64BIT_FLAG (34) /*!< \c Yaesu DATA-FM-N */ #define RIG_MODE_SPEC CONSTANT_64BIT_FLAG (35) /*!< \c Unfiltered as in PowerSDR */ -#define RIG_MODE_BIT36 CONSTANT_64BIT_FLAG (36) /*!< \c reserved for future expansion */ +#define RIG_MODE_CWN CONSTANT_64BIT_FLAG (36) /*!< \c CWN -- Narrow band CW (FT-736R) */ #define RIG_MODE_BIT37 CONSTANT_64BIT_FLAG (37) /*!< \c reserved for future expansion */ #define RIG_MODE_BIT38 CONSTANT_64BIT_FLAG (38) /*!< \c reserved for future expansion */ #define RIG_MODE_BIT39 CONSTANT_64BIT_FLAG (39) /*!< \c reserved for future expansion */ diff --git a/rigs/yaesu/ft736.c b/rigs/yaesu/ft736.c index ec4a023eb..6f3edce0d 100644 --- a/rigs/yaesu/ft736.c +++ b/rigs/yaesu/ft736.c @@ -38,7 +38,7 @@ -#define FT736_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_FM) +#define FT736_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_FMN|RIG_MODE_CWN) #define FT736_VFOS (RIG_VFO_A) @@ -181,10 +181,10 @@ const struct rig_caps ft736_caps = /* mode/filter list, remember: order matters! */ .filters = { - {RIG_MODE_SSB | RIG_MODE_CW | RIG_MODE_CWR, kHz(2.2)}, - {RIG_MODE_CW | RIG_MODE_CWR, Hz(600)}, - {RIG_MODE_FM, kHz(12)}, - {RIG_MODE_FM, kHz(8)}, + {RIG_MODE_CW | RIG_MODE_SSB, kHz(2.2)}, + {RIG_MODE_FM, kHz(12)}, + {RIG_MODE_FMN, kHz(8)}, + {RIG_MODE_CWN, Hz(600)}, RIG_FLT_END, }, @@ -291,9 +291,9 @@ int ft736_set_freq(RIG *rig, vfo_t vfo, freq_t freq) #define MD_LSB 0x00 #define MD_USB 0x01 #define MD_CW 0x02 -#define MD_CWR 0x03 -#define MD_AM 0x04 +#define MD_CWN 0x82 #define MD_FM 0x08 +#define MD_FMN 0x88 int ft736_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { @@ -311,17 +311,17 @@ int ft736_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) */ switch (mode) { - case RIG_MODE_CW: md = MD_CW; break; + case RIG_MODE_CW: md = MD_CW; break; - case RIG_MODE_CWR: md = MD_CWR; break; + case RIG_MODE_CWN: md = MD_CWN; break; case RIG_MODE_USB: md = MD_USB; break; case RIG_MODE_LSB: md = MD_LSB; break; - case RIG_MODE_FM: md = MD_FM; break; + case RIG_MODE_FM: md = MD_FM; break; - case RIG_MODE_AM: md = MD_AM; break; + case RIG_MODE_FMN: md = MD_FMN; break; default: return -RIG_EINVAL; /* sorry, wrong MODE */ @@ -397,17 +397,17 @@ int ft736_set_split_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) */ switch (mode) { - case RIG_MODE_CW: md = MD_CW; break; + case RIG_MODE_CW: md = MD_CW; break; - case RIG_MODE_CWR: md = MD_CWR; break; + case RIG_MODE_CWN: md = MD_CWN; break; case RIG_MODE_USB: md = MD_USB; break; case RIG_MODE_LSB: md = MD_LSB; break; - case RIG_MODE_FM: md = MD_FM; break; + case RIG_MODE_FM: md = MD_FM; break; - case RIG_MODE_AM: md = MD_AM; break; + case RIG_MODE_FMN: md = MD_FMN; break; default: return -RIG_EINVAL; /* sorry, wrong MODE */ diff --git a/src/misc.c b/src/misc.c index 08f6d4130..bc679198f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -453,6 +453,7 @@ static const struct { RIG_MODE_PSKR, "PSKR"}, { RIG_MODE_C4FM, "C4FM"}, { RIG_MODE_SPEC, "SPEC"}, + { RIG_MODE_CWN, "CWN"}, { RIG_MODE_NONE, "" }, }; From 32460321ab1be1bcab8072acc6abde5e3905b69d Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Fri, 27 Aug 2021 22:25:53 -0500 Subject: [PATCH 59/97] astyle files --- rigs/kenwood/kenwood.c | 2 +- rigs/yaesu/ft736.c | 4 ++-- src/rig.c | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 245325d24..589c2150b 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1257,7 +1257,7 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) // 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 (split && vfo_function == '0') { strcat(cmdbuf, ";FT1"); } retval = kenwood_transaction(rig, cmdbuf, NULL, 0); diff --git a/rigs/yaesu/ft736.c b/rigs/yaesu/ft736.c index 6f3edce0d..a16ed49e5 100644 --- a/rigs/yaesu/ft736.c +++ b/rigs/yaesu/ft736.c @@ -311,7 +311,7 @@ int ft736_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) */ switch (mode) { - case RIG_MODE_CW: md = MD_CW; break; + case RIG_MODE_CW: md = MD_CW; break; case RIG_MODE_CWN: md = MD_CWN; break; @@ -319,7 +319,7 @@ int ft736_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) case RIG_MODE_LSB: md = MD_LSB; break; - case RIG_MODE_FM: md = MD_FM; break; + case RIG_MODE_FM: md = MD_FM; break; case RIG_MODE_FMN: md = MD_FMN; break; diff --git a/src/rig.c b/src/rig.c index 9241c90b7..75885e8b6 100644 --- a/src/rig.c +++ b/src/rig.c @@ -2951,6 +2951,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) TRACE; rc2 = RIG_OK; + if (!targetable_ptt) { rc2 = caps->set_vfo(rig, curr_vfo); From 623bef2f61a6624f02bf9ff8dcb15c0e1f275d19 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 28 Aug 2021 09:10:35 -0500 Subject: [PATCH 60/97] Move Startup debug line after set_debug_level --- tests/rigctl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/rigctl.c b/tests/rigctl.c index 5286778c0..6e027faf8 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -155,12 +155,6 @@ int main(int argc, char *argv[]) char resp_sep = '\n'; int i; - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) Startup:", __FILE__, __LINE__); - - for (i = 0; i < argc; ++i) { rig_debug(RIG_DEBUG_VERBOSE, " %s", argv[i]); } - - rig_debug(RIG_DEBUG_VERBOSE, "%s", "\n"); - while (1) { int c; @@ -446,6 +440,13 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) Startup:", __FILE__, __LINE__); + + for (i = 0; i < argc; ++i) { rig_debug(RIG_DEBUG_VERBOSE, " %s", argv[i]); } + + rig_debug(RIG_DEBUG_VERBOSE, "%s", "\n"); + + rig_debug(RIG_DEBUG_VERBOSE, "rigctl %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to \n\n"); From 72099a63ce52794309d228ecbfb3fb6493d06bc5 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 28 Aug 2021 09:53:19 -0500 Subject: [PATCH 61/97] Move Startup message after debug_set_level in rigctld.c --- tests/rigctld.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/rigctld.c b/tests/rigctld.c index 64a29c7f7..508ae8cdf 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -269,12 +269,6 @@ int main(int argc, char *argv[]) int vfo_mode = 0; /* vfo_mode=0 means target VFO is current VFO */ int i; - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) Startup:", __FILE__, __LINE__); - - for (i = 0; i < argc; ++i) { rig_debug(RIG_DEBUG_VERBOSE, " %s", argv[i]); } - - rig_debug(RIG_DEBUG_VERBOSE, "%s", "\n"); - while (1) { int c; @@ -583,6 +577,13 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) Startup:", __FILE__, __LINE__); + + for (i = 0; i < argc; ++i) { rig_debug(RIG_DEBUG_VERBOSE, " %s", argv[i]); } + + rig_debug(RIG_DEBUG_VERBOSE, "%s", "\n"); + + rig_debug(RIG_DEBUG_VERBOSE, "rigctld %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to \n\n"); From fe46bcf540c31755c4f6e2a90049196050e1d056 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 28 Aug 2021 09:54:37 -0500 Subject: [PATCH 62/97] Fix set_split_vfo to use correct RX vfo instead of TX vfo https://github.com/Hamlib/Hamlib/issues/762 https://github.com/Hamlib/Hamlib/issues/430 --- src/rig.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/rig.c b/src/rig.c index 75885e8b6..dce1adc0c 100644 --- a/src/rig.c +++ b/src/rig.c @@ -4512,7 +4512,7 @@ int HAMLIB_API rig_get_split_freq_mode(RIG *rig, * \sa rig_get_split_vfo() */ int HAMLIB_API rig_set_split_vfo(RIG *rig, - vfo_t vfo, + vfo_t rx_vfo, split_t split, vfo_t tx_vfo) { @@ -4521,6 +4521,8 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, vfo_t curr_vfo; ENTERFUNC; + rig_debug(RIG_DEBUG_VERBOSE, "%s: rx_vfo=%s, split=%d, tx_vfo=%s\n", __func__, + rig_strvfo(rx_vfo), split, rig_strvfo(tx_vfo)); if (CHECK_RIG_ARG(rig)) { @@ -4534,31 +4536,26 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, RETURNFUNC(-RIG_ENAVAIL); } - vfo = vfo_fixup(rig, tx_vfo, split); - - if (vfo != RIG_VFO_A && vfo != RIG_VFO_B) - { - rig_debug(RIG_DEBUG_ERR, "%s: expected VFOA/B but got %s\n", __func__, - rig_strvfo(vfo)); - } + rx_vfo = vfo_fixup(rig, rx_vfo, split); + tx_vfo = vfo_fixup(rig, tx_vfo, split); // set rig to the the requested RX VFO TRACE; if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) #if BUILTINFUNC - rig_set_vfo(rig, vfo == RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A, + rig_set_vfo(rig, rx_vfo == RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A, __builtin_FUNCTION()); #else - rig_set_vfo(rig, vfo == RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A); + rig_set_vfo(rig, rx_vfo == RIG_VFO_B ? RIG_VFO_B : RIG_VFO_A); #endif - if (vfo == RIG_VFO_CURR - || vfo == rig->state.current_vfo) + if (rx_vfo == RIG_VFO_CURR + || rx_vfo == rig->state.current_vfo) { TRACE; - retcode = caps->set_split_vfo(rig, vfo, split, tx_vfo); + retcode = caps->set_split_vfo(rig, rx_vfo, split, tx_vfo); if (retcode == RIG_OK) { @@ -4581,7 +4578,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) { - retcode = caps->set_vfo(rig, vfo); + retcode = caps->set_vfo(rig, rx_vfo); if (retcode != RIG_OK) { @@ -4590,7 +4587,7 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, } TRACE; - retcode = caps->set_split_vfo(rig, vfo, split, tx_vfo); + retcode = caps->set_split_vfo(rig, rx_vfo, split, tx_vfo); /* try and revert even if we had an error above */ if (!(caps->targetable_vfo & RIG_TARGETABLE_FREQ)) From a0e692006f197ee3495d1c915e1b2844902ea8fe Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 28 Aug 2021 10:21:16 -0500 Subject: [PATCH 63/97] Remove override of PKTUSB mode for Icom rigs -- don't think we need this Was causing mode toggling on IC7300 during PTT transitions in JTDX --- rigs/icom/icom.c | 2 ++ rigs/icom/icom.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 7880b04f5..c4466300a 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -1809,6 +1809,7 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, switch (mode) { +#if 0 // don't think this is needed anymore -- W9MDB 20210828 case RIG_MODE_PKTUSB: // xFE xFE x6E xE0 x1A x06 x01 xFD switches mod input from MIC to ACC // This apparently works for IC-756ProIII but nobody has asked for it yet @@ -1826,6 +1827,7 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, case RIG_MODE_PKTAM: icom_mode = RIG_MODE_AM; break; +#endif default: icom_mode = mode; diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index b765dcaf4..d13f9d650 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "20210824" +#define BACKEND_VER "20210828" #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) From 21038df9f6c6eb1ca5a7c84731bd2347232ce8e1 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 28 Aug 2021 10:31:00 -0500 Subject: [PATCH 64/97] Fix testcache.c --- tests/testcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testcache.c b/tests/testcache.c index 9451aac2e..f0485c242 100644 --- a/tests/testcache.c +++ b/tests/testcache.c @@ -164,7 +164,7 @@ int main(int argc, char *argv[]) rig_get_split_vfo(my_rig, RIG_VFO_A, &split, &tx_vfo); printf("split=%d, tx_vfo=%s\n", split, rig_strvfo(tx_vfo)); - if (split != RIG_SPLIT_ON || tx_vfo != RIG_VFO_B) { printf("split#2 failed\n"); exit(1); } + if (split != RIG_SPLIT_ON || (tx_vfo != RIG_VFO_B && tx_vfo != RIG_VFO_SUB)) { printf("split#2 failed\n"); exit(1); } printf("All OK\n"); rig_close(my_rig); From 8092588d97ee165db9b6e9dc81cda6d5e4f8622f Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 28 Aug 2021 17:09:27 -0500 Subject: [PATCH 65/97] Remove unnecessary set_mode command from TARGETABLE_MODE Icom rigs https://github.com/Hamlib/Hamlib/issues/762 https://github.com/Hamlib/Hamlib/issues/430 --- rigs/icom/icom.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index c4466300a..6f3e187cd 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -1809,7 +1809,7 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, switch (mode) { -#if 0 // don't think this is needed anymore -- W9MDB 20210828 + case RIG_MODE_PKTUSB: // xFE xFE x6E xE0 x1A x06 x01 xFD switches mod input from MIC to ACC // This apparently works for IC-756ProIII but nobody has asked for it yet @@ -1827,7 +1827,6 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, case RIG_MODE_PKTAM: icom_mode = RIG_MODE_AM; break; -#endif default: icom_mode = mode; @@ -1837,7 +1836,16 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, rig_debug(RIG_DEBUG_VERBOSE, "%s mode=%d, width=%d, curr_vfo=%s\n", __func__, (int)icom_mode, (int)width, rig_strvfo(rig->state.current_vfo)); - retval = icom_set_mode(rig, vfo, icom_mode, width); + + // we only need to change base mode if we aren't using cmd 26 later + if (!(rig->caps->targetable_vfo & RIG_TARGETABLE_MODE)) + { + retval = icom_set_mode(rig, vfo, icom_mode, width); + } + else + { + retval = RIG_OK; + } hl_usleep(50 * 1000); // pause for possible transceive message which we'll flush From 7b6105720288b6495fcf99680845b135b0ff08ea Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 28 Aug 2021 22:35:16 -0500 Subject: [PATCH 66/97] For kenwood rigs reset split after set_vfo FR command if needed Side effect of this change is support of reverse split by changing to VFOB https://github.com/Hamlib/Hamlib/issues/746 --- rigs/kenwood/kenwood.c | 14 ++++++++++++++ rigs/kenwood/kenwood.h | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 589c2150b..0333b2c7a 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1118,6 +1118,20 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) snprintf(cmdbuf, sizeof(cmdbuf), "FR%c", vfo_function); + // as we change VFO we will change split to the other VFO + // some rigs turn split off with FR command + if (priv->split) + { + if (vfo_function == '0') + { + strcat(cmdbuf, ";FT1"); + } + else + { + strcat(cmdbuf, ";FT0"); + } + } + if (RIG_IS_TS50 || RIG_IS_TS940) { cmdbuf[1] = 'N'; diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index a5c0242a3..7c1190fc3 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -28,7 +28,7 @@ #include "token.h" #include "misc.h" -#define BACKEND_VER "20210827" +#define BACKEND_VER "20210828" #define EOM_KEN ';' #define EOM_TH '\r' From 76b3f6196cbc2de246a7897f00b581f4b8b760fd Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 28 Aug 2021 23:44:35 -0500 Subject: [PATCH 67/97] Fix display of arguments for rigctl non-readline version https://github.com/Hamlib/Hamlib/issues/773 --- tests/rigctl_parse.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 61bac1dd7..9c5106213 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -878,18 +878,18 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } } - //rig_debug(RIG_DEBUG_TRACE, "%s: debug1\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug1\n", __func__); if ((cmd_entry->flags & ARG_IN_LINE) && (cmd_entry->flags & ARG_IN1) && cmd_entry->arg1) { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug2\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug2\n", __func__); if (interactive) { char *nl; - //rig_debug(RIG_DEBUG_TRACE, "%s: debug2a\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug2a\n", __func__); if (fgets(arg1, MAXARGSZ, fin) == NULL) @@ -948,13 +948,13 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } else if ((cmd_entry->flags & ARG_IN1) && cmd_entry->arg1) { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug3\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug3\n", __func__); if (interactive) { arg1[0] = fgetc(fin); arg1[1] = 0; - //rig_debug(RIG_DEBUG_TRACE, "%s: debug4 arg1=%c\n", __func__, arg1[0]); + rig_debug(RIG_DEBUG_TRACE, "%s: debug4 arg1=%c\n", __func__, arg1[0]); if (prompt && arg1[0] == 0x0a) { @@ -988,22 +988,25 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } } - //rig_debug(RIG_DEBUG_TRACE, "%s: debug5\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug5\n", __func__); if (p1 && p1[0] != '?' && (cmd_entry->flags & ARG_IN2) && cmd_entry->arg2) { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug6\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug6\n", __func__); if (interactive) { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug7\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug7\n", __func__); - if (prompt) + arg1[0] = fgetc(fin); + arg1[1] = 0; + + if (prompt && arg1[0] == 0x0a) { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug8\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug8\n", __func__); fprintf_flush(fout, "%s: ", cmd_entry->arg2); } @@ -1017,7 +1020,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } else { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug9\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug9\n", __func__); retcode = next_word(arg2, argc, argv, 0); if (EOF == retcode) @@ -1035,22 +1038,22 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } } - //rig_debug(RIG_DEBUG_TRACE, "%s: debug10\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug10\n", __func__); if (p1 && p1[0] != '?' && (cmd_entry->flags & ARG_IN3) && cmd_entry->arg3) { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug11\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug11\n", __func__); if (interactive) { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug12\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug12\n", __func__); if (prompt) { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug13\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug13\n", __func__); fprintf_flush(fout, "%s: ", cmd_entry->arg3); } @@ -1064,7 +1067,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } else { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug14\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: debug14\n", __func__); retcode = next_word(arg3, argc, argv, 0); if (EOF == retcode) From 95a737ea56fd5da65af86b261d0fed6253b99952 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 29 Aug 2021 00:03:27 -0500 Subject: [PATCH 68/97] Put rigctl flow debug in if statement https://github.com/Hamlib/Hamlib/issues/773 --- tests/rigctl_parse.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 9c5106213..af2fb2556 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -36,6 +36,9 @@ #include #include +// If true adds some debug statements to see flow of rigctl parsing +int debugflow = 0; + #ifdef HAVE_LIBREADLINE # if defined(HAVE_READLINE_READLINE_H) # include @@ -878,18 +881,19 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } } - rig_debug(RIG_DEBUG_TRACE, "%s: debug1\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug1\n", __func__); } if ((cmd_entry->flags & ARG_IN_LINE) && (cmd_entry->flags & ARG_IN1) && cmd_entry->arg1) { - rig_debug(RIG_DEBUG_TRACE, "%s: debug2\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug2\n", __func__); } if (interactive) { char *nl; - rig_debug(RIG_DEBUG_TRACE, "%s: debug2a\n", __func__); + + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug2a\n", __func__); } if (fgets(arg1, MAXARGSZ, fin) == NULL) @@ -899,7 +903,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, if (arg1[0] == 0xa) { - //rig_debug(RIG_DEBUG_TRACE, "%s: debug2b\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug2b\n", __func__); } if (prompt) { @@ -948,13 +952,14 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } else if ((cmd_entry->flags & ARG_IN1) && cmd_entry->arg1) { - rig_debug(RIG_DEBUG_TRACE, "%s: debug3\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug3\n", __func__); } if (interactive) { arg1[0] = fgetc(fin); arg1[1] = 0; - rig_debug(RIG_DEBUG_TRACE, "%s: debug4 arg1=%c\n", __func__, arg1[0]); + + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug4 arg1=%c\n", __func__, arg1[0]); } if (prompt && arg1[0] == 0x0a) { @@ -988,25 +993,26 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } } - rig_debug(RIG_DEBUG_TRACE, "%s: debug5\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug5\n", __func__); } if (p1 && p1[0] != '?' && (cmd_entry->flags & ARG_IN2) && cmd_entry->arg2) { - rig_debug(RIG_DEBUG_TRACE, "%s: debug6\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug6\n", __func__); } if (interactive) { - rig_debug(RIG_DEBUG_TRACE, "%s: debug7\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug7\n", __func__); } arg1[0] = fgetc(fin); arg1[1] = 0; if (prompt && arg1[0] == 0x0a) { - rig_debug(RIG_DEBUG_TRACE, "%s: debug8\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug8\n", __func__); } + fprintf_flush(fout, "%s: ", cmd_entry->arg2); } @@ -1020,7 +1026,8 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } else { - rig_debug(RIG_DEBUG_TRACE, "%s: debug9\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug9\n", __func__); } + retcode = next_word(arg2, argc, argv, 0); if (EOF == retcode) @@ -1038,22 +1045,23 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } } - rig_debug(RIG_DEBUG_TRACE, "%s: debug10\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug10\n", __func__); } if (p1 && p1[0] != '?' && (cmd_entry->flags & ARG_IN3) && cmd_entry->arg3) { - rig_debug(RIG_DEBUG_TRACE, "%s: debug11\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug11\n", __func__); } if (interactive) { - rig_debug(RIG_DEBUG_TRACE, "%s: debug12\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug12\n", __func__); } if (prompt) { - rig_debug(RIG_DEBUG_TRACE, "%s: debug13\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug13\n", __func__); } + fprintf_flush(fout, "%s: ", cmd_entry->arg3); } @@ -1067,7 +1075,8 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, } else { - rig_debug(RIG_DEBUG_TRACE, "%s: debug14\n", __func__); + if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug14\n", __func__); } + retcode = next_word(arg3, argc, argv, 0); if (EOF == retcode) From 970dff70a3538fbf25500e3e4be4a3784a60bb01 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 29 Aug 2021 08:29:26 -0500 Subject: [PATCH 69/97] Make kenwood set_split_vfo behave the same as set_vfo in both directions https://github.com/Hamlib/Hamlib/issues/746 --- rigs/kenwood/kenwood.c | 14 +++++++++++++- rigs/kenwood/kenwood.h | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 0333b2c7a..a03a8ea61 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -1119,7 +1119,7 @@ int kenwood_set_vfo(RIG *rig, vfo_t vfo) snprintf(cmdbuf, sizeof(cmdbuf), "FR%c", vfo_function); // as we change VFO we will change split to the other VFO - // some rigs turn split off with FR command + // some rigs turn split off with FR command if (priv->split) { if (vfo_function == '0') @@ -1273,6 +1273,18 @@ int kenwood_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo) // So we'll turn it back on just in case if (split && vfo_function == '0') { strcat(cmdbuf, ";FT1"); } + 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) diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index 7c1190fc3..e0973afc3 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -28,7 +28,7 @@ #include "token.h" #include "misc.h" -#define BACKEND_VER "20210828" +#define BACKEND_VER "20210829" #define EOM_KEN ';' #define EOM_TH '\r' From 39d3c2f6818c6e2c208b55b3b1afe13623899f6d Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 29 Aug 2021 09:59:47 -0500 Subject: [PATCH 70/97] Fix rigctl/rigctld interaction regression from issue 773 https://github.com/Hamlib/Hamlib/issues/778 https://github.com/Hamlib/Hamlib/issues/773 --- tests/rigctl_parse.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index af2fb2556..4d350be3a 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -1006,10 +1006,10 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, { if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug7\n", __func__); } - arg1[0] = fgetc(fin); - arg1[1] = 0; + arg2[0] = fgetc(fin); + arg2[1] = 0; - if (prompt && arg1[0] == 0x0a) + if (prompt && arg2[0] == 0x0a) { if (debugflow) { rig_debug(RIG_DEBUG_TRACE, "%s: debug8\n", __func__); } From e16a77aaa66a71ee948788278bbfbb08e040eb18 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 29 Aug 2021 23:32:29 -0500 Subject: [PATCH 71/97] Fix Startup information in rigctl and rigctld --- tests/rigctl.c | 7 ++++--- tests/rigctld.c | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/rigctl.c b/tests/rigctl.c index 6e027faf8..58a2b6b03 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -154,6 +154,7 @@ int main(int argc, char *argv[]) int ext_resp = 0; char resp_sep = '\n'; int i; + char rigstartup[1024]; while (1) { @@ -440,11 +441,11 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) Startup:", __FILE__, __LINE__); + snprintf(rigstartup, sizeof(rigstartup), "%s(%d) Startup:", __FILE__, __LINE__); - for (i = 0; i < argc; ++i) { rig_debug(RIG_DEBUG_VERBOSE, " %s", argv[i]); } + for (i = 0; i < argc; ++i) { strcat(rigstartup, " "); strcat(rigstartup, argv[i]); } - rig_debug(RIG_DEBUG_VERBOSE, "%s", "\n"); + rig_debug(RIG_DEBUG_VERBOSE, "%s\n", rigstartup); rig_debug(RIG_DEBUG_VERBOSE, "rigctl %s\n", hamlib_version2); diff --git a/tests/rigctld.c b/tests/rigctld.c index 508ae8cdf..854227e03 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -257,6 +257,7 @@ int main(int argc, char *argv[]) int uplink = 0; char host[NI_MAXHOST]; char serv[NI_MAXSERV]; + char rigstartup[1024]; #if HAVE_SIGACTION struct sigaction act; #endif @@ -577,12 +578,11 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); - rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) Startup:", __FILE__, __LINE__); + snprintf(rigstartup, sizeof(rigstartup), "%s(%d) Startup:", __FILE__, __LINE__); - for (i = 0; i < argc; ++i) { rig_debug(RIG_DEBUG_VERBOSE, " %s", argv[i]); } - - rig_debug(RIG_DEBUG_VERBOSE, "%s", "\n"); + for (i = 0; i < argc; ++i) { strcat(rigstartup, " "); strcat(rigstartup, argv[i]); } + rig_debug(RIG_DEBUG_VERBOSE, "%s\n", rigstartup); rig_debug(RIG_DEBUG_VERBOSE, "rigctld %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", From ecf53e22efca028da46a9963365fdf5e53e5127f Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 30 Aug 2021 08:45:56 -0500 Subject: [PATCH 72/97] If set_split_freq_mode is called when split=off we'll turn on split based on current vfo selection https://github.com/Hamlib/Hamlib/issues/764 --- src/rig.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rig.c b/src/rig.c index dce1adc0c..dba18783b 100644 --- a/src/rig.c +++ b/src/rig.c @@ -4369,6 +4369,19 @@ int HAMLIB_API rig_set_split_freq_mode(RIG *rig, caps = rig->caps; + // if split is off we'll turn it on + if (rig->state.cache.split == 0) + { + if (rig->state.current_vfo & (RIG_VFO_A | RIG_VFO_MAIN)) + { + rig_set_split_vfo(rig, RIG_VFO_A, 1, RIG_VFO_B); + } + else + { + rig_set_split_vfo(rig, RIG_VFO_B, 1, RIG_VFO_A); + } + } + vfo = vfo_fixup(rig, RIG_VFO_TX, rig->state.cache.split); // get the TX VFO rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s, tx_freq=%.0f, tx_mode=%s, tx_width=%d\n", __func__, From 20221524f89a30a0faff30572fd8af5284b795c1 Mon Sep 17 00:00:00 2001 From: Chuck Ritola Date: Mon, 30 Aug 2021 00:18:42 -0400 Subject: [PATCH 73/97] Map FCDPP LNA and Mixer Gain as PREAMP values. Closes #766 --- rigs/kit/funcube.c | 215 +++++++++++++++++++++++++-------------------- 1 file changed, 118 insertions(+), 97 deletions(-) diff --git a/rigs/kit/funcube.c b/rigs/kit/funcube.c index 1402471fc..b79b5f724 100644 --- a/rigs/kit/funcube.c +++ b/rigs/kit/funcube.c @@ -36,10 +36,11 @@ #include #include "hamlib/rig.h" #include "token.h" +#include "misc.h" #include "kit.h" -#define BACKEND_VER "20200112" +#define BACKEND_VER "20210830" /* * Compile this model only if libusb is available @@ -56,6 +57,8 @@ #include "funcube.h" +static int funcube_hid_cmd(RIG *rig, unsigned char *au8BufOut, unsigned char *au8BufIn, int inputSize); + static int funcube_init(RIG *rig); static int funcubeplus_init(RIG *rig); static int funcube_cleanup(RIG *rig); @@ -180,23 +183,17 @@ const struct rig_caps funcubeplus_caps = .has_get_func = RIG_FUNC_NONE, .has_set_func = RIG_FUNC_NONE, - .has_get_level = RIG_LEVEL_ATT | RIG_LEVEL_PREAMP | RIG_LEVEL_RF, // RIG_LEVEL_ATT: Mixer gain on/off - // RIG_LEVEL_PREAMP: LNA gain on/off + .has_get_level = RIG_LEVEL_PREAMP | RIG_LEVEL_RF, + // RIG_LEVEL_PREAMP: 10dB=LNAon MixGainOff. 20dB=LNAoff, MixGainOn. 30dB=LNAOn, MixGainOn // RIG_LEVEL_RF 0..1 : IF gain 0 .. 59 dB - - - .has_set_level = RIG_LEVEL_ATT | RIG_LEVEL_PREAMP | RIG_LEVEL_RF, // RIG_LEVEL_ATT: Mixer gain on/off - // RIG_LEVEL_PREAMP: LNA gain on/off - // RIG_LEVEL_RF 0..1 : IF gain 0 .. 59 dB - // so values have to be mapped + .has_set_level = RIG_LEVEL_PREAMP | RIG_LEVEL_RF, .has_get_parm = RIG_PARM_NONE, .has_set_parm = RIG_PARM_NONE, .level_gran = {}, .parm_gran = {}, .ctcss_list = NULL, .dcs_list = NULL, - //.preamp = { 5, 10, 15, 20, 25, 30, RIG_DBLST_END, }, - //.attenuator = { 0, 1, 2, RIG_DBLST_END, }, + .preamp = { 10, 20, 30, RIG_DBLST_END, }, .max_rit = Hz(0), .max_xit = Hz(0), .max_ifshift = Hz(0), @@ -638,6 +635,7 @@ int funcube_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) return RIG_OK; } + int funcube_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { libusb_device_handle *udh = rig->state.rigport.handle; @@ -761,44 +759,12 @@ int funcube_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return RIG_OK; } -int funcubepro_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) + +int funcube_hid_cmd(RIG *rig, unsigned char *au8BufOut, unsigned char *au8BufIn, int inputSize) { libusb_device_handle *udh = rig->state.rigport.handle; int ret; int actual_length; - unsigned char au8BufOut[64] = { 0 }; // endpoint size - unsigned char au8BufIn[64] = { 0 }; // endpoint size - - switch (level) - { - case RIG_LEVEL_PREAMP: - au8BufOut[0] = REQUEST_SET_LNA_GAIN; // Command to set LNA gain - au8BufOut[1] = val.i & 0x1; - break; - - case RIG_LEVEL_ATT: - au8BufOut[0] = REQUEST_SET_MIXER_GAIN; // Command to Mixer gain - au8BufOut[1] = val.i & 0x1; - break; - - case RIG_LEVEL_RF: - au8BufOut[0] = REQUEST_SET_IF_GAIN; // Command to set IF gain - au8BufOut[1] = (int)(val.f * 100) ; - - if (au8BufOut[1] > 59) - { - au8BufOut[1] = 59; - } - - break; - - - default: - rig_debug(RIG_DEBUG_ERR, "%s: unsupported level %s\n", __func__, - rig_strlevel(level)); - return -RIG_EINVAL; - } - rig_debug(RIG_DEBUG_TRACE, "%s: HID packet set to %02x%02x%02x%02x\n", __func__, au8BufOut[0] & 0xFF, au8BufOut[1] & 0xFF, au8BufOut[2] & 0xFF, au8BufOut[3] & 0xFF); @@ -813,10 +779,10 @@ int funcubepro_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) libusb_error_name(ret)); } - ret = libusb_interrupt_transfer(udh, INPUT_ENDPOINT, au8BufIn, sizeof(au8BufIn), + ret = libusb_interrupt_transfer(udh, INPUT_ENDPOINT, au8BufIn, inputSize, &actual_length, rig->state.rigport.timeout); - if (ret < 0 || actual_length != sizeof(au8BufIn)) + if (ret < 0 || actual_length != inputSize) { rig_debug(RIG_DEBUG_ERR, "%s: libusb_interrupt_transfer failed (%d): %s\n", __func__, ret, @@ -828,85 +794,140 @@ int funcubepro_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) if (au8BufIn[1] != FUNCUBE_SUCCESS) { - rig_debug(RIG_DEBUG_ERR, "%s: REQUEST_GET_FREQ_HZ not supported\n", - __func__); + rig_debug(RIG_DEBUG_ERR, "%s: failed to perform FUNCube HID command %d.\n", + __func__, au8BufOut[0]); return -RIG_EIO; } return RIG_OK; } -int funcubepro_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) + +int funcubepro_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { - libusb_device_handle *udh = rig->state.rigport.handle; + ENTERFUNC; int ret; - int actual_length; unsigned char au8BufOut[64] = { 0 }; // endpoint size unsigned char au8BufIn[64] = { 0 }; // endpoint size switch (level) { - case RIG_LEVEL_ATT: - au8BufOut[0] = REQUEST_GET_MIXER_GAIN; // Command to Mixer gain enabled - break; - case RIG_LEVEL_PREAMP: - au8BufOut[0] = REQUEST_GET_LNA_GAIN; // Command to get LNA gain enabled - break; + rig_debug(RIG_DEBUG_TRACE, "%s: Setting PREAMP state to %d.\n", + __func__, val.i); + au8BufOut[0] = REQUEST_SET_LNA_GAIN; // Command to set LNA gain + + if( val.i == 10 || val.i == 30 ) + { + au8BufOut[1] = 1; + } + else + { + au8BufOut[1] = 0; + } + + ret = funcube_hid_cmd(rig, au8BufOut, au8BufIn, sizeof(au8BufIn)); + + if( ret < 0 ) + { + return ret; + } + + au8BufOut[0] = REQUEST_SET_MIXER_GAIN; // Set mixer gain + + if( val.i == 20 || val.i == 30 ) + { + au8BufOut[1] = 1; + } + else + { + au8BufOut[1] = 0; + } + + return funcube_hid_cmd(rig, au8BufOut, au8BufIn, sizeof(au8BufIn)); case RIG_LEVEL_RF: - au8BufOut[0] = REQUEST_GET_IF_GAIN; - break; + au8BufOut[0] = REQUEST_SET_IF_GAIN; // Command to set IF gain + au8BufOut[1] = (int)(val.f * 100) ; + + if (au8BufOut[1] > 59) + { + au8BufOut[1] = 59; + } + + return funcube_hid_cmd(rig, au8BufOut, au8BufIn, sizeof(au8BufIn)); default: rig_debug(RIG_DEBUG_ERR, "%s: unsupported level %s\n", __func__, rig_strlevel(level)); return -RIG_EINVAL; } +} - rig_debug(RIG_DEBUG_TRACE, "%s: HID packet set to %02x%02x%02x%02x\n", - __func__, au8BufOut[0] & 0xFF, au8BufOut[1] & 0xFF, au8BufOut[2] & 0xFF, - au8BufOut[3] & 0xFF); - - ret = libusb_interrupt_transfer(udh, OUTPUT_ENDPOINT, au8BufOut, - sizeof(au8BufOut), &actual_length, rig->state.rigport.timeout); - - if (ret < 0) - { - rig_debug(RIG_DEBUG_ERR, "%s: libusb_interrupt_transfer failed (%d): %s\n", - __func__, ret, - libusb_error_name(ret)); - } - - ret = libusb_interrupt_transfer(udh, INPUT_ENDPOINT, au8BufIn, sizeof(au8BufIn), - &actual_length, rig->state.rigport.timeout); - - if (ret < 0 || actual_length != sizeof(au8BufIn)) - { - rig_debug(RIG_DEBUG_ERR, "%s: libusb_interrupt_transfer failed (%d): %s\n", - __func__, ret, - libusb_error_name(ret)); - } - - rig_debug(RIG_DEBUG_TRACE, "%s: Answer buf=%02x%02x%02x\n", - __func__, au8BufIn[0] & 0xFF, au8BufIn[1] & 0xFF, au8BufIn[2] & 0xFF); - - if (au8BufIn[1] != FUNCUBE_SUCCESS) - { - rig_debug(RIG_DEBUG_ERR, "%s: REQUEST_LEVEL_x failed\n", - __func__); - return -RIG_EIO; - } +int funcubepro_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) +{ + ENTERFUNC; + int ret; + int gain_state; + unsigned char au8BufOut[64] = { 0 }; // endpoint size + unsigned char au8BufIn[64] = { 0 }; // endpoint size switch (level) { + case RIG_LEVEL_PREAMP: - case RIG_LEVEL_ATT: - val->i = au8BufIn[2] & 0x01; - break; + au8BufOut[0] = REQUEST_GET_MIXER_GAIN; // Command to get mixer gain enabled + ret = funcube_hid_cmd(rig, au8BufOut, au8BufIn, sizeof(au8BufIn)); + + if( ret < 0 ) + { + return ret; + } + + rig_debug(RIG_DEBUG_TRACE, "%s: Mixer gain state returned %d.\n", + __func__, au8BufIn[2] & 0xFF); + + gain_state = au8BufIn[2] & 0x1; + + au8BufOut[0] = REQUEST_GET_LNA_GAIN; // Command to get LNA gain enabled + + ret = funcube_hid_cmd(rig, au8BufOut, au8BufIn, sizeof(au8BufIn)); + + if( ret < 0 ) + { + return ret; + } + + rig_debug(RIG_DEBUG_TRACE, "%s: LNA gain state returned %d.\n", + __func__, au8BufIn[2] & 0xFF); + + //Mixer gain is 20dB 0x2 + gain_state *= 2; + + //Add the LNA gain if present (10dB) 0x1 + gain_state += ( au8BufIn[2] & 0x1 ); + + //Scale it to tens 1->10dB 2->20dB 3->30dB + gain_state *= 10; + + rig_debug(RIG_DEBUG_TRACE, "%s: Calculated gain state is %d.\n", + __func__, gain_state); + + if( gain_state > 30 || gain_state < 0 || gain_state % 10 != 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: unrecognized composite gain: %d\n", __func__, + gain_state); + return -RIG_EINVAL; + } + + val->i = gain_state; + + return RIG_OK; case RIG_LEVEL_RF: + au8BufOut[0] = REQUEST_GET_IF_GAIN; + ret = funcube_hid_cmd(rig, au8BufOut, au8BufIn, sizeof(au8BufIn)); val->f = ((float)au8BufIn[2]) / 100.; - break; + return ret; default: rig_debug(RIG_DEBUG_ERR, "%s: unsupported level %s\n", __func__, From d48f1aed426b8c2b7215eef23a1b6cc685988038 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 30 Aug 2021 10:01:36 -0500 Subject: [PATCH 74/97] Improve ser_open error message --- src/iofunc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/iofunc.c b/src/iofunc.c index 6c4cc43a9..9f2109248 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -76,8 +76,8 @@ int HAMLIB_API port_open(hamlib_port_t *p) if (status < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: serial_open(%s) status=%d\n", __func__, - p->pathname, status); + rig_debug(RIG_DEBUG_ERR, "%s: serial_open(%s) status=%d, err=%s\n", __func__, + p->pathname, status, strerror(errno)); RETURNFUNC(status); } From 32de5c34854b0d382159a09ff54ffa406be9e9af Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 30 Aug 2021 10:04:50 -0500 Subject: [PATCH 75/97] astyle files --- rigs/kit/funcube.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/rigs/kit/funcube.c b/rigs/kit/funcube.c index b79b5f724..4038356ae 100644 --- a/rigs/kit/funcube.c +++ b/rigs/kit/funcube.c @@ -57,7 +57,8 @@ #include "funcube.h" -static int funcube_hid_cmd(RIG *rig, unsigned char *au8BufOut, unsigned char *au8BufIn, int inputSize); +static int funcube_hid_cmd(RIG *rig, unsigned char *au8BufOut, + unsigned char *au8BufIn, int inputSize); static int funcube_init(RIG *rig); static int funcubeplus_init(RIG *rig); @@ -760,7 +761,8 @@ int funcube_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return RIG_OK; } -int funcube_hid_cmd(RIG *rig, unsigned char *au8BufOut, unsigned char *au8BufIn, int inputSize) +int funcube_hid_cmd(RIG *rig, unsigned char *au8BufOut, unsigned char *au8BufIn, + int inputSize) { libusb_device_handle *udh = rig->state.rigport.handle; int ret; @@ -813,10 +815,10 @@ int funcubepro_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { case RIG_LEVEL_PREAMP: rig_debug(RIG_DEBUG_TRACE, "%s: Setting PREAMP state to %d.\n", - __func__, val.i); + __func__, val.i); au8BufOut[0] = REQUEST_SET_LNA_GAIN; // Command to set LNA gain - if( val.i == 10 || val.i == 30 ) + if (val.i == 10 || val.i == 30) { au8BufOut[1] = 1; } @@ -824,17 +826,17 @@ int funcubepro_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { au8BufOut[1] = 0; } - + ret = funcube_hid_cmd(rig, au8BufOut, au8BufIn, sizeof(au8BufIn)); - - if( ret < 0 ) + + if (ret < 0) { return ret; } au8BufOut[0] = REQUEST_SET_MIXER_GAIN; // Set mixer gain - if( val.i == 20 || val.i == 30 ) + if (val.i == 20 || val.i == 30) { au8BufOut[1] = 1; } @@ -878,13 +880,13 @@ int funcubepro_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) au8BufOut[0] = REQUEST_GET_MIXER_GAIN; // Command to get mixer gain enabled ret = funcube_hid_cmd(rig, au8BufOut, au8BufIn, sizeof(au8BufIn)); - if( ret < 0 ) + if (ret < 0) { return ret; } rig_debug(RIG_DEBUG_TRACE, "%s: Mixer gain state returned %d.\n", - __func__, au8BufIn[2] & 0xFF); + __func__, au8BufIn[2] & 0xFF); gain_state = au8BufIn[2] & 0x1; @@ -892,30 +894,30 @@ int funcubepro_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) ret = funcube_hid_cmd(rig, au8BufOut, au8BufIn, sizeof(au8BufIn)); - if( ret < 0 ) + if (ret < 0) { return ret; } rig_debug(RIG_DEBUG_TRACE, "%s: LNA gain state returned %d.\n", - __func__, au8BufIn[2] & 0xFF); + __func__, au8BufIn[2] & 0xFF); //Mixer gain is 20dB 0x2 gain_state *= 2; //Add the LNA gain if present (10dB) 0x1 - gain_state += ( au8BufIn[2] & 0x1 ); + gain_state += (au8BufIn[2] & 0x1); //Scale it to tens 1->10dB 2->20dB 3->30dB gain_state *= 10; rig_debug(RIG_DEBUG_TRACE, "%s: Calculated gain state is %d.\n", - __func__, gain_state); + __func__, gain_state); - if( gain_state > 30 || gain_state < 0 || gain_state % 10 != 0) + if (gain_state > 30 || gain_state < 0 || gain_state % 10 != 0) { rig_debug(RIG_DEBUG_ERR, "%s: unrecognized composite gain: %d\n", __func__, - gain_state); + gain_state); return -RIG_EINVAL; } From 44157ad114db04767f2cf0756d3568f04660a3d8 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 30 Aug 2021 10:41:05 -0500 Subject: [PATCH 76/97] Update tests/Makefile.am to not remove build scripts --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 3fac3cf77..654478e16 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -127,4 +127,4 @@ testcookie.sh: echo './testcookie 1' > testcookie.sh chmod +x ./testcookie.sh -CLEANFILES = testrig.sh testfreq.sh testbcd.sh testloc.sh testrigcaps.sh testcache.sh testcookie.sh testlibusb +CLEANFILES = testrig.sh testfreq.sh testbcd.sh testloc.sh testrigcaps.sh testcache.sh testcookie.sh testlibusb build-w32.sh build-w64.sh build-w64-jtsdk.sh From 4c62b3d2bee00b8c5248269441a1eaa753fd371c Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 30 Aug 2021 15:19:16 -0500 Subject: [PATCH 77/97] Update rotctl.1 man page --- doc/man1/rotctl.1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/man1/rotctl.1 b/doc/man1/rotctl.1 index e783e5e5f..a85d8e1a1 100644 --- a/doc/man1/rotctl.1 +++ b/doc/man1/rotctl.1 @@ -19,6 +19,7 @@ rotctl \- control antenna rotators .OP \-hiIlLuV .OP \-m id .OP \-r device +.OP \-R device2 .OP \-s baud .OP \-t char .OP \-C parm=val @@ -87,6 +88,20 @@ etc. on MS Windows. The BSD flavors and Mac OS/X have their own designations. See your system's documentation. . .TP +.BR \-R ", " \-\-rot\-file2 = \fIdevice\fP +Use +.I device +as the file name of the port connected to the 2nd rotator. +e.g. 2nd rotator used for elevation. +.IP +Often a serial port, but could be a USB to serial adapter. Typically +.IR /dev/ttyS0 ", " /dev/ttyS1 ", " /dev/ttyUSB0 , +etc. on Linux, +.IR COM1 ", " COM2 , +etc. on MS Windows. The BSD flavors and Mac OS/X have their own designations. +See your system's documentation. +. +.TP .BR \-s ", " \-\-serial\-speed = \fIbaud\fP Set serial speed to .I baud From 9dce7680d086b8f1e2771c888b7283c0f84d9b54 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 30 Aug 2021 17:38:00 -0500 Subject: [PATCH 78/97] Update NEWS for 4.3 release --- NEWS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 1cc539b33..84526076f 100644 --- a/NEWS +++ b/NEWS @@ -7,10 +7,13 @@ Copyright (C) 2000-2021 Michael Black W9MDB, and others Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net Version 4.3 - * 2021-??-?? + * 2021-08-31 * libusb-1.0.23 or greater is now required or use --without-libusb * Generating documentation now requires GNU source-highlighter. * Added IC-575 + * Less VFO swapping of newer Icom rigs -- zero swapping in WSJTX and JTDX + * Dual rotator control in rotctl -R option + * Started work on simulators -- very crude right now but usable to debug some things * Overhaul of rig split -- reverse split (VFOA=RX VFOB=TX) should work for rigs capable of it Starting VFO does not matter -- rig will end up on RX VFO S VFOA 1 VFOB From 3cdf09388fca2cc06ac575a0f457de3c129e2461 Mon Sep 17 00:00:00 2001 From: Nate Bargmann Date: Tue, 31 Aug 2021 21:00:22 -0500 Subject: [PATCH 79/97] Change release date to 2021-09-01 --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 84526076f..d7761cb66 100644 --- a/NEWS +++ b/NEWS @@ -7,7 +7,7 @@ Copyright (C) 2000-2021 Michael Black W9MDB, and others Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net Version 4.3 - * 2021-08-31 + * 2021-09-01 * libusb-1.0.23 or greater is now required or use --without-libusb * Generating documentation now requires GNU source-highlighter. * Added IC-575 From f196d14b8449db864f88e81159a41c9f8f93ba8c Mon Sep 17 00:00:00 2001 From: Nate Bargmann Date: Tue, 31 Aug 2021 21:09:30 -0500 Subject: [PATCH 80/97] Advance to version 4.4~git --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 2ff5cbdb8..6aa937e17 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.3~git],[hamlib-developer@lists.sourceforge.net],[hamlib],[http://www.hamlib.org]) +AC_INIT([Hamlib],[4.4~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=3 +ABI_REVISION=4 ABI_AGE=0 AC_DEFINE_UNQUOTED([ABI_VERSION], [$ABI_VERSION], [Frontend ABI version]) From 5a8922b5b54d17502afb3185fdcdf22b7d94390e Mon Sep 17 00:00:00 2001 From: Nate Bargmann Date: Tue, 31 Aug 2021 21:09:55 -0500 Subject: [PATCH 81/97] Update for 4.4 release --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index d7761cb66..d2e2d8cc8 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ Copyright (C) 2000-2021 Michael Black W9MDB, and others Please send Hamlib bug reports to hamlib-developer@lists.sourceforge.net +Version 4.4 + * 2021-??-?? + Version 4.3 * 2021-09-01 * libusb-1.0.23 or greater is now required or use --without-libusb From 287e79d31895b18a7457397be841971a58537def Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Mon, 30 Aug 2021 21:48:59 +0200 Subject: [PATCH 82/97] Stop copying table to private data, use table direct. The table is never written so there is no point makeing the copy; it only adds confusion for a programmer. --- rigs/yaesu/ft1000d.c | 23 ++++++++--------------- rigs/yaesu/ft1000mp.c | 12 ++---------- rigs/yaesu/ft840.c | 26 +++++++++----------------- rigs/yaesu/ft857.c | 25 ++++++------------------- rigs/yaesu/ft890.c | 26 +++++++++----------------- rigs/yaesu/ft897.c | 25 ++++++------------------- rigs/yaesu/ft900.c | 26 +++++++++----------------- rigs/yaesu/ft920.c | 27 +++++++++------------------ rigs/yaesu/ft990.c | 24 +++++++++--------------- rigs/yaesu/vx1700.c | 4 ++-- 10 files changed, 69 insertions(+), 149 deletions(-) diff --git a/rigs/yaesu/ft1000d.c b/rigs/yaesu/ft1000d.c index 8d801cd96..9329273ad 100644 --- a/rigs/yaesu/ft1000d.c +++ b/rigs/yaesu/ft1000d.c @@ -135,7 +135,6 @@ struct ft1000d_priv_data vfo_t split_vfo; /* TX VFO in split mode Added on 16 Dec 2016 to include FT1000D function */ split_t split; /* split active or not Added on 16 Dec 2016 to include FT1000D function */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of CAT cmd */ - yaesu_cmd_set_t pcs[FT1000D_NATIVE_SIZE]; /* private cmd set */ ft1000d_update_data_t update_data; /* returned data */ }; @@ -325,9 +324,6 @@ int ft1000d_init(RIG *rig) priv = rig->state.priv; -// Copy native cmd set to private cmd storage area - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - // Set default pacing value priv->pacing = FT1000D_PACING_DEFAULT_VALUE; @@ -3297,7 +3293,7 @@ int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * * Returns: RIG_OK if all called functions are successful, * otherwise returns error from called functiion @@ -3305,7 +3301,6 @@ int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) { struct rig_state *rig_s; - struct ft1000d_priv_data *priv; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3316,17 +3311,16 @@ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - priv = (struct ft1000d_priv_data *)rig->state.priv; rig_s = &rig->state; - if (!priv->pcs[ci].ncomp) + if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to send incomplete sequence\n", __func__); return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) priv->pcs[ci].nseq, + err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3345,7 +3339,7 @@ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * p1-p4 Command parameters * * Returns: RIG_OK if all called functions are successful, @@ -3374,7 +3368,7 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, priv = (struct ft1000d_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -3408,7 +3402,6 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct * freq freq_t frequency value * * Returns: RIG_OK if all called functions are successful, @@ -3434,7 +3427,7 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) priv = (struct ft1000d_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -3469,7 +3462,7 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) * change the rit frequency. * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * rit shortfreq_t frequency value * * Returns: RIG_OK if all called functions are successful, @@ -3494,7 +3487,7 @@ int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv = (struct ft1000d_priv_data *) rig->state.priv; rig_s = &rig->state; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); diff --git a/rigs/yaesu/ft1000mp.c b/rigs/yaesu/ft1000mp.c index 260150a11..61f28ae75 100644 --- a/rigs/yaesu/ft1000mp.c +++ b/rigs/yaesu/ft1000mp.c @@ -206,7 +206,6 @@ struct ft1000mp_priv_data unsigned int read_update_delay; /* depends on pacing value */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ - yaesu_cmd_set_t pcs[FT1000MP_NATIVE_SIZE]; /* private cmd set */ unsigned char update_data[2 * FT1000MP_STATUS_UPDATE_LENGTH]; /* returned data--max value, some are less */ }; @@ -642,11 +641,6 @@ int ft1000mp_init(RIG *rig) priv = rig->state.priv; - /* - * Copy native cmd set to private cmd storage area - */ - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - /* TODO: read pacing from preferences */ priv->pacing = FT1000MP_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ @@ -1601,25 +1595,23 @@ static int ft1000mp_get_update_data(RIG *rig, unsigned char ci, static int ft1000mp_send_priv_cmd(RIG *rig, unsigned char ci) { struct rig_state *rig_s; - struct ft1000mp_priv_data *p; unsigned char *cmd; /* points to sequence to send */ unsigned char cmd_index; /* index of sequence to send */ ENTERFUNC; - p = (struct ft1000mp_priv_data *)rig->state.priv; rig_s = &rig->state; cmd_index = ci; /* get command */ - if (! p->pcs[cmd_index].ncomp) + if (! ncmd[cmd_index].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: attempt to send incomplete sequence\n", __func__); RETURNFUNC(-RIG_EINVAL); } - cmd = (unsigned char *) p->pcs[cmd_index].nseq; /* get native sequence */ + cmd = (unsigned char *) ncmd[cmd_index].nseq; /* get native sequence */ rig_flush(&rig_s->rigport); write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); diff --git a/rigs/yaesu/ft840.c b/rigs/yaesu/ft840.c index c4cb1b1b2..c381217dd 100644 --- a/rigs/yaesu/ft840.c +++ b/rigs/yaesu/ft840.c @@ -201,7 +201,6 @@ struct ft840_priv_data vfo_t current_vfo; /* active VFO from last cmd */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ - yaesu_cmd_set_t pcs[FT840_NATIVE_SIZE]; /* private cmd set */ unsigned char update_data[FT840_ALL_DATA_LENGTH]; /* returned data--max value, some are less */ unsigned char current_mem; /* private memory channel number */ @@ -366,11 +365,6 @@ static int ft840_init(RIG *rig) priv = rig->state.priv; - /* - * Copy native cmd set to private cmd storage area - */ - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - /* TODO: read pacing from preferences */ priv->pacing = FT840_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ priv->read_update_delay = @@ -1743,7 +1737,7 @@ static int ft840_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * * Returns: RIG_OK if all called functions are successful, * otherwise returns error from called functiion @@ -1752,7 +1746,6 @@ static int ft840_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft840_send_static_cmd(RIG *rig, unsigned char ci) { struct rig_state *rig_s; - struct ft840_priv_data *priv; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1762,17 +1755,16 @@ static int ft840_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - priv = (struct ft840_priv_data *)rig->state.priv; rig_s = &rig->state; - if (!priv->pcs[ci].ncomp) + if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to send incomplete sequence\n", __func__); return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) priv->pcs[ci].nseq, + err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1791,7 +1783,7 @@ static int ft840_send_static_cmd(RIG *rig, unsigned char ci) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * p1-p4 Command parameters * * Returns: RIG_OK if all called functions are successful, @@ -1820,7 +1812,7 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci, priv = (struct ft840_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -1854,7 +1846,7 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci, * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * freq freq_t frequency value * * Returns: RIG_OK if all called functions are successful, @@ -1881,7 +1873,7 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) priv = (struct ft840_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -1918,7 +1910,7 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * rit shortfreq_t frequency value * p1 P1 value -- CLAR_SET_FREQ * p2 P2 value -- CLAR_OFFSET_PLUS || CLAR_OFFSET_MINUS @@ -1950,7 +1942,7 @@ static int ft840_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv = (struct ft840_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); diff --git a/rigs/yaesu/ft857.c b/rigs/yaesu/ft857.c index fc70327d6..22a640891 100644 --- a/rigs/yaesu/ft857.c +++ b/rigs/yaesu/ft857.c @@ -76,8 +76,6 @@ struct ft857_priv_data { - yaesu_cmd_set_t pcs[FT857_NATIVE_SIZE]; /* TODO: why? */ - /* rx status */ struct timeval rx_status_tv; unsigned char rx_status; @@ -316,8 +314,6 @@ const struct rig_caps ft857_caps = int ft857_init(RIG *rig) { - struct ft857_priv_data *priv; - rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); if ((rig->state.priv = calloc(1, sizeof(struct ft857_priv_data))) == NULL) @@ -325,11 +321,6 @@ int ft857_init(RIG *rig) return -RIG_ENOMEM; } - priv = rig->state.priv; - - /* Copy complete native cmd set to private cmd storage area */ - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - return RIG_OK; } @@ -400,12 +391,11 @@ static int check_cache_timeout(struct timeval *tv) static int ft857_read_eeprom(RIG *rig, unsigned short addr, unsigned char *out) { - struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv; unsigned char data[YAESU_CMD_LENGTH]; int n; rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); - memcpy(data, (char *)p->pcs[FT857_NATIVE_CAT_EEPROM_READ].nseq, + memcpy(data, (char *)ncmd[FT857_NATIVE_CAT_EEPROM_READ].nseq, YAESU_CMD_LENGTH); data[0] = addr >> 8; @@ -465,7 +455,7 @@ static int ft857_get_status(RIG *rig, int status) rig_flush(&rig->state.rigport); - write_block(&rig->state.rigport, (char *) p->pcs[status].nseq, + write_block(&rig->state.rigport, (char *) ncmd[status].nseq, YAESU_CMD_LENGTH); if ((n = read_block(&rig->state.rigport, (char *) data, len)) < 0) @@ -499,17 +489,15 @@ static int ft857_get_status(RIG *rig, int status) */ static int ft857_send_cmd(RIG *rig, int index) { - struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv; - rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); - if (p->pcs[index].ncomp == 0) + if (ncmd[index].ncomp == 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: incomplete sequence\n", __func__); return -RIG_EINTERNAL; } - write_block(&rig->state.rigport, (char *) p->pcs[index].nseq, YAESU_CMD_LENGTH); + write_block(&rig->state.rigport, (char *) ncmd[index].nseq, YAESU_CMD_LENGTH); return ft817_read_ack(rig); } @@ -518,18 +506,17 @@ static int ft857_send_cmd(RIG *rig, int index) */ static int ft857_send_icmd(RIG *rig, int index, unsigned char *data) { - struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv; unsigned char cmd[YAESU_CMD_LENGTH]; rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); - if (p->pcs[index].ncomp == 1) + if (ncmd[index].ncomp == 1) { rig_debug(RIG_DEBUG_VERBOSE, "%s: complete sequence\n", __func__); return -RIG_EINTERNAL; } - cmd[YAESU_CMD_LENGTH - 1] = p->pcs[index].nseq[YAESU_CMD_LENGTH - 1]; + cmd[YAESU_CMD_LENGTH - 1] = ncmd[index].nseq[YAESU_CMD_LENGTH - 1]; memcpy(cmd, data, YAESU_CMD_LENGTH - 1); write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH); diff --git a/rigs/yaesu/ft890.c b/rigs/yaesu/ft890.c index 34d5dba96..0ef0e00e4 100644 --- a/rigs/yaesu/ft890.c +++ b/rigs/yaesu/ft890.c @@ -139,7 +139,6 @@ struct ft890_priv_data vfo_t current_vfo; /* active VFO from last cmd */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ - yaesu_cmd_set_t pcs[FT890_NATIVE_SIZE]; /* private cmd set */ unsigned char update_data[FT890_ALL_DATA_LENGTH]; /* returned data--max value, some are less */ unsigned char current_mem; /* private memory channel number */ @@ -302,11 +301,6 @@ static int ft890_init(RIG *rig) priv = rig->state.priv; - /* - * Copy native cmd set to private cmd storage area - */ - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - /* TODO: read pacing from preferences */ priv->pacing = FT890_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ priv->read_update_delay = @@ -1682,7 +1676,7 @@ static int ft890_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * * Returns: RIG_OK if all called functions are successful, * otherwise returns error from called functiion @@ -1691,7 +1685,6 @@ static int ft890_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft890_send_static_cmd(RIG *rig, unsigned char ci) { struct rig_state *rig_s; - struct ft890_priv_data *priv; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1701,17 +1694,16 @@ static int ft890_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - priv = (struct ft890_priv_data *)rig->state.priv; rig_s = &rig->state; - if (!priv->pcs[ci].ncomp) + if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to send incomplete sequence\n", __func__); return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) priv->pcs[ci].nseq, + err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1730,7 +1722,7 @@ static int ft890_send_static_cmd(RIG *rig, unsigned char ci) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * p1-p4 Command parameters * * Returns: RIG_OK if all called functions are successful, @@ -1759,7 +1751,7 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci, priv = (struct ft890_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -1793,7 +1785,7 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci, * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * freq freq_t frequency value * * Returns: RIG_OK if all called functions are successful, @@ -1820,7 +1812,7 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) priv = (struct ft890_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -1857,7 +1849,7 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * rit shortfreq_t frequency value * p1 P1 value -- CLAR_SET_FREQ * p2 P2 value -- CLAR_OFFSET_PLUS || CLAR_OFFSET_MINUS @@ -1888,7 +1880,7 @@ static int ft890_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv = (struct ft890_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); diff --git a/rigs/yaesu/ft897.c b/rigs/yaesu/ft897.c index bf8e33a37..3c41e531d 100644 --- a/rigs/yaesu/ft897.c +++ b/rigs/yaesu/ft897.c @@ -81,8 +81,6 @@ struct ft897_priv_data { - yaesu_cmd_set_t pcs[FT897_NATIVE_SIZE]; /* TODO: why? */ - /* rx status */ struct timeval rx_status_tv; unsigned char rx_status; @@ -492,8 +490,6 @@ const struct rig_caps ft897d_caps = int ft897_init(RIG *rig) { - struct ft897_priv_data *priv; - rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); if ((rig->state.priv = calloc(1, sizeof(struct ft897_priv_data))) == NULL) @@ -501,11 +497,6 @@ int ft897_init(RIG *rig) return -RIG_ENOMEM; } - priv = rig->state.priv; - - /* Copy complete native cmd set to private cmd storage area */ - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - return RIG_OK; } @@ -576,12 +567,11 @@ static int check_cache_timeout(struct timeval *tv) static int ft897_read_eeprom(RIG *rig, unsigned short addr, unsigned char *out) { - struct ft897_priv_data *p = (struct ft897_priv_data *) rig->state.priv; unsigned char data[YAESU_CMD_LENGTH]; int n; rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - memcpy(data, (char *)p->pcs[FT897_NATIVE_CAT_EEPROM_READ].nseq, + memcpy(data, (char *)ncmd[FT897_NATIVE_CAT_EEPROM_READ].nseq, YAESU_CMD_LENGTH); data[0] = addr >> 8; @@ -641,7 +631,7 @@ static int ft897_get_status(RIG *rig, int status) rig_flush(&rig->state.rigport); - write_block(&rig->state.rigport, (char *) p->pcs[status].nseq, + write_block(&rig->state.rigport, (char *) ncmd[status].nseq, YAESU_CMD_LENGTH); if ((n = read_block(&rig->state.rigport, (char *) data, len)) < 0) @@ -956,17 +946,15 @@ int ft897_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) */ static int ft897_send_cmd(RIG *rig, int index) { - struct ft897_priv_data *p = (struct ft897_priv_data *) rig->state.priv; - rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - if (p->pcs[index].ncomp == 0) + if (ncmd[index].ncomp == 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: incomplete sequence\n", __func__); return -RIG_EINTERNAL; } - write_block(&rig->state.rigport, (char *) p->pcs[index].nseq, YAESU_CMD_LENGTH); + write_block(&rig->state.rigport, (char *) ncmd[index].nseq, YAESU_CMD_LENGTH); return ft817_read_ack(rig); } @@ -975,18 +963,17 @@ static int ft897_send_cmd(RIG *rig, int index) */ static int ft897_send_icmd(RIG *rig, int index, unsigned char *data) { - struct ft897_priv_data *p = (struct ft897_priv_data *) rig->state.priv; unsigned char cmd[YAESU_CMD_LENGTH]; rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - if (p->pcs[index].ncomp == 1) + if (ncmd[index].ncomp == 1) { rig_debug(RIG_DEBUG_VERBOSE, "%s: Complete sequence\n", __func__); return -RIG_EINTERNAL; } - cmd[YAESU_CMD_LENGTH - 1] = p->pcs[index].nseq[YAESU_CMD_LENGTH - 1]; + cmd[YAESU_CMD_LENGTH - 1] = ncmd[index].nseq[YAESU_CMD_LENGTH - 1]; memcpy(cmd, data, YAESU_CMD_LENGTH - 1); write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH); diff --git a/rigs/yaesu/ft900.c b/rigs/yaesu/ft900.c index 7e730686c..63571919e 100644 --- a/rigs/yaesu/ft900.c +++ b/rigs/yaesu/ft900.c @@ -140,7 +140,6 @@ struct ft900_priv_data vfo_t current_vfo; /* active VFO from last cmd */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ - yaesu_cmd_set_t pcs[FT900_NATIVE_SIZE]; /* private cmd set */ unsigned char update_data[FT900_ALL_DATA_LENGTH]; /* returned data--max value, some are less */ unsigned char current_mem; /* private memory channel number */ @@ -304,11 +303,6 @@ static int ft900_init(RIG *rig) priv = rig->state.priv; - /* - * Copy native cmd set to private cmd storage area - */ - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - /* TODO: read pacing from preferences */ priv->pacing = FT900_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ priv->read_update_delay = @@ -1684,7 +1678,7 @@ static int ft900_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * * Returns: RIG_OK if all called functions are successful, * otherwise returns error from called functiion @@ -1693,7 +1687,6 @@ static int ft900_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft900_send_static_cmd(RIG *rig, unsigned char ci) { struct rig_state *rig_s; - struct ft900_priv_data *priv; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1703,17 +1696,16 @@ static int ft900_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - priv = (struct ft900_priv_data *)rig->state.priv; rig_s = &rig->state; - if (!priv->pcs[ci].ncomp) + if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to send incomplete sequence\n", __func__); return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) priv->pcs[ci].nseq, + err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1732,7 +1724,7 @@ static int ft900_send_static_cmd(RIG *rig, unsigned char ci) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * p1-p4 Command parameters * * Returns: RIG_OK if all called functions are successful, @@ -1761,7 +1753,7 @@ static int ft900_send_dynamic_cmd(RIG *rig, unsigned char ci, priv = (struct ft900_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -1795,7 +1787,7 @@ static int ft900_send_dynamic_cmd(RIG *rig, unsigned char ci, * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * freq freq_t frequency value * * Returns: RIG_OK if all called functions are successful, @@ -1822,7 +1814,7 @@ static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) priv = (struct ft900_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -1859,7 +1851,7 @@ static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * rit shortfreq_t frequency value * p1 P1 value -- CLAR_SET_FREQ * p2 P2 value -- CLAR_OFFSET_PLUS || CLAR_OFFSET_MINUS @@ -1890,7 +1882,7 @@ static int ft900_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv = (struct ft900_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); diff --git a/rigs/yaesu/ft920.c b/rigs/yaesu/ft920.c index f6cf64f19..d44fe5527 100644 --- a/rigs/yaesu/ft920.c +++ b/rigs/yaesu/ft920.c @@ -135,7 +135,6 @@ struct ft920_priv_data split_t split; /* split active or not */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of 1 constructed CAT cmd */ - yaesu_cmd_set_t pcs[FT920_NATIVE_SIZE]; /* private cmd set */ unsigned char update_data[FT920_VFO_DATA_LENGTH]; /* returned data--max value, some are less */ }; @@ -382,11 +381,6 @@ static int ft920_init(RIG *rig) priv = rig->state.priv; - /* - * Copy native cmd set to private cmd storage area - */ - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - /* TODO: read pacing from preferences */ priv->pacing = FT920_PACING_DEFAULT_VALUE; /* set pacing to minimum for now */ @@ -2397,7 +2391,7 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * * Returns: RIG_OK if all called functions are successful, * otherwise returns error from called functiion @@ -2406,7 +2400,6 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft920_send_static_cmd(RIG *rig, unsigned char ci) { struct rig_state *rig_s; - struct ft920_priv_data *priv; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -2416,21 +2409,19 @@ static int ft920_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - priv = (struct ft920_priv_data *)rig->state.priv; rig_s = &rig->state; - /* * If we've been passed a command index (ci) that is marked * as dynamic (0), then bail out. */ - if (!priv->pcs[ci].ncomp) + if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to send incomplete sequence\n", __func__); return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) priv->pcs[ci].nseq, + err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -2449,7 +2440,7 @@ static int ft920_send_static_cmd(RIG *rig, unsigned char ci) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * p1-p4 Command parameters * * Returns: RIG_OK if all called functions are successful, @@ -2482,7 +2473,7 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, * If we've been passed a command index (ci) that is marked * as static (1), then bail out. */ - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempted to modify a complete command sequence: %i\n", @@ -2516,7 +2507,7 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * freq freq_t frequency value * * Returns: RIG_OK if all called functions are successful, @@ -2547,7 +2538,7 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) * If we've been passed a command index (ci) that is marked * as static (1), then bail out. */ - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -2583,7 +2574,7 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * rit shortfreq_t frequency value * p1 P1 value -- CLAR_SET_FREQ * p2 P2 value -- CLAR_OFFSET_PLUS || CLAR_OFFSET_MINUS @@ -2618,7 +2609,7 @@ static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) * If we've been passed a command index (ci) that is marked * as static (1), then bail out. */ - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); diff --git a/rigs/yaesu/ft990.c b/rigs/yaesu/ft990.c index 3aeb82d69..41cec45d7 100644 --- a/rigs/yaesu/ft990.c +++ b/rigs/yaesu/ft990.c @@ -125,7 +125,6 @@ struct ft990_priv_data unsigned int read_update_delay; /* depends on pacing value */ vfo_t current_vfo; /* active VFO from last cmd */ unsigned char p_cmd[YAESU_CMD_LENGTH]; /* private copy of CAT cmd */ - yaesu_cmd_set_t pcs[FT990_NATIVE_SIZE]; /* private cmd set */ ft990_update_data_t update_data; /* returned data */ }; @@ -310,9 +309,6 @@ int ft990_init(RIG *rig) priv = rig->state.priv; -// Copy native cmd set to private cmd storage area - memcpy(priv->pcs, ncmd, sizeof(ncmd)); - // Set default pacing value priv->pacing = FT990_PACING_DEFAULT_VALUE; @@ -3221,7 +3217,7 @@ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * * Returns: RIG_OK if all called functions are successful, * otherwise returns error from called functiion @@ -3229,7 +3225,6 @@ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) int ft990_send_static_cmd(RIG *rig, unsigned char ci) { struct rig_state *rig_s; - struct ft990_priv_data *priv; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3239,17 +3234,16 @@ int ft990_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - priv = (struct ft990_priv_data *)rig->state.priv; rig_s = &rig->state; - if (!priv->pcs[ci].ncomp) + if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to send incomplete sequence\n", __func__); return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) priv->pcs[ci].nseq, + err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3267,7 +3261,7 @@ int ft990_send_static_cmd(RIG *rig, unsigned char ci) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * p1-p4 Command parameters * * Returns: RIG_OK if all called functions are successful, @@ -3295,7 +3289,7 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci, priv = (struct ft990_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -3328,7 +3322,7 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci, * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * freq freq_t frequency value * * Returns: RIG_OK if all called functions are successful, @@ -3354,7 +3348,7 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) priv = (struct ft990_priv_data *)rig->state.priv; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); @@ -3388,7 +3382,7 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) * change the rit frequency. * * Arguments: *rig Valid RIG instance - * ci Command index of the pcs struct + * ci Command index of the ncmd table * rit shortfreq_t frequency value * * Returns: RIG_OK if all called functions are successful, @@ -3413,7 +3407,7 @@ int ft990_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv = (struct ft990_priv_data *) rig->state.priv; rig_s = &rig->state; - if (priv->pcs[ci].ncomp) + if (ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: Attempt to modify complete sequence\n", __func__); diff --git a/rigs/yaesu/vx1700.c b/rigs/yaesu/vx1700.c index bbc071422..c675df43b 100644 --- a/rigs/yaesu/vx1700.c +++ b/rigs/yaesu/vx1700.c @@ -288,7 +288,7 @@ static int vx1700_do_transaction(RIG *rig, * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the ncmd struct + * ci Command index of the ncmd table * * Returns: RIG_OK if all called functions are successful, * otherwise returns error from called functiion @@ -314,7 +314,7 @@ static int vx1700_do_static_cmd(RIG *rig, unsigned char ci) * TODO: place variant of this in yaesu.c * * Arguments: *rig Valid RIG instance - * ci Command index of the ncmd struct + * ci Command index of the cmd struct * p1-p4 Command parameters * * Returns: RIG_OK if all called functions are successful, From b6837801a65591dcc9ed64701b5cfd174ffeb7cc Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Mon, 30 Aug 2021 22:42:51 +0200 Subject: [PATCH 83/97] Drop pointless rig_s assignment from Yeasu code. rig_s was assigned once and use once, better use rig->state direct; it gives less code to read. Also dramatically shrinked send_priv_cmd for ft1000mp, ft100, ft600, ft747 and ft847 by simply using ncmd direct instead of via a variabel. --- rigs/yaesu/ft100.c | 26 +++++--------------------- rigs/yaesu/ft1000d.c | 32 ++++++++++---------------------- rigs/yaesu/ft1000mp.c | 26 +++++--------------------- rigs/yaesu/ft600.c | 15 ++------------- rigs/yaesu/ft747.c | 21 ++++----------------- rigs/yaesu/ft840.c | 23 +++++------------------ rigs/yaesu/ft847.c | 20 ++------------------ rigs/yaesu/ft890.c | 23 +++++------------------ rigs/yaesu/ft900.c | 27 +++++++-------------------- rigs/yaesu/ft920.c | 24 ++++++------------------ rigs/yaesu/ft990.c | 26 ++++++-------------------- 11 files changed, 57 insertions(+), 206 deletions(-) diff --git a/rigs/yaesu/ft100.c b/rigs/yaesu/ft100.c index 98871fad5..2919f8362 100644 --- a/rigs/yaesu/ft100.c +++ b/rigs/yaesu/ft100.c @@ -386,19 +386,12 @@ int ft100_close(RIG *rig) static int ft100_send_priv_cmd(RIG *rig, unsigned char cmd_index) { - - struct rig_state *rig_s; - unsigned char *cmd; /* points to sequence to send */ - rig_debug(RIG_DEBUG_VERBOSE, "%s called (%d)\n", __func__, cmd_index); if (!rig) { return -RIG_EINVAL; } - rig_s = &rig->state; - - cmd = (unsigned char *) &ncmd[cmd_index].nseq; /* get native sequence */ - - return write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) &ncmd[cmd_index].nseq, + YAESU_CMD_LENGTH); } static int ft100_read_status(RIG *rig) @@ -463,14 +456,11 @@ static int ft100_read_flags(RIG *rig) int ft100_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; unsigned char cmd_index; /* index of sequence to send */ if (!rig) { return -RIG_EINVAL; } - rig_s = &rig->state; - rig_debug(RIG_DEBUG_VERBOSE, "ft100: requested freq = %"PRIfreq" Hz \n", freq); cmd_index = FT100_NATIVE_CAT_SET_FREQ; @@ -481,7 +471,7 @@ int ft100_set_freq(RIG *rig, vfo_t vfo, freq_t freq) freq = (int)freq / 10; to_bcd(p_cmd, freq, 8); /* store bcd format in in p_cmd */ - return write_block(&rig_s->rigport, (char *) p_cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) p_cmd, YAESU_CMD_LENGTH); } int ft100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) @@ -1045,13 +1035,10 @@ int ft100_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *shift) */ int ft100_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) { - struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; unsigned char cmd_index; /* index of sequence to send */ int pcode; - rig_s = &rig->state; - for (pcode = 0; pcode < 104 && ft100_dcs_list[pcode] != 0; pcode++) { if (ft100_dcs_list[pcode] == code) @@ -1075,7 +1062,7 @@ int ft100_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) p_cmd[3] = (char)pcode; - return write_block(&rig_s->rigport, (char *) p_cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) p_cmd, YAESU_CMD_LENGTH); } int ft100_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code) @@ -1102,7 +1089,6 @@ int ft100_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code) */ int ft100_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) { - struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; unsigned char cmd_index; /* index of sequence to send */ int ptone; @@ -1121,8 +1107,6 @@ int ft100_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) return -RIG_EINVAL; } - rig_s = &rig->state; - rig_debug(RIG_DEBUG_VERBOSE, "%s = %.1f Hz, n=%d\n", __func__, (float)tone / 10, ptone); @@ -1132,7 +1116,7 @@ int ft100_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) p_cmd[3] = (char)ptone; - return write_block(&rig_s->rigport, (char *) p_cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) p_cmd, YAESU_CMD_LENGTH); } int ft100_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone) diff --git a/rigs/yaesu/ft1000d.c b/rigs/yaesu/ft1000d.c index 9329273ad..15029354b 100644 --- a/rigs/yaesu/ft1000d.c +++ b/rigs/yaesu/ft1000d.c @@ -2332,7 +2332,6 @@ int ft1000d_get_vfo(RIG *rig, vfo_t *vfo) int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) { struct ft1000d_priv_data *priv; - struct rig_state *rig_s; unsigned char mdata[YAESU_CMD_LENGTH]; int err; @@ -2375,8 +2374,7 @@ int ft1000d_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) return err; } - rig_s = &rig->state; - err = read_block(&rig_s->rigport, (char *) mdata, FT1000D_READ_METER_LENGTH); + err = read_block(&rig->state.rigport, (char *) mdata, FT1000D_READ_METER_LENGTH); if (err < 0) { @@ -3267,7 +3265,7 @@ int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) return -RIG_EINVAL; } - n = read_block(&rig_s->rigport, p, rl); + n = read_block(&rig->state.rigport, p, rl); } while (n < 0 && retry-- >= 0); @@ -3300,7 +3298,6 @@ int ft1000d_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) */ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3311,8 +3308,6 @@ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; - if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, @@ -3320,7 +3315,7 @@ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3328,7 +3323,7 @@ int ft1000d_send_static_cmd(RIG *rig, unsigned char ci) return err; } - hl_usleep(rig_s->rigport.write_delay * 1000); + hl_usleep(rig->state.rigport.write_delay * 1000); return RIG_OK; } @@ -3349,7 +3344,6 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft1000d_priv_data *priv; int err; @@ -3375,7 +3369,6 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[3] = p1; @@ -3383,7 +3376,7 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[1] = p3; priv->p_cmd[0] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3391,7 +3384,7 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, return err; } - hl_usleep(rig_s->rigport.write_delay * 1000); + hl_usleep(rig->state.rigport.write_delay * 1000); return RIG_OK; } @@ -3409,7 +3402,6 @@ int ft1000d_send_dynamic_cmd(RIG *rig, unsigned char ci, */ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft1000d_priv_data *priv; int err; // cppcheck-suppress * @@ -3434,8 +3426,6 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -3445,7 +3435,7 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT1000D_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3453,7 +3443,7 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return err; } - hl_usleep(rig_s->rigport.write_delay * 1000); + hl_usleep(rig->state.rigport.write_delay * 1000); return RIG_OK; } @@ -3471,7 +3461,6 @@ int ft1000d_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { struct ft1000d_priv_data *priv; - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3485,7 +3474,6 @@ int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) rig_debug(RIG_DEBUG_TRACE, "%s: passed rit = %li Hz\n", __func__, rit); priv = (struct ft1000d_priv_data *) rig->state.priv; - rig_s = &rig->state; if (ncmd[ci].ncomp) { @@ -3513,7 +3501,7 @@ int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) // Store bcd format into privat command storage area to_bcd(priv->p_cmd, labs(rit) / 10, FT1000D_BCD_RIT); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3521,7 +3509,7 @@ int ft1000d_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) return err; } - hl_usleep(rig_s->rigport.write_delay * 1000); + hl_usleep(rig->state.rigport.write_delay * 1000); return RIG_OK; } diff --git a/rigs/yaesu/ft1000mp.c b/rigs/yaesu/ft1000mp.c index 61f28ae75..09c95396f 100644 --- a/rigs/yaesu/ft1000mp.c +++ b/rigs/yaesu/ft1000mp.c @@ -703,7 +703,7 @@ int ft1000mp_open(RIG *rig) /* send PACING cmd to rig */ cmd = p->p_cmd; - write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH); ft1000mp_get_vfo(rig, &rig->state.current_vfo); /* TODO */ @@ -715,7 +715,6 @@ int ft1000mp_open(RIG *rig) int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rig_s; struct ft1000mp_priv_data *p; unsigned char *cmd; /* points to sequence to send */ int cmd_index = 0; @@ -724,8 +723,6 @@ int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) p = (struct ft1000mp_priv_data *)rig->state.priv; - rig_s = &rig->state; - rig_debug(RIG_DEBUG_TRACE, "%s: requested freq = %"PRIfreq" Hz \n", __func__, freq); @@ -768,7 +765,7 @@ int ft1000mp_set_freq(RIG *rig, vfo_t vfo, freq_t freq) (freq_t)from_bcd(p->p_cmd, 8) * 10); cmd = p->p_cmd; /* get native sequence */ - write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH); RETURNFUNC(RIG_OK); } @@ -1560,21 +1557,19 @@ int ft1000mp_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) static int ft1000mp_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) { - struct rig_state *rig_s; struct ft1000mp_priv_data *p; int n; /* for read_ */ ENTERFUNC; p = (struct ft1000mp_priv_data *)rig->state.priv; - rig_s = &rig->state; // timeout retries are done in read_block now // based on rig backed retry value /* send UPDATE command to fetch data*/ ft1000mp_send_priv_cmd(rig, ci); - n = read_block(&rig_s->rigport, (char *) p->update_data, rl); + n = read_block(&rig->state.rigport, (char *) p->update_data, rl); if (n == -RIG_ETIMEOUT) { @@ -1594,26 +1589,15 @@ static int ft1000mp_get_update_data(RIG *rig, unsigned char ci, static int ft1000mp_send_priv_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; - unsigned char *cmd; /* points to sequence to send */ - unsigned char cmd_index; /* index of sequence to send */ - ENTERFUNC; - rig_s = &rig->state; - - cmd_index = ci; /* get command */ - - if (! ncmd[cmd_index].ncomp) + if (! ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, "%s: attempt to send incomplete sequence\n", __func__); RETURNFUNC(-RIG_EINVAL); } - - cmd = (unsigned char *) ncmd[cmd_index].nseq; /* get native sequence */ - rig_flush(&rig_s->rigport); - write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); RETURNFUNC(RIG_OK); diff --git a/rigs/yaesu/ft600.c b/rigs/yaesu/ft600.c index 78dc78089..437555598 100644 --- a/rigs/yaesu/ft600.c +++ b/rigs/yaesu/ft600.c @@ -298,19 +298,11 @@ int ft600_close(RIG *rig) static int ft600_send_priv_cmd(RIG *rig, unsigned char cmd_index) { - - struct rig_state *rig_s; - unsigned char *cmd; /* points to sequence to send */ - rig_debug(RIG_DEBUG_VERBOSE, "%s called (%d)\n", __func__, cmd_index); if (!rig) { return -RIG_EINVAL; } - rig_s = &rig->state; - - cmd = (unsigned char *) &ncmd[cmd_index].nseq; /* get native sequence */ - - return write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) &ncmd[cmd_index].nseq, YAESU_CMD_LENGTH); } static int ft600_read_status(RIG *rig) @@ -386,14 +378,11 @@ int ft600_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) int ft600_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; unsigned char cmd_index; /* index of sequence to send */ if (!rig) { return -RIG_EINVAL; } - rig_s = &rig->state; - rig_debug(RIG_DEBUG_VERBOSE, "ft600: requested freq = %"PRIfreq" Hz \n", freq); cmd_index = FT600_NATIVE_CAT_SET_FREQ; @@ -403,7 +392,7 @@ int ft600_set_freq(RIG *rig, vfo_t vfo, freq_t freq) freq = (int)freq / 10; to_bcd(p_cmd, freq, 8); /* store bcd format in in p_cmd */ - return write_block(&rig_s->rigport, (char *) p_cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) p_cmd, YAESU_CMD_LENGTH); } int ft600_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) diff --git a/rigs/yaesu/ft747.c b/rigs/yaesu/ft747.c index 7793420c5..1d6ff2675 100644 --- a/rigs/yaesu/ft747.c +++ b/rigs/yaesu/ft747.c @@ -372,7 +372,7 @@ int ft747_open(RIG *rig) /* send PACING cmd to rig, once for all */ - ret = write_block(&rig_s->rigport, (char *)p->p_cmd, YAESU_CMD_LENGTH); + ret = write_block(&rig->state.rigport, (char *)p->p_cmd, YAESU_CMD_LENGTH); if (ret < 0) { @@ -407,7 +407,6 @@ int ft747_close(RIG *rig) int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rig_s; struct ft747_priv_data *p; unsigned char *cmd; /* points to sequence to send */ // cppcheck-suppress * @@ -415,8 +414,6 @@ int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq) p = (struct ft747_priv_data *)rig->state.priv; - rig_s = &rig->state; - rig_debug(RIG_DEBUG_VERBOSE, "ft747: requested freq = %"PRIfreq" Hz \n", freq); /* @@ -435,7 +432,7 @@ int ft747_set_freq(RIG *rig, vfo_t vfo, freq_t freq) rig_force_cache_timeout(&p->status_tv); cmd = p->p_cmd; /* get native sequence */ - return write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) cmd, YAESU_CMD_LENGTH); } @@ -909,24 +906,14 @@ static int ft747_get_update_data(RIG *rig) static int ft747_send_priv_cmd(RIG *rig, unsigned char ci) { - - struct rig_state *rig_s; - unsigned char *cmd; /* points to sequence to send */ - unsigned char cmd_index; /* index of sequence to send */ - - rig_s = &rig->state; - - cmd_index = ci; /* get command */ - - if (! ft747_ncmd[cmd_index].ncomp) + if (! ft747_ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_VERBOSE, "%s: attempt to send incomplete sequence\n", __func__); return -RIG_EINVAL; } - cmd = (unsigned char *) ft747_ncmd[cmd_index].nseq; /* get native sequence */ - return write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) ft747_ncmd[ci].nseq, YAESU_CMD_LENGTH); } diff --git a/rigs/yaesu/ft840.c b/rigs/yaesu/ft840.c index c381217dd..5e9f573b7 100644 --- a/rigs/yaesu/ft840.c +++ b/rigs/yaesu/ft840.c @@ -1697,7 +1697,6 @@ static int ft840_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) static int ft840_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) { - struct rig_state *rig_s; struct ft840_priv_data *priv; int n, err; /* for read_ */ @@ -1709,7 +1708,6 @@ static int ft840_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) } priv = (struct ft840_priv_data *)rig->state.priv; - rig_s = &rig->state; err = ft840_send_static_cmd(rig, ci); @@ -1718,7 +1716,7 @@ static int ft840_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) return err; } - n = read_block(&rig_s->rigport, (char *) priv->update_data, rl); + n = read_block(&rig->state.rigport, (char *) priv->update_data, rl); if (n < 0) { @@ -1745,7 +1743,6 @@ static int ft840_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft840_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1755,8 +1752,6 @@ static int ft840_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; - if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, @@ -1764,7 +1759,7 @@ static int ft840_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1794,7 +1789,6 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft840_priv_data *priv; int err; @@ -1819,7 +1813,6 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[P1] = p1; /* ick */ @@ -1827,7 +1820,7 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[P3] = p3; priv->p_cmd[P4] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1855,7 +1848,6 @@ static int ft840_send_dynamic_cmd(RIG *rig, unsigned char ci, static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft840_priv_data *priv; int err; // cppcheck-suppress * @@ -1880,8 +1872,6 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -1891,7 +1881,7 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT840_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1924,7 +1914,6 @@ static int ft840_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) #ifdef USE_FT840_SET_RIT static int ft840_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { - struct rig_state *rig_s; struct ft840_priv_data *priv; unsigned char p1; unsigned char p2; @@ -1949,8 +1938,6 @@ static int ft840_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) return -RIG_EINVAL; } - rig_s = &rig->state; - p1 = CLAR_SET_FREQ; if (rit < 0) @@ -1976,7 +1963,7 @@ static int ft840_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv->p_cmd[P1] = p1; /* ick */ priv->p_cmd[P2] = p2; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) diff --git a/rigs/yaesu/ft847.c b/rigs/yaesu/ft847.c index 69242e705..addef7550 100644 --- a/rigs/yaesu/ft847.c +++ b/rigs/yaesu/ft847.c @@ -645,15 +645,6 @@ int ft847_close(RIG *rig) static int ft847_send_priv_cmd(RIG *rig, int cmd_index) { - - struct rig_state *rig_s; - unsigned char *cmd; /* points to sequence to send */ - - if (!rig) - { - return -RIG_EINVAL; - } - if (! ncmd[cmd_index].ncomp) { rig_debug(RIG_DEBUG_VERBOSE, "%s: attempt to send incomplete sequence\n", @@ -661,11 +652,7 @@ static int ft847_send_priv_cmd(RIG *rig, int cmd_index) return -RIG_EINVAL; } - rig_s = &rig->state; - - cmd = (unsigned char *) ncmd[cmd_index].nseq; /* get native sequence */ - - return write_block(&rig_s->rigport, (char *) cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *) ncmd[cmd_index].nseq, YAESU_CMD_LENGTH); } @@ -717,7 +704,6 @@ static int opcode_vfo(RIG *rig, unsigned char *cmd, int cmd_index, vfo_t vfo) int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { - struct rig_state *rig_s; unsigned char p_cmd[YAESU_CMD_LENGTH]; /* sequence to send */ int ret; // cppcheck-suppress * @@ -728,8 +714,6 @@ int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - rig_debug(RIG_DEBUG_VERBOSE, "ft847: requested freq = %"PRIfreq" Hz, vfo=%s\n", freq, rig_strvfo(vfo)); @@ -761,7 +745,7 @@ int ft847_set_freq(RIG *rig, vfo_t vfo, freq_t freq) } } - return write_block(&rig_s->rigport, (char *)p_cmd, YAESU_CMD_LENGTH); + return write_block(&rig->state.rigport, (char *)p_cmd, YAESU_CMD_LENGTH); } #define MD_LSB 0x00 diff --git a/rigs/yaesu/ft890.c b/rigs/yaesu/ft890.c index 0ef0e00e4..5c1b63e47 100644 --- a/rigs/yaesu/ft890.c +++ b/rigs/yaesu/ft890.c @@ -1636,7 +1636,6 @@ static int ft890_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) static int ft890_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) { - struct rig_state *rig_s; struct ft890_priv_data *priv; int n, err; /* for read_ */ @@ -1648,7 +1647,6 @@ static int ft890_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) } priv = (struct ft890_priv_data *)rig->state.priv; - rig_s = &rig->state; err = ft890_send_static_cmd(rig, ci); @@ -1657,7 +1655,7 @@ static int ft890_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) return err; } - n = read_block(&rig_s->rigport, (char *) priv->update_data, rl); + n = read_block(&rig->state.rigport, (char *) priv->update_data, rl); if (n < 0) { @@ -1684,7 +1682,6 @@ static int ft890_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft890_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1694,8 +1691,6 @@ static int ft890_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; - if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, @@ -1703,7 +1698,7 @@ static int ft890_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1733,7 +1728,6 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft890_priv_data *priv; int err; @@ -1758,7 +1752,6 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[P1] = p1; /* ick */ @@ -1766,7 +1759,7 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[P3] = p3; priv->p_cmd[P4] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1794,7 +1787,6 @@ static int ft890_send_dynamic_cmd(RIG *rig, unsigned char ci, static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft890_priv_data *priv; int err; // cppcheck-suppress * @@ -1819,8 +1811,6 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -1830,7 +1820,7 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT890_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1862,7 +1852,6 @@ static int ft890_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) static int ft890_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { - struct rig_state *rig_s; struct ft890_priv_data *priv; unsigned char p1; unsigned char p2; @@ -1887,8 +1876,6 @@ static int ft890_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) return -RIG_EINVAL; } - rig_s = &rig->state; - p1 = CLAR_SET_FREQ; if (rit < 0) @@ -1914,7 +1901,7 @@ static int ft890_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv->p_cmd[P1] = p1; /* ick */ priv->p_cmd[P2] = p2; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) diff --git a/rigs/yaesu/ft900.c b/rigs/yaesu/ft900.c index 63571919e..72f561a6c 100644 --- a/rigs/yaesu/ft900.c +++ b/rigs/yaesu/ft900.c @@ -1638,10 +1638,9 @@ static int ft900_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) static int ft900_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) { - struct rig_state *rig_s; struct ft900_priv_data *priv; - int n, err; /* for read_ */ - + int err; + int n; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); if (!rig) @@ -1650,7 +1649,6 @@ static int ft900_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) } priv = (struct ft900_priv_data *)rig->state.priv; - rig_s = &rig->state; err = ft900_send_static_cmd(rig, ci); @@ -1659,7 +1657,7 @@ static int ft900_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) return err; } - n = read_block(&rig_s->rigport, (char *) priv->update_data, rl); + n = read_block(&rig->state.rigport, (char *) priv->update_data, rl); if (n < 0) { @@ -1686,7 +1684,6 @@ static int ft900_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft900_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -1696,8 +1693,6 @@ static int ft900_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; - if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, @@ -1705,7 +1700,7 @@ static int ft900_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1735,7 +1730,6 @@ static int ft900_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft900_priv_data *priv; int err; @@ -1760,7 +1754,6 @@ static int ft900_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[P1] = p1; /* ick */ @@ -1768,7 +1761,7 @@ static int ft900_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[P3] = p3; priv->p_cmd[P4] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1796,7 +1789,6 @@ static int ft900_send_dynamic_cmd(RIG *rig, unsigned char ci, static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft900_priv_data *priv; int err; // cppcheck-suppress * @@ -1821,8 +1813,6 @@ static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -1832,7 +1822,7 @@ static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT900_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -1864,7 +1854,6 @@ static int ft900_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) static int ft900_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { - struct rig_state *rig_s; struct ft900_priv_data *priv; unsigned char p1; unsigned char p2; @@ -1889,8 +1878,6 @@ static int ft900_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) return -RIG_EINVAL; } - rig_s = &rig->state; - p1 = CLAR_SET_FREQ; if (rit < 0) @@ -1916,7 +1903,7 @@ static int ft900_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv->p_cmd[P1] = p1; /* ick */ priv->p_cmd[P2] = p2; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) diff --git a/rigs/yaesu/ft920.c b/rigs/yaesu/ft920.c index d44fe5527..900cbc2f4 100644 --- a/rigs/yaesu/ft920.c +++ b/rigs/yaesu/ft920.c @@ -453,7 +453,7 @@ static int ft920_open(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s: read pacing = %i\n", __func__, priv->pacing); - err = write_block(&rig_s->rigport, (char *) priv->p_cmd, YAESU_CMD_LENGTH); + err = write_block(&rig->state.rigport, (char *) priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) { @@ -2350,7 +2350,6 @@ static int ft920_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) { - struct rig_state *rig_s; struct ft920_priv_data *priv; int n; /* for read_ */ int err; @@ -2363,7 +2362,6 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) } priv = (struct ft920_priv_data *)rig->state.priv; - rig_s = &rig->state; err = ft920_send_static_cmd(rig, ci); @@ -2372,7 +2370,7 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) return err; } - n = read_block(&rig_s->rigport, (char *)priv->update_data, rl); + n = read_block(&rig->state.rigport, (char *)priv->update_data, rl); if (n < 0) { @@ -2399,7 +2397,6 @@ static int ft920_get_update_data(RIG *rig, unsigned char ci, unsigned char rl) static int ft920_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -2409,7 +2406,6 @@ static int ft920_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; /* * If we've been passed a command index (ci) that is marked * as dynamic (0), then bail out. @@ -2421,7 +2417,7 @@ static int ft920_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -2451,7 +2447,6 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft920_priv_data *priv; int err; @@ -2481,7 +2476,6 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[P1] = p1; /* ick */ @@ -2489,7 +2483,7 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[P3] = p3; priv->p_cmd[P4] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) { @@ -2516,7 +2510,6 @@ static int ft920_send_dynamic_cmd(RIG *rig, unsigned char ci, static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft920_priv_data *priv; int err; // cppcheck-suppress * @@ -2545,8 +2538,6 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -2556,7 +2547,7 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT920_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) { @@ -2587,7 +2578,6 @@ static int ft920_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { - struct rig_state *rig_s; struct ft920_priv_data *priv; unsigned char p1; unsigned char p2; @@ -2616,8 +2606,6 @@ static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) return -RIG_EINVAL; } - rig_s = &rig->state; - p1 = CLAR_SET_FREQ; if (rit < 0) @@ -2642,7 +2630,7 @@ static int ft920_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) priv->p_cmd[P1] = p1; /* ick */ priv->p_cmd[P2] = p2; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) { diff --git a/rigs/yaesu/ft990.c b/rigs/yaesu/ft990.c index 41cec45d7..4c59dae02 100644 --- a/rigs/yaesu/ft990.c +++ b/rigs/yaesu/ft990.c @@ -2281,7 +2281,6 @@ int ft990_get_vfo(RIG *rig, vfo_t *vfo) int ft990_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) { struct ft990_priv_data *priv; - struct rig_state *rig_s; unsigned char mdata[YAESU_CMD_LENGTH]; int err; @@ -2324,8 +2323,7 @@ int ft990_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *value) return err; } - rig_s = &rig->state; - err = read_block(&rig_s->rigport, (char *) mdata, FT990_READ_METER_LENGTH); + err = read_block(&rig->state.rigport, (char *) mdata, FT990_READ_METER_LENGTH); if (err < 0) { @@ -3124,7 +3122,6 @@ int ft990_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) */ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) { - struct rig_state *rig_s; struct ft990_priv_data *priv; int n; int err; @@ -3142,7 +3139,6 @@ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) } priv = (struct ft990_priv_data *)rig->state.priv; - rig_s = &rig->state; if (ci == FT990_NATIVE_UPDATE_MEM_CHNL_DATA) // P4 = 0x01 to 0x5a for channel 1 - 90 @@ -3194,7 +3190,7 @@ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) return -RIG_EINVAL; } - n = read_block(&rig_s->rigport, p, rl); + n = read_block(&rig->state.rigport, p, rl); if (n < 0) { @@ -3224,7 +3220,6 @@ int ft990_get_update_data(RIG *rig, unsigned char ci, unsigned short ch) */ int ft990_send_static_cmd(RIG *rig, unsigned char ci) { - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3234,8 +3229,6 @@ int ft990_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - rig_s = &rig->state; - if (!ncmd[ci].ncomp) { rig_debug(RIG_DEBUG_TRACE, @@ -3243,7 +3236,7 @@ int ft990_send_static_cmd(RIG *rig, unsigned char ci) return -RIG_EINVAL; } - err = write_block(&rig_s->rigport, (char *) ncmd[ci].nseq, + err = write_block(&rig->state.rigport, (char *) ncmd[ci].nseq, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3271,7 +3264,6 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci, unsigned char p1, unsigned char p2, unsigned char p3, unsigned char p4) { - struct rig_state *rig_s; struct ft990_priv_data *priv; int err; @@ -3296,7 +3288,6 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci, return -RIG_EINVAL; } - rig_s = &rig->state; memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); priv->p_cmd[3] = p1; @@ -3304,7 +3295,7 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci, priv->p_cmd[1] = p3; priv->p_cmd[0] = p4; - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3330,7 +3321,6 @@ int ft990_send_dynamic_cmd(RIG *rig, unsigned char ci, */ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) { - struct rig_state *rig_s; struct ft990_priv_data *priv; int err; // cppcheck-suppress * @@ -3355,8 +3345,6 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) return -RIG_EINVAL; } - rig_s = &rig->state; - /* Copy native cmd freq_set to private cmd storage area */ memcpy(&priv->p_cmd, &ncmd[ci].nseq, YAESU_CMD_LENGTH); @@ -3366,7 +3354,7 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) rig_debug(RIG_DEBUG_TRACE, fmt, __func__, (int64_t)from_bcd(priv->p_cmd, FT990_BCD_DIAL) * 10); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) @@ -3391,7 +3379,6 @@ int ft990_send_dial_freq(RIG *rig, unsigned char ci, freq_t freq) int ft990_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) { struct ft990_priv_data *priv; - struct rig_state *rig_s; int err; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -3405,7 +3392,6 @@ int ft990_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) rig_debug(RIG_DEBUG_TRACE, "%s: passed rit = %li Hz\n", __func__, rit); priv = (struct ft990_priv_data *) rig->state.priv; - rig_s = &rig->state; if (ncmd[ci].ncomp) { @@ -3433,7 +3419,7 @@ int ft990_send_rit_freq(RIG *rig, unsigned char ci, shortfreq_t rit) // Store bcd format into privat command storage area to_bcd(priv->p_cmd, labs(rit) / 10, FT990_BCD_RIT); - err = write_block(&rig_s->rigport, (char *) &priv->p_cmd, + err = write_block(&rig->state.rigport, (char *) &priv->p_cmd, YAESU_CMD_LENGTH); if (err != RIG_OK) From 9162127e9c719b61d95fc26a948b56ee1b84ed52 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 1 Sep 2021 09:00:56 -0500 Subject: [PATCH 84/97] Fix icom_set_func so that it can also turn off DUAL_WATCH In ic756.c remove ic756_set_func and use icom_set_func instead --- rigs/icom/ic756.c | 50 +++++++---------------------------------------- rigs/icom/icom.h | 2 +- 2 files changed, 8 insertions(+), 44 deletions(-) diff --git a/rigs/icom/ic756.c b/rigs/icom/ic756.c index 64e8243f8..cee4dc2a3 100644 --- a/rigs/icom/ic756.c +++ b/rigs/icom/ic756.c @@ -88,8 +88,6 @@ struct cmdparams ic756pro_cmdparms[] = { 247 ,60 } \ } } -int ic756_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); - /* * This function deals with the older type radios with only 2 filter widths * (0 - normal, 1 - narrow) @@ -144,7 +142,7 @@ const struct rig_caps ic756_caps = RIG_MODEL(RIG_MODEL_IC756), .model_name = "IC-756", .mfg_name = "Icom", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -260,7 +258,7 @@ const struct rig_caps ic756_caps = .decode_event = icom_decode_event, .set_level = icom_set_level, .get_level = icom_get_level, - .set_func = ic756_set_func, + .set_func = icom_set_func, .get_func = icom_get_func, .set_mem = icom_set_mem, .vfo_op = icom_vfo_op, @@ -307,7 +305,7 @@ const struct rig_caps ic756pro_caps = RIG_MODEL(RIG_MODEL_IC756PRO), .model_name = "IC-756PRO", .mfg_name = "Icom", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -422,7 +420,7 @@ const struct rig_caps ic756pro_caps = .decode_event = icom_decode_event, .set_level = icom_set_level, .get_level = icom_get_level, - .set_func = ic756_set_func, + .set_func = icom_set_func, .get_func = icom_get_func, .set_mem = icom_set_mem, .vfo_op = icom_vfo_op, @@ -544,7 +542,7 @@ const struct rig_caps ic756pro2_caps = RIG_MODEL(RIG_MODEL_IC756PROII), .model_name = "IC-756PROII", .mfg_name = "Icom", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -662,7 +660,7 @@ const struct rig_caps ic756pro2_caps = .get_parm = icom_get_parm, .set_level = icom_set_level, .get_level = icom_get_level, - .set_func = ic756_set_func, + .set_func = icom_set_func, .get_func = icom_get_func, .set_mem = icom_set_mem, .vfo_op = icom_vfo_op, @@ -1105,7 +1103,7 @@ const struct rig_caps ic756pro3_caps = .get_parm = icom_get_parm, .set_level = icom_set_level, .get_level = icom_get_level, - .set_func = ic756_set_func, + .set_func = icom_set_func, .get_func = icom_get_func, .set_mem = icom_set_mem, .vfo_op = icom_vfo_op, @@ -1130,37 +1128,3 @@ const struct rig_caps ic756pro3_caps = .set_ext_parm = ic756pro2_set_ext_parm, .get_ext_parm = ic756pro2_get_ext_parm, }; - -int ic756_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) -{ - unsigned char fctbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN]; - int fct_len = 0, acklen, retval; - int fct_cn, fct_sc; /* Command Number, Subcommand */ - - switch (func) - { - case RIG_FUNC_DUAL_WATCH: - fct_cn = C_SET_VFO; - fct_sc = status ? S_DUAL_ON : S_DUAL_OFF; - break; - - default: - return icom_set_func(rig, vfo, func, status); - } - - retval = icom_transaction(rig, fct_cn, fct_sc, fctbuf, fct_len, ackbuf, - &acklen); - - if (retval != RIG_OK) - { - return retval; - } - - if (acklen != 1) - { - rig_debug(RIG_DEBUG_ERR, "%s: wrong frame len=%d\n", __func__, acklen); - return -RIG_EPROTO; - } - - return RIG_OK; -} diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index d13f9d650..6c6e3d428 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -30,7 +30,7 @@ #include #endif -#define BACKEND_VER "20210828" +#define BACKEND_VER "20210901" #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) From e78a8258ce2ebe86dd1494067524e4059ed9f314 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 1 Sep 2021 09:06:23 -0500 Subject: [PATCH 85/97] Fix gp2000_get_mode bogus sscanf -- potential seg fault function would not work --- rigs/rs/gp2000.c | 5 ++++- rigs/rs/gp2000.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rigs/rs/gp2000.c b/rigs/rs/gp2000.c index cfc34e3bb..f2b7e4026 100644 --- a/rigs/rs/gp2000.c +++ b/rigs/rs/gp2000.c @@ -237,7 +237,7 @@ gp2000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) int buf_len, retval; int nmode; char *pmode = "UNKNOWN"; - int n = sscanf(buf, "%*cI%d", &nmode); + int n; rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo)); @@ -252,8 +252,11 @@ gp2000_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return retval; } + n = sscanf(buf, "%*cI%d", &nmode); + if (n != 1) { + rig_debug(RIG_DEBUG_ERR, "%s: unable to parse mode from '%s'\n", __func__, buf); return -RIG_EPROTO; } diff --git a/rigs/rs/gp2000.h b/rigs/rs/gp2000.h index 13ff3874c..848f1ca00 100644 --- a/rigs/rs/gp2000.h +++ b/rigs/rs/gp2000.h @@ -25,7 +25,7 @@ #define _XK2000_H 1 #undef BACKEND_VER -#define BACKEND_VER "20180307" +#define BACKEND_VER "20210901" #include From 731eb39df84dca6d2e6b7b7686d34a38f89b0487 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 1 Sep 2021 09:08:13 -0500 Subject: [PATCH 86/97] Really fix icom_set_func so that it can also turn off DUAL_WATCH --- rigs/icom/icom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 6f3e187cd..7d1d7eb96 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -6579,7 +6579,7 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) case RIG_FUNC_DUAL_WATCH: fct_cn = C_SET_VFO; - fct_sc = S_DUAL; + fct_sc = status ? S_DUAL_ON : S_DUAL_OFF; break; case RIG_FUNC_SATMODE: From 99b7a2da24dca2fd3bbec4f0957feceff5552d0b Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 1 Sep 2021 09:11:00 -0500 Subject: [PATCH 87/97] Fix bogus sscanf in kpa_get_powerstat -- function would not work --- amplifiers/elecraft/kpa.c | 4 +++- amplifiers/elecraft/kpa1500.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/amplifiers/elecraft/kpa.c b/amplifiers/elecraft/kpa.c index dc066de61..fa0ed55af 100644 --- a/amplifiers/elecraft/kpa.c +++ b/amplifiers/elecraft/kpa.c @@ -505,7 +505,7 @@ int kpa_get_powerstat(AMP *amp, powerstat_t *status) int retval; int operate; int ampon; - int nargs = sscanf(responsebuf, "^ON%d", &on); + int nargs; rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -518,6 +518,8 @@ int kpa_get_powerstat(AMP *amp, powerstat_t *status) if (retval != RIG_OK) { return retval; } + nargs = sscanf(responsebuf, "^ON%d", &on); + if (nargs != 1) { rig_debug(RIG_DEBUG_VERBOSE, "%s Error: ^ON response='%s'\n", __func__, diff --git a/amplifiers/elecraft/kpa1500.c b/amplifiers/elecraft/kpa1500.c index 65724a4f4..ea3b27750 100644 --- a/amplifiers/elecraft/kpa1500.c +++ b/amplifiers/elecraft/kpa1500.c @@ -65,7 +65,7 @@ const struct amp_caps kpa1500_amp_caps = AMP_MODEL(AMP_MODEL_ELECRAFT_KPA1500), .model_name = "KPA1500", .mfg_name = "Elecraft", - .version = "20200112.0", + .version = "20210901.0", .copyright = "LGPL", .status = RIG_STATUS_ALPHA, .amp_type = AMP_TYPE_OTHER, From 0e67bcd1fc55c9af2149588dbc290975a48ab493 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 1 Sep 2021 12:45:29 -0500 Subject: [PATCH 88/97] Do not do vfo_fixup on satmode rigs https://github.com/Hamlib/Hamlib/issues/782 --- src/rig.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rig.c b/src/rig.c index dba18783b..bec62059c 100644 --- a/src/rig.c +++ b/src/rig.c @@ -4549,8 +4549,12 @@ int HAMLIB_API rig_set_split_vfo(RIG *rig, RETURNFUNC(-RIG_ENAVAIL); } - rx_vfo = vfo_fixup(rig, rx_vfo, split); - tx_vfo = vfo_fixup(rig, tx_vfo, split); + // We fix up vfos for non-satmode rigs + if (!(rig->caps->has_get_func & RIG_FUNC_SATMODE)) + { + rx_vfo = vfo_fixup(rig, rx_vfo, split); + tx_vfo = vfo_fixup(rig, tx_vfo, split); + } // set rig to the the requested RX VFO TRACE; From d6350d1f0f9b3a2a7d36ace5ee70d6ff44fc6945 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 2 Sep 2021 17:08:10 -0500 Subject: [PATCH 89/97] Fix compilation of misc.c with gmtime_r replacement function for mingw https://github.com/Hamlib/Hamlib/issues/784 --- src/misc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/misc.c b/src/misc.c index bc679198f..76121037f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -2346,6 +2346,27 @@ uint32_t CRC32_function(uint8_t *buf, uint32_t len) return crc ^ 0xFFFFFFFF; } +#if defined(_WIN32) +// gmtime_r can be defined by mingw +#ifndef gmtime_r +static struct tm *gmtime_r(const time_t *t, struct tm *r) +{ + // gmtime is threadsafe in windows because it uses TLS + struct tm *theTm = gmtime(t); + + if (theTm) + { + *r = *theTm; + return r; + } + else + { + return 0; + } +} +#endif // gmtime_r +#endif // _WIN32 + //! @cond Doxygen_Suppress char *date_strget(char *buf, int buflen) { From e825e5b4c994ba70721bf731d9ef052820d5c3c5 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sun, 22 Aug 2021 20:53:24 +0200 Subject: [PATCH 90/97] ft817: Move relevant code fomr header to C file. Dropped pointless NULL check before free. Explicitly implemented digi_mode instead of awkward add on to fm_status Handle unlikely case of getting bogus digi mode, this prevent a garbage read while determining the bandwidth of the mode --- rigs/yaesu/ft817.c | 148 ++++++++++++++++++++++++++++++++++----------- rigs/yaesu/ft817.h | 77 +---------------------- rigs/yaesu/ft857.c | 3 +- rigs/yaesu/ft897.c | 3 +- 4 files changed, 117 insertions(+), 114 deletions(-) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 73d67fd1c..044874838 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -71,6 +71,52 @@ #include "bandplan.h" #include "cal.h" +enum ft817_native_cmd_e +{ + FT817_NATIVE_CAT_LOCK_ON = 0, + FT817_NATIVE_CAT_LOCK_OFF, + FT817_NATIVE_CAT_PTT_ON, + FT817_NATIVE_CAT_PTT_OFF, + FT817_NATIVE_CAT_SET_FREQ, + FT817_NATIVE_CAT_SET_MODE_LSB, + FT817_NATIVE_CAT_SET_MODE_USB, + FT817_NATIVE_CAT_SET_MODE_CW, + FT817_NATIVE_CAT_SET_MODE_CWR, + FT817_NATIVE_CAT_SET_MODE_AM, + FT817_NATIVE_CAT_SET_MODE_FM, + FT817_NATIVE_CAT_SET_MODE_FM_N, + FT817_NATIVE_CAT_SET_MODE_DIG, + FT817_NATIVE_CAT_SET_MODE_PKT, + FT817_NATIVE_CAT_CLAR_ON, + FT817_NATIVE_CAT_CLAR_OFF, + FT817_NATIVE_CAT_SET_CLAR_FREQ, + FT817_NATIVE_CAT_SET_VFOAB, + FT817_NATIVE_CAT_SPLIT_ON, + FT817_NATIVE_CAT_SPLIT_OFF, + FT817_NATIVE_CAT_SET_RPT_SHIFT_MINUS, + FT817_NATIVE_CAT_SET_RPT_SHIFT_PLUS, + FT817_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, + FT817_NATIVE_CAT_SET_RPT_OFFSET, + FT817_NATIVE_CAT_SET_DCS_ON, + FT817_NATIVE_CAT_SET_CTCSS_ON, + FT817_NATIVE_CAT_SET_CTCSS_ENC_ON, + FT817_NATIVE_CAT_SET_CTCSS_DCS_OFF, + FT817_NATIVE_CAT_SET_CTCSS_FREQ, + FT817_NATIVE_CAT_SET_DCS_CODE, + FT817_NATIVE_CAT_GET_RX_STATUS, + FT817_NATIVE_CAT_GET_TX_STATUS, + FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS, + FT817_NATIVE_CAT_PWR_WAKE, + FT817_NATIVE_CAT_PWR_ON, + FT817_NATIVE_CAT_PWR_OFF, + FT817_NATIVE_CAT_EEPROM_READ, + FT817_NATIVE_SIZE /* end marker */ +}; + + +typedef enum ft817_native_cmd_e ft817_native_cmd_t; + + struct ft817_priv_data { /* rx status */ @@ -83,11 +129,43 @@ struct ft817_priv_data /* freq & mode status */ struct timeval fm_status_tv; - unsigned char fm_status[YAESU_CMD_LENGTH + 1]; + unsigned char fm_status[YAESU_CMD_LENGTH]; + /* Digi mode is not part of regular fm_status reponse. + * So keep track of it in a separate variable. */ + unsigned char dig_mode; }; +static int ft817_init(RIG *rig); +static int ft817_open(RIG *rig); +static int ft817_cleanup(RIG *rig); +static int ft817_close(RIG *rig); static int ft817_get_vfo(RIG *rig, vfo_t *vfo); static int ft817_set_vfo(RIG *rig, vfo_t vfo); +static int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq); +static int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); +static int ft817_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); +static int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); +static int ft817_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); +static int ft817_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); +static int ft817_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); +static int ft817_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code); +static int ft817_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone); +static int ft817_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code); +static int ft817_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone); +static int ft817_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift); +static int ft817_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs); +static int ft817_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); +static int ft817_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd); +static int ft817_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); +static int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, + vfo_t *tx_vfo); +static int ft817_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, + vfo_t tx_vfo); +static int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power, + freq_t freq, rmode_t mode); +static int ft817_mW2power(RIG *rig, float *power, unsigned int mwpower, + freq_t freq, rmode_t mode); /* Native ft817 cmd set prototypes. These are READ ONLY as each */ /* rig instance will copy from these and modify if required . */ @@ -493,7 +571,7 @@ const struct rig_caps ft818_caps = /* ---------------------------------------------------------------------- */ -int ft817_init(RIG *rig) +static int ft817_init(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called, version %s\n", __func__, rig->caps->version); @@ -506,28 +584,25 @@ int ft817_init(RIG *rig) return RIG_OK; } -int ft817_cleanup(RIG *rig) +static int ft817_cleanup(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - if (rig->state.priv) - { - free(rig->state.priv); - } + free(rig->state.priv); rig->state.priv = NULL; return RIG_OK; } -int ft817_open(RIG *rig) +static int ft817_open(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); return RIG_OK; } -int ft817_close(RIG *rig) +static int ft817_close(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); @@ -657,12 +732,14 @@ static int ft817_get_status(RIG *rig, int status) if (status == FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS) { - if ((n = ft817_read_eeprom(rig, 0x0065, &p->fm_status[5])) < 0) + unsigned char dig_mode; + if ((n = ft817_read_eeprom(rig, 0x0065, &dig_mode)) < 0) { return n; } - p->fm_status[5] >>= 5; + /* Top 3 bit define the digi mode */ + p->dig_mode = dig_mode >> 5; } gettimeofday(tv, NULL); @@ -672,7 +749,7 @@ static int ft817_get_status(RIG *rig, int status) /* ---------------------------------------------------------------------- */ -int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) +static int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; freq_t f1 = 0, f2 = 0; @@ -693,7 +770,7 @@ 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, 5); + dump_hex(p->fm_status, sizeof(p->fm_status)/sizeof(p->fm_status[0])); } #if 1 // user must be twiddling the VFO @@ -716,7 +793,7 @@ int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) } -int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) +static int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; @@ -763,7 +840,7 @@ int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) break; case 0x0a: - switch (p->fm_status[5]) + switch (p->dig_mode) { case FT817_DIGI_RTTY: *mode = RIG_MODE_RTTYR; break; @@ -774,6 +851,9 @@ int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) case FT817_DIGI_USER_L: *mode = RIG_MODE_PKTLSB; break; case FT817_DIGI_USER_U: *mode = RIG_MODE_PKTUSB; break; + + default: + *mode = RIG_MODE_NONE; } break; @@ -798,7 +878,7 @@ int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) return RIG_OK; } -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; int n; @@ -831,7 +911,7 @@ int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) return RIG_OK; } -int ft817_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) +static int ft817_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; @@ -978,7 +1058,7 @@ static int ft817_get_raw_smeter_level(RIG *rig, value_t *val) } -int ft817_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) +static int ft817_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { switch (level) { @@ -1007,7 +1087,7 @@ int ft817_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return RIG_OK; } -int ft817_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) +static int ft817_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) { struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; @@ -1151,7 +1231,7 @@ static int ft817_set_vfo(RIG *rig, vfo_t vfo) -int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq) +static int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq) { unsigned char data[YAESU_CMD_LENGTH - 1]; int retval; @@ -1169,7 +1249,7 @@ int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq) return retval; } -int ft817_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) +static int ft817_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) { int index; /* index of sequence to send */ @@ -1227,7 +1307,7 @@ int ft817_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) return ft817_send_cmd(rig, index); } -int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) +static int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { int index; ptt_t ptt_response = -1; @@ -1288,7 +1368,7 @@ int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) } -int ft817_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) +static int ft817_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); @@ -1329,7 +1409,7 @@ int ft817_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) } } -int ft817_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) +static int ft817_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) { unsigned char data[YAESU_CMD_LENGTH - 1]; /* int n; */ @@ -1356,7 +1436,7 @@ int ft817_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code) return ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_DCS_CODE, data); } -int ft817_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code) +static int ft817_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code) { unsigned char data[YAESU_CMD_LENGTH - 1]; int n; @@ -1381,7 +1461,7 @@ int ft817_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code) } -int ft817_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) +static int ft817_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) { unsigned char data[YAESU_CMD_LENGTH - 1]; int n; @@ -1406,7 +1486,7 @@ int ft817_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone) } -int ft817_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) +static int ft817_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) { unsigned char data[YAESU_CMD_LENGTH - 1]; int n; @@ -1430,7 +1510,7 @@ int ft817_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone) return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_CTCSS_ON); } -int ft817_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift) +static int ft817_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift) { /* Note: this doesn't have effect unless FT817 is in FM mode although the command is accepted in any mode. @@ -1454,7 +1534,7 @@ int ft817_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift) return -RIG_EINVAL; } -int ft817_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs) +static int ft817_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs) { unsigned char data[YAESU_CMD_LENGTH - 1]; @@ -1466,7 +1546,7 @@ int ft817_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs) return ft817_send_icmd(rig, FT817_NATIVE_CAT_SET_RPT_OFFSET, data); } -int ft817_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit) +static int ft817_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit) { unsigned char data[YAESU_CMD_LENGTH - 1]; int n; @@ -1521,7 +1601,7 @@ int ft817_set_powerstat(RIG *rig, powerstat_t status) } } -int ft817_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) +static int ft817_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); @@ -1545,7 +1625,7 @@ int ft817_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) /* FIXME: this function silently ignores the vfo args and just turns split ON or OFF. */ -int ft817_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) +static int ft817_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) { int index, n; @@ -1588,7 +1668,7 @@ int ft817_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) 3 bars = 1W 1 bar = 0.5W */ -int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power, +static int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power, freq_t freq, rmode_t mode) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); @@ -1598,7 +1678,7 @@ int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power, /* FIXME: currently ignores mode and freq */ -int ft817_mW2power(RIG *rig, float *power, unsigned int mwpower, +static int ft817_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq, rmode_t mode) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); diff --git a/rigs/yaesu/ft817.h b/rigs/yaesu/ft817.h index 97532dc07..0e23be2e2 100644 --- a/rigs/yaesu/ft817.h +++ b/rigs/yaesu/ft817.h @@ -76,82 +76,7 @@ #define FT817_CACHE_TIMEOUT 50 -enum ft817_native_cmd_e -{ - FT817_NATIVE_CAT_LOCK_ON = 0, - FT817_NATIVE_CAT_LOCK_OFF, - FT817_NATIVE_CAT_PTT_ON, - FT817_NATIVE_CAT_PTT_OFF, - FT817_NATIVE_CAT_SET_FREQ, - FT817_NATIVE_CAT_SET_MODE_LSB, - FT817_NATIVE_CAT_SET_MODE_USB, - FT817_NATIVE_CAT_SET_MODE_CW, - FT817_NATIVE_CAT_SET_MODE_CWR, - FT817_NATIVE_CAT_SET_MODE_AM, - FT817_NATIVE_CAT_SET_MODE_FM, - FT817_NATIVE_CAT_SET_MODE_FM_N, - FT817_NATIVE_CAT_SET_MODE_DIG, - FT817_NATIVE_CAT_SET_MODE_PKT, - FT817_NATIVE_CAT_CLAR_ON, - FT817_NATIVE_CAT_CLAR_OFF, - FT817_NATIVE_CAT_SET_CLAR_FREQ, - FT817_NATIVE_CAT_SET_VFOAB, - FT817_NATIVE_CAT_SPLIT_ON, - FT817_NATIVE_CAT_SPLIT_OFF, - FT817_NATIVE_CAT_SET_RPT_SHIFT_MINUS, - FT817_NATIVE_CAT_SET_RPT_SHIFT_PLUS, - FT817_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX, - FT817_NATIVE_CAT_SET_RPT_OFFSET, - FT817_NATIVE_CAT_SET_DCS_ON, - FT817_NATIVE_CAT_SET_CTCSS_ON, - FT817_NATIVE_CAT_SET_CTCSS_ENC_ON, - FT817_NATIVE_CAT_SET_CTCSS_DCS_OFF, - FT817_NATIVE_CAT_SET_CTCSS_FREQ, - FT817_NATIVE_CAT_SET_DCS_CODE, - FT817_NATIVE_CAT_GET_RX_STATUS, - FT817_NATIVE_CAT_GET_TX_STATUS, - FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS, - FT817_NATIVE_CAT_PWR_WAKE, - FT817_NATIVE_CAT_PWR_ON, - FT817_NATIVE_CAT_PWR_OFF, - FT817_NATIVE_CAT_EEPROM_READ, - FT817_NATIVE_SIZE /* end marker */ -}; - - -typedef enum ft817_native_cmd_e ft817_native_cmd_t; - - -/* fixme: why declare static? it has no effect */ -static int ft817_init(RIG *rig); -static int ft817_open(RIG *rig); -static int ft817_cleanup(RIG *rig); -static int ft817_close(RIG *rig); -static int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq); -static int ft817_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); -static int ft817_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); -static int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); -static int ft817_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); -static int ft817_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); -static int ft817_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); -static int ft817_set_func(RIG *rig, vfo_t vfo, setting_t func, int status); -static int ft817_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code); -static int ft817_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone); -static int ft817_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t code); -static int ft817_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone); -static int ft817_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift); -static int ft817_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs); -static int ft817_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); -static int ft817_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd); int ft817_set_powerstat(RIG *rig, powerstat_t status); -static int ft817_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op); -static int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, - vfo_t *tx_vfo); -static int ft817_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, - vfo_t tx_vfo); -static int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power, - freq_t freq, rmode_t mode); -static int ft817_mW2power(RIG *rig, float *power, unsigned int mwpower, - freq_t freq, rmode_t mode); +int ft817_read_ack(RIG *rig); #endif /* _FT817_H */ diff --git a/rigs/yaesu/ft857.c b/rigs/yaesu/ft857.c index 22a640891..70392672c 100644 --- a/rigs/yaesu/ft857.c +++ b/rigs/yaesu/ft857.c @@ -70,6 +70,7 @@ #include "serial.h" #include "yaesu.h" #include "ft857.h" +#include "ft817.h" /* We use functions from the 817 code */ #include "misc.h" #include "tones.h" #include "bandplan.h" @@ -163,8 +164,6 @@ enum ft857_digi #define FT857_VFO_ALL (RIG_VFO_A|RIG_VFO_B) #define FT857_ANTS 0 -extern int ft817_read_ack(RIG *rig); -extern int ft817_set_powerstat(RIG *rig, powerstat_t status); static int ft857_send_icmd(RIG *rig, int index, unsigned char *data); const struct rig_caps ft857_caps = diff --git a/rigs/yaesu/ft897.c b/rigs/yaesu/ft897.c index 3c41e531d..310080ebf 100644 --- a/rigs/yaesu/ft897.c +++ b/rigs/yaesu/ft897.c @@ -75,6 +75,7 @@ #include "serial.h" #include "yaesu.h" #include "ft897.h" +#include "ft817.h" /* We use functions from the 817 code */ #include "misc.h" #include "tones.h" #include "bandplan.h" @@ -127,8 +128,6 @@ static int ft897_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t rptr_shift); static int ft897_set_rptr_offs(RIG *rig, vfo_t vfo, shortfreq_t offs); static int ft897_set_rit(RIG *rig, vfo_t vfo, shortfreq_t rit); static int ft897_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd); -extern int ft817_read_ack(RIG *rig); -extern int ft817_set_powerstat(RIG *rig, powerstat_t status); /* Native ft897 cmd set prototypes. These are READ ONLY as each */ /* rig instance will copy from these and modify if required . */ From 12889cd95711fcff392d62b17f557b52d8f9d4e7 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sun, 22 Aug 2021 20:58:29 +0200 Subject: [PATCH 91/97] Add definition of TX metering CAT command --- rigs/yaesu/ft817.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 044874838..eb68fb371 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -110,6 +110,7 @@ enum ft817_native_cmd_e FT817_NATIVE_CAT_PWR_ON, FT817_NATIVE_CAT_PWR_OFF, FT817_NATIVE_CAT_EEPROM_READ, + FT817_NATIVE_CAT_GET_TX_METERING, FT817_NATIVE_SIZE /* end marker */ }; @@ -211,6 +212,7 @@ static const yaesu_cmd_set_t ncmd[] = { 1, { 0x00, 0x00, 0x00, 0x00, 0x0f } }, /* pwr on */ { 1, { 0x00, 0x00, 0x00, 0x00, 0x8f } }, /* pwr off */ { 0, { 0x00, 0x00, 0x00, 0x00, 0xbb } }, /* eeprom read */ + { 1, { 0x00, 0x00, 0x00, 0x00, 0xbd } }, /* get TX metering levels (PWR, SWR, MOD, ALC) */ }; enum ft817_digi From 775fc832f6dab9b55f6b101411408b68de93a723 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sun, 22 Aug 2021 20:59:04 +0200 Subject: [PATCH 92/97] Drop unused command typedef --- rigs/yaesu/ft817.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index eb68fb371..dd125ab32 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -114,10 +114,6 @@ enum ft817_native_cmd_e FT817_NATIVE_SIZE /* end marker */ }; - -typedef enum ft817_native_cmd_e ft817_native_cmd_t; - - struct ft817_priv_data { /* rx status */ From 53035454f241ded78231275de73dd1b2379ad88d Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sun, 22 Aug 2021 21:11:44 +0200 Subject: [PATCH 93/97] Use plain 5 instead of YAESU_CMD_LENGTH as it is not related and only brings confusion --- rigs/yaesu/ft817.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index dd125ab32..8138d79d8 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -126,7 +126,7 @@ struct ft817_priv_data /* freq & mode status */ struct timeval fm_status_tv; - unsigned char fm_status[YAESU_CMD_LENGTH]; + unsigned char fm_status[5]; /* 5 bytes, NOT related to YAESU_CMD_LENGTH */ /* Digi mode is not part of regular fm_status reponse. * So keep track of it in a separate variable. */ unsigned char dig_mode; @@ -688,7 +688,7 @@ static int ft817_get_status(RIG *rig, int status) { case FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS: data = p->fm_status; - len = YAESU_CMD_LENGTH; + len = 5; /* Answer is 5 long; 4 bytes BCD freq, 1 byte status */ tv = &p->fm_status_tv; break; From 83b887ca8c4450f3bcc330e2f22d2ab6b5570ba1 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sun, 22 Aug 2021 23:16:41 +0200 Subject: [PATCH 94/97] Properly implement getting ALC, RFPOWER and SWR for 817/818. Previous implementation used improper command, and incorrect calibration, and did not enable it in the caps. Add SWR since that was easy enough. --- rigs/yaesu/ft817.c | 154 ++++++++++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 64 deletions(-) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 8138d79d8..5034d84b6 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -122,7 +122,14 @@ struct ft817_priv_data /* tx status */ struct timeval tx_status_tv; - unsigned char tx_status; + unsigned char tx_status; /* Raw data from rig. Highest bit 0 = PTT */ + + /* tx levels */ + struct timeval tx_level_tv; + unsigned char swr_level; + unsigned char alc_level; + unsigned char mod_level; + unsigned char pwr_level; /* TX power level */ /* freq & mode status */ struct timeval fm_status_tv; @@ -231,7 +238,7 @@ enum ft817_digi #define FT817_AM_TX_MODES (RIG_MODE_AM) #define FT817_VFO_ALL (RIG_VFO_A|RIG_VFO_B) -#define FT817_ANTS 0 +#define FT817_ANTS (RIG_ANT_1|RIG_ANT_2) /* ant-1 on the back, ant-2 BNC at the front */ #define FT817_STR_CAL { 16, \ { \ @@ -308,7 +315,9 @@ const struct rig_caps ft817_caps = .retry = 5, .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, + .has_get_level = + 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, @@ -451,7 +460,9 @@ const struct rig_caps ft818_caps = .retry = 5, .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, + .has_get_level = + 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, @@ -535,7 +546,10 @@ const struct rig_caps ft818_caps = RIG_FLT_END, }, - .str_cal = FT817_STR_CAL, + .str_cal = FT817_STR_CAL, + .swr_cal = FT817_SWR_CAL, + .alc_cal = FT817_ALC_CAL, + .rfpower_meter_cal = FT817_PWR_CAL, .rig_init = ft817_init, .rig_cleanup = ft817_cleanup, @@ -681,6 +695,7 @@ static int ft817_get_status(RIG *rig, int status) int len; int n; int retries = rig->state.rigport.retry; + unsigned char result[2]; rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); @@ -688,7 +703,8 @@ static int ft817_get_status(RIG *rig, int status) { case FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS: data = p->fm_status; - len = 5; /* Answer is 5 long; 4 bytes BCD freq, 1 byte status */ + /* Answer is 5 long; 4 bytes BCD freq, 1 byte status */ + len = 5; tv = &p->fm_status_tv; break; @@ -698,12 +714,19 @@ static int ft817_get_status(RIG *rig, int status) tv = &p->rx_status_tv; break; + case FT817_NATIVE_CAT_GET_TX_METERING: + data = result; + len = sizeof(result)/sizeof(result[0]); /* We expect two bytes */ + tv = &p->tx_level_tv; + break; + case FT817_NATIVE_CAT_GET_TX_STATUS: data = &p->tx_status; len = 1; tv = &p->tx_status_tv; break; + default: rig_debug(RIG_DEBUG_ERR, "%s: Internal error!\n", __func__); return -RIG_EINTERNAL; @@ -725,19 +748,41 @@ 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); return -RIG_EIO; } - if (status == FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS) + switch(status) { - unsigned char dig_mode; - if ((n = ft817_read_eeprom(rig, 0x0065, &dig_mode)) < 0) + case FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS: { - return n; - } + unsigned char dig_mode; + 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; + /* Top 3 bit define the digi mode */ + p->dig_mode = dig_mode >> 5; + } + 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); + break; } gettimeofday(tv, NULL); @@ -930,64 +975,45 @@ static int ft817_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) return RIG_OK; } -static int ft817_get_alc_level(RIG *rig, value_t *val) +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; rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - if (check_cache_timeout(&p->tx_status_tv)) + if (check_cache_timeout(&p->tx_level_tv)) { int n; + ptt_t ptt; - if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_STATUS)) < 0) + /* Default to not keyed */ + *tx_level = 0; + + /* TX metering is special; it sends 1 byte if not keyed and 2 if keyed. + * To handle this properly we first verify the rig is keyed. + * Otherwise we experience at least a full timeout and + * perhaps pointless retries + timeouts. + */ + n = ft817_get_ptt(rig, 0, &ptt); + if (n != RIG_OK) + { + return n; + } + + if (ptt == RIG_PTT_OFF) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: rig not keyed\n", __func__); + return -RIG_ERJCTED; //Or return OK? + } + + n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_METERING); + if (n != RIG_OK) { return n; } } - /* Valid only if PTT is on. - FT-817 returns the number of bars in the lowest 4 bits - */ - if ((p->tx_status & 0x80) == 0) - { - val->f = rig_raw2val_float(p->tx_status >> 4, &rig->caps->alc_cal); - } - else // not transmitting so zero - { - val->f = 0.0; - } - - return RIG_OK; -} - -static int ft817_get_pometer_level(RIG *rig, value_t *val) -{ - struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv; - - rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - - if (check_cache_timeout(&p->tx_status_tv)) - { - int n; - - if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_STATUS)) < 0) - { - return n; - } - } - - /* Valid only if PTT is on. - FT-817 returns the number of bars in the lowest 4 bits - */ - if ((p->tx_status & 0x80) == 0) - { - val->f = rig_raw2val_float(p->tx_status >> 4, &rig->caps->rfpower_meter_cal); - } - else // not transmitting so zero - { - val->f = 0.0; - } + val->f = rig_raw2val_float(*tx_level, cal); return RIG_OK; } @@ -1058,25 +1084,25 @@ 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) { case RIG_LEVEL_STRENGTH: /* The front-end will always call for RAWSTR and use the cal_table */ return ft817_get_smeter_level(rig, val); - break; case RIG_LEVEL_RAWSTR: return ft817_get_raw_smeter_level(rig, val); - break; case RIG_LEVEL_RFPOWER: - return ft817_get_pometer_level(rig, val); - break; + return ft817_get_tx_level(rig, val, &p->pwr_level, &rig->caps->rfpower_meter_cal); case RIG_LEVEL_ALC: - return ft817_get_alc_level(rig, val); - break; + return ft817_get_tx_level(rig, val, &p->alc_level, &rig->caps->alc_cal); + + case RIG_LEVEL_SWR: + return ft817_get_tx_level(rig, val, &p->swr_level, &rig->caps->swr_cal); default: return -RIG_EINVAL; From 4cf092fc0bdf77365e0df1aa77a1f7e5fe59db97 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Tue, 24 Aug 2021 23:23:48 +0200 Subject: [PATCH 95/97] Implement get_ant (for 818 only) Add antenna info to RX lists --- rigs/yaesu/ft817.c | 173 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 138 insertions(+), 35 deletions(-) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 5034d84b6..38bc56d21 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -170,6 +170,8 @@ static int ft817_power2mW(RIG *rig, unsigned int *mwpower, float power, freq_t freq, rmode_t mode); 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); /* Native ft817 cmd set prototypes. These are READ ONLY as each */ /* rig instance will copy from these and modify if required . */ @@ -238,7 +240,9 @@ enum ft817_digi #define FT817_AM_TX_MODES (RIG_MODE_AM) #define FT817_VFO_ALL (RIG_VFO_A|RIG_VFO_B) -#define FT817_ANTS (RIG_ANT_1|RIG_ANT_2) /* ant-1 on the back, ant-2 BNC at the front */ +#define FT817_ANT_FRONT (RIG_ANT_1) +#define FT817_ANT_REAR (RIG_ANT_2) +#define FT817_ANTS (FT817_ANT_FRONT | FT817_ANT_REAR) #define FT817_STR_CAL { 16, \ { \ @@ -338,10 +342,10 @@ const struct rig_caps ft817_caps = .chan_list = { RIG_CHAN_END, }, .rx_range_list1 = { - {kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1}, - {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1}, - {MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1}, - {MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1}, + {kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, RIG_FRNG_END, }, .tx_range_list1 = { @@ -362,10 +366,10 @@ const struct rig_caps ft817_caps = .rx_range_list2 = { - {kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1}, - {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1}, - {MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1}, - {MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1}, + {kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, RIG_FRNG_END, }, @@ -407,7 +411,7 @@ const struct rig_caps ft817_caps = .rfpower_meter_cal = FT817_PWR_CAL, .rig_init = ft817_init, - .rig_cleanup = ft817_cleanup, + .rig_cleanup = ft817_cleanup, .rig_open = ft817_open, .rig_close = ft817_close, .get_vfo = ft817_get_vfo, @@ -416,24 +420,24 @@ const struct rig_caps ft817_caps = .get_freq = ft817_get_freq, .set_mode = ft817_set_mode, .get_mode = ft817_get_mode, - .set_ptt = ft817_set_ptt, - .get_ptt = ft817_get_ptt, - .get_dcd = ft817_get_dcd, + .set_ptt = ft817_set_ptt, + .get_ptt = ft817_get_ptt, + .get_dcd = ft817_get_dcd, .set_rptr_shift = ft817_set_rptr_shift, .set_rptr_offs = ft817_set_rptr_offs, .set_split_vfo = ft817_set_split_vfo, .get_split_vfo = ft817_get_split_vfo, - .set_rit = ft817_set_rit, + .set_rit = ft817_set_rit, .set_dcs_code = ft817_set_dcs_code, .set_ctcss_tone = ft817_set_ctcss_tone, - .set_dcs_sql = ft817_set_dcs_sql, + .set_dcs_sql = ft817_set_dcs_sql, .set_ctcss_sql = ft817_set_ctcss_sql, - .power2mW = ft817_power2mW, - .mW2power = ft817_mW2power, + .power2mW = ft817_power2mW, + .mW2power = ft817_mW2power, .set_powerstat = ft817_set_powerstat, .get_level = ft817_get_level, .set_func = ft817_set_func, - .vfo_op = ft817_vfo_op, + .vfo_op = ft817_vfo_op, }; const struct rig_caps ft818_caps = @@ -483,15 +487,16 @@ const struct rig_caps ft818_caps = .chan_list = { RIG_CHAN_END, }, .rx_range_list1 = { - {kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1}, - {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1}, - {MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1}, - {MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1}, + {kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, RIG_FRNG_END, }, .tx_range_list1 = { FRQ_RNG_HF(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS), FRQ_RNG_HF(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS), + /* TODO 60m is available seems always available on the 818 */ FRQ_RNG_6m(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS), FRQ_RNG_6m(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS), @@ -507,10 +512,10 @@ const struct rig_caps ft818_caps = .rx_range_list2 = { - {kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1}, - {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1}, - {MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1}, - {MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1}, + {kHz(100), MHz(56), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(118), MHz(164), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, + {MHz(420), MHz(470), FT817_ALL_RX_MODES, -1, -1, FT817_VFO_ALL, FT817_ANTS}, RIG_FRNG_END, }, @@ -552,7 +557,7 @@ const struct rig_caps ft818_caps = .rfpower_meter_cal = FT817_PWR_CAL, .rig_init = ft817_init, - .rig_cleanup = ft817_cleanup, + .rig_cleanup = ft817_cleanup, .rig_open = ft817_open, .rig_close = ft817_close, .get_vfo = ft817_get_vfo, @@ -561,24 +566,25 @@ const struct rig_caps ft818_caps = .get_freq = ft817_get_freq, .set_mode = ft817_set_mode, .get_mode = ft817_get_mode, - .set_ptt = ft817_set_ptt, - .get_ptt = ft817_get_ptt, - .get_dcd = ft817_get_dcd, + .set_ptt = ft817_set_ptt, + .get_ptt = ft817_get_ptt, + .get_dcd = ft817_get_dcd, .set_rptr_shift = ft817_set_rptr_shift, .set_rptr_offs = ft817_set_rptr_offs, .set_split_vfo = ft817_set_split_vfo, .get_split_vfo = ft817_get_split_vfo, - .set_rit = ft817_set_rit, + .set_rit = ft817_set_rit, .set_dcs_code = ft817_set_dcs_code, .set_ctcss_tone = ft817_set_ctcss_tone, - .set_dcs_sql = ft817_set_dcs_sql, + .set_dcs_sql = ft817_set_dcs_sql, .set_ctcss_sql = ft817_set_ctcss_sql, - .power2mW = ft817_power2mW, - .mW2power = ft817_mW2power, + .power2mW = ft817_power2mW, + .mW2power = ft817_mW2power, .set_powerstat = ft817_set_powerstat, + .get_ant = ft817_get_ant, .get_level = ft817_get_level, .set_func = ft817_set_func, - .vfo_op = ft817_vfo_op, + .vfo_op = ft817_vfo_op, }; /* ---------------------------------------------------------------------- */ @@ -1140,6 +1146,103 @@ static int ft817_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) return RIG_OK; } +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) +{ + /* The FT818/817 has no targetable antenna, so rig.c switched the active VFO */ + int ret; + unsigned char eeprom_band, eeprom_ant; + + /* Read eeprom for current 'band' for both VFO's */ + ret = ft817_read_eeprom(rig, 0x59, &eeprom_band); + if (ret != RIG_OK) + { + return ret; + } + + /* Read eeprom for antenna selection per band. + * 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; + } + + /* if CURR then get real VFO before parsing EEPROM */ + if (vfo == RIG_VFO_CURR) + { + vfo = rig->state.current_vfo; + } + + /* 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; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: Unsupported VFO %d!\n", + __func__, vfo); + return -RIG_EINTERNAL; + } + + /* The 817/818 does not have a antenna selection per VFO but per band. + * So we read the band for the requested VFO and then map it to the + * selected antenna. + * TODO THIS IS 818 specific info: the 817 does not have 60m and + * thus has a shifted numbering! + */ + switch(eeprom_band) { + case 0: /* 160M */ + case 1: /* 80M */ + case 2: /* 60M */ + 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; + break; + + case 0xB: /* FM BCB 76Mhz - 108Mhz, bit 2 */ + eeprom_ant &= 1<<2; + break; + + case 0xC: /* Airband, bit 3 */ + eeprom_ant &= 1<<3; + break; + + case 0xD: /* 2M, bit 4 */ + eeprom_ant &= 1<<4; + break; + + case 0xE: /* 70cm / UHF, bit 5 */ + eeprom_ant &= 1<<5; + break; + + case 0xF: /* Free-tuning?, bit 6 */ + eeprom_ant &= 1<<6; + break; + } + + /* We have no split TX/RX capability per VFO. + * So only set ant_curr and leave rx/tx set to unknown. */ + *ant_curr = eeprom_ant ? FT817_ANT_REAR : FT817_ANT_FRONT; + + return RIG_OK; +} + /* ---------------------------------------------------------------------- */ int ft817_read_ack(RIG *rig) From 49b2eca6c1d355ce15e15c897e6ef241c989f9e2 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sat, 4 Sep 2021 22:56:06 +0200 Subject: [PATCH 96/97] Add get_ant for 817. NO TESTED! I ONLY HAVE A FT818! --- rigs/yaesu/ft817.c | 52 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 38bc56d21..1ee0e1010 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -57,6 +57,7 @@ #include #include /* String function definitions */ #include /* UNIX standard function definitions */ +#include #ifdef HAVE_SYS_TIME_H #include @@ -172,6 +173,8 @@ 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); +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); /* Native ft817 cmd set prototypes. These are READ ONLY as each */ /* rig instance will copy from these and modify if required . */ @@ -435,6 +438,7 @@ const struct rig_caps ft817_caps = .power2mW = ft817_power2mW, .mW2power = ft817_mW2power, .set_powerstat = ft817_set_powerstat, + .get_ant = ft817_get_ant, .get_level = ft817_get_level, .set_func = ft817_set_func, .vfo_op = ft817_vfo_op, @@ -581,7 +585,7 @@ const struct rig_caps ft818_caps = .power2mW = ft817_power2mW, .mW2power = ft817_mW2power, .set_powerstat = ft817_set_powerstat, - .get_ant = ft817_get_ant, + .get_ant = ft818_get_ant, .get_level = ft817_get_level, .set_func = ft817_set_func, .vfo_op = ft817_vfo_op, @@ -1020,6 +1024,7 @@ static int ft817_get_tx_level(RIG *rig, value_t *val, unsigned char *tx_level, c } val->f = rig_raw2val_float(*tx_level, cal); + rig_debug(RIG_DEBUG_VERBOSE, "%s: level %f\n", __func__, val->f); return RIG_OK; } @@ -1146,10 +1151,11 @@ static int ft817_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) return RIG_OK; } -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) +static int ft818_817_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, bool is817) { - /* The FT818/817 has no targetable antenna, so rig.c switched the active VFO */ + /* The FT818/817 has no RIG_TARGETABLE_ALL + * so rig.c switched the active VFO to the one requested */ int ret; unsigned char eeprom_band, eeprom_ant; @@ -1176,7 +1182,7 @@ static int ft817_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) { + switch (vfo) { case RIG_VFO_A: eeprom_band &= 0xF; break; @@ -1190,16 +1196,29 @@ static int ft817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, return -RIG_EINTERNAL; } + /* The 818 and the 817 differ in bands: the 818 has 60m. + * The band selection flags for the 818 and 817 thus differ: + * 2 means 60m on 818 and 40m for 817. + * And the rest of the values are shifted. + * + * So to make the code simple: if we have a 817 and 2 or higher band then + * add 1 to the value to align it on the 818 mapping. + */ + if (is817 && eeprom_band >= 2) + { + eeprom_band++; + } + /* The 817/818 does not have a antenna selection per VFO but per band. * So we read the band for the requested VFO and then map it to the * selected antenna. - * TODO THIS IS 818 specific info: the 817 does not have 60m and - * thus has a shifted numbering! */ - switch(eeprom_band) { + + + switch (eeprom_band) { case 0: /* 160M */ case 1: /* 80M */ - case 2: /* 60M */ + case 2: /* 60M, 818 only */ case 3: /* 40M */ case 4: /* 30M */ case 5: /* 20M */ @@ -1243,6 +1262,21 @@ static int ft817_get_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t *option, return RIG_OK; } +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) +{ + return ft818_817_get_ant(rig, vfo, ant, option, ant_curr, ant_tx, ant_rx, + 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) +{ + return ft818_817_get_ant(rig, vfo, ant, option, ant_curr, ant_tx, ant_rx, + false); + +} /* ---------------------------------------------------------------------- */ int ft817_read_ack(RIG *rig) From 6f02f38fdc752270b7cac6311bc8434d0d624600 Mon Sep 17 00:00:00 2001 From: Wouter van Gulik Date: Sun, 29 Aug 2021 22:01:12 +0200 Subject: [PATCH 97/97] Add 60m to the 818 tx capabilities, it is one fo the few differences between 818 and 817. --- rigs/yaesu/ft817.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 1ee0e1010..7e3619ac8 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -500,7 +500,10 @@ const struct rig_caps ft818_caps = .tx_range_list1 = { FRQ_RNG_HF(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS), FRQ_RNG_HF(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS), - /* TODO 60m is available seems always available on the 818 */ + + /* One of the key differences between 817 and 818: the 818 has 60m! */ + FRQ_RNG_60m(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS), + FRQ_RNG_60m(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS), FRQ_RNG_6m(1, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS), FRQ_RNG_6m(1, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS), @@ -526,7 +529,10 @@ const struct rig_caps ft818_caps = .tx_range_list2 = { FRQ_RNG_HF(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS), FRQ_RNG_HF(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS), - /* FIXME: 60 meters in US version */ + + /* One of the key differences between 817 and 818: the 818 has 60m! */ + FRQ_RNG_60m(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS), + FRQ_RNG_60m(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS), FRQ_RNG_6m(2, FT817_OTHER_TX_MODES, W(0.5), W(5), FT817_VFO_ALL, FT817_ANTS), FRQ_RNG_6m(2, FT817_AM_TX_MODES, W(0.5), W(1.5), FT817_VFO_ALL, FT817_ANTS),