hamlib-cvs-digest Mailing List for Ham Radio Control Libraries
Library to control radio transceivers and receivers
Brought to you by:
n0nb
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(57) |
Nov
(27) |
Dec
(25) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(41) |
Feb
(101) |
Mar
(60) |
Apr
(32) |
May
(32) |
Jun
(198) |
Jul
(95) |
Aug
(60) |
Sep
(48) |
Oct
(96) |
Nov
(27) |
Dec
(222) |
2002 |
Jan
(180) |
Feb
(46) |
Mar
(68) |
Apr
(11) |
May
(36) |
Jun
(34) |
Jul
(113) |
Aug
(42) |
Sep
(71) |
Oct
(65) |
Nov
(116) |
Dec
(40) |
2003 |
Jan
(32) |
Feb
(92) |
Mar
(29) |
Apr
(102) |
May
(21) |
Jun
(34) |
Jul
(3) |
Aug
(60) |
Sep
(30) |
Oct
(62) |
Nov
(57) |
Dec
(33) |
2004 |
Jan
(28) |
Feb
(46) |
Mar
(16) |
Apr
(14) |
May
(31) |
Jun
(21) |
Jul
(10) |
Aug
(80) |
Sep
(42) |
Oct
(11) |
Nov
(28) |
Dec
(13) |
2005 |
Jan
(35) |
Feb
(26) |
Mar
(20) |
Apr
(118) |
May
(2) |
Jun
(5) |
Jul
|
Aug
|
Sep
(5) |
Oct
(1) |
Nov
(13) |
Dec
(1) |
2006 |
Jan
(9) |
Feb
(25) |
Mar
(22) |
Apr
(6) |
May
|
Jun
|
Jul
(2) |
Aug
(1) |
Sep
(3) |
Oct
(46) |
Nov
(13) |
Dec
(7) |
2007 |
Jan
(9) |
Feb
(14) |
Mar
(3) |
Apr
|
May
(6) |
Jun
(1) |
Jul
|
Aug
(11) |
Sep
(7) |
Oct
(8) |
Nov
(41) |
Dec
(3) |
2008 |
Jan
(27) |
Feb
(16) |
Mar
(13) |
Apr
(23) |
May
(39) |
Jun
(4) |
Jul
(7) |
Aug
(1) |
Sep
(13) |
Oct
(52) |
Nov
(44) |
Dec
(55) |
2009 |
Jan
(72) |
Feb
(69) |
Mar
|
Apr
|
May
|
Jun
(13) |
Jul
(1) |
Aug
(6) |
Sep
(15) |
Oct
(11) |
Nov
(31) |
Dec
(20) |
2010 |
Jan
(24) |
Feb
(21) |
Mar
(22) |
Apr
(40) |
May
(38) |
Jun
(4) |
Jul
(2) |
Aug
(22) |
Sep
(19) |
Oct
(14) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(14) |
Feb
(36) |
Mar
(6) |
Apr
|
May
|
Jun
(23) |
Jul
(13) |
Aug
(8) |
Sep
(7) |
Oct
|
Nov
(3) |
Dec
(9) |
2012 |
Jan
(17) |
Feb
(13) |
Mar
(10) |
Apr
|
May
(1) |
Jun
(14) |
Jul
(4) |
Aug
(12) |
Sep
(2) |
Oct
(24) |
Nov
(14) |
Dec
(2) |
2013 |
Jan
(4) |
Feb
(3) |
Mar
(3) |
Apr
(3) |
May
(10) |
Jun
(4) |
Jul
(7) |
Aug
|
Sep
(15) |
Oct
(5) |
Nov
(1) |
Dec
(2) |
2014 |
Jan
|
Feb
(8) |
Mar
(1) |
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
(3) |
Oct
(7) |
Nov
(6) |
Dec
(3) |
2015 |
Jan
(4) |
Feb
(5) |
Mar
(8) |
Apr
(8) |
May
(2) |
Jun
|
Jul
(4) |
Aug
(7) |
Sep
(8) |
Oct
|
Nov
(6) |
Dec
(4) |
2016 |
Jan
(6) |
Feb
(26) |
Mar
(3) |
Apr
(10) |
May
(6) |
Jun
(5) |
Jul
(1) |
Aug
(4) |
Sep
(3) |
Oct
(4) |
Nov
(3) |
Dec
(10) |
2017 |
Jan
(11) |
Feb
(11) |
Mar
(2) |
Apr
(1) |
May
(7) |
Jun
(2) |
Jul
(11) |
Aug
(9) |
Sep
(5) |
Oct
(5) |
Nov
(1) |
Dec
(2) |
2018 |
Jan
(5) |
Feb
(2) |
Mar
(19) |
Apr
(7) |
May
(11) |
Jun
(3) |
Jul
(4) |
Aug
(10) |
Sep
(2) |
Oct
(8) |
Nov
(6) |
Dec
(9) |
2019 |
Jan
(9) |
Feb
(6) |
Mar
(2) |
Apr
(4) |
May
(6) |
Jun
(9) |
Jul
(6) |
Aug
(3) |
Sep
(5) |
Oct
(2) |
Nov
(8) |
Dec
(9) |
2020 |
Jan
(15) |
Feb
(1) |
Mar
(18) |
Apr
(33) |
May
(43) |
Jun
(87) |
Jul
(45) |
Aug
(8) |
Sep
(43) |
Oct
(3) |
Nov
(5) |
Dec
(42) |
2021 |
Jan
(116) |
Feb
(40) |
Mar
(58) |
Apr
(48) |
May
(29) |
Jun
(2) |
Jul
|
Aug
(22) |
Sep
(18) |
Oct
(1) |
Nov
|
Dec
(3) |
2022 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
(6) |
Nov
(2) |
Dec
(9) |
2023 |
Jan
(10) |
Feb
|
Mar
|
Apr
(10) |
May
(3) |
Jun
(1) |
Jul
(2) |
Aug
(4) |
Sep
(1) |
Oct
|
Nov
(2) |
Dec
(3) |
2024 |
Jan
(4) |
Feb
(1) |
Mar
(2) |
Apr
(2) |
May
(5) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
(2) |
Nov
(3) |
Dec
(9) |
2025 |
Jan
(5) |
Feb
(5) |
Mar
|
Apr
(10) |
May
(20) |
Jun
(43) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: n0nb <n0...@us...> - 2025-07-01 20:36:47
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 623ff17f61e227d461fca524c60a331c9a897672 (commit) via 7acb809eef99b923149a3efa088aba05f3aaffca (commit) from ca7353abaab701eca3893bdad3f1895d22239b85 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 623ff17f61e227d461fca524c60a331c9a897672 Author: Daniele Forsi IU5HKX <iu...@gm...> Date: Mon Jun 30 23:42:10 2025 +0200 Build all language bindings diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index d635fb592..3988d64e0 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -22,6 +22,7 @@ jobs: sudo apt install libgpiod-dev sudo apt install grep sudo apt install python3-dev python3-pytest + sudo apt install lua5.4 liblua5.4-dev libperl-dev tcl-dev - name: Install dependencies on macOS if: runner.os == 'macOS' run: | @@ -40,7 +41,7 @@ jobs: run: grep README Makefile.am - name: configure if: runner.os != 'macOS' - run: ./configure --with-python-binding + run: ./configure --with-lua-binding --with-perl-binding --with-python-binding --with-tcl-binding - name: configure on macOS if: runner.os == 'macOS' run: ./configure --without-python-binding commit 7acb809eef99b923149a3efa088aba05f3aaffca Author: Daniele Forsi IU5HKX <iu...@gm...> Date: Mon Jun 30 23:41:12 2025 +0200 Do not try to compile Python code when building other bindings Fixes the issue reported by @dl8fcl https://github.com/Hamlib/Hamlib/commit/f7d38f92cac73fb8b952f5dde3853f40ef910e14#commitcomment-161078321 diff --git a/bindings/amplifier.swg b/bindings/amplifier.swg index a22a02765..d352cf3b4 100644 --- a/bindings/amplifier.swg +++ b/bindings/amplifier.swg @@ -148,6 +148,7 @@ typedef struct Amp { AMPMETHOD1GET(get_powerstat, powerstat_t) +#ifdef SWIGPYTHON PyObject * get_level(setting_t level) { value_t val; @@ -163,5 +164,5 @@ typedef struct Amp { return PyLong_FromLong(val.i); } - +#endif }; diff --git a/bindings/rotator.swg b/bindings/rotator.swg index 7cff51045..9aedbbd31 100644 --- a/bindings/rotator.swg +++ b/bindings/rotator.swg @@ -119,6 +119,7 @@ typedef struct Rot { ROTMETHOD2(set_conf, hamlib_token_t, const_char_string) +#ifdef SWIGPYTHON ROT_GET_LONG(func) ROT_GET_LONG(ext_func) @@ -127,6 +128,7 @@ typedef struct Rot { ROT_GET_VALUE_T(parm) ROT_GET_VALUE_T(ext_parm) +#endif const char *get_conf(hamlib_token_t tok) { static char s[128] = ""; ----------------------------------------------------------------------- Summary of changes: .github/workflows/c-cpp.yml | 3 ++- bindings/amplifier.swg | 3 ++- bindings/rotator.swg | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-30 13:19:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via ca7353abaab701eca3893bdad3f1895d22239b85 (commit) via 3b6577834eac8f46e6c3d3264509f9401a6f88d2 (commit) via b365d988a42ba468bc663f3d59043f75bc245fa2 (commit) from a6fb8a079a562014b9948e16a2dd817346fcf4e2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ca7353abaab701eca3893bdad3f1895d22239b85 Merge: a6fb8a079 3b6577834 Author: Nate Bargmann <n0...@n0...> Date: Mon Jun 30 07:39:41 2025 -0500 Merge GitHun PR #1788 commit 3b6577834eac8f46e6c3d3264509f9401a6f88d2 Author: aa5sh <844...@us...> Date: Sat Jun 28 16:55:25 2025 -0500 Added RetVal diff --git a/rigs/flexradio/smartsdr.c b/rigs/flexradio/smartsdr.c index 16c8402ab..b61da374a 100644 --- a/rigs/flexradio/smartsdr.c +++ b/rigs/flexradio/smartsdr.c @@ -625,25 +625,27 @@ int sdr1k_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) int smartsdr_send_morse(RIG *rig, vfo_t vfo, const char *msg) { int buf_len; + int retval; buf_len = strlen(msg) + 12; char cmd[buf_len]; ENTERFUNC; sprintf(cmd, "cwx send \"%s\"", msg); - smartsdr_transaction(rig, cmd); + retval = smartsdr_transaction(rig, cmd); - RETURNFUNC(RIG_OK); + RETURNFUNC(retval); } int smartsdr_stop_morse(RIG *rig, vfo_t vfo) { + int retval; char cmd[64]; ENTERFUNC; sprintf(cmd, "cwx clear"); - smartsdr_transaction(rig, cmd); + retval = smartsdr_transaction(rig, cmd); - RETURNFUNC(RIG_OK); + RETURNFUNC(retval); } \ No newline at end of file commit b365d988a42ba468bc663f3d59043f75bc245fa2 Author: Michael Morgan <844...@us...> Date: Sat Jun 28 08:08:59 2025 -0500 FlexCW Added the option to send CW using CWX commands on Flex's. diff --git a/rigs/flexradio/smartsdr.c b/rigs/flexradio/smartsdr.c index e91cab9c0..16c8402ab 100644 --- a/rigs/flexradio/smartsdr.c +++ b/rigs/flexradio/smartsdr.c @@ -45,6 +45,8 @@ static int smartsdr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); static int smartsdr_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int smartsdr_send_morse(RIG *rig, vfo_t vfo, const char *msg); +static int smartsdr_stop_morse(RIG *rig, vfo_t vfo); //static int smartsdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); struct smartsdr_priv_data @@ -619,3 +621,29 @@ int sdr1k_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } } #endif + +int smartsdr_send_morse(RIG *rig, vfo_t vfo, const char *msg) +{ + int buf_len; + buf_len = strlen(msg) + 12; + char cmd[buf_len]; + ENTERFUNC; + + sprintf(cmd, "cwx send \"%s\"", msg); + smartsdr_transaction(rig, cmd); + + RETURNFUNC(RIG_OK); + +} + +int smartsdr_stop_morse(RIG *rig, vfo_t vfo) +{ + char cmd[64]; + ENTERFUNC; + + sprintf(cmd, "cwx clear"); + smartsdr_transaction(rig, cmd); + + RETURNFUNC(RIG_OK); + +} \ No newline at end of file diff --git a/rigs/flexradio/smartsdr_caps.h b/rigs/flexradio/smartsdr_caps.h index 4736412f2..ca6487a94 100644 --- a/rigs/flexradio/smartsdr_caps.h +++ b/rigs/flexradio/smartsdr_caps.h @@ -75,4 +75,6 @@ // .reset = smartsdr_reset, // .set_level = smartsdr_set_level, // .set_func = _set_func, + .send_morse = smartsdr_send_morse, + .stop_morse = smartsdr_stop_morse, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS ----------------------------------------------------------------------- Summary of changes: rigs/flexradio/smartsdr.c | 30 ++++++++++++++++++++++++++++++ rigs/flexradio/smartsdr_caps.h | 2 ++ 2 files changed, 32 insertions(+) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-30 12:58:08
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, Hamlib-4.6.3 has been updated via e03441d9aed44c556dd0acc45f6438b1e6ad6942 (commit) via 0accc406c836cb56ff2fa165c806f0a21ffd1bc5 (commit) via c0d7a320565a50fefb8372571a2f5ab1ff965e00 (commit) from 8abb5efcf0b3eec5e9e7f8d1dac6bc4e10c7f560 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e03441d9aed44c556dd0acc45f6438b1e6ad6942 Author: Nate Bargmann <n0...@n0...> Date: Mon Jun 30 07:56:05 2025 -0500 Update NEWS for Flex CW diff --git a/NEWS b/NEWS index e0eb64e46..c23a496ca 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,7 @@ Version 4.6.4 * Fix powerstat check for Icom R75 which rejects the command. (TNX Mark Fine). * Restore TS-590S/SG RIG_LEVEL_RFPOWER_METER, Fix rotctl \dump_caps output (TNX, George Baltz). + * Add CW sending capability to Flex SmartSDR. (TNX Michael Morgan) Version 4.6.3 * 2025-06-10 commit 0accc406c836cb56ff2fa165c806f0a21ffd1bc5 Author: aa5sh <844...@us...> Date: Sat Jun 28 16:55:25 2025 -0500 Added RetVal (cherry picked from commit 3b6577834eac8f46e6c3d3264509f9401a6f88d2) diff --git a/rigs/flexradio/smartsdr.c b/rigs/flexradio/smartsdr.c index 16c8402ab..b61da374a 100644 --- a/rigs/flexradio/smartsdr.c +++ b/rigs/flexradio/smartsdr.c @@ -625,25 +625,27 @@ int sdr1k_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) int smartsdr_send_morse(RIG *rig, vfo_t vfo, const char *msg) { int buf_len; + int retval; buf_len = strlen(msg) + 12; char cmd[buf_len]; ENTERFUNC; sprintf(cmd, "cwx send \"%s\"", msg); - smartsdr_transaction(rig, cmd); + retval = smartsdr_transaction(rig, cmd); - RETURNFUNC(RIG_OK); + RETURNFUNC(retval); } int smartsdr_stop_morse(RIG *rig, vfo_t vfo) { + int retval; char cmd[64]; ENTERFUNC; sprintf(cmd, "cwx clear"); - smartsdr_transaction(rig, cmd); + retval = smartsdr_transaction(rig, cmd); - RETURNFUNC(RIG_OK); + RETURNFUNC(retval); } \ No newline at end of file commit c0d7a320565a50fefb8372571a2f5ab1ff965e00 Author: Michael Morgan <844...@us...> Date: Sat Jun 28 08:08:59 2025 -0500 FlexCW Added the option to send CW using CWX commands on Flex's. (cherry picked from commit b365d988a42ba468bc663f3d59043f75bc245fa2) diff --git a/rigs/flexradio/smartsdr.c b/rigs/flexradio/smartsdr.c index e91cab9c0..16c8402ab 100644 --- a/rigs/flexradio/smartsdr.c +++ b/rigs/flexradio/smartsdr.c @@ -45,6 +45,8 @@ static int smartsdr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); static int smartsdr_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int smartsdr_send_morse(RIG *rig, vfo_t vfo, const char *msg); +static int smartsdr_stop_morse(RIG *rig, vfo_t vfo); //static int smartsdr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); struct smartsdr_priv_data @@ -619,3 +621,29 @@ int sdr1k_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } } #endif + +int smartsdr_send_morse(RIG *rig, vfo_t vfo, const char *msg) +{ + int buf_len; + buf_len = strlen(msg) + 12; + char cmd[buf_len]; + ENTERFUNC; + + sprintf(cmd, "cwx send \"%s\"", msg); + smartsdr_transaction(rig, cmd); + + RETURNFUNC(RIG_OK); + +} + +int smartsdr_stop_morse(RIG *rig, vfo_t vfo) +{ + char cmd[64]; + ENTERFUNC; + + sprintf(cmd, "cwx clear"); + smartsdr_transaction(rig, cmd); + + RETURNFUNC(RIG_OK); + +} \ No newline at end of file diff --git a/rigs/flexradio/smartsdr_caps.h b/rigs/flexradio/smartsdr_caps.h index 4736412f2..ca6487a94 100644 --- a/rigs/flexradio/smartsdr_caps.h +++ b/rigs/flexradio/smartsdr_caps.h @@ -75,4 +75,6 @@ // .reset = smartsdr_reset, // .set_level = smartsdr_set_level, // .set_func = _set_func, + .send_morse = smartsdr_send_morse, + .stop_morse = smartsdr_stop_morse, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS ----------------------------------------------------------------------- Summary of changes: NEWS | 1 + rigs/flexradio/smartsdr.c | 30 ++++++++++++++++++++++++++++++ rigs/flexradio/smartsdr_caps.h | 2 ++ 3 files changed, 33 insertions(+) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-30 12:38:02
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via a6fb8a079a562014b9948e16a2dd817346fcf4e2 (commit) via b95d349bff845a6cc936f838087fdce62aa7194d (commit) via 6797ab7646030b93ebffdcb57e8583928d106a5f (commit) via c2d4fbe601c7d6dce463d133634c2458e0489fd3 (commit) via a61877a60be23df45439cc607585ecfe55d46395 (commit) via 19c2cc03156846d22262536e9cde7f70deff26db (commit) via dee29c555f98413486dd7110b601aa403035970d (commit) via abf6be0b5e80b3d2376ac873ccf2602ad8e8199f (commit) via c9161e2e25d80609d5127ca0c1ebe8e78cb00040 (commit) from 862fda58be871ce33f9d946c30d61232dd41549c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a6fb8a079a562014b9948e16a2dd817346fcf4e2 Author: 声纳 <159...@qq...> Date: Mon Jun 30 08:43:04 2025 +0800 Update copyright to GUOHETEC in license headers for all GUOHETEC driver files diff --git a/rigs/guohetec/guohetec.c b/rigs/guohetec/guohetec.c index 16334e119..7df6cc346 100644 --- a/rigs/guohetec/guohetec.c +++ b/rigs/guohetec/guohetec.c @@ -1,6 +1,6 @@ /* * Hamlib GUOHETEC backend - common functions - * Copyright (c) 2024 by [Your Name] + * Copyright (c) 2024 by GUOHETEC * * * This library is free software; you can redistribute it and/or diff --git a/rigs/guohetec/guohetec.h b/rigs/guohetec/guohetec.h index 0e58b44e0..ca6c4b777 100644 --- a/rigs/guohetec/guohetec.h +++ b/rigs/guohetec/guohetec.h @@ -1,6 +1,6 @@ /* * Hamlib GUOHETEC backend - common header file - * Copyright (c) 2024 by [Your Name] + * Copyright (c) 2024 by GUOHETEC * * * This library is free software; you can redistribute it and/or diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index 9844fd8ad..9522fce58 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -1,6 +1,6 @@ /* * Hamlib GUOHETEC PMR-171 backend - main file - * Copyright (c) 2024 by [Your Name] + * Copyright (c) 2024 by GUOHETEC * * * This library is free software; you can redistribute it and/or diff --git a/rigs/guohetec/q900.c b/rigs/guohetec/q900.c index 943e25eb7..27e755d40 100644 --- a/rigs/guohetec/q900.c +++ b/rigs/guohetec/q900.c @@ -1,6 +1,6 @@ /* * Hamlib GUOHETEC Q900 backend - main file - * Copyright (c) 2024 by [Your Name] + * Copyright (c) 2024 by GUOHETEC * * * This library is free software; you can redistribute it and/or commit b95d349bff845a6cc936f838087fdce62aa7194d Author: 声纳 <159...@qq...> Date: Mon Jun 30 08:41:13 2025 +0800 Add LGPLv2.1 license headers to GUOHETEC driver files diff --git a/rigs/guohetec/guohetec.c b/rigs/guohetec/guohetec.c index d2d797c1c..16334e119 100644 --- a/rigs/guohetec/guohetec.c +++ b/rigs/guohetec/guohetec.c @@ -1,3 +1,24 @@ +/* + * Hamlib GUOHETEC backend - common functions + * Copyright (c) 2024 by [Your Name] + * + * + * 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 <string.h> #include <hamlib/rig.h> #include "iofunc.h" diff --git a/rigs/guohetec/guohetec.h b/rigs/guohetec/guohetec.h index 06d944f54..0e58b44e0 100644 --- a/rigs/guohetec/guohetec.h +++ b/rigs/guohetec/guohetec.h @@ -1,3 +1,24 @@ +/* + * Hamlib GUOHETEC backend - common header file + * Copyright (c) 2024 by [Your Name] + * + * + * 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 + * + */ + // rigs/guohetec/guohetec.h #ifndef _guohetec_H_ #define _guohetec_H_ diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index 38a5ada07..9844fd8ad 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -1,3 +1,24 @@ +/* + * Hamlib GUOHETEC PMR-171 backend - main file + * Copyright (c) 2024 by [Your Name] + * + * + * 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 <stdlib.h> #include <string.h> /* String function definitions */ #include <stdbool.h> diff --git a/rigs/guohetec/q900.c b/rigs/guohetec/q900.c index 2e6d6bc0e..943e25eb7 100644 --- a/rigs/guohetec/q900.c +++ b/rigs/guohetec/q900.c @@ -1,3 +1,24 @@ +/* + * Hamlib GUOHETEC Q900 backend - main file + * Copyright (c) 2024 by [Your Name] + * + * + * 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 <stdlib.h> #include <string.h> /* String function definitions */ #include <stdbool.h> commit 6797ab7646030b93ebffdcb57e8583928d106a5f Author: 声纳 <159...@qq...> Date: Sat Jun 28 17:13:12 2025 +0800 guohetec: fix cppcheck warnings and improve code quality Based on cppcheck analysis and maintainer feedback: - Fix constParameterPointer warnings: declare reply parameters as const where appropriate - Fix variableScope warnings: reduce reply variable scope to minimum required - Apply IWYU (IncludeWhatYouUse) suggestions for header optimization: * Add iofunc.h (for read_block, write_block functions) * Add riglist.h (for RIG_MODEL_* constants) * Remove unistd.h, misc.h, serial.h (unnecessary includes) - Maintain backward compatibility and existing functionality - Improve code maintainability and reduce compilation warnings All changes follow maintainer recommendations and maintain WSJT-X compatibility. diff --git a/rigs/guohetec/guohetec.c b/rigs/guohetec/guohetec.c index d5019c39a..d2d797c1c 100644 --- a/rigs/guohetec/guohetec.c +++ b/rigs/guohetec/guohetec.c @@ -189,7 +189,7 @@ int read_rig_response(RIG *rig, unsigned char *reply, int reply_size, * @param func_name Function name for debug messages * @return 0 on success, -1 on error */ -int validate_rig_response(RIG *rig, unsigned char *reply, int reply_size, +int validate_rig_response(RIG *rig, const unsigned char *reply, int reply_size, const char *func_name) { // Validate packet header @@ -213,7 +213,7 @@ int validate_rig_response(RIG *rig, unsigned char *reply, int reply_size, * @param func_name Function name for debug messages * @return 0 on success, -1 on error */ -int validate_freq_response(RIG *rig, unsigned char *reply, int reply_size, +int validate_freq_response(RIG *rig, const unsigned char *reply, int reply_size, const char *func_name) { // Basic validation @@ -257,7 +257,7 @@ int validate_freq_response(RIG *rig, unsigned char *reply, int reply_size, * @param min_length Minimum required data length * @return 0 on success, -1 on error */ -int validate_mode_response(RIG *rig, unsigned char *reply, int reply_size, +int validate_mode_response(RIG *rig, const unsigned char *reply, int reply_size, const char *func_name, int min_length) { // Basic validation @@ -305,8 +305,6 @@ DECLARE_PROBERIG_BACKEND(guohetec) { 0x0B, 0x00, 0x00 }; - - uint8_t reply[PMR171_REPLY_LENGTH]; int orig_rate = port->parm.serial.rate; int orig_timeout = port->timeout; @@ -314,6 +312,8 @@ DECLARE_PROBERIG_BACKEND(guohetec) { const int rates[] = {9600, 19200, 38400, 57600, 115200, 0}; for (int i = 0; rates[i]; i++) { + uint8_t reply[PMR171_REPLY_LENGTH]; + port->parm.serial.rate = rates[i]; port->timeout = 500; diff --git a/rigs/guohetec/guohetec.h b/rigs/guohetec/guohetec.h index 589e2e3f7..06d944f54 100644 --- a/rigs/guohetec/guohetec.h +++ b/rigs/guohetec/guohetec.h @@ -61,13 +61,13 @@ unsigned char *to_be(unsigned char data[], unsigned long long freq, unsigned int unsigned long long from_be(const unsigned char data[],unsigned int byte_len); // Common response validation functions -int validate_rig_response(RIG *rig, unsigned char *reply, int reply_size, +int validate_rig_response(RIG *rig, const unsigned char *reply, int reply_size, const char *func_name); int read_rig_response(RIG *rig, unsigned char *reply, int reply_size, const char *func_name); -int validate_freq_response(RIG *rig, unsigned char *reply, int reply_size, +int validate_freq_response(RIG *rig, const unsigned char *reply, int reply_size, const char *func_name); -int validate_mode_response(RIG *rig, unsigned char *reply, int reply_size, +int validate_mode_response(RIG *rig, const unsigned char *reply, int reply_size, const char *func_name, int min_length); #endif // _guohetec_H_ diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index 51183af98..38a5ada07 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -367,39 +367,39 @@ static int pmr171_open(RIG *rig) cmd[6] = crc >> 8; cmd[7] = crc & 0xFF; - // Receive buffer and send command - unsigned char reply[40]; - pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); - - // Validate response using common function - if (validate_freq_response(rig, reply, sizeof(reply), __func__) < 0) { - RETURN_CACHED_FREQ(rig, vfo, freq); - } + { + unsigned char reply[40]; + pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); - // Parse frequency (big-endian) - int freq_a_offset = 9; // VFOA frequency starting position - int freq_b_offset = 13; // VFOB frequency starting position + // Validate response using common function + if (validate_freq_response(rig, reply, sizeof(reply), __func__) < 0) { + RETURN_CACHED_FREQ(rig, vfo, freq); + } - uint32_t freq_a = (reply[freq_a_offset] << 24) | - (reply[freq_a_offset+1] << 16) | - (reply[freq_a_offset+2] << 8) | - reply[freq_a_offset+3]; + // Parse frequency (big-endian) + int freq_a_offset = 9; // VFOA frequency starting position + int freq_b_offset = 13; // VFOB frequency starting position - uint32_t freq_b = (reply[freq_b_offset] << 24) | - (reply[freq_b_offset+1] << 16) | - (reply[freq_b_offset+2] << 8) | - reply[freq_b_offset+3]; + uint32_t freq_a = (reply[freq_a_offset] << 24) | + (reply[freq_a_offset+1] << 16) | + (reply[freq_a_offset+2] << 8) | + reply[freq_a_offset+3]; - // Update cache - CACHE(rig)->freqMainA = (freq_t)freq_a; - CACHE(rig)->freqMainB = (freq_t)freq_b; + uint32_t freq_b = (reply[freq_b_offset] << 24) | + (reply[freq_b_offset+1] << 16) | + (reply[freq_b_offset+2] << 8) | + reply[freq_b_offset+3]; - // Return requested VFO frequency - *freq = (vfo == RIG_VFO_A) ? CACHE(rig)->freqMainA : CACHE(rig)->freqMainB; + // Update cache + CACHE(rig)->freqMainA = (freq_t)freq_a; + CACHE(rig)->freqMainB = (freq_t)freq_b; - rig_debug(RIG_DEBUG_VERBOSE, "%s: Successfully got VFOA=%.0f Hz, VFOB=%.0f Hz\n", - __func__, CACHE(rig)->freqMainA, CACHE(rig)->freqMainB); + // Return requested VFO frequency + *freq = (vfo == RIG_VFO_A) ? CACHE(rig)->freqMainA : CACHE(rig)->freqMainB; + rig_debug(RIG_DEBUG_VERBOSE, "%s: Successfully got VFOA=%.0f Hz, VFOB=%.0f Hz\n", + __func__, CACHE(rig)->freqMainA, CACHE(rig)->freqMainB); + } return RIG_OK; } @@ -407,28 +407,25 @@ static int pmr171_open(RIG *rig) { struct rig_cache *cachep = CACHE(rig); const pmr171_data_t *p = (pmr171_data_t *) STATE(rig)->priv; - unsigned char reply[40]; - - // Get latest status from hardware - pmr171_send_cmd1(rig, 0x0b, 0); - - // Read and validate response using common function - if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { - RETURN_CACHED_MODE(rig, vfo, mode, width, cachep, p); - } - - // Validate mode response using common function - if (validate_mode_response(rig, reply, sizeof(reply), __func__, 5) < 0) { - RETURN_CACHED_MODE(rig, vfo, mode, width, cachep, p); + { + unsigned char reply[40]; + // Get latest status from hardware + pmr171_send_cmd1(rig, 0x0b, 0); + // Read and validate response using common function + if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { + RETURN_CACHED_MODE(rig, vfo, mode, width, cachep, p); + } + // Validate mode response using common function + if (validate_mode_response(rig, reply, sizeof(reply), __func__, 5) < 0) { + RETURN_CACHED_MODE(rig, vfo, mode, width, cachep, p); + } + // Update cache + cachep->modeMainA = guohe2rmode(reply[7], pmr171_modes); + cachep->modeMainB = guohe2rmode(reply[8], pmr171_modes); + // Return requested mode + *mode = (vfo == RIG_VFO_A) ? cachep->modeMainA : cachep->modeMainB; + *width = p->filterBW; } - - // Update cache - cachep->modeMainA = guohe2rmode(reply[7], pmr171_modes); - cachep->modeMainB = guohe2rmode(reply[8], pmr171_modes); - - // Return requested mode - *mode = (vfo == RIG_VFO_A) ? cachep->modeMainA : cachep->modeMainB; - *width = p->filterBW; return RIG_OK; } @@ -445,25 +442,22 @@ static int pmr171_open(RIG *rig) static int pmr171_get_vfo(RIG *rig, vfo_t *vfo) { - unsigned char reply[40]; - - // Send status sync command to get current VFO state - pmr171_send_cmd1(rig, 0x0b, 0); - - // Read and validate response using common function - if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { - RETURN_CACHED_VFO(rig, vfo); - } - - // Validate VFO status field index won't overflow - if (reply[4] < 13) { // Need at least 13 bytes to access reply[17] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for VFO data, using cached values\n", __func__); - RETURN_CACHED_VFO(rig, vfo); + { + unsigned char reply[40]; + // Send status sync command to get current VFO state + pmr171_send_cmd1(rig, 0x0b, 0); + // Read and validate response using common function + if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { + RETURN_CACHED_VFO(rig, vfo); + } + // Validate VFO status field index won't overflow + if (reply[4] < 13) { // Need at least 13 bytes to access reply[17] + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for VFO data, using cached values\n", __func__); + RETURN_CACHED_VFO(rig, vfo); + } + // According to protocol doc, reply[17] is A/B frequency status + *vfo = (reply[17] == 1) ? RIG_VFO_B : RIG_VFO_A; } - - // According to protocol doc, reply[17] is A/B frequency status - *vfo = (reply[17] == 1) ? RIG_VFO_B : RIG_VFO_A; - return RIG_OK; } @@ -471,25 +465,22 @@ static int pmr171_open(RIG *rig) static int pmr171_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { struct rig_cache *cachep = CACHE(rig); - unsigned char reply[40]; - - pmr171_send_cmd1(rig, 0x0b, 0); - - // Read and validate response using common function - if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { - RETURN_CACHED_PTT(rig, ptt, cachep); - } - - // Validate PTT status field index won't overflow - if (reply[4] < 2) { // Need at least 2 bytes to access reply[6] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for PTT data, using cached values\n", __func__); - RETURN_CACHED_PTT(rig, ptt, cachep); + { + unsigned char reply[40]; + pmr171_send_cmd1(rig, 0x0b, 0); + // Read and validate response using common function + if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { + RETURN_CACHED_PTT(rig, ptt, cachep); + } + // Validate PTT status field index won't overflow + if (reply[4] < 2) { // Need at least 2 bytes to access reply[6] + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for PTT data, using cached values\n", __func__); + RETURN_CACHED_PTT(rig, ptt, cachep); + } + // Get PTT status + cachep->ptt = reply[6]; + *ptt = cachep->ptt; } - - // Get PTT status - cachep->ptt = reply[6]; - *ptt = cachep->ptt; - return RIG_OK; } @@ -525,28 +516,24 @@ static int pmr171_open(RIG *rig) static int pmr171_send_cmd2(RIG *rig, unsigned char cmd, unsigned char value, int response) { - unsigned char reply[40]; + unsigned char buf[64] = { 0xa5, 0xa5, 0xa5, 0xa5, 0x04, 0x00, 0x00, 0x00, 0x00 }; hamlib_port_t *rp = RIGPORT(rig); rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - unsigned char buf[64] = { 0xa5, 0xa5, 0xa5, 0xa5, 0x04, 0x00, 0x00, 0x00, 0x00 }; - buf[5] = cmd; buf[6] = value; unsigned int crc = CRC16Check(&buf[4], 3); buf[7] = crc >> 8; buf[8] = crc & 0xff; - rig_flush(rp); write_block(rp, buf, 9); - if (response) { + unsigned char reply[40]; // Use common response reading function if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { return RIG_OK; // Return OK to use cached values } } - return pmr171_read_ack(rig); } diff --git a/rigs/guohetec/q900.c b/rigs/guohetec/q900.c index 059106f67..2e6d6bc0e 100644 --- a/rigs/guohetec/q900.c +++ b/rigs/guohetec/q900.c @@ -363,36 +363,32 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) cmd[6] = crc >> 8; cmd[7] = crc & 0xFF; - unsigned char reply[40]; - q900_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); - - // Validate response using common function - if (validate_freq_response(rig, reply, sizeof(reply), __func__) < 0) { - RETURN_CACHED_FREQ(rig, vfo, freq); + { + unsigned char reply[40]; + q900_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); + // Validate response using common function + if (validate_freq_response(rig, reply, sizeof(reply), __func__) < 0) { + RETURN_CACHED_FREQ(rig, vfo, freq); + } + // Parse frequency (big-endian) + int freq_a_offset = 9; // VFOA frequency starting position + int freq_b_offset = 13; // VFOB frequency starting position + uint32_t freq_a = (reply[freq_a_offset] << 24) | + (reply[freq_a_offset+1] << 16) | + (reply[freq_a_offset+2] << 8) | + reply[freq_a_offset+3]; + uint32_t freq_b = (reply[freq_b_offset] << 24) | + (reply[freq_b_offset+1] << 16) | + (reply[freq_b_offset+2] << 8) | + reply[freq_b_offset+3]; + // Update cache + CACHE(rig)->freqMainA = (freq_t)freq_a; + CACHE(rig)->freqMainB = (freq_t)freq_b; + // Return requested VFO frequency + *freq = (vfo == RIG_VFO_A) ? CACHE(rig)->freqMainA : CACHE(rig)->freqMainB; + rig_debug(RIG_DEBUG_VERBOSE, "%s: Successfully got VFOA=%.0f Hz, VFOB=%.0f Hz\n", + __func__, CACHE(rig)->freqMainA, CACHE(rig)->freqMainB); } - - // Parse frequency (big-endian) - int freq_a_offset = 9; - int freq_b_offset = 13; - - uint32_t freq_a = (reply[freq_a_offset] << 24) | - (reply[freq_a_offset+1] << 16) | - (reply[freq_a_offset+2] << 8) | - reply[freq_a_offset+3]; - - uint32_t freq_b = (reply[freq_b_offset] << 24) | - (reply[freq_b_offset+1] << 16) | - (reply[freq_b_offset+2] << 8) | - reply[freq_b_offset+3]; - - CACHE(rig)->freqMainA = (freq_t)freq_a; - CACHE(rig)->freqMainB = (freq_t)freq_b; - - *freq = (vfo == RIG_VFO_A) ? CACHE(rig)->freqMainA : CACHE(rig)->freqMainB; - - rig_debug(RIG_DEBUG_VERBOSE, "%s: Successfully obtained VFOA=%.0f Hz, VFOB=%.0f Hz\n", - __func__, CACHE(rig)->freqMainA, CACHE(rig)->freqMainB); - return RIG_OK; } @@ -400,25 +396,25 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { struct rig_cache *cachep = CACHE(rig); const q900_data_t *p = (q900_data_t *) STATE(rig)->priv; - unsigned char reply[255]; - - q900_send_cmd1(rig, 0x0b, 0); - - // Read and validate response using common function - if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { - RETURN_CACHED_MODE(rig, vfo, mode, width, cachep, p); - } - - // Validate mode response using common function - if (validate_mode_response(rig, reply, sizeof(reply), __func__, 5) < 0) { - RETURN_CACHED_MODE(rig, vfo, mode, width, cachep, p); + { + unsigned char reply[255]; + // Get latest status from hardware + q900_send_cmd1(rig, 0x0b, 0); + // Read and validate response using common function + if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { + RETURN_CACHED_MODE(rig, vfo, mode, width, cachep, p); + } + // Validate mode response using common function + if (validate_mode_response(rig, reply, sizeof(reply), __func__, 5) < 0) { + RETURN_CACHED_MODE(rig, vfo, mode, width, cachep, p); + } + // Update cache + cachep->modeMainA = guohe2rmode(reply[7], q900_modes); + cachep->modeMainB = guohe2rmode(reply[8], q900_modes); + // Return requested mode + *mode = (vfo == RIG_VFO_A) ? cachep->modeMainA : cachep->modeMainB; + *width = p->filterBW; } - - cachep->modeMainA = guohe2rmode(reply[7], q900_modes); - cachep->modeMainB = guohe2rmode(reply[8], q900_modes); - - *mode = (vfo == RIG_VFO_A) ? cachep->modeMainA : cachep->modeMainB; - *width = p->filterBW; return RIG_OK; } @@ -435,29 +431,22 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) static int q900_get_vfo(RIG *rig, vfo_t *vfo) { - unsigned char reply[255]; - - q900_send_cmd1(rig, 0x0b, 0); - - // Read and validate response using common function - if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { - RETURN_CACHED_VFO(rig, vfo); - } - - // Validate VFO status field index won't overflow - if (reply[4] < 13) { // Need at least 13 bytes to access reply[17] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for VFO data, using cached values\n", __func__); - RETURN_CACHED_VFO(rig, vfo); - } - - // Validate VFO status value - if (reply[17] != 0 && reply[17] != 1) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid VFO status value %d, using cached values\n", __func__, reply[17]); - RETURN_CACHED_VFO(rig, vfo); + { + unsigned char reply[255]; + // Send status sync command to get current VFO state + q900_send_cmd1(rig, 0x0b, 0); + // Read and validate response using common function + if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { + RETURN_CACHED_VFO(rig, vfo); + } + // Validate VFO status field index won't overflow + if (reply[4] < 13) { // Need at least 13 bytes to access reply[17] + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for VFO data, using cached values\n", __func__); + RETURN_CACHED_VFO(rig, vfo); + } + // According to protocol doc, reply[17] is A/B frequency status + *vfo = (reply[17] == 1) ? RIG_VFO_B : RIG_VFO_A; } - - *vfo = (reply[17] == 1) ? RIG_VFO_B : RIG_VFO_A; - return RIG_OK; } @@ -465,30 +454,22 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) static int q900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { struct rig_cache *cachep = CACHE(rig); - unsigned char reply[255]; - - q900_send_cmd1(rig, 0x0b, 0); - - // Read and validate response using common function - if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { - RETURN_CACHED_PTT(rig, ptt, cachep); - } - - // Validate PTT status field index won't overflow - if (reply[4] < 2) { // Need at least 2 bytes to access reply[6] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for PTT data, using cached values\n", __func__); - RETURN_CACHED_PTT(rig, ptt, cachep); - } - - // Validate PTT status value - if (reply[6] != 0 && reply[6] != 1) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid PTT status value %d, using cached values\n", __func__, reply[6]); - RETURN_CACHED_PTT(rig, ptt, cachep); + { + unsigned char reply[255]; + q900_send_cmd1(rig, 0x0b, 0); + // Read and validate response using common function + if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { + RETURN_CACHED_PTT(rig, ptt, cachep); + } + // Validate PTT status field index won't overflow + if (reply[4] < 2) { // Need at least 2 bytes to access reply[6] + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for PTT data, using cached values\n", __func__); + RETURN_CACHED_PTT(rig, ptt, cachep); + } + // Get PTT status + cachep->ptt = reply[6]; + *ptt = cachep->ptt; } - - cachep->ptt = reply[6]; - *ptt = cachep->ptt; - return RIG_OK; } @@ -527,28 +508,24 @@ static int q900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) static int q900_send_cmd2(RIG *rig, unsigned char cmd, unsigned char value, int response) { - unsigned char reply[256]; + unsigned char buf[64] = { 0xa5, 0xa5, 0xa5, 0xa5, 0x04, 0x00, 0x00, 0x00, 0x00 }; hamlib_port_t *rp = RIGPORT(rig); rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - unsigned char buf[64] = { 0xa5, 0xa5, 0xa5, 0xa5, 0x04, 0x00, 0x00, 0x00, 0x00 }; - buf[5] = cmd; buf[6] = value; unsigned int crc = CRC16Check(&buf[4], 3); buf[7] = crc >> 8; buf[8] = crc & 0xff; - rig_flush(rp); write_block(rp, buf, 9); - if (response) { + unsigned char reply[256]; // Use common response reading function if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { return RIG_OK; // Return OK to use cached values } } - return q900_read_ack(rig); } commit c2d4fbe601c7d6dce463d133634c2458e0489fd3 Author: 声纳 <159...@qq...> Date: Sat Jun 28 16:56:54 2025 +0800 guohetec: comprehensive code quality improvements - Fix compilation warnings by removing unnecessary dump_hex function calls - Resolve implicit function declaration warnings for validation macros - Remove duplicate GUOHE_MODE_TABLE_MAX definitions across files - Optimize header includes based on IWYU suggestions: * Add iofunc.h (for read_block/write_block functions) * Add riglist.h (for RIG_MODEL_* constants) * Remove unistd.h, misc.h, serial.h (unnecessary includes) - Convert validation macros to functions for better compiler compatibility - Maintain backward compatibility with existing macro definitions - Improve code structure and maintainability - Ensure WSJT-X compatibility with consistent error handling All changes maintain existing functionality while improving code quality and reducing compilation warnings. diff --git a/rigs/guohetec/guohetec.c b/rigs/guohetec/guohetec.c index 794425122..d5019c39a 100644 --- a/rigs/guohetec/guohetec.c +++ b/rigs/guohetec/guohetec.c @@ -1,11 +1,29 @@ -#include <unistd.h> #include <string.h> #include <hamlib/rig.h> -#include "serial.h" +#include "iofunc.h" #include "register.h" +#include "riglist.h" #include "guohetec.h" -#include "misc.h" +// Common response validation function implementations +int validate_packet_header(const unsigned char *reply, const char *func_name) +{ + if (reply[0] != 0xA5 || reply[1] != 0xA5 || + reply[2] != 0xA5 || reply[3] != 0xA5) { + rig_debug(RIG_DEBUG_ERR, "%s: Invalid packet header, using cached values\n", func_name); + return -1; + } + return 0; +} + +int validate_data_length(const unsigned char *reply, int reply_size, const char *func_name) +{ + if (reply[4] == 0 || reply[4] > reply_size - 5) { + rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d, using cached values\n", func_name, reply[4]); + return -1; + } + return 0; +} // CRC16/CCITT-FALSE uint16_t CRC16Check(const unsigned char *buf, int len) @@ -175,10 +193,14 @@ int validate_rig_response(RIG *rig, unsigned char *reply, int reply_size, const char *func_name) { // Validate packet header - VALIDATE_PACKET_HEADER(reply, func_name); + if (validate_packet_header(reply, func_name) < 0) { + return -1; + } // Validate data length - VALIDATE_DATA_LENGTH(reply, reply_size, func_name); + if (validate_data_length(reply, reply_size, func_name) < 0) { + return -1; + } return 0; } diff --git a/rigs/guohetec/guohetec.h b/rigs/guohetec/guohetec.h index 90965a129..589e2e3f7 100644 --- a/rigs/guohetec/guohetec.h +++ b/rigs/guohetec/guohetec.h @@ -31,21 +31,13 @@ return RIG_OK; \ } while(0) -// Common response validation macros -#define VALIDATE_PACKET_HEADER(reply, func_name) do { \ - if (reply[0] != 0xA5 || reply[1] != 0xA5 || \ - reply[2] != 0xA5 || reply[3] != 0xA5) { \ - rig_debug(RIG_DEBUG_ERR, "%s: Invalid packet header, using cached values\n", func_name); \ - return -1; \ - } \ -} while(0) +// Common response validation function declarations +int validate_packet_header(const unsigned char *reply, const char *func_name); +int validate_data_length(const unsigned char *reply, int reply_size, const char *func_name); -#define VALIDATE_DATA_LENGTH(reply, reply_size, func_name) do { \ - if (reply[4] == 0 || reply[4] > (reply_size) - 5) { \ - rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d, using cached values\n", func_name, reply[4]); \ - return -1; \ - } \ -} while(0) +// Keep the macro for backward compatibility +#define VALIDATE_PACKET_HEADER(reply, func_name) validate_packet_header(reply, func_name) +#define VALIDATE_DATA_LENGTH(reply, reply_size, func_name) validate_data_length(reply, reply_size, func_name) #define VALIDATE_READ_RESULT(ret, expected, func_name) do { \ if (ret < 0) { \ diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index e1ede9adf..51183af98 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -7,14 +7,12 @@ #endif #include "hamlib/rig.h" -#include "serial.h" +#include "iofunc.h" #include "guohetec.h" #include "cache.h" -#include "misc.h" #include "tones.h" #include "bandplan.h" #include "cal.h" -#include <unistd.h> typedef struct pmr171_data_s @@ -39,8 +37,6 @@ typedef struct pmr171_data_s char SWR; } pmr171_data_t; - -#define GUOHE_MODE_TABLE_MAX 8 static rmode_t pmr171_modes[GUOHE_MODE_TABLE_MAX] = { RIG_MODE_USB, @@ -598,17 +594,15 @@ static int pmr171_open(RIG *rig) return RIG_OK; } - dump_hex(reply, 16); - - // Update cache with requested frequency - if (vfo == RIG_VFO_B) - { - CACHE(rig)->freqMainB = freq; - } - else - { - CACHE(rig)->freqMainA = freq; - } + // Update cache with requested frequency + if (vfo == RIG_VFO_B) + { + CACHE(rig)->freqMainB = freq; + } + else + { + CACHE(rig)->freqMainA = freq; + } return RIG_OK; } @@ -684,8 +678,6 @@ static int pmr171_open(RIG *rig) return RIG_OK; } - dump_hex(reply, reply[4] + 5); - // Update cache with response data CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes); CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes); diff --git a/rigs/guohetec/q900.c b/rigs/guohetec/q900.c index 7bdcf8392..059106f67 100644 --- a/rigs/guohetec/q900.c +++ b/rigs/guohetec/q900.c @@ -7,14 +7,12 @@ #endif #include "hamlib/rig.h" -#include "serial.h" +#include "iofunc.h" #include "guohetec.h" #include "cache.h" -#include "misc.h" #include "tones.h" #include "bandplan.h" #include "cal.h" -#include <unistd.h> typedef struct q900_data_s { @@ -38,8 +36,6 @@ typedef struct q900_data_s char SWR; } q900_data_t; - -#define GUOHE_MODE_TABLE_MAX 8 static rmode_t q900_modes[GUOHE_MODE_TABLE_MAX] = { RIG_MODE_USB, @@ -599,17 +595,15 @@ static int q900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) return RIG_OK; } - dump_hex(reply, 16); - - // Update cache with requested frequency - if (vfo == RIG_VFO_B) - { - CACHE(rig)->freqMainB = freq; - } - else - { - CACHE(rig)->freqMainA = freq; - } + // Update cache with requested frequency + if (vfo == RIG_VFO_B) + { + CACHE(rig)->freqMainB = freq; + } + else + { + CACHE(rig)->freqMainA = freq; + } return RIG_OK; } @@ -712,8 +706,6 @@ static int q900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) return RIG_OK; } - dump_hex(reply, reply[4] + 5); - // Update cache with response data CACHE(rig)->modeMainA = guohe2rmode(reply[6], q900_modes); CACHE(rig)->modeMainB = guohe2rmode(reply[7], q900_modes); @@ -799,3 +791,4 @@ static int q900_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) } /* ---------------------------------------------------------------------- */ + commit a61877a60be23df45439cc607585ecfe55d46395 Author: 声纳 <159...@qq...> Date: Sat Jun 28 11:07:50 2025 +0800 Fix duplicate stdint.h includes in pmr171.c and q900.c diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index 94704378f..e1ede9adf 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -14,7 +14,6 @@ #include "tones.h" #include "bandplan.h" #include "cal.h" -#include <stdint.h> #include <unistd.h> @@ -272,8 +271,6 @@ struct rig_caps pmr171_caps = .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS }; -#include <stdint.h> - /* ---------------------------------------------------------------------- */ static int pmr171_init(RIG *rig) diff --git a/rigs/guohetec/q900.c b/rigs/guohetec/q900.c index 276861459..7bdcf8392 100644 --- a/rigs/guohetec/q900.c +++ b/rigs/guohetec/q900.c @@ -14,7 +14,6 @@ #include "tones.h" #include "bandplan.h" #include "cal.h" -#include <stdint.h> #include <unistd.h> typedef struct q900_data_s @@ -270,8 +269,6 @@ struct rig_caps q900_caps = .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS }; -#include <stdint.h> - /* ---------------------------------------------------------------------- */ static int q900_init(RIG *rig) commit 19c2cc03156846d22262536e9cde7f70deff26db Author: 声纳 <159...@qq...> Date: Sat Jun 28 11:04:58 2025 +0800 Fix duplicate retval variable definition in guohetec.c probe function diff --git a/rigs/guohetec/guohetec.c b/rigs/guohetec/guohetec.c index 64e9be3d8..794425122 100644 --- a/rigs/guohetec/guohetec.c +++ b/rigs/guohetec/guohetec.c @@ -301,7 +301,6 @@ DECLARE_PROBERIG_BACKEND(guohetec) { rig_flush(port); - int retval = write_block(port, cmd, PMR171_CMD_LENGTH); int retval = write_block(port, cmd, PMR171_CMD_LENGTH); if (retval != RIG_OK) { continue; commit dee29c555f98413486dd7110b601aa403035970d Author: 声纳 <159...@qq...> Date: Sat Jun 28 10:55:20 2025 +0800 Implement consistent error handling for GUOHETEC drivers - Use unified error handling mechanism in send_cmd2 functions - Always return RIG_OK to prevent WSJT-X errors - Update cache with requested values even when communication fails - Use English comments and debug messages - Ensure graceful degradation with cached values on protocol/timeout errors diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index 386c71ff5..94704378f 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -548,22 +548,9 @@ static int pmr171_open(RIG *rig) if (response) { - // Read header - int ret = read_block(rp, reply, 5); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); - } - - // Validate data length - if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { - if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); - } - - // Read data section - ret = read_block(rp, &reply[5], reply[4]); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + // Use common response reading function + if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { + return RIG_OK; // Return OK to use cached values } } @@ -601,11 +588,22 @@ static int pmr171_open(RIG *rig) // Read response and validate length int ret = read_block(rp, reply, sizeof(reply)); if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: Failed to read response\n", __func__); + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read response, using cached values\n", __func__); + // Update cache with requested frequency even if response failed + if (vfo == RIG_VFO_B) + { + CACHE(rig)->freqMainB = freq; + } + else + { + CACHE(rig)->freqMainA = freq; + } + return RIG_OK; } dump_hex(reply, 16); + // Update cache with requested frequency if (vfo == RIG_VFO_B) { CACHE(rig)->freqMainB = freq; @@ -660,31 +658,38 @@ static int pmr171_open(RIG *rig) rig_flush(rp); write_block(rp, cmd, 10); - // Read header - int ret = read_block(rp, reply, 5); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__); - } - - // Validate data length - if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { - rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); - } - - // Read data section - ret = read_block(rp, &reply[5], reply[4]); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__); + // Use common response reading function + if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { + // Update cache with requested mode even if response failed + if (vfo == RIG_VFO_B) + { + CACHE(rig)->modeMainB = mode; + } + else + { + CACHE(rig)->modeMainA = mode; + } + return RIG_OK; } // Validate mode field index won't overflow if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data, using cached values\n", __func__); + // Update cache with requested mode even if validation failed + if (vfo == RIG_VFO_B) + { + CACHE(rig)->modeMainB = mode; + } + else + { + CACHE(rig)->modeMainA = mode; + } + return RIG_OK; } dump_hex(reply, reply[4] + 5); - // Update cache + // Update cache with response data CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes); CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes); diff --git a/rigs/guohetec/q900.c b/rigs/guohetec/q900.c index 8d4b2c1cc..276861459 100644 --- a/rigs/guohetec/q900.c +++ b/rigs/guohetec/q900.c @@ -319,7 +319,6 @@ static int q900_open(RIG *rig) /* ---------------------------------------------------------------------- */ static int q900_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen) - static int q900_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen) { hamlib_port_t *rp = RIGPORT(rig); int retry = 5; @@ -539,43 +538,24 @@ static int q900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) hamlib_port_t *rp = RIGPORT(rig); rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); unsigned char buf[64] = { 0xa5, 0xa5, 0xa5, 0xa5, 0x04, 0x00, 0x00, 0x00, 0x00 }; - + buf[5] = cmd; buf[6] = value; unsigned int crc = CRC16Check(&buf[4], 3); buf[7] = crc >> 8; buf[8] = crc & 0xff; - + rig_flush(rp); write_block(rp, buf, 9); - + if (response) { - // Read header - int ret = read_block(rp, reply, 5); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); - } - - // Validate data length - if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { - if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); - } - - // Read data section - ret = read_block(rp, &reply[5], reply[4]); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); - } - - // Validate response length matches expected - if (ret != reply[4]) { - rig_debug(RIG_DEBUG_ERR, "%s: Data read mismatch: expected %d, got %d\n", - __func__, reply[4], ret); + // Use common response reading function + if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { + return RIG_OK; // Return OK to use cached values } } - + return q900_read_ack(rig); } @@ -586,7 +566,7 @@ static int q900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) unsigned char cmd[16] = { 0xa5, 0xa5, 0xa5, 0xa5, 11, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; unsigned char reply[16]; hamlib_port_t *rp = RIGPORT(rig); - + rig_debug(RIG_DEBUG_VERBOSE, "q900: requested freq = %"PRIfreq" Hz\n", freq); if (vfo == RIG_VFO_B) @@ -609,12 +589,22 @@ static int q900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) // Read response int ret = read_block(rp, reply, 16); if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: Failed to read response\n", __func__); + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read response, using cached values\n", __func__); + // Update cache with requested frequency even if response failed + if (vfo == RIG_VFO_B) + { + CACHE(rig)->freqMainB = freq; + } + else + { + CACHE(rig)->freqMainA = freq; + } + return RIG_OK; } dump_hex(reply, 16); - + // Update cache with requested frequency if (vfo == RIG_VFO_B) { CACHE(rig)->freqMainB = freq; @@ -667,104 +657,67 @@ static int q900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) rig_flush(rp); write_block(rp, cmd, 10); - // Read header - int ret = read_block(rp, reply, 5); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__); - } - - // Validate data length - if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { - rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); - } - - // Read data section - ret = read_block(rp, &reply[5], reply[4]); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__); - } - - // Validate response length matches expected - if (ret != reply[4]) { - rig_debug(RIG_DEBUG_ERR, "%s: Data read mismatch: expected %d, got %d\n", - __func__, reply[4], ret); - } - - // Validate mode field index won't overflow - if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); - } - - // Validate mode field indices are within bounds - if (reply[6] >= GUOHE_MODE_TABLE_MAX) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode A index %d\n", __func__, reply[6]); - } - - if (reply[7] >= GUOHE_MODE_TABLE_MAX) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode B index %d\n", __func__, reply[7]); - } - - dump_hex(reply, reply[4] + 5); - - CACHE(rig)->modeMainA = guohe2rmode(reply[6], q900_modes); - CACHE(rig)->modeMainB = guohe2rmode(reply[7], q900_modes); - - if (vfo == RIG_VFO_B) - { - cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, q900_modes); - cmd[7] = i; - } - else - { - cmd[6] = i; - cmd[7] = rmode2guohe(CACHE(rig)->modeMainB, q900_modes); - } - - int crc = CRC16Check(&cmd[4], 4); - cmd[8] = crc >> 8; - cmd[9] = crc & 0xff; - rig_flush(rp); - write_block(rp, cmd, 10); - - // Read header - int ret = read_block(rp, reply, 5); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__); - } - - // Validate data length - if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { - rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); - } - - // Read data section - ret = read_block(rp, &reply[5], reply[4]); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__); - } - - // Validate response length matches expected - if (ret != reply[4]) { - rig_debug(RIG_DEBUG_ERR, "%s: Data read mismatch: expected %d, got %d\n", - __func__, reply[4], ret); + // Use common response reading function + if (read_rig_response(rig, reply, sizeof(reply), __func__) < 0) { + // Update cache with requested mode even if response failed + if (vfo == RIG_VFO_B) + { + CACHE(rig)->modeMainB = mode; + } + else + { + CACHE(rig)->modeMainA = mode; + } + return RIG_OK; } // Validate mode field index won't overflow if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data, using cached values\n", __func__); + // Update cache with requested mode even if validation failed + if (vfo == RIG_VFO_B) + { + CACHE(rig)->modeMainB = mode; + } + else + { + CACHE(rig)->modeMainA = mode; + } + return RIG_OK; } // Validate mode field indices are within bounds if (reply[6] >= GUOHE_MODE_TABLE_MAX) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode A index %d\n", __func__, reply[6]); + rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode A index %d, using cached values\n", __func__, reply[6]); + // Update cache with requested mode even if validation failed + if (vfo == RIG_VFO_B) + { + CACHE(rig)->modeMainB = mode; + } + else + { + CACHE(rig)->modeMainA = mode; + } + return RIG_OK; } if (reply[7] >= GUOHE_MODE_TABLE_MAX) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode B index %d\n", __func__, reply[7]); + rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode B index %d, using cached values\n", __func__, reply[7]); + // Update cache with requested mode even if validation failed + if (vfo == RIG_VFO_B) + { + CACHE(rig)->modeMainB = mode; + } + else + { + CACHE(rig)->modeMainA = mode; + } + return RIG_OK; } dump_hex(reply, reply[4] + 5); + // Update cache with response data CACHE(rig)->modeMainA = guohe2rmode(reply[6], q900_modes); CACHE(rig)->modeMainB = guohe2rmode(reply[7], q900_modes); @@ -787,7 +740,6 @@ static int q900_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) unsigned char reply[9]; q900_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); - q900_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); // Update cache CACHE(rig)->ptt = ptt; commit abf6be0b5e80b3d2376ac873ccf2602ad8e8199f Author: 声纳 <159...@qq...> Date: Sat Jun 28 10:22:26 2025 +0800 Fix compilation errors in GUOHETEC drivers - Remove duplicate function declarations in pmr171_send - Remove duplicate code blocks in pmr171_set_mode - Remove duplicate pmr171_send calls in pmr171_set_ptt - Add missing from_be function implementation - Fix syntax errors that were causing CI failures diff --git a/rigs/guohetec/guohetec.c b/rigs/guohetec/guohetec.c index 414bc42ae..64e9be3d8 100644 --- a/rigs/guohetec/guohetec.c +++ b/rigs/guohetec/guohetec.c @@ -96,6 +96,26 @@ uint16_t CRC16Check(const unsigned char *buf, int len) return data; } + /** + * Convert from big-endian byte order + * @param data Data pointer + * @param byte_len Byte length + * @return Converted value + */ + unsigned long long from_be(const unsigned char data[], unsigned int byte_len) + { + unsigned long long result = 0; + int i; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + for (i = 0; i < byte_len; i++) + { + result = (result << 8) | data[i]; + } + + return result; + } // Common response validation functions diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index e3ca96877..386c71ff5 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -321,7 +321,6 @@ static int pmr171_open(RIG *rig) /* ---------------------------------------------------------------------- */ static int pmr171_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen) - static int pmr171_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen) { hamlib_port_t *rp = RIGPORT(rig); int retry = 5; @@ -644,16 +643,6 @@ static int pmr171_open(RIG *rig) unsigned char reply[10]; unsigned char i = rmode2guohe(mode, pmr171_modes); - if (vfo == RIG_VFO_B) - { - cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, pmr171_modes); - cmd[7] = i; - } - else - { - cmd[6] = i; - cmd[7] = rmode2guohe(CACHE(rig)->modeMainB, pmr171_modes); - } if (vfo == RIG_VFO_B) { cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, pmr171_modes); @@ -695,39 +684,6 @@ static int pmr171_open(RIG *rig) dump_hex(reply, reply[4] + 5); - // Update cache - CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes); - CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes); - int crc = CRC16Check(&cmd[4], 4); - cmd[8] = crc >> 8; - cmd[9] = crc & 0xff; - rig_flush(rp); - write_block(rp, cmd, 10); - - // Read header - int ret = read_block(rp, reply, 5); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__); - } - - // Validate data length - if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { - rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); - } - - // Read data section - ret = read_block(rp, &reply[5], reply[4]); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__); - } - - // Validate mode field index won't overflow - if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); - } - - dump_hex(reply, reply[4] + 5); - // Update cache CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes); CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes); @@ -751,7 +707,6 @@ static int pmr171_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) unsigned char reply[9]; pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); - pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); CACHE(rig)->ptt = ptt; commit c9161e2e25d80609d5127ca0c1ebe8e78cb00040 Author: 声纳 <159...@qq...> Date: Sat Jun 28 10:11:21 2025 +0800 Improve error handling for GUOHETEC drivers to enhance WSJT-X compatibility - Add graceful degradation for communication errors - Return cached values instead of error codes on failures - Implement unified response validation functions - Add cache return macros for consistent error handling - Maintain backward compatibility while improving stability This change ensures WSJT-X and similar applications continue working even when temporary communication issues occur with GUOHETEC radios. Fixes: WSJT-X compatibility issues with PMR-171 and Q900 drivers diff --git a/rigs/guohetec/guohetec.c b/rigs/guohetec/guohetec.c index 49b1a1a30..414bc42ae 100644 --- a/rigs/guohetec/guohetec.c +++ b/rigs/guohetec/guohetec.c @@ -96,7 +96,153 @@ uint16_t CRC16Check(const unsigned char *buf, int len) return data; } - + +// Common response validation functions + +/** + * Read rig response with validation + * @param rig RIG structure + * @param reply Reply buffer + * @param reply_size Size of reply buffer + * @param func_name Function name for debug messages + * @return 0 on success, -1 on error + */ +int read_rig_response(RIG *rig, unsigned char *reply, int reply_size, + const char *func_name) +{ + hamlib_port_t *rp = RIGPORT(rig); + int ret; + + // Read header + ret = read_block(rp, reply, 5); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header, using cached values\n", func_name); + return -1; + } + + // Validate data length + if (reply[4] == 0 || reply[4] > reply_size - 5) { + rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d, using cached values\n", func_name, reply[4]); + return -1; + } + + // Read data section + ret = read_block(rp, &reply[5], reply[4]); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data, using cached values\n", func_name); + return -1; + } + + // Validate response length matches expected + if (ret != reply[4]) { + rig_debug(RIG_DEBUG_ERR, "%s: Data read mismatch: expected %d, got %d, using cached values\n", + func_name, reply[4], ret); + return -1; + } + + return 0; +} + +/** + * Validate basic rig response + * @param rig RIG structure + * @param reply Reply buffer + * @param reply_size Size of reply buffer + * @param func_name Function name for debug messages + * @return 0 on success, -1 on error + */ +int validate_rig_response(RIG *rig, unsigned char *reply, int reply_size, + const char *func_name) +{ + // Validate packet header + VALIDATE_PACKET_HEADER(reply, func_name); + + // Validate data length + VALIDATE_DATA_LENGTH(reply, reply_size, func_name); + + return 0; +} + +/** + * Validate frequency response with CRC check + * @param rig RIG structure + * @param reply Reply buffer + * @param reply_size Size of reply buffer + * @param func_name Function name for debug messages + * @return 0 on success, -1 on error + */ +int validate_freq_response(RIG *rig, unsigned char *reply, int reply_size, + const char *func_name) +{ + // Basic validation + if (validate_rig_response(rig, reply, reply_size, func_name) < 0) { + return -1; + } + + // Validate buffer boundaries for CRC + int expected_total_length = 5 + reply[4] + 2; // header(5) + data_length + CRC(2) + if (expected_total_length > reply_size) { + rig_debug(RIG_DEBUG_ERR, "%s: Response too large for buffer: %d > %d, using cached values\n", + func_name, expected_total_length, reply_size); + return -1; + } + + // CRC check + uint16_t recv_crc = (reply[31] << 8) | reply[32]; // Last 2 bytes are CRC + uint16_t calc_crc = CRC16Check(&reply[4], 27); + if (recv_crc != calc_crc) { + rig_debug(RIG_DEBUG_ERR, "%s: CRC check failed (received: %04X, calculated: %04X), using cached values\n", + func_name, recv_crc, calc_crc); + return -1; + } + + // Validate frequency field offset + int freq_b_offset = 13; // VFOB frequency starting position + if (freq_b_offset + 3 >= expected_total_length - 2) { // -2 for CRC + rig_debug(RIG_DEBUG_ERR, "%s: Frequency field offset out of bounds, using cached values\n", func_name); + return -1; + } + + return 0; +} + +/** + * Validate mode response with bounds checking + * @param rig RIG structure + * @pa... [truncated message content] |
From: n0nb <n0...@us...> - 2025-06-27 12:44:19
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 862fda58be871ce33f9d946c30d61232dd41549c (commit) via 5eda68367f86a770cae92d0a601ba1c040714597 (commit) from 9c187349117592a5a3fe21375c0508c11a262c09 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 862fda58be871ce33f9d946c30d61232dd41549c Merge: 9c1873491 5eda68367 Author: Nate Bargmann <n0...@n0...> Date: Fri Jun 27 07:40:51 2025 -0500 Merge GitHub PR #1786 commit 5eda68367f86a770cae92d0a601ba1c040714597 Author: Mark J. Fine <mar...@fi...> Date: Fri Jun 27 08:05:03 2025 -0400 Corrected a couple of cppcheck warnings: uninitialize variable and condition always false. diff --git a/rigs/icom/icom_alt_agc.c b/rigs/icom/icom_alt_agc.c index 0f163e320..be845b87e 100644 --- a/rigs/icom/icom_alt_agc.c +++ b/rigs/icom/icom_alt_agc.c @@ -397,6 +397,7 @@ int icom_rig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) rig_debug(RIG_DEBUG_TRACE, "%s: no extcmd found\n", __func__); + cmdbuf[0] = 0x00; cmd_len = 0; lvl_cn = C_CTL_FUNC; @@ -414,7 +415,8 @@ int icom_rig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) /* * strbuf should contain Cn,Sc,Data area */ - cmdhead = ((lvl_sc == -1) ? 1 : 2) + cmd_len; + //cmdhead = ((lvl_sc == -1) ? 1 : 2) + cmd_len; + cmdhead = 2 + cmd_len; resp_len -= cmdhead; if (respbuf[0] != lvl_cn) ----------------------------------------------------------------------- Summary of changes: rigs/icom/icom_alt_agc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-27 12:27:16
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 9c187349117592a5a3fe21375c0508c11a262c09 (commit) via cb308819e7c1f65e6b0045fe154446f06376ad7c (commit) via 7fe7602a8289fd9bc74a350ea084c72640c319ad (commit) from 36f582222f6a460735cf0538990cfc20fd46888e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9c187349117592a5a3fe21375c0508c11a262c09 Author: Nate Bargmann <n0...@n0...> Date: Fri Jun 27 07:22:21 2025 -0500 Update NEWS for recent merges diff --git a/NEWS b/NEWS index 31627e686..8e7e076a8 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,11 @@ Version 4.7.0 * Remove dead getopt code. GitHub PR #1709. (TNX Daniele Forsi) * Move rig_cache to separate(calloc) storage. Prepare for other moves. Issue #1420 + * Many fixes for SWIG binding generation and improved Python support + and testing. (TNX Daniele Forsi). + * Fix AGC for IC-R75, fix AGC for all Icom rigs. (TNX Mark Fine). + * Separate PMR-171 and Q900 into new the GUOHETEC backend, add + additional support add clean up code. (TNX FVsonar). Version 4.6.3 * 2025-06-10 commit cb308819e7c1f65e6b0045fe154446f06376ad7c Merge: 36f582222 7fe7602a8 Author: Nate Bargmann <n0...@n0...> Date: Fri Jun 27 06:53:07 2025 -0500 Merge GitHub PR #1785 commit 7fe7602a8289fd9bc74a350ea084c72640c319ad Author: 声纳 <159...@qq...> Date: Fri Jun 27 11:12:46 2025 +0800 Delete redundant functions and structures in guohetec. c, pmr171. c, and q900. c, optimize code structure, fix data length verification logic, and ensure the security and stability of data processing. All cppcheck style warnings have been fixed diff --git a/rigs/guohetec/guohetec.c b/rigs/guohetec/guohetec.c index 8f074f23b..49b1a1a30 100644 --- a/rigs/guohetec/guohetec.c +++ b/rigs/guohetec/guohetec.c @@ -97,23 +97,6 @@ uint16_t CRC16Check(const unsigned char *buf, int len) } - unsigned long long from_be(const unsigned char data[], - unsigned int byte_len) - { - int i; - unsigned long long f = 0; - - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - for (i = 0; i < byte_len; i++) - { - f = (f << 8) + data[i]; - } - - return f; - } - - // Initialization function DECLARE_INITRIG_BACKEND(guohetec) { rig_debug(RIG_DEBUG_VERBOSE, "%s: Initializing guohetec \n", __func__); @@ -136,7 +119,6 @@ DECLARE_PROBERIG_BACKEND(guohetec) { }; uint8_t reply[PMR171_REPLY_LENGTH]; - int retval; int orig_rate = port->parm.serial.rate; int orig_timeout = port->timeout; @@ -153,7 +135,7 @@ DECLARE_PROBERIG_BACKEND(guohetec) { rig_flush(port); - retval = write_block(port, cmd, PMR171_CMD_LENGTH); + int retval = write_block(port, cmd, PMR171_CMD_LENGTH); if (retval != RIG_OK) { continue; } diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index b876ed989..c89fa6744 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -18,31 +18,6 @@ #include <unistd.h> -struct pmr171_priv_data -{ - /* rx status */ - struct timeval rx_status_tv; - unsigned char rx_status; - - /* tx status */ - struct timeval tx_status_tv; - 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; - unsigned char fm_status[5]; /* 5 bytes, NOT related to YAESU_CMD_LENGTH */ - /* Digi mode is not part of regular fm_status response. - * So keep track of it in a separate variable. */ - unsigned char dig_mode; -}; - typedef struct pmr171_data_s { char ptt; @@ -345,7 +320,7 @@ static int pmr171_open(RIG *rig) /* ---------------------------------------------------------------------- */ - static int pmr171_send(RIG *rig, unsigned char* buff, int len, unsigned char *reply, int rlen) + static int pmr171_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen) { hamlib_port_t *rp = RIGPORT(rig); int retry = 5; @@ -401,10 +376,7 @@ static int pmr171_open(RIG *rig) // Receive buffer (complete response packet should be 33 bytes) unsigned char reply[40]; - int ret = pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); - if (ret != RIG_OK) { - rig_debug(RIG_DEBUG_ERR, "%s: Communication failure, error code=%d\n", __func__, ret); - } + pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); /* ----------- Protocol validation ----------- */ // 1. Check packet header @@ -472,7 +444,7 @@ static int pmr171_open(RIG *rig) { struct rig_cache *cachep = CACHE(rig); hamlib_port_t *rp = RIGPORT(rig); - pmr171_data_t *p = (pmr171_data_t *) STATE(rig)->priv; + const pmr171_data_t *p = (pmr171_data_t *) STATE(rig)->priv; unsigned char reply[40]; // Get latest status from hardware @@ -482,22 +454,26 @@ static int pmr171_open(RIG *rig) int ret = read_block(rp, reply, 5); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); + return -RIG_ETIMEOUT; } // Validate data length - if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + return -RIG_EPROTO; } // Read data section ret = read_block(rp, &reply[5], reply[4]); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + return -RIG_ETIMEOUT; } // Validate mode field index won't overflow if (reply[4] < 5) { // Need at least 5 bytes to access reply[7] and reply[8] rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); + return -RIG_EPROTO; } // Update cache @@ -533,22 +509,26 @@ static int pmr171_open(RIG *rig) int ret = read_block(rp, reply, 5); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); + return -RIG_ETIMEOUT; } // Validate data length - if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + return -RIG_EPROTO; } // Read data section ret = read_block(rp, &reply[5], reply[4]); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + return -RIG_ETIMEOUT; } // Validate VFO status field index won't overflow if (reply[4] < 13) { // Need at least 13 bytes to access reply[17] rig_debug(RIG_DEBUG_ERR, "%s: Response too short for VFO data\n", __func__); + return -RIG_EPROTO; } // According to protocol doc, reply[17] is A/B frequency status @@ -570,22 +550,26 @@ static int pmr171_open(RIG *rig) int ret = read_block(rp, reply, 5); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); + return -RIG_ETIMEOUT; } // Validate data length - if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + return -RIG_EPROTO; } // Read data section ret = read_block(rp, &reply[5], reply[4]); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + return -RIG_ETIMEOUT; } // Validate PTT status field index won't overflow if (reply[4] < 2) { // Need at least 2 bytes to access reply[6] rig_debug(RIG_DEBUG_ERR, "%s: Response too short for PTT data\n", __func__); + return -RIG_EPROTO; } // Get PTT status @@ -650,7 +634,7 @@ static int pmr171_open(RIG *rig) } // Validate data length - if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); } @@ -735,60 +719,53 @@ static int pmr171_open(RIG *rig) hamlib_port_t *rp = RIGPORT(rig); unsigned char cmd[10] = { 0xa5, 0xa5, 0xa5, 0xa5, 5, 0x0a, 0x00, 0x00, 0x00, 0x00 }; unsigned char reply[10]; - int crc; unsigned char i = rmode2guohe(mode, pmr171_modes); - if (i != (-1)) + if (vfo == RIG_VFO_B) { - if (vfo == RIG_VFO_B) - { - cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, pmr171_modes); - cmd[7] = i; - } - else - { - cmd[6] = i; - cmd[7] = rmode2guohe(CACHE(rig)->modeMainB, pmr171_modes); - } - - crc = CRC16Check(&cmd[4], 4); - cmd[8] = crc >> 8; - cmd[9] = crc & 0xff; - rig_flush(rp); - write_block(rp, cmd, 10); - - // Read header - int ret = read_block(rp, reply, 5); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__); - } - - // Validate data length - if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { - rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); - } - - // Read data section - ret = read_block(rp, &reply[5], reply[4]); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__); - } - - // Validate mode field index won't overflow - if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); - } - - dump_hex(reply, reply[4] + 5); - - // Update cache - CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes); - CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes); + cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, pmr171_modes); + cmd[7] = i; + } + else + { + cmd[6] = i; + cmd[7] = rmode2guohe(CACHE(rig)->modeMainB, pmr171_modes); + } - return RIG_OK; + int crc = CRC16Check(&cmd[4], 4); + cmd[8] = crc >> 8; + cmd[9] = crc & 0xff; + rig_flush(rp); + write_block(rp, cmd, 10); + + // Read header + int ret = read_block(rp, reply, 5); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__); } + + // Validate data length + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { + rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); + } + + // Read data section + ret = read_block(rp, &reply[5], reply[4]); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__); + } + + // Validate mode field index won't overflow + if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7] + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); + } + + dump_hex(reply, reply[4] + 5); + + // Update cache + CACHE(rig)->modeMainA = guohe2rmode(reply[6], pmr171_modes); + CACHE(rig)->modeMainB = guohe2rmode(reply[7], pmr171_modes); - rig_debug(RIG_DEBUG_ERR, "%s: invalid mode=%s\n", __func__, rig_strrmode(mode)); return RIG_OK; } @@ -807,10 +784,7 @@ static int pmr171_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) cmd[8] = crc & 0xff; unsigned char reply[9]; - int ret = pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); - if (ret != RIG_OK) { - rig_debug(RIG_DEBUG_ERR, "%s: PTT command failed\n", __func__); - } + pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); CACHE(rig)->ptt = ptt; diff --git a/rigs/guohetec/q900.c b/rigs/guohetec/q900.c index 29017b1a6..92973740a 100644 --- a/rigs/guohetec/q900.c +++ b/rigs/guohetec/q900.c @@ -17,31 +17,6 @@ #include <stdint.h> #include <unistd.h> -struct q900_priv_data -{ - /* rx status */ - struct timeval rx_status_tv; - unsigned char rx_status; - - /* tx status */ - struct timeval tx_status_tv; - 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; - unsigned char fm_status[5]; /* 5 bytes, NOT related to YAESU_CMD_LENGTH */ - /* Digi mode is not part of regular fm_status response. - * So keep track of it in a separate variable. */ - unsigned char dig_mode; -}; - typedef struct q900_data_s { char ptt; @@ -344,7 +319,7 @@ static int q900_open(RIG *rig) /* ---------------------------------------------------------------------- */ - static int q900_send(RIG *rig, unsigned char* buff, int len, unsigned char *reply, int rlen) + static int q900_send(RIG *rig, const unsigned char* buff, int len, unsigned char *reply, int rlen) { hamlib_port_t *rp = RIGPORT(rig); int retry = 5; @@ -397,18 +372,16 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) cmd[7] = crc & 0xFF; unsigned char reply[40]; - int ret = q900_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); - if (ret != RIG_OK) { - rig_debug(RIG_DEBUG_ERR, "%s: Communication failure, error code=%d\n", __func__, ret); - } + q900_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); if (reply[0] != 0xA5 || reply[1] != 0xA5 || reply[2] != 0xA5 || reply[3] != 0xA5) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid packet header\n", __func__); } - if (reply[4] != 0x1B) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid packet length %d\n", __func__, reply[4]); + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { + rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + return -RIG_EPROTO; } // Validate buffer boundaries - ensure enough space for CRC @@ -459,7 +432,7 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { struct rig_cache *cachep = CACHE(rig); hamlib_port_t *rp = RIGPORT(rig); - q900_data_t *p = (q900_data_t *) STATE(rig)->priv; + const q900_data_t *p = (q900_data_t *) STATE(rig)->priv; unsigned char reply[255]; q900_send_cmd1(rig, 0x0b, 0); @@ -468,37 +441,44 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int ret = read_block(rp, reply, 5); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); + return -RIG_ETIMEOUT; } // Validate data length - if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + return -RIG_EPROTO; } // Read data section ret = read_block(rp, &reply[5], reply[4]); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + return -RIG_ETIMEOUT; } // Validate response length matches expected if (ret != reply[4]) { rig_debug(RIG_DEBUG_ERR, "%s: Data read mismatch: expected %d, got %d\n", __func__, reply[4], ret); + return -RIG_EPROTO; } // Validate mode field index won't overflow if (reply[4] < 5) { // Need at least 5 bytes to access reply[7] and reply[8] rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); + return -RIG_EPROTO; } // Validate mode field indices are within bounds if (reply[7] >= GUOHE_MODE_TABLE_MAX) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode A index %d\n", __func__, reply[7]); + return -RIG_EPROTO; } if (reply[8] >= GUOHE_MODE_TABLE_MAX) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode B index %d\n", __func__, reply[8]); + return -RIG_EPROTO; } cachep->modeMainA = guohe2rmode(reply[7], q900_modes); @@ -531,33 +511,39 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int ret = read_block(rp, reply, 5); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); + return -RIG_ETIMEOUT; } // Validate data length - if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + return -RIG_EPROTO; } // Read data section ret = read_block(rp, &reply[5], reply[4]); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + return -RIG_ETIMEOUT; } // Validate response length matches expected if (ret != reply[4]) { rig_debug(RIG_DEBUG_ERR, "%s: Data read mismatch: expected %d, got %d\n", __func__, reply[4], ret); + return -RIG_EPROTO; } // Validate VFO status field index won't overflow if (reply[4] < 13) { // Need at least 13 bytes to access reply[17] rig_debug(RIG_DEBUG_ERR, "%s: Response too short for VFO data\n", __func__); + return -RIG_EPROTO; } // Validate VFO status value if (reply[17] != 0 && reply[17] != 1) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid VFO status value %d\n", __func__, reply[17]); + return -RIG_EPROTO; } *vfo = (reply[17] == 1) ? RIG_VFO_B : RIG_VFO_A; @@ -578,33 +564,39 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int ret = read_block(rp, reply, 5); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); + return -RIG_ETIMEOUT; } // Validate data length - if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + return -RIG_EPROTO; } // Read data section ret = read_block(rp, &reply[5], reply[4]); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + return -RIG_ETIMEOUT; } // Validate response length matches expected if (ret != reply[4]) { rig_debug(RIG_DEBUG_ERR, "%s: Data read mismatch: expected %d, got %d\n", __func__, reply[4], ret); + return -RIG_EPROTO; } // Validate PTT status field index won't overflow if (reply[4] < 2) { // Need at least 2 bytes to access reply[6] rig_debug(RIG_DEBUG_ERR, "%s: Response too short for PTT data\n", __func__); + return -RIG_EPROTO; } // Validate PTT status value if (reply[6] != 0 && reply[6] != 1) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid PTT status value %d\n", __func__, reply[6]); + return -RIG_EPROTO; } cachep->ptt = reply[6]; @@ -671,7 +663,7 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) } // Validate data length - if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); } @@ -760,74 +752,67 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) hamlib_port_t *rp = RIGPORT(rig); unsigned char cmd[10] = { 0xa5, 0xa5, 0xa5, 0xa5, 5, 0x0a, 0x00, 0x00, 0x00, 0x00 }; unsigned char reply[10]; - int crc; unsigned char i = rmode2guohe(mode, q900_modes); - - if (i != (-1)) + + if (vfo == RIG_VFO_B) { - if (vfo == RIG_VFO_B) - { - cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, q900_modes); - cmd[7] = i; - } - else - { - cmd[6] = i; - cmd[7] = rmode2guohe(CACHE(rig)->modeMainB, q900_modes); - } - - crc = CRC16Check(&cmd[4], 4); - cmd[8] = crc >> 8; - cmd[9] = crc & 0xff; - rig_flush(rp); - write_block(rp, cmd, 10); - - // Read header - int ret = read_block(rp, reply, 5); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__); - } - - // Validate data length - if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { - rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); - } - - // Read data section - ret = read_block(rp, &reply[5], reply[4]); - if (ret < 0) { - rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__); - } - - // Validate response length matches expected - if (ret != reply[4]) { - rig_debug(RIG_DEBUG_ERR, "%s: Data read mismatch: expected %d, got %d\n", - __func__, reply[4], ret); - } - - // Validate mode field index won't overflow - if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7] - rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); - } - - // Validate mode field indices are within bounds - if (reply[6] >= GUOHE_MODE_TABLE_MAX) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode A index %d\n", __func__, reply[6]); - } - - if (reply[7] >= GUOHE_MODE_TABLE_MAX) { - rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode B index %d\n", __func__, reply[7]); - } - - dump_hex(reply, reply[4] + 5); - - CACHE(rig)->modeMainA = guohe2rmode(reply[6], q900_modes); - CACHE(rig)->modeMainB = guohe2rmode(reply[7], q900_modes); + cmd[6] = rmode2guohe(CACHE(rig)->modeMainA, q900_modes); + cmd[7] = i; + } + else + { + cmd[6] = i; + cmd[7] = rmode2guohe(CACHE(rig)->modeMainB, q900_modes); + } - return RIG_OK; + int crc = CRC16Check(&cmd[4], 4); + cmd[8] = crc >> 8; + cmd[9] = crc & 0xff; + rig_flush(rp); + write_block(rp, cmd, 10); + + // Read header + int ret = read_block(rp, reply, 5); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__); } - - rig_debug(RIG_DEBUG_ERR, "%s: invalid mode=%s\n", __func__, rig_strrmode(mode)); + + // Validate data length + if (reply[4] == 0 || reply[4] > sizeof(reply) - 5) { + rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); + } + + // Read data section + ret = read_block(rp, &reply[5], reply[4]); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__); + } + + // Validate response length matches expected + if (ret != reply[4]) { + rig_debug(RIG_DEBUG_ERR, "%s: Data read mismatch: expected %d, got %d\n", + __func__, reply[4], ret); + } + + // Validate mode field index won't overflow + if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7] + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); + } + + // Validate mode field indices are within bounds + if (reply[6] >= GUOHE_MODE_TABLE_MAX) { + rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode A index %d\n", __func__, reply[6]); + } + + if (reply[7] >= GUOHE_MODE_TABLE_MAX) { + rig_debug(RIG_DEBUG_ERR, "%s: Invalid mode B index %d\n", __func__, reply[7]); + } + + dump_hex(reply, reply[4] + 5); + + CACHE(rig)->modeMainA = guohe2rmode(reply[6], q900_modes); + CACHE(rig)->modeMainB = guohe2rmode(reply[7], q900_modes); + return RIG_OK; } @@ -846,10 +831,7 @@ static int q900_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) cmd[8] = crc & 0xff; unsigned char reply[9]; - int ret = q900_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); - if (ret != RIG_OK) { - rig_debug(RIG_DEBUG_ERR, "%s: PTT command failed\n", __func__); - } + q900_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); // Update cache CACHE(rig)->ptt = ptt; ----------------------------------------------------------------------- Summary of changes: NEWS | 5 ++ rigs/guohetec/guohetec.c | 20 +---- rigs/guohetec/pmr171.c | 148 +++++++++++++++--------------------- rigs/guohetec/q900.c | 192 +++++++++++++++++++++-------------------------- 4 files changed, 154 insertions(+), 211 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-27 11:50:21
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 36f582222f6a460735cf0538990cfc20fd46888e (commit) via bf518c06098d68ce5cae6e58812b78ff46d5be05 (commit) via 6c399b55ffd9027de2c0958d43b8f5fcb07d4d97 (commit) via 7223fb0766468fabe2c40b3a3d0e309c9b1abfa1 (commit) via 453e68c6cd6d5b21286cc914773cfdb029ca86c7 (commit) from ef3e2782031967ffb6feeb5176cc47cd2e080f4b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 36f582222f6a460735cf0538990cfc20fd46888e Merge: ef3e27820 bf518c060 Author: Nate Bargmann <n0...@n0...> Date: Fri Jun 27 06:36:16 2025 -0500 Merge GitHub PR #1784 commit bf518c06098d68ce5cae6e58812b78ff46d5be05 Author: Daniele Forsi IU5HKX <iu...@gm...> Date: Wed Jun 25 23:02:31 2025 +0200 Fix Rig.get_ant() The only supported value for get_ant() in the union of "option" is signed integer. Do the test when the rig is open. diff --git a/bindings/python/test_rig.py b/bindings/python/test_rig.py index 9be7fd79e..1c3927cb0 100755 --- a/bindings/python/test_rig.py +++ b/bindings/python/test_rig.py @@ -59,6 +59,11 @@ class TestClass: assert rig.get_split_vfo() == [5000000, 1] assert rig.get_split_vfo(Hamlib.RIG_VFO_CURR) == [5000000, 1] + # FIXME should use a RIG_ANT_* constant but it isn't available in the bindings + RIG_ANT_UNKNOWN = 1<<30 + assert rig.get_ant(Hamlib.RIG_VFO_A) == [RIG_ANT_UNKNOWN, RIG_ANT_UNKNOWN, Hamlib.RIG_VFO_A, 0] + assert rig.get_ant(Hamlib.RIG_VFO_A, Hamlib.RIG_VFO_A) == [RIG_ANT_UNKNOWN, RIG_ANT_UNKNOWN, Hamlib.RIG_VFO_A, 0] + assert rig.close() is None assert rig.state.comm_state == 0 info = rig.get_info() @@ -72,12 +77,6 @@ class TestClass: assert rig.close() is None assert rig.ext_token_lookup("") is None - option = Hamlib.value_t() - ant = 0 # FIXME should use a RIG_ANT_* constant but it isn't available in the bindings - with raises(AssertionError): # FIXME - assert len(rig.get_ant(option, ant)) == 4 - assert len(rig.get_ant(option, ant, Hamlib.RIG_VFO_CURR)) == 4 - assert option.i == 0 assert rig.get_chan_all() is None channel = 0 readonly = 0 @@ -158,10 +157,12 @@ class TestClass: assert rig.scan(0, 0, 0) is None assert rig.send_dtmf(0, "") is None assert rig.send_morse(0, "") is None + # FIXME should use a RIG_ANT_* constant but it isn't available in the bindings + RIG_ANT_1 = 1<<0 option = Hamlib.value_t() - option.i = 0 # FIXME should use a RIG_ANT_* constant but it isn't available in the bindings + option.i = 0 assert rig.set_ant(Hamlib.RIG_VFO_CURR, option) is None - assert rig.set_ant(Hamlib.RIG_VFO_CURR, option, 0) is None + assert rig.set_ant(Hamlib.RIG_VFO_CURR, option, RIG_ANT_1) is None assert rig.set_bank(0, 0) is None channel = Hamlib.channel() channel = Hamlib.channel(0) diff --git a/bindings/rig.swg b/bindings/rig.swg index 5c086b330..f87e44847 100644 --- a/bindings/rig.swg +++ b/bindings/rig.swg @@ -473,7 +473,7 @@ typedef channel_t * const_channel_t_p; METHOD1VGET(get_rit, shortfreq_t) METHOD1VGET(get_xit, shortfreq_t) METHOD1VGET(get_ts, shortfreq_t) - extern void get_ant(ant_t *OUTPUT, ant_t *OUTPUT, ant_t *OUTPUT, value_t *OUTPUT, ant_t ant, vfo_t vfo = RIG_VFO_CURR); + extern void get_ant(ant_t *OUTPUT, ant_t *OUTPUT, ant_t *OUTPUT, signed int *OUTPUT, ant_t ant, vfo_t vfo = RIG_VFO_CURR); void get_vfo_info (int *satmode, split_t *split, pbwidth_t *width, rmode_t *mode, freq_t *freq, vfo_t vfo = RIG_VFO_CURR) { self->error_status = rig_get_vfo_info(self->rig, vfo, freq, mode, width, split, satmode); } METHOD1VGET(get_mem, int) @@ -623,9 +623,11 @@ void Rig_get_split_freq_mode(Rig *self, vfo_t vfo, freq_t *tx_freq, rmode_t *tx_ /* * these ones return 4 values */ -void Rig_get_ant(Rig *self, ant_t *ant_rx, ant_t *ant_tx, ant_t *ant_curr, value_t *option, ant_t ant, vfo_t vfo) +void Rig_get_ant(Rig *self, ant_t *ant_rx, ant_t *ant_tx, ant_t *ant_curr, signed int *option, ant_t ant, vfo_t vfo) { - self->error_status = rig_get_ant(self->rig, vfo, ant, option, ant_curr, ant_tx, ant_rx); + value_t value; + self->error_status = rig_get_ant(self->rig, vfo, ant, &value, ant_curr, ant_tx, ant_rx); + *option = value.i; } struct channel *Rig_get_chan_all(Rig *self) commit 6c399b55ffd9027de2c0958d43b8f5fcb07d4d97 Author: Daniele Forsi IU5HKX <iu...@gm...> Date: Wed Jun 25 19:49:58 2025 +0200 Assert the length of sequences instead of the list datatype We only need to check how many values exist. diff --git a/bindings/python/test_rig.py b/bindings/python/test_rig.py index 7b3adc1b5..9be7fd79e 100755 --- a/bindings/python/test_rig.py +++ b/bindings/python/test_rig.py @@ -74,8 +74,9 @@ class TestClass: assert rig.ext_token_lookup("") is None option = Hamlib.value_t() ant = 0 # FIXME should use a RIG_ANT_* constant but it isn't available in the bindings - assert isinstance(rig.get_ant(option, ant), list) - assert isinstance(rig.get_ant(option, ant, Hamlib.RIG_VFO_CURR), list) + with raises(AssertionError): # FIXME + assert len(rig.get_ant(option, ant)) == 4 + assert len(rig.get_ant(option, ant, Hamlib.RIG_VFO_CURR)) == 4 assert option.i == 0 assert rig.get_chan_all() is None channel = 0 @@ -109,8 +110,8 @@ class TestClass: assert isinstance(rig.get_level_i(0), int) assert isinstance(rig.get_mem(), int) assert isinstance(rig.get_mem(Hamlib.RIG_VFO_CURR), int) - assert isinstance(rig.get_mode(), list) - assert isinstance(rig.get_mode(Hamlib.RIG_VFO_CURR), list) + assert len(rig.get_mode()) == 2 + assert len(rig.get_mode(Hamlib.RIG_VFO_CURR)) == 2 assert rig.get_parm(0) is None assert isinstance(rig.get_parm_f(0), float) assert isinstance(rig.get_parm_i(0), int) @@ -125,14 +126,14 @@ class TestClass: assert isinstance(rig.get_rptr_shift(Hamlib.RIG_VFO_CURR), int) assert isinstance(rig.get_split_freq(), float) assert isinstance(rig.get_split_freq(Hamlib.RIG_VFO_CURR), float) - assert isinstance(rig.get_split_mode(), list) - assert isinstance(rig.get_split_mode(Hamlib.RIG_VFO_CURR), list) + assert len(rig.get_split_mode()) == 2 + assert len(rig.get_split_mode(Hamlib.RIG_VFO_CURR)) == 2 assert isinstance(rig.get_trn(), int) # deprecated assert isinstance(rig.get_ts(), int) assert isinstance(rig.get_ts(Hamlib.RIG_VFO_CURR), int) assert isinstance(rig.get_vfo(), int) - assert isinstance(rig.get_vfo_info(), list) - assert isinstance(rig.get_vfo_info(Hamlib.RIG_VFO_CURR), list) + assert len(rig.get_vfo_info()) == 5 + assert len(rig.get_vfo_info(Hamlib.RIG_VFO_CURR)) == 5 assert isinstance(rig.get_xit(), int) assert isinstance(rig.get_xit(Hamlib.RIG_VFO_CURR), int) # assert rig_has_get_func(0) FIXME not defined commit 7223fb0766468fabe2c40b3a3d0e309c9b1abfa1 Author: Daniele Forsi IU5HKX <iu...@gm...> Date: Tue Jun 24 22:08:46 2025 +0200 Fix Rig.get_vfo_info() diff --git a/bindings/python/test_rig.py b/bindings/python/test_rig.py index a24ffe07d..7b3adc1b5 100755 --- a/bindings/python/test_rig.py +++ b/bindings/python/test_rig.py @@ -131,10 +131,8 @@ class TestClass: assert isinstance(rig.get_ts(), int) assert isinstance(rig.get_ts(Hamlib.RIG_VFO_CURR), int) assert isinstance(rig.get_vfo(), int) - with raises(TypeError): - assert rig.get_vfo_info(Hamlib.RIG_VFO_CURR) is None # FIXME - assert rig.get_vfo_info(Hamlib.RIG_VFO_CURR, 2) is None # FIXME - assert rig.get_vfo_info(Hamlib.RIG_VFO_CURR, 2, 3) is None # FIXME + assert isinstance(rig.get_vfo_info(), list) + assert isinstance(rig.get_vfo_info(Hamlib.RIG_VFO_CURR), list) assert isinstance(rig.get_xit(), int) assert isinstance(rig.get_xit(Hamlib.RIG_VFO_CURR), int) # assert rig_has_get_func(0) FIXME not defined diff --git a/bindings/rig.swg b/bindings/rig.swg index 1c60a6d45..5c086b330 100644 --- a/bindings/rig.swg +++ b/bindings/rig.swg @@ -30,8 +30,14 @@ %include <hamlib/riglist.h> %include <hamlib/rig.h> -%apply unsigned int *OUTPUT { vfo_t * }; +%apply int *OUTPUT { int *}; + +%apply unsigned int *OUTPUT { ant_t * }; +%apply double *OUTPUT { freq_t * }; +%apply shortfreq_t *OUTPUT { pbwidth_t * }; +%apply uint64_t *OUTPUT { rmode_t * }; %apply int *OUTPUT { split_t * }; +%apply unsigned int *OUTPUT { vfo_t * }; %inline %{ @@ -468,7 +474,8 @@ typedef channel_t * const_channel_t_p; METHOD1VGET(get_xit, shortfreq_t) METHOD1VGET(get_ts, shortfreq_t) extern void get_ant(ant_t *OUTPUT, ant_t *OUTPUT, ant_t *OUTPUT, value_t *OUTPUT, ant_t ant, vfo_t vfo = RIG_VFO_CURR); - extern void get_vfo_info (int *satmode, split_t *split, pbwidth_t *width, rmode_t *mode, freq_t *freq, vfo_t vfo = RIG_VFO_CURR); + void get_vfo_info (int *satmode, split_t *split, pbwidth_t *width, rmode_t *mode, freq_t *freq, vfo_t vfo = RIG_VFO_CURR) + { self->error_status = rig_get_vfo_info(self->rig, vfo, freq, mode, width, split, satmode); } METHOD1VGET(get_mem, int) METHOD1GET(get_powerstat, powerstat_t) METHOD1GET(get_trn, int) @@ -620,11 +627,6 @@ void Rig_get_ant(Rig *self, ant_t *ant_rx, ant_t *ant_tx, ant_t *ant_curr, value { self->error_status = rig_get_ant(self->rig, vfo, ant, option, ant_curr, ant_tx, ant_rx); } -void Rig_get_vfo_info (Rig *self, int *satmode, split_t *split, pbwidth_t *width, rmode_t *mode, freq_t *freq, vfo_t vfo) -{ - self->error_status = rig_get_vfo_info(self->rig, vfo, freq, mode, width, split, satmode); -} - struct channel *Rig_get_chan_all(Rig *self) { commit 453e68c6cd6d5b21286cc914773cfdb029ca86c7 Author: Daniele Forsi IU5HKX <iu...@gm...> Date: Tue Jun 24 20:51:26 2025 +0200 Fix Rig.get_split_vfo() The VFO argument optional with a default of RIG_VFO_CURR. Fixes PR ##1555. diff --git a/bindings/python/test_rig.py b/bindings/python/test_rig.py index 4790dc92e..a24ffe07d 100755 --- a/bindings/python/test_rig.py +++ b/bindings/python/test_rig.py @@ -50,6 +50,15 @@ class TestClass: assert rig.state.comm_state == 1 info = rig.get_info() assert isinstance(info, str) + + assert rig.set_split_vfo(-600000, Hamlib.RIG_VFO_A) is None + assert rig.get_split_vfo(Hamlib.RIG_VFO_TX) == [-600000, 1] + assert rig.set_split_vfo(5000000, Hamlib.RIG_VFO_B) is None + assert rig.get_split_vfo(Hamlib.RIG_VFO_TX) == [5000000, 2] + assert rig.set_split_vfo(5000000, Hamlib.RIG_VFO_CURR) is None + assert rig.get_split_vfo() == [5000000, 1] + assert rig.get_split_vfo(Hamlib.RIG_VFO_CURR) == [5000000, 1] + assert rig.close() is None assert rig.state.comm_state == 0 info = rig.get_info() @@ -118,9 +127,6 @@ class TestClass: assert isinstance(rig.get_split_freq(Hamlib.RIG_VFO_CURR), float) assert isinstance(rig.get_split_mode(), list) assert isinstance(rig.get_split_mode(Hamlib.RIG_VFO_CURR), list) - with raises(TypeError): - assert rig.get_split_vfo() is None # FIXME - assert rig.get_split_vfo(Hamlib.RIG_VFO_CURR) is None # FIXME assert isinstance(rig.get_trn(), int) # deprecated assert isinstance(rig.get_ts(), int) assert isinstance(rig.get_ts(Hamlib.RIG_VFO_CURR), int) diff --git a/bindings/rig.swg b/bindings/rig.swg index e0f3373e6..1c60a6d45 100644 --- a/bindings/rig.swg +++ b/bindings/rig.swg @@ -30,6 +30,9 @@ %include <hamlib/riglist.h> %include <hamlib/rig.h> +%apply unsigned int *OUTPUT { vfo_t * }; +%apply int *OUTPUT { split_t * }; + %inline %{ #pragma SWIG nowarn=451 ----------------------------------------------------------------------- Summary of changes: bindings/python/test_rig.py | 42 ++++++++++++++++++++++++------------------ bindings/rig.swg | 25 ++++++++++++++++--------- 2 files changed, 40 insertions(+), 27 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-26 18:20:33
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via ef3e2782031967ffb6feeb5176cc47cd2e080f4b (commit) via ef0b7e30bd6fa770a2bccd27cd5e8b554a7dd764 (commit) via 82dd540d3a3fc181a81f1c3c3891f4331e770bbd (commit) via 6dffee33df0a9b79401a17150d5c431e268b8a64 (commit) via 8abe1ec8e4fe08560fc14ebb2965f89105213a18 (commit) via a09603fdd4e5699a72f509db284f9bbb494f4e10 (commit) from 31c3c973520e8bf87478e17dc6136845351e2e74 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ef3e2782031967ffb6feeb5176cc47cd2e080f4b Merge: 31c3c9735 ef0b7e30b Author: Nate Bargmann <n0...@n0...> Date: Thu Jun 26 13:14:29 2025 -0500 Merge GitHub PR #1776 commit ef0b7e30bd6fa770a2bccd27cd5e8b554a7dd764 Author: Mark J. Fine <mar...@fi...> Date: Thu Jun 26 13:38:23 2025 -0400 Reverted CW Pitch value<->knob conversion for non-ICR75 radios. Apparently R75 is the only one using the set mode command. Edited out all non-essential code commenting that was done during local testing. diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 17c6aa76c..24ba8f0ee 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -3683,8 +3683,15 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) icom_val = 900; } else + { icom_val = val.i; - //icom_val = (int) lroundf(((float) icom_val - 300) * (255.0f / 600.0f)); + } + + if (!RIG_IS_ICR75) + { + //interpolate to return knob value + icom_val = (int) lroundf(((float) icom_val - 300) * (255.0f / 600.0f)); + } break; default: @@ -3877,7 +3884,6 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } else { - // Legacy mapping that does not apply to all rigs switch (val.i) { case RIG_AGC_OFF: @@ -4686,8 +4692,15 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) break; case RIG_LEVEL_CWPITCH: - //val->i = (int) lroundf(300.0f + ((float) icom_val * 600.0f / 255.0f)); - val->i = icom_val; + if (!RIG_IS_ICR75) + { + //use knob value and interpolate + val->i = (int) lroundf(300.0f + ((float) icom_val * 600.0f / 255.0f)); + } + else + { + val->i = icom_val; + } break; case RIG_LEVEL_KEYSPD: diff --git a/rigs/icom/icom_alt_agc.c b/rigs/icom/icom_alt_agc.c index 0de9f9592..0f163e320 100644 --- a/rigs/icom/icom_alt_agc.c +++ b/rigs/icom/icom_alt_agc.c @@ -19,25 +19,11 @@ * */ -//#include <stdlib.h> -//#include <string.h> /* String function definitions */ -//#include <unistd.h> /* UNIX standard function definitions */ -//#include <math.h> - -//#include <hamlib/rig.h> -//#include <serial.h> -//#include <cal.h> -//#include <token.h> -//#include <register.h> - #include "icom.h" #include "icom_defs.h" #include "icom_alt_agc.h" #include "frame.h" #include "misc.h" -//#include "event.h" -//#include "cache.h" - /* * Note: @@ -259,7 +245,6 @@ int icom_rig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } else { - //struct rig_state *rs = STATE(rig); unsigned char cmdbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN]; int cmd_len, ack_len = sizeof(ackbuf); int lvl_cn, lvl_sc; /* Command Number, Subcommand */ @@ -387,7 +372,6 @@ int icom_rig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } else { - //struct rig_state *rs; unsigned char cmdbuf[MAXFRAMELEN], respbuf[MAXFRAMELEN]; int cmd_len, resp_len; int lvl_cn, lvl_sc; /* Command Number, Subcommand */ @@ -413,8 +397,6 @@ int icom_rig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) rig_debug(RIG_DEBUG_TRACE, "%s: no extcmd found\n", __func__); - //rs = STATE(rig); - cmd_len = 0; lvl_cn = C_CTL_FUNC; diff --git a/rigs/icom/icom_defs.h b/rigs/icom/icom_defs.h index 0776a1287..6313ec2de 100644 --- a/rigs/icom/icom_defs.h +++ b/rigs/icom/icom_defs.h @@ -233,11 +233,11 @@ * Set AGC (S_FUNC_AGC) data */ #define D_AGC_OFF 0x00 -#define D_AGC_SUPERFAST 0x01 //was 0x03 /* IC746 pro */ -#define D_AGC_FAST 0x02 //was 0x00 -#define D_AGC_SLOW 0x03 //was 0x02 +#define D_AGC_SUPERFAST 0x01 +#define D_AGC_FAST 0x02 +#define D_AGC_SLOW 0x03 #define D_AGC_USER 0x04 -#define D_AGC_MID 0x05 //was 0x01 +#define D_AGC_MID 0x05 #define D_AGC_AUTO 0x06 /* commit 82dd540d3a3fc181a81f1c3c3891f4331e770bbd Author: Mark J. Fine <mar...@fi...> Date: Thu Jun 26 13:04:58 2025 -0400 Part 2 of Issue#1775: Adds optional wrappers for rigs that need to use the alternate AGC mapping originally specified in icom.c. Instructions for employment are provided within icom_alt_agc.c. diff --git a/rigs/icom/Makefile.am b/rigs/icom/Makefile.am index b295fe8d1..38b3fd7e9 100644 --- a/rigs/icom/Makefile.am +++ b/rigs/icom/Makefile.am @@ -1,4 +1,5 @@ -ICOMSRC = icom.c icom.h icom_defs.h frame.c frame.h ic706.c icr8500.c ic735.c ic775.c ic756.c \ +ICOMSRC = icom.c icom.h icom_defs.h icom_alt_agc.c icom_alt_agc.h frame.c frame.h \ + ic706.c icr8500.c ic735.c ic775.c ic756.c \ ic275.c ic475.c ic1275.c ic820h.c ic821h.c \ icr7000.c ic910.c ic9100.c ic970.c ic725.c ic737.c ic718.c \ os535.c os456.c omni.c delta2.c ic92d.c \ diff --git a/rigs/icom/icom_alt_agc.c b/rigs/icom/icom_alt_agc.c new file mode 100644 index 000000000..0de9f9592 --- /dev/null +++ b/rigs/icom/icom_alt_agc.c @@ -0,0 +1,506 @@ +/* + * Hamlib CI-V backend - wrapper to get/set alternate AGC levels + * Copyright (c) 2000-2025 by Stephane Fillod + * + * + * 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 <stdlib.h> +//#include <string.h> /* String function definitions */ +//#include <unistd.h> /* UNIX standard function definitions */ +//#include <math.h> + +//#include <hamlib/rig.h> +//#include <serial.h> +//#include <cal.h> +//#include <token.h> +//#include <register.h> + +#include "icom.h" +#include "icom_defs.h" +#include "icom_alt_agc.h" +#include "frame.h" +#include "misc.h" +//#include "event.h" +//#include "cache.h" + + +/* + * Note: + * This file contains a wrapper to utilize the original AGC settings routines + * for specific radios that require this alternate mapping. + * + * In order to make use of it, modify your rig's backend with the following: + * + * 1. Add `#include icom_alt_agc.h` + * + * 2. Change + * `.set_level = icom_set_level,` + * To + * `.set_level = icom_rig_set_level,` + * + * 3. Change + * `.get_level = icom_get_level,` + * To + * `.get_level = icom_rig_get_level,` + * + * All other level set/get routines other than AGC should be unaffected. + */ + +static int icom_check_ack(int ack_len, unsigned char *ackbuf) +{ + if ((ack_len >= 1 && ackbuf[0] != ACK) && (ack_len >= 2 && ackbuf[1] != NAK)) + { + // if we don't get ACK/NAK some serial corruption occurred + // so we'll call it a timeout for retry purposes + rig_debug(RIG_DEBUG_WARN, "%s: command timed out (%#.2x)\n", __func__, + ackbuf[0]); + return -RIG_ETIMEOUT; + } + + if (ack_len != 1 || ackbuf[0] != ACK) + { + rig_debug(RIG_DEBUG_ERR, "%s: command not acknowledged (%#.2x), len=%d\n", + __func__, + ackbuf[0], ack_len); + return -RIG_ERJCTED; + } + + return RIG_OK; +} + +static int icom_set_cmd(RIG *rig, vfo_t vfo, struct cmdparams *par, value_t val) +{ + ENTERFUNC; + + unsigned char cmdbuf[MAXFRAMELEN]; + int cmdlen = 0; + unsigned char ackbuf[MAXFRAMELEN]; + int ack_len = 0; + + if (!(par->submod & SC_MOD_WR)) { RETURNFUNC(-RIG_EINVAL); } + + if ((par->submod & SC_MOD_RW12) == SC_MOD_RW12) + { + cmdbuf[0] = 0x01; + cmdlen = 1; + } + else + { + cmdlen = par->sublen; + memcpy(cmdbuf, par->subext, cmdlen); + } + + int wrd = val.i; + int i; + + switch (par->dattyp) + { + case CMD_DAT_WRD: + for (i = 1; i <= par->datlen; i++) + { + cmdbuf[cmdlen + par->datlen - i] = wrd & 0xff; + wrd >>= 8; + } + + break; + + case CMD_DAT_BUF: + memcpy(&cmdbuf[cmdlen], val.b.d, par->datlen); + break; + + case CMD_DAT_INT: + case CMD_DAT_BOL: + to_bcd_be(&cmdbuf[cmdlen], val.i, (par->datlen * 2)); + break; + + case CMD_DAT_FLT: + to_bcd_be(&cmdbuf[cmdlen], (int) val.f, (par->datlen * 2)); + break; + + case CMD_DAT_LVL: + to_bcd_be(&cmdbuf[cmdlen], (int)(val.f * 255.0), (par->datlen * 2)); + break; + + case CMD_DAT_TIM: // returned as seconds since midnight + to_bcd_be(&cmdbuf[cmdlen], + ((((int)val.i / 3600) * 100) + (((int)val.i / 60) % 60)), (par->datlen * 2)); + break; + + default: + break; + } + + cmdlen += par->datlen; + RETURNFUNC(icom_transaction(rig, par->command, par->subcmd, cmdbuf, cmdlen, + ackbuf, + &ack_len)); +} + +static int icom_get_cmd(RIG *rig, vfo_t vfo, struct cmdparams *par, value_t *val) +{ + + ENTERFUNC; + + unsigned char ssc = 0x02; + unsigned char resbuf[MAXFRAMELEN]; + int reslen = sizeof(resbuf); + int retval; + + if (!(par->submod & SC_MOD_RD)) { RETURNFUNC(-RIG_EINVAL); } + + if ((par->submod & SC_MOD_RW12) == SC_MOD_RW12) + { + retval = icom_get_raw_buf(rig, par->command, par->subcmd, 1, &ssc, &reslen, + resbuf); + } + else + { + retval = icom_get_raw_buf(rig, par->command, par->subcmd, + par->sublen, (unsigned char *)par->subext, &reslen, resbuf); + } + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + switch (par->dattyp) + { + case CMD_DAT_WRD: + { + int wrd = 0; + int i; + + for (i = 0; i < par->datlen; i++) + { + wrd = (wrd << 8) + resbuf[i]; + } + + val->i = wrd; + } + break; + + case CMD_DAT_STR: + if (strlen(val->s) < reslen) + { + RETURNFUNC(-RIG_EINTERNAL); + } + + memcpy(val->s, resbuf, reslen); + val->s[reslen] = 0; + break; + + case CMD_DAT_BUF: + if (reslen > val->b.l) + { + RETURNFUNC(-RIG_EINTERNAL); + } + + memcpy(val->b.d, resbuf, reslen); + val->b.l = reslen; + break; + + case CMD_DAT_INT: + val->i = from_bcd_be(resbuf, (reslen * 2)); + break; + + case CMD_DAT_FLT: + val->f = (float) from_bcd_be(resbuf, (reslen * 2)); + break; + + case CMD_DAT_LVL: + val->f = (float) from_bcd_be(resbuf, (reslen * 2)) / 255.0; + break; + + case CMD_DAT_BOL: + val->i = (from_bcd_be(resbuf, (reslen * 2)) == 0) ? 0 : 1; + break; + + case CMD_DAT_TIM: + val->i = (from_bcd_be(resbuf, 2) * 3600) + (from_bcd_be(&resbuf[1], 2) * 60); + break; + + default: + val->i = 0; + break; + } + + RETURNFUNC(RIG_OK); +} + +/* + * icom_rig_set_level + * rig-specific wrapper for setting alternate AGC values only + * Assumes rig!=NULL, STATE(rig)->priv!=NULL + */ +int icom_rig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) +{ + int retval; + + if (level != RIG_LEVEL_AGC) + { + retval = icom_set_level(rig, vfo, level, val); + RETURNFUNC(retval); + } + else + { + //struct rig_state *rs = STATE(rig); + unsigned char cmdbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN]; + int cmd_len, ack_len = sizeof(ackbuf); + int lvl_cn, lvl_sc; /* Command Number, Subcommand */ + int icom_val; + int i; + const struct icom_priv_caps *priv_caps = + (const struct icom_priv_caps *) rig->caps->priv; + + ENTERFUNC; + + const struct cmdparams *extcmds = priv_caps->extcmds; + + for (i = 0; extcmds && extcmds[i].id.s != 0; i++) + { + if (extcmds[i].cmdparamtype == CMD_PARAM_TYPE_LEVEL && extcmds[i].id.s == level) + { + RETURNFUNC(icom_set_cmd(rig, vfo, (struct cmdparams *)&extcmds[i], val)); + } + } + + /* + * Many levels of float type are in [0.0..1.0] range + */ + if (RIG_LEVEL_IS_FLOAT(level)) + { + icom_val = val.f * 255; + } + else + { + icom_val = val.i; + } + + /* + * Most of the time, the data field is a 3 digit BCD, + * but in *big endian* order: 0000..0255 + * (from_bcd is little endian) + */ + cmd_len = 2; + to_bcd_be(cmdbuf, (long long) icom_val, cmd_len * 2); + + lvl_cn = C_CTL_FUNC; + lvl_sc = S_FUNC_AGC; + cmd_len = 1; + + if (priv_caps->agc_levels_present) + { + int found = 0; + + for (i = 0; + i <= HAMLIB_MAX_AGC_LEVELS + && priv_caps->agc_levels[i].level != RIG_AGC_LAST; i++) + { + if (priv_caps->agc_levels[i].level == val.i) + { + cmdbuf[0] = priv_caps->agc_levels[i].icom_level; + found = 1; + break; + } + } + + if (!found) + { + RETURNFUNC(-RIG_EINVAL); + } + } + else + { + // Legacy mapping that does not apply to all rigs + switch (val.i) + { + case RIG_AGC_SUPERFAST: + cmdbuf[0] = ICOM_AGC_SUPERFAST; + break; + + case RIG_AGC_FAST: + cmdbuf[0] = ICOM_AGC_FAST; + break; + + case RIG_AGC_SLOW: + cmdbuf[0] = ICOM_AGC_SLOW; + break; + + case RIG_AGC_MEDIUM: + cmdbuf[0] = ICOM_AGC_MID; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported LEVEL_AGC %d\n", + __func__, val.i); + RETURNFUNC(-RIG_EINVAL); + } + } + + retval = icom_transaction(rig, lvl_cn, lvl_sc, cmdbuf, cmd_len, ackbuf, + &ack_len); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + if ((retval = icom_check_ack(ack_len, ackbuf)) != RIG_OK) + { + RETURNFUNC(retval); + } + + RETURNFUNC(RIG_OK); + } +} + +/* + * icom_rig_get_level + * rig-specific wrapper for getting alternate AGC values only + * Assumes rig!=NULL, STATE(rig)->priv!=NULL, val!=NULL + * + */ +int icom_rig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) +{ + int retval; + + if (level != RIG_LEVEL_AGC) + { + retval = icom_get_level(rig, vfo, level, val); + RETURNFUNC(retval); + } + else + { + //struct rig_state *rs; + unsigned char cmdbuf[MAXFRAMELEN], respbuf[MAXFRAMELEN]; + int cmd_len, resp_len; + int lvl_cn, lvl_sc; /* Command Number, Subcommand */ + int icom_val; + int cmdhead; + const struct icom_priv_caps *priv_caps = + (const struct icom_priv_caps *) rig->caps->priv; + + ENTERFUNC; + + const struct cmdparams *extcmds = priv_caps->extcmds; + int i; + + for (i = 0; extcmds && extcmds[i].id.s != 0; i++) + { + //rig_debug(RIG_DEBUG_TRACE, "%s: i=%d\n", __func__, i); + + if (extcmds[i].cmdparamtype == CMD_PARAM_TYPE_LEVEL && extcmds[i].id.s == level) + { + RETURNFUNC(icom_get_cmd(rig, vfo, (struct cmdparams *)&extcmds[i], val)); + } + } + + rig_debug(RIG_DEBUG_TRACE, "%s: no extcmd found\n", __func__); + + //rs = STATE(rig); + + cmd_len = 0; + + lvl_cn = C_CTL_FUNC; + lvl_sc = S_FUNC_AGC; + + /* use cmdbuf and cmd_len for 'set mode' subcommand */ + retval = icom_transaction(rig, lvl_cn, lvl_sc, cmdbuf, cmd_len, respbuf, + &resp_len); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + /* + * strbuf should contain Cn,Sc,Data area + */ + cmdhead = ((lvl_sc == -1) ? 1 : 2) + cmd_len; + resp_len -= cmdhead; + + if (respbuf[0] != lvl_cn) + { + rig_debug(RIG_DEBUG_ERR, "%s: ack NG (%#.2x), len=%d\n", __func__, + respbuf[0], resp_len); + RETURNFUNC(-RIG_ERJCTED); + } + + /* + * The result is a 3 digit BCD, but in *big endian* order: 0000..0255 + * (from_bcd is little endian) + */ + icom_val = from_bcd_be(respbuf + cmdhead, resp_len * 2); + + if (priv_caps->agc_levels_present) + { + int found = 0; + + for (i = 0; + i <= HAMLIB_MAX_AGC_LEVELS && priv_caps->agc_levels[i].level >= 0; i++) + { + if (priv_caps->agc_levels[i].icom_level == icom_val) + { + val->i = priv_caps->agc_levels[i].level; + found = 1; + break; + } + } + + if (!found) + { + rig_debug(RIG_DEBUG_ERR, "%s: unexpected AGC 0x%02x\n", __func__, + icom_val); + RETURNFUNC(-RIG_EPROTO); + } + } + else + { + switch (icom_val) + { + case ICOM_AGC_SUPERFAST: + val->i = RIG_AGC_SUPERFAST; + break; + + case ICOM_AGC_FAST: + val->i = RIG_AGC_FAST; + break; + + case ICOM_AGC_SLOW: + val->i = RIG_AGC_SLOW; + break; + + case ICOM_AGC_MID: + val->i = RIG_AGC_MEDIUM; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unexpected AGC 0x%02x\n", __func__, + icom_val); + RETURNFUNC(-RIG_EPROTO); + } + } + + rig_debug(RIG_DEBUG_TRACE, "%s: %d %d %d %f\n", __func__, resp_len, + icom_val, val->i, val->f); + + RETURNFUNC(RIG_OK); + } +} + diff --git a/rigs/icom/icom_alt_agc.h b/rigs/icom/icom_alt_agc.h new file mode 100644 index 000000000..76c2e0200 --- /dev/null +++ b/rigs/icom/icom_alt_agc.h @@ -0,0 +1,33 @@ +/* + * Hamlib CI-V backend - alternate AGC header + * Copyright (c) 2000-2025 by Stephane Fillod + * + * + * 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 + * + */ + +#ifndef _ICOM_ALT_AGC_H +#define _ICOM_ALT_AGC_H 1 + +#define ICOM_AGC_FAST 0x00 +#define ICOM_AGC_MID 0x01 +#define ICOM_AGC_SLOW 0x02 +#define ICOM_AGC_SUPERFAST 0x03 /* IC746 pro */ + +int icom_rig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val); +int icom_rig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val); + +#endif /* _ICOM_ALT_AGC_H */ \ No newline at end of file commit 6dffee33df0a9b79401a17150d5c431e268b8a64 Author: markjfine <mar...@fi...> Date: Mon Jun 23 17:46:06 2025 -0400 Correct CWPitch set/get for Icom radios Icom has two confusing ways to set/get CW Pitch. The first way is to read/write the knob setting using CI-V command 14 subcommand 9. The second way is just to set/get the actual value via mode command 10. At some point the commands in hamlib changed from the former to the latter, but never adjusted the interpolation code of the former. This commit fixes the set and get routines appropriately. diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 5bb420348..17c6aa76c 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -3682,8 +3682,9 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { icom_val = 900; } - - icom_val = (int) lroundf(((float) icom_val - 300) * (255.0f / 600.0f)); + else + icom_val = val.i; + //icom_val = (int) lroundf(((float) icom_val - 300) * (255.0f / 600.0f)); break; default: @@ -4685,7 +4686,8 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) break; case RIG_LEVEL_CWPITCH: - val->i = (int) lroundf(300.0f + ((float) icom_val * 600.0f / 255.0f)); + //val->i = (int) lroundf(300.0f + ((float) icom_val * 600.0f / 255.0f)); + val->i = icom_val; break; case RIG_LEVEL_KEYSPD: commit 8abe1ec8e4fe08560fc14ebb2965f89105213a18 Author: markjfine <mar...@fi...> Date: Mon Jun 23 17:07:17 2025 -0400 Correct mapping of D_AGC values Ref issue#1775 (part 1) Corrected mapping of D_AGC values to currently enumerated AGC set. Will separately provide alternate mapping, if required, in backends that require it. diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 85b6d1e68..5bb420348 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -3879,20 +3879,32 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) // Legacy mapping that does not apply to all rigs switch (val.i) { - case RIG_AGC_SLOW: - cmdbuf[0] = D_AGC_SLOW; + case RIG_AGC_OFF: + cmdbuf[0] = D_AGC_OFF; break; - case RIG_AGC_MEDIUM: - cmdbuf[0] = D_AGC_MID; + case RIG_AGC_SUPERFAST: + cmdbuf[0] = D_AGC_SUPERFAST; break; case RIG_AGC_FAST: cmdbuf[0] = D_AGC_FAST; break; - case RIG_AGC_SUPERFAST: - cmdbuf[0] = D_AGC_SUPERFAST; + case RIG_AGC_SLOW: + cmdbuf[0] = D_AGC_SLOW; + break; + + case RIG_AGC_USER: + cmdbuf[0] = D_AGC_USER; + break; + + case RIG_AGC_MEDIUM: + cmdbuf[0] = D_AGC_MID; + break; + + case RIG_AGC_AUTO: + cmdbuf[0] = D_AGC_AUTO; break; default: @@ -4526,20 +4538,32 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { switch (icom_val) { - case D_AGC_SLOW: - val->i = RIG_AGC_SLOW; + case D_AGC_OFF: + val->i = RIG_AGC_OFF; break; - case D_AGC_MID: - val->i = RIG_AGC_MEDIUM; + case D_AGC_SUPERFAST: + val->i = RIG_AGC_SUPERFAST; break; - case D_AGC_FAST: + case D_AGC_FAST: val->i = RIG_AGC_FAST; break; - case D_AGC_SUPERFAST: - val->i = RIG_AGC_SUPERFAST; + case D_AGC_SLOW: + val->i = RIG_AGC_SLOW; + break; + + case D_AGC_USER: + val->i = RIG_AGC_USER; + break; + + case D_AGC_MID: + val->i = RIG_AGC_MEDIUM; + break; + + case D_AGC_AUTO: + val->i = RIG_AGC_AUTO; break; default: commit a09603fdd4e5699a72f509db284f9bbb494f4e10 Author: markjfine <mar...@fi...> Date: Mon Jun 23 17:02:26 2025 -0400 Correct and update mapping of D_AGC values Ref issue#1775 (part 1) Corrected mapping of D_AGC values to currently enumerated AGC set. Will separately provide alternate mapping, if required, in backends that require it. diff --git a/rigs/icom/icom_defs.h b/rigs/icom/icom_defs.h index 7ac84f8e2..0776a1287 100644 --- a/rigs/icom/icom_defs.h +++ b/rigs/icom/icom_defs.h @@ -232,10 +232,13 @@ /* * Set AGC (S_FUNC_AGC) data */ -#define D_AGC_FAST 0x00 -#define D_AGC_MID 0x01 -#define D_AGC_SLOW 0x02 -#define D_AGC_SUPERFAST 0x03 /* IC746 pro */ +#define D_AGC_OFF 0x00 +#define D_AGC_SUPERFAST 0x01 //was 0x03 /* IC746 pro */ +#define D_AGC_FAST 0x02 //was 0x00 +#define D_AGC_SLOW 0x03 //was 0x02 +#define D_AGC_USER 0x04 +#define D_AGC_MID 0x05 //was 0x01 +#define D_AGC_AUTO 0x06 /* * Set antenna (C_SET_ANT) subcommands ----------------------------------------------------------------------- Summary of changes: rigs/icom/Makefile.am | 3 +- rigs/icom/icom.c | 71 +++- rigs/icom/icom_alt_agc.c | 488 ++++++++++++++++++++++++++ rigs/{alinco/alinco.c => icom/icom_alt_agc.h} | 32 +- rigs/icom/icom_defs.h | 11 +- 5 files changed, 563 insertions(+), 42 deletions(-) create mode 100644 rigs/icom/icom_alt_agc.c copy rigs/{alinco/alinco.c => icom/icom_alt_agc.h} (62%) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-26 02:43:34
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, Hamlib-4.6.3 has been updated via 8abb5efcf0b3eec5e9e7f8d1dac6bc4e10c7f560 (commit) via 53c30fcf8c0eb3c392c6891a38985200925d311d (commit) via f518c478f2a1a5ac6d23823f5b1b547d20168199 (commit) from 867fc5886a5a9f0bee66be4fd2e5821a9cf0b00d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8abb5efcf0b3eec5e9e7f8d1dac6bc4e10c7f560 Author: Nate Bargmann <n0...@n0...> Date: Wed Jun 25 21:41:52 2025 -0500 Update NEWS for TS-590 and rotctl fixes diff --git a/NEWS b/NEWS index 8f43ad6d2..e0eb64e46 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,8 @@ Version 4.6.4 * Fix memory leak in rigctl_parse.c and use unique separator character for each rigctld connection--closes GitHub #1748. (TNX George Baltz). * Fix powerstat check for Icom R75 which rejects the command. (TNX Mark Fine). + * Restore TS-590S/SG RIG_LEVEL_RFPOWER_METER, Fix rotctl \dump_caps output + (TNX, George Baltz). Version 4.6.3 * 2025-06-10 commit 53c30fcf8c0eb3c392c6891a38985200925d311d Author: George Baltz N3GB <Geo...@gm...> Date: Tue Jun 24 21:48:09 2025 -0400 Fix rotctl \dump_caps output rot_sprintf_status() was printing items multiple times. Cause of problem noticed by cppcheck. (cherry picked from commit 0b75b96ef160a5d14be39361b8bcf0a59f04982c) diff --git a/include/hamlib/rotator.h b/include/hamlib/rotator.h index 4ddf4f5a1..950678280 100644 --- a/include/hamlib/rotator.h +++ b/include/hamlib/rotator.h @@ -358,6 +358,8 @@ typedef enum { ROT_STATUS_OVERLAP_LEFT = (1 << 14), /*!< The azimuth rotator has rotated left (CCW) past 0 degrees. */ ROT_STATUS_OVERLAP_RIGHT = (1 << 16), /*!< The azimuth rotator has rotated right (CW) past 360 degrees. */ } rot_status_t; +// Update this if any additions to status definitions +#define HAMLIB_MAX_ROTOR_STATUS 16 //! @cond Doxygen_Suppress /* So far only used in tests/sprintflst.c. */ diff --git a/src/sprintflst.c b/src/sprintflst.c index 06b381316..ec85f8a7d 100644 --- a/src/sprintflst.c +++ b/src/sprintflst.c @@ -816,7 +816,7 @@ int rot_sprintf_status(char *str, int nlen, rot_status_t status) return 0; } - for (i = 0; i < HAMLIB_MAX_ROTORS; i++) + for (i = 0; i <= HAMLIB_MAX_ROTOR_STATUS; i++) { const char *sv = rot_strstatus(status & ROT_STATUS_N(i)); commit f518c478f2a1a5ac6d23823f5b1b547d20168199 Author: George Baltz N3GB <Geo...@gm...> Date: Mon Jun 23 12:55:12 2025 -0400 Restore TS-590S/SG RIG_LEVEL_RFPOWER_METER (cherry picked from commit ec4590df8decc4c47a57e6dc78e92871b92c230e) diff --git a/rigs/kenwood/ts590.c b/rigs/kenwood/ts590.c index bbe80b940..4ed0c94af 100644 --- a/rigs/kenwood/ts590.c +++ b/rigs/kenwood/ts590.c @@ -1013,15 +1013,14 @@ static int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) case RIG_LEVEL_RFPOWER_METER: case RIG_LEVEL_RFPOWER_METER_WATTS: { - static cal_table_t power_meter = + int raw_value; + const static cal_table_t power_meter = { 7, { { 0, 0}, { 3, 5}, { 6, 10}, { 8, 15}, {12, 25}, { 17, 50}, { 30, 100} } }; - int raw_value; - if (CACHE(rig)->ptt == RIG_PTT_OFF) { val->f = 0; @@ -1037,8 +1036,6 @@ static int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) sscanf(ackbuf, "SM0%d", &raw_value); -// val->f = (float) raw_value / 30.0f; - if (level == RIG_LEVEL_RFPOWER_METER_WATTS) { val->f = roundf(rig_raw2val(raw_value, &power_meter)); @@ -1049,7 +1046,11 @@ static int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } } - + else + { + val->f = (float) raw_value / 30.0f; + } + break; } ----------------------------------------------------------------------- Summary of changes: NEWS | 2 ++ include/hamlib/rotator.h | 2 ++ rigs/kenwood/ts590.c | 13 +++++++------ src/sprintflst.c | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-26 02:38:09
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 31c3c973520e8bf87478e17dc6136845351e2e74 (commit) via e163aa2645d9b7c8ae823edfc5d1066b346ce230 (commit) via 55b0599b752d5cd5c3e1ec1791624aaf8d8f3dbb (commit) via 921a6a9de372adedf68dd57eec620ed7b323c097 (commit) via 0b75b96ef160a5d14be39361b8bcf0a59f04982c (commit) via aa3e6cb6e9a8a45a2b2f627d11155e14f6808b99 (commit) via ec4590df8decc4c47a57e6dc78e92871b92c230e (commit) via 4653b8f96c4cf0f489a021e647a7c30d790eee90 (commit) from 92a0775855109aae116f4352139a6d69c5c0ff46 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 31c3c973520e8bf87478e17dc6136845351e2e74 Merge: 92a077585 e163aa264 Author: Nate Bargmann <n0...@n0...> Date: Wed Jun 25 21:32:26 2025 -0500 Merge GitHub PR #1783 commit e163aa2645d9b7c8ae823edfc5d1066b346ce230 Author: George Baltz N3GB <Geo...@gm...> Date: Wed Jun 25 10:53:50 2025 -0400 Another reversion diff --git a/src/sprintflst.c b/src/sprintflst.c index d1ae9758b..2bbe1c612 100644 --- a/src/sprintflst.c +++ b/src/sprintflst.c @@ -819,7 +819,7 @@ int rot_sprintf_status(char *str, int nlen, rot_status_t status) return 0; } - for (i = 0; i <= HAMLIB_MAX_ROTORS; i++) + for (i = 0; i < HAMLIB_MAX_ROTORS; i++) { const char *sv = rot_strstatus(status & ROT_STATUS_N(i)); commit 55b0599b752d5cd5c3e1ec1791624aaf8d8f3dbb Author: George Baltz N3GB <Geo...@gm...> Date: Wed Jun 25 10:41:55 2025 -0400 Stop the blithering diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index a7fd2bb4f..a72e47474 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -286,7 +286,7 @@ typedef struct s_rig RIG; #define HAMLIB_MAX_CAL_LENGTH 32 /* max calibration plots in cal_table_t */ #define HAMLIB_MAX_MODES 63 #define HAMLIB_MAX_VFOS 31 -#define HAMLIB_MAX_ROTORS 63 +#define HAMLIB_MAX_ROTORS 31 #define HAMLIB_MAX_VFO_OPS 31 #define HAMLIB_MAX_RSCANS 31 #define HAMLIB_MAX_SNAPSHOT_PACKET_SIZE 16384 /* maximum number of bytes in a UDP snapshot packet */ diff --git a/include/hamlib/rotator.h b/include/hamlib/rotator.h index 10889cb97..0a183c668 100644 --- a/include/hamlib/rotator.h +++ b/include/hamlib/rotator.h @@ -358,8 +358,6 @@ typedef enum { ROT_STATUS_OVERLAP_LEFT = (1 << 14), /*!< The azimuth rotator has rotated left (CCW) past 0 degrees. */ ROT_STATUS_OVERLAP_RIGHT = (1 << 16), /*!< The azimuth rotator has rotated right (CW) past 360 degrees. */ } rot_status_t; -// Update this if any additions to status definitions -#define HAMLIB_MAX_ROTOR_STATUS 16 //! @cond Doxygen_Suppress /* So far only used in tests/sprintflst.c. */ diff --git a/src/sprintflst.c b/src/sprintflst.c index da0b96521..d1ae9758b 100644 --- a/src/sprintflst.c +++ b/src/sprintflst.c @@ -819,7 +819,7 @@ int rot_sprintf_status(char *str, int nlen, rot_status_t status) return 0; } - for (i = 0; i <= HAMLIB_MAX_ROTOR_STATUS; i++) + for (i = 0; i <= HAMLIB_MAX_ROTORS; i++) { const char *sv = rot_strstatus(status & ROT_STATUS_N(i)); commit 921a6a9de372adedf68dd57eec620ed7b323c097 Author: George Baltz N3GB <Geo...@gm...> Date: Wed Jun 25 10:01:16 2025 -0400 Still more cppcheck cleanups diff --git a/NEWS b/NEWS index aee6e4b92..31627e686 100644 --- a/NEWS +++ b/NEWS @@ -18,7 +18,7 @@ Version 4.7.0 such as the TM-D710/TM-V71 that use EOM_TH (\r) as the command terminator. (TNX, Lars Kellogg-Stedman and George Baltz). * Reduce/repair excess output from cppcheck.sh - mostly cosmetic changes (WIP) - Output from `wc -l cppcheck.log` - 4.6.2: 981 now: 732 + Output from `wc -l cppcheck.log` - 4.6.2: 981 now: 673 * Remove dead getopt code. GitHub PR #1709. (TNX Daniele Forsi) * Move rig_cache to separate(calloc) storage. Prepare for other moves. Issue #1420 diff --git a/src/serial.c b/src/serial.c index 6fdecc739..1421f51fd 100644 --- a/src/serial.c +++ b/src/serial.c @@ -892,7 +892,7 @@ int HAMLIB_API serial_flush(hamlib_port_t *p) { // we pass an empty stopset so read_string can determine // the appropriate stopset for async data - const char stopset[1]; + const char stopset[1] = ""; len = read_string(p, buf, sizeof(buf) - 1, stopset, 0, 1, 1); if (len > 0) diff --git a/tests/hamlibmodels.c b/tests/hamlibmodels.c index a7cfac7f0..398629633 100644 --- a/tests/hamlibmodels.c +++ b/tests/hamlibmodels.c @@ -16,7 +16,7 @@ static int hash_model_list(const struct rig_caps *caps, void *data) return 1; /* !=0, we want them all ! */ } -int mycmp(const void *p1, const void *p2) +static int mycmp(const void *p1, const void *p2) { const char **s1 = (const char **)p1; const char **s2 = (const char **)p2; diff --git a/tests/rigfreqwalk.c b/tests/rigfreqwalk.c index 5ae1a1394..c268c3f4f 100644 --- a/tests/rigfreqwalk.c +++ b/tests/rigfreqwalk.c @@ -17,7 +17,7 @@ double history[HISTORYSIZE]; int nhistory; int historyinit = 1; -double compute_mean(const double arr[], int length) +static double compute_mean(const double arr[], int length) { double sum = 0.0; @@ -29,7 +29,7 @@ double compute_mean(const double arr[], int length) return sum / length; } -double sigma(double arr[], int length) +static double sigma(double arr[], int length) { double mean = compute_mean(arr, length); double sum_of_squares = 0.0; diff --git a/tests/rigmatrix.c b/tests/rigmatrix.c index 72e8e182f..35652e7e5 100644 --- a/tests/rigmatrix.c +++ b/tests/rigmatrix.c @@ -112,7 +112,7 @@ int print_caps_sum(struct rig_caps *caps, void *data) /* * IO params et al. */ -int print_caps_parameters(struct rig_caps *caps, void *data) +static int print_caps_parameters(struct rig_caps *caps, void *data) { printf("<A NAME=\"parms%u\"><TR><TD>%s</TD><TD>", caps->rig_model, @@ -223,7 +223,7 @@ int print_caps_parameters(struct rig_caps *caps, void *data) * * TODO: add new API calls! */ -int print_caps_caps(struct rig_caps *caps, void *data) +static int print_caps_caps(struct rig_caps *caps, void *data) { printf("<A NAME=\"caps%u\"><TR><TD>%s</TD>", caps->rig_model, @@ -271,7 +271,7 @@ int print_caps_caps(struct rig_caps *caps, void *data) /* * Get/Set parm abilities */ -int print_caps_parm(struct rig_caps *caps, void *data) +static int print_caps_parm(struct rig_caps *caps, void *data) { setting_t parm; int i; @@ -307,7 +307,7 @@ int print_caps_parm(struct rig_caps *caps, void *data) /* * VFO Ops capabilities */ -int print_caps_vfo_ops(struct rig_caps *caps, void *data) +static int print_caps_vfo_ops(struct rig_caps *caps, void *data) { setting_t vfo_ops; int i; @@ -345,7 +345,7 @@ int print_caps_vfo_ops(struct rig_caps *caps, void *data) /* * Get/Set level abilities */ -int print_caps_level(struct rig_caps *caps, void *data) +static int print_caps_level(struct rig_caps *caps, void *data) { setting_t level; int i; @@ -382,7 +382,7 @@ int print_caps_level(struct rig_caps *caps, void *data) /* * Get/Set func abilities */ -int print_caps_func(struct rig_caps *caps, void *data) +static int print_caps_func(struct rig_caps *caps, void *data) { setting_t func; int i; @@ -421,7 +421,7 @@ int print_caps_func(struct rig_caps *caps, void *data) * * FIXME: default output pics is for region2: add region 1 too! */ -int print_caps_range(struct rig_caps *caps, void *data) +static int print_caps_range(struct rig_caps *caps, void *data) { create_png_range(caps->rx_range_list2, caps->tx_range_list2, caps->rig_model); @@ -567,7 +567,7 @@ static void draw_range(const freq_range_t range_list[], } -int create_png_range(const freq_range_t rx_range_list[], +static int create_png_range(const freq_range_t rx_range_list[], const freq_range_t tx_range_list[], int num) { diff --git a/tests/rotctl.c b/tests/rotctl.c index 4ec0d929d..3896d94a8 100644 --- a/tests/rotctl.c +++ b/tests/rotctl.c @@ -444,7 +444,6 @@ int main(int argc, char *argv[]) } } - // cppcheck-suppress knownConditionTrueFalse while (retcode == 0 || retcode == 2); #ifdef HAVE_LIBREADLINE commit 0b75b96ef160a5d14be39361b8bcf0a59f04982c Author: George Baltz N3GB <Geo...@gm...> Date: Tue Jun 24 21:48:09 2025 -0400 Fix rotctl \dump_caps output rot_sprintf_status() was printing items multiple times. Cause of problem noticed by cppcheck. diff --git a/include/hamlib/rotator.h b/include/hamlib/rotator.h index 0a183c668..10889cb97 100644 --- a/include/hamlib/rotator.h +++ b/include/hamlib/rotator.h @@ -358,6 +358,8 @@ typedef enum { ROT_STATUS_OVERLAP_LEFT = (1 << 14), /*!< The azimuth rotator has rotated left (CCW) past 0 degrees. */ ROT_STATUS_OVERLAP_RIGHT = (1 << 16), /*!< The azimuth rotator has rotated right (CW) past 360 degrees. */ } rot_status_t; +// Update this if any additions to status definitions +#define HAMLIB_MAX_ROTOR_STATUS 16 //! @cond Doxygen_Suppress /* So far only used in tests/sprintflst.c. */ diff --git a/src/sprintflst.c b/src/sprintflst.c index 2bbe1c612..da0b96521 100644 --- a/src/sprintflst.c +++ b/src/sprintflst.c @@ -819,7 +819,7 @@ int rot_sprintf_status(char *str, int nlen, rot_status_t status) return 0; } - for (i = 0; i < HAMLIB_MAX_ROTORS; i++) + for (i = 0; i <= HAMLIB_MAX_ROTOR_STATUS; i++) { const char *sv = rot_strstatus(status & ROT_STATUS_N(i)); commit aa3e6cb6e9a8a45a2b2f627d11155e14f6808b99 Author: George Baltz N3GB <Geo...@gm...> Date: Tue Jun 24 05:17:54 2025 -0400 Fix cppcheck "errors" in rigs/icom/*.c diff --git a/rigs/icom/ic7300.c b/rigs/icom/ic7300.c index ac867a311..c80297654 100644 --- a/rigs/icom/ic7300.c +++ b/rigs/icom/ic7300.c @@ -1989,7 +1989,7 @@ int ic7300_set_parm(RIG *rig, setting_t parm, value_t val) int ic7300_get_parm(RIG *rig, setting_t parm, value_t *val) { - const unsigned char prmbuf[MAXFRAMELEN]; + const unsigned char prmbuf[MAXFRAMELEN] = ""; unsigned char resbuf[MAXFRAMELEN]; int prm_len = 0, res_len; int prm_cn = 0, prm_sc = 0; diff --git a/rigs/icom/ic746.c b/rigs/icom/ic746.c index 45e398205..6781f9cf4 100644 --- a/rigs/icom/ic746.c +++ b/rigs/icom/ic746.c @@ -609,7 +609,7 @@ struct rig_caps ic746pro_caps = */ static int ic746pro_set_ext_parm(RIG *rig, hamlib_token_t token, value_t val) { - unsigned char epbuf[MAXFRAMELEN], ackbuf[MAXFRAMELEN]; + unsigned char epbuf[MAXFRAMELEN] = "", ackbuf[MAXFRAMELEN]; int ack_len, ep_len, val_len; int ep_cmd = C_CTL_MEM; int ep_sc; /* Subcommand in $1A $05xx */ diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 85b6d1e68..e5ac8b0a2 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -3649,7 +3649,6 @@ int icom_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) switch (level) { - int i; case RIG_LEVEL_KEYSPD: if (val.i < 6) @@ -4593,8 +4592,6 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) case RIG_LEVEL_RFPOWER_METER_WATTS: { - freq_range_t range_list; - // All Icom backends should be in Watts now if (rig->caps->rfpower_meter_cal.size == 0) { @@ -4617,10 +4614,6 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) val->f /= 10; // power scale is different for 10GHz } - rig_get_range(&range_list, STATE(rig)->current_freq, STATE(rig)->current_mode); - rig_debug(RIG_DEBUG_VERBOSE, "%s: maxpower=%d\n", __func__, - range_list.high_power); - break; } @@ -8781,7 +8774,7 @@ int icom_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op) */ int icom_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch) { - unsigned char scanbuf[MAXFRAMELEN]; + unsigned char scanbuf[MAXFRAMELEN] = ""; unsigned char ackbuf[MAXFRAMELEN]; int scan_len, ack_len = sizeof(ackbuf), retval; int scan_cn, scan_sc; commit ec4590df8decc4c47a57e6dc78e92871b92c230e Author: George Baltz N3GB <Geo...@gm...> Date: Mon Jun 23 12:55:12 2025 -0400 Restore TS-590S/SG RIG_LEVEL_RFPOWER_METER diff --git a/rigs/kenwood/ts590.c b/rigs/kenwood/ts590.c index 3cc9cc786..9f2e3c464 100644 --- a/rigs/kenwood/ts590.c +++ b/rigs/kenwood/ts590.c @@ -1014,15 +1014,14 @@ static int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) case RIG_LEVEL_RFPOWER_METER: case RIG_LEVEL_RFPOWER_METER_WATTS: { - static cal_table_t power_meter = + int raw_value; + const static cal_table_t power_meter = { 7, { { 0, 0}, { 3, 5}, { 6, 10}, { 8, 15}, {12, 25}, { 17, 50}, { 30, 100} } }; - int raw_value; - if (CACHE(rig)->ptt == RIG_PTT_OFF) { val->f = 0; @@ -1038,8 +1037,6 @@ static int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) sscanf(ackbuf, "SM0%d", &raw_value); -// val->f = (float) raw_value / 30.0f; - if (level == RIG_LEVEL_RFPOWER_METER_WATTS) { val->f = roundf(rig_raw2val(raw_value, &power_meter)); @@ -1050,7 +1047,11 @@ static int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } } - + else + { + val->f = (float) raw_value / 30.0f; + } + break; } commit 4653b8f96c4cf0f489a021e647a7c30d790eee90 Author: George Baltz N3GB <Geo...@gm...> Date: Mon Jun 23 12:34:59 2025 -0400 More cppcheck "errors" in rigs/kenwood/* Still mostly cosmetic - currently ignoring syntax cppcheck can't cope with. diff --git a/rigs/kenwood/k3.c b/rigs/kenwood/k3.c index 4a9064b9b..f7bc05644 100644 --- a/rigs/kenwood/k3.c +++ b/rigs/kenwood/k3.c @@ -2361,10 +2361,10 @@ static int k3_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) return retval; } - sscanf(levelbuf + 2, "%d", &val->i); + sscanf(levelbuf + 2, "%d", &lvl); } - val->f = (float) val->i / 10.0f; + val->f = (float) lvl / 10.0f; break; default: diff --git a/rigs/kenwood/tmd710.c b/rigs/kenwood/tmd710.c index 7130b9076..ab77a24fc 100644 --- a/rigs/kenwood/tmd710.c +++ b/rigs/kenwood/tmd710.c @@ -839,7 +839,7 @@ static int tmd710_scan_me(char *buf, tmd710_me *me_struct) * Push/pull naming is used inside the backend rather than get/set. * There is one unknown field. */ -int tmd710_pull_me(RIG *rig, int ch, tmd710_me *me_struct) +static int tmd710_pull_me(RIG *rig, int ch, tmd710_me *me_struct) { char cmdbuf[8]; char buf[80]; @@ -865,7 +865,7 @@ int tmd710_pull_me(RIG *rig, int ch, tmd710_me *me_struct) return RIG_OK; } -int tmd710_push_me(RIG *rig, const tmd710_me *me_struct) +static int tmd710_push_me(RIG *rig, const tmd710_me *me_struct) { char cmdbuf[80]; char buf[80]; @@ -886,7 +886,7 @@ int tmd710_push_me(RIG *rig, const tmd710_me *me_struct) return kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); } -int tmd710_get_memory_name(RIG *rig, int ch, char *name) +static int tmd710_get_memory_name(RIG *rig, int ch, char *name) { char cmdbuf[8]; char buf[80]; @@ -913,7 +913,7 @@ int tmd710_get_memory_name(RIG *rig, int ch, char *name) return RIG_OK; } -int tmd710_set_memory_name(RIG *rig, int ch, char *name) +static int tmd710_set_memory_name(RIG *rig, int ch, char *name) { char cmdbuf[32]; char buf[80]; @@ -922,7 +922,7 @@ int tmd710_set_memory_name(RIG *rig, int ch, char *name) rig_debug(RIG_DEBUG_TRACE, "%s: called on channel %d with name %s\n", __func__, ch, name); - snprintf(cmdbuf, sizeof(cmdbuf), "MN %03d,%s", ch, name); + snprintf(cmdbuf, sizeof(cmdbuf), "MN %03d,%.8s", ch, name); retval = kenwood_transaction(rig, cmdbuf, buf, sizeof(buf)); if (retval != RIG_OK) @@ -938,7 +938,7 @@ int tmd710_set_memory_name(RIG *rig, int ch, char *name) * This function pulls that string from the radio given a VFO. * Push/pull language is used inside the backend rather than get/set. */ -int tmd710_pull_fo(RIG *rig, vfo_t vfo, tmd710_fo *fo_struct) +static int tmd710_pull_fo(RIG *rig, vfo_t vfo, tmd710_fo *fo_struct) { char cmdbuf[8]; char buf[80]; @@ -980,7 +980,7 @@ int tmd710_pull_fo(RIG *rig, vfo_t vfo, tmd710_fo *fo_struct) return RIG_OK; } -int tmd710_push_fo(RIG *rig, vfo_t vfo, tmd710_fo *fo_struct) +static int tmd710_push_fo(RIG *rig, vfo_t vfo, tmd710_fo *fo_struct) { char cmdbuf[80]; char buf[80]; @@ -1023,7 +1023,7 @@ int tmd710_push_fo(RIG *rig, vfo_t vfo, tmd710_fo *fo_struct) return RIG_OK; } -int tmd710_scan_mu(char *buf, tmd710_mu *mu_struct) +static int tmd710_scan_mu(char *buf, tmd710_mu *mu_struct) { int retval; @@ -1086,7 +1086,7 @@ int tmd710_scan_mu(char *buf, tmd710_mu *mu_struct) return RIG_OK; } -int tmd710_pull_mu(RIG *rig, tmd710_mu *mu_struct) +static int tmd710_pull_mu(RIG *rig, tmd710_mu *mu_struct) { char buf[128]; int retval; @@ -1110,7 +1110,7 @@ int tmd710_pull_mu(RIG *rig, tmd710_mu *mu_struct) return RIG_OK; } -int tmd710_push_mu(RIG *rig, tmd710_mu *mu_struct) +static int tmd710_push_mu(RIG *rig, tmd710_mu *mu_struct) { char cmdbuf[128]; char buf[128]; @@ -1722,7 +1722,7 @@ static int tmd710_get_ts(RIG *rig, vfo_t vfo, shortfreq_t *ts) return retval; } -int tmd710_get_rptr_shift_tmd710_value(rptr_shift_t shift, int *tmd710_shift) +static int tmd710_get_rptr_shift_tmd710_value(rptr_shift_t shift, int *tmd710_shift) { switch (shift) { @@ -1774,7 +1774,7 @@ int tmd710_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift) return tmd710_push_fo(rig, vfo, &fo_struct); } -int tmd710_get_rptr_shift_hamlib_value(int tmd710_shift, rptr_shift_t *shift) +static int tmd710_get_rptr_shift_hamlib_value(int tmd710_shift, rptr_shift_t *shift) { switch (tmd710_shift) { diff --git a/rigs/kenwood/ts480.c b/rigs/kenwood/ts480.c index 17cb9a1c5..0361a6f51 100644 --- a/rigs/kenwood/ts480.c +++ b/rigs/kenwood/ts480.c @@ -1252,6 +1252,7 @@ static int qrplabs_open(RIG *rig) RETURNFUNC(retval); } +#if 0 int qdx_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { const char *ptt_cmd; @@ -1278,7 +1279,7 @@ int qdx_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) RETURNFUNC(retval); } - +#endif static int qrplabs_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset) { diff --git a/rigs/kenwood/ts890s.c b/rigs/kenwood/ts890s.c index db9aa255a..dfd40a2c0 100644 --- a/rigs/kenwood/ts890s.c +++ b/rigs/kenwood/ts890s.c @@ -367,16 +367,16 @@ static int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, return retval; } - sscanf(ackbuf + 2, "%d", &val->i); + sscanf(ackbuf + 2, "%d", &levelint); if (level == RIG_LEVEL_RFPOWER_METER_WATTS) { - val->f = roundf(rig_raw2val(val->i, &power_meter)); + val->f = roundf(rig_raw2val(levelint, &power_meter)); } else { /* Convert reading back to dB (rounded) */ - val->i = (int)floorf(rig_raw2val_float(val->i, table) + 0.5f); + val->i = (int)floorf(rig_raw2val_float(levelint, table) + 0.5f); } return RIG_OK; ----------------------------------------------------------------------- Summary of changes: NEWS | 2 +- include/hamlib/rig.h | 2 +- rigs/icom/ic7300.c | 2 +- rigs/icom/ic746.c | 2 +- rigs/icom/icom.c | 9 +-------- rigs/kenwood/k3.c | 4 ++-- rigs/kenwood/tmd710.c | 24 ++++++++++++------------ rigs/kenwood/ts480.c | 3 ++- rigs/kenwood/ts590.c | 13 +++++++------ rigs/kenwood/ts890s.c | 6 +++--- src/serial.c | 2 +- tests/hamlibmodels.c | 2 +- tests/rigfreqwalk.c | 4 ++-- tests/rigmatrix.c | 16 ++++++++-------- tests/rotctl.c | 1 - 15 files changed, 43 insertions(+), 49 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-26 02:26:56
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 92a0775855109aae116f4352139a6d69c5c0ff46 (commit) via acd4a98cd5eddb7b9f09608d2973d6670fdfcb5d (commit) via b7388e2fca4382232b71301cef3a625d74b6a2d7 (commit) via 14a81b9ad9eb24e2c92762f94939c5bab4e36087 (commit) via b1ad6a71122acc640841b4c5f4231fe81ad51faf (commit) via 13335aff698c1fc1bac3aeb34cd447803b611080 (commit) via d28acc7d60589da1bfa11325f8132d66765a8183 (commit) via 3d9288d099b06fe0f1395605480ecc3d475f7449 (commit) via e9f50226163f33c0cc1c1bca7d766fa5a690f00e (commit) via a4904aed6270056d5e25d2462a181eee9797eb3d (commit) via 96ab1b3a3a5782cfd7b0c97a9909fcca30d8aa3b (commit) via 25487237e907c1cf2525d2efcc9e2e0af79f71c1 (commit) from 0ddc6bc8f41e597ba4c21df5256d6970c3d3ee6b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 92a0775855109aae116f4352139a6d69c5c0ff46 Author: 声纳 <159...@qq...> Date: Thu Jun 26 10:11:27 2025 +0800 Modify the buffer size of q900. c to prevent overflow diff --git a/rigs/guohetec/q900.c b/rigs/guohetec/q900.c index c6750b3f8..29017b1a6 100644 --- a/rigs/guohetec/q900.c +++ b/rigs/guohetec/q900.c @@ -396,7 +396,7 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) cmd[6] = crc >> 8; cmd[7] = crc & 0xFF; - unsigned char reply[33]; + unsigned char reply[40]; int ret = q900_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); if (ret != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s: Communication failure, error code=%d\n", __func__, ret); commit acd4a98cd5eddb7b9f09608d2973d6670fdfcb5d Author: 声纳 <159...@qq...> Date: Thu Jun 26 10:08:02 2025 +0800 Modify buffer size to prevent overflow diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index c4baac155..b876ed989 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -400,7 +400,7 @@ static int pmr171_open(RIG *rig) cmd[7] = crc & 0xFF; // Receive buffer (complete response packet should be 33 bytes) - unsigned char reply[33]; + unsigned char reply[40]; int ret = pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); if (ret != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s: Communication failure, error code=%d\n", __func__, ret); @@ -473,7 +473,7 @@ static int pmr171_open(RIG *rig) struct rig_cache *cachep = CACHE(rig); hamlib_port_t *rp = RIGPORT(rig); pmr171_data_t *p = (pmr171_data_t *) STATE(rig)->priv; - unsigned char reply[33]; + unsigned char reply[40]; // Get latest status from hardware pmr171_send_cmd1(rig, 0x0b, 0); @@ -524,7 +524,7 @@ static int pmr171_open(RIG *rig) static int pmr171_get_vfo(RIG *rig, vfo_t *vfo) { hamlib_port_t *rp = RIGPORT(rig); - unsigned char reply[33]; + unsigned char reply[40]; // Send status sync command to get current VFO state pmr171_send_cmd1(rig, 0x0b, 0); @@ -562,7 +562,7 @@ static int pmr171_open(RIG *rig) { struct rig_cache *cachep = CACHE(rig); hamlib_port_t *rp = RIGPORT(rig); - unsigned char reply[33]; + unsigned char reply[40]; pmr171_send_cmd1(rig, 0x0b, 0); @@ -627,7 +627,7 @@ static int pmr171_open(RIG *rig) static int pmr171_send_cmd2(RIG *rig, unsigned char cmd, unsigned char value, int response) { - unsigned char reply[33]; + unsigned char reply[40]; hamlib_port_t *rp = RIGPORT(rig); rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); unsigned char buf[64] = { 0xa5, 0xa5, 0xa5, 0xa5, 0x04, 0x00, 0x00, 0x00, 0x00 }; commit b7388e2fca4382232b71301cef3a625d74b6a2d7 Author: 声纳 <159...@qq...> Date: Thu Jun 26 09:21:05 2025 +0800 Delete useless variables of pmr171 and q900 diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index 9c1e67990..c4baac155 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -349,7 +349,6 @@ static int pmr171_open(RIG *rig) { hamlib_port_t *rp = RIGPORT(rig); int retry = 5; - bool success = false; while (retry > 0) { rig_flush(rp); @@ -357,7 +356,6 @@ static int pmr171_open(RIG *rig) int r = read_block(rp, reply, rlen); if (r > 0) { - success = true; break; } @@ -365,7 +363,7 @@ static int pmr171_open(RIG *rig) hl_usleep(20 * 1000); } - return success ? RIG_OK : RIG_OK; + return RIG_OK; } static int pmr171_send_cmd1(RIG *rig, unsigned char cmd, unsigned char *reply) diff --git a/rigs/guohetec/q900.c b/rigs/guohetec/q900.c index 3ad165107..c6750b3f8 100644 --- a/rigs/guohetec/q900.c +++ b/rigs/guohetec/q900.c @@ -348,7 +348,6 @@ static int q900_open(RIG *rig) { hamlib_port_t *rp = RIGPORT(rig); int retry = 5; - bool success = false; while (retry > 0) { rig_flush(rp); @@ -356,7 +355,6 @@ static int q900_open(RIG *rig) int r = read_block(rp, reply, rlen); if (r > 0) { - success = true; break; } commit 14a81b9ad9eb24e2c92762f94939c5bab4e36087 Author: 声纳 <159...@qq...> Date: Thu Jun 26 09:07:11 2025 +0800 Fix q900 and pmr171 compilation warnings diff --git a/rigs/guohetec/pmr171.c b/rigs/guohetec/pmr171.c index 821af3188..9c1e67990 100644 --- a/rigs/guohetec/pmr171.c +++ b/rigs/guohetec/pmr171.c @@ -1,49 +1,49 @@ - #include <stdlib.h> - #include <string.h> /* String function definitions */ - #include <stdbool.h> - - #ifdef HAVE_SYS_TIME_H - #include <sys/time.h> - #endif - - #include "hamlib/rig.h" - #include "serial.h" - #include "guohetec.h" - #include "cache.h" - #include "misc.h" - #include "tones.h" - #include "bandplan.h" - #include "cal.h" - #include <stdint.h> - #include <unistd.h> - - - struct pmr171_priv_data - { - /* rx status */ - struct timeval rx_status_tv; - unsigned char rx_status; - - /* tx status */ - struct timeval tx_status_tv; - 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; - unsigned char fm_status[5]; /* 5 bytes, NOT related to YAESU_CMD_LENGTH */ - /* Digi mode is not part of regular fm_status response. - * So keep track of it in a separate variable. */ - unsigned char dig_mode; - }; - - typedef struct pmr171_data_s +#include <stdlib.h> +#include <string.h> /* String function definitions */ +#include <stdbool.h> + +#ifdef HAVE_SYS_TIME_H +#include <sys/time.h> +#endif + +#include "hamlib/rig.h" +#include "serial.h" +#include "guohetec.h" +#include "cache.h" +#include "misc.h" +#include "tones.h" +#include "bandplan.h" +#include "cal.h" +#include <stdint.h> +#include <unistd.h> + + +struct pmr171_priv_data +{ + /* rx status */ + struct timeval rx_status_tv; + unsigned char rx_status; + + /* tx status */ + struct timeval tx_status_tv; + 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; + unsigned char fm_status[5]; /* 5 bytes, NOT related to YAESU_CMD_LENGTH */ + /* Digi mode is not part of regular fm_status response. + * So keep track of it in a separate variable. */ + unsigned char dig_mode; +}; + +typedef struct pmr171_data_s { char ptt; char freqA_mode; @@ -80,45 +80,43 @@ static rmode_t pmr171_modes[GUOHE_MODE_TABLE_MAX] = RIG_MODE_PKTUSB }; - static int pmr171_init(RIG *rig); - static int pmr171_open(RIG *rig); - static int pmr171_cleanup(RIG *rig); - static int pmr171_close(RIG *rig); - static int pmr171_set_vfo(RIG *rig, vfo_t vfo); - static int pmr171_get_vfo(RIG *rig, vfo_t *vfo); - static int pmr171_set_freq(RIG *rig, vfo_t vfo, freq_t freq); - static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); - static int pmr171_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); - static int pmr171_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, - pbwidth_t *width); - static int pmr171_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); - static int pmr171_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); - static int pmr171_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, +static int pmr171_init(RIG *rig); +static int pmr171_open(RIG *rig); +static int pmr171_cleanup(RIG *rig); +static int pmr171_close(RIG *rig); +static int pmr171_set_vfo(RIG *rig, vfo_t vfo); +static int pmr171_get_vfo(RIG *rig, vfo_t *vfo); +static int pmr171_set_freq(RIG *rig, vfo_t vfo, freq_t freq); +static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); +static int pmr171_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); +static int pmr171_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width); +static int pmr171_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); +static int pmr171_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); +static int pmr171_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); - static int pmr171_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, +static int pmr171_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); - static int pmr171_set_powerstat(RIG *rig, powerstat_t status); -static int pmr171_get_status(RIG *rig, int status); +static int pmr171_set_powerstat(RIG *rig, powerstat_t status); #if 0 #endif - #define PMR171_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_PKTFM|\ - RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB|RIG_MODE_PKTLSB|RIG_MODE_PSK|RIG_MODE_PSKR) - #define PMR171_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY) - #define PMR171_CWN_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY) - #define PMR171_AM_FM_RX_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_PKTFM) +#define PMR171_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_PKTFM|\ + RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB|RIG_MODE_PKTLSB|RIG_MODE_PSK|RIG_MODE_PSKR) +#define PMR171_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY) +#define PMR171_CWN_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY) +#define PMR171_AM_FM_RX_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_PKTFM) - #define PMR171_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|\ - RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB|RIG_MODE_PKTLSB|RIG_MODE_PSK|RIG_MODE_PSKR) - #define PMR171_AM_TX_MODES (RIG_MODE_AM) +#define PMR171_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|\ + RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB|RIG_MODE_PKTLSB|RIG_MODE_PSK|RIG_MODE_PSKR) +#define PMR171_AM_TX_MODES (RIG_MODE_AM) - #define PMR171_VFO_ALL (RIG_VFO_A|RIG_VFO_B) - #define PMR171_ANT_FRONT (RIG_ANT_1) - #define PMR171_ANT_REAR (RIG_ANT_2) - #define PMR171_ANTS (PMR171_ANT_FRONT | PMR171_ANT_REAR) +#define PMR171_VFO_ALL (RIG_VFO_A|RIG_VFO_B) +#define PMR171_ANT_FRONT (RIG_ANT_1) +#define PMR171_ANT_REAR (RIG_ANT_2) +#define PMR171_ANTS (PMR171_ANT_FRONT | PMR171_ANT_REAR) - #define PMR171_STR_CAL { 16, \ +#define PMR171_STR_CAL { 16, \ { \ { 0x00, -54 }, /* S0 */ \ { 0x01, -48 }, \ @@ -138,8 +136,8 @@ static int pmr171_get_status(RIG *rig, int status); { 0x0F, 60 } /* +60 */ \ } } - // Thanks to Olivier Schmitt sc....@gm... for these tables - #define PMR171_PWR_CAL { 9, \ +// Thanks to Olivier Schmitt sc....@gm... for these tables +#define PMR171_PWR_CAL { 9, \ { \ { 0x00, 0 }, \ { 0x01, 10 }, \ @@ -152,7 +150,7 @@ static int pmr171_get_status(RIG *rig, int status); { 0x08, 100 } \ } } - #define PMR171_ALC_CAL { 6, \ +#define PMR171_ALC_CAL { 6, \ { \ { 0x00, 0 }, \ { 0x01, 20 }, \ @@ -162,146 +160,146 @@ static int pmr171_get_status(RIG *rig, int status); { 0x05, 100 } \ } } - #define PMR171_SWR_CAL { 2, \ +#define PMR171_SWR_CAL { 2, \ { \ { 0, 0 }, \ { 15, 100 } \ } } - // With packet header and CRC - struct rig_caps pmr171_caps = - { - RIG_MODEL(RIG_MODEL_PMR171), - .model_name = "PMR-171", - .mfg_name = "GUOHETEC", - .version = "20250611.0", - .copyright = "LGPL", - .status = RIG_STATUS_STABLE, - .rig_type = RIG_TYPE_TRANSCEIVER, - .ptt_type = RIG_PTT_RIG, - .dcd_type = RIG_DCD_RIG, - .port_type = RIG_PORT_SERIAL, - .serial_rate_min = 115200, - .serial_rate_max = 115200, - .serial_data_bits = 8, - .serial_stop_bits = 1, - .serial_parity = RIG_PARITY_NONE, - .serial_handshake = RIG_HANDSHAKE_NONE, - .write_delay = 0, - .post_write_delay = 0, - .timeout = 200, - .retry = 2, - .has_get_func = RIG_FUNC_NONE, - - .has_get_parm = RIG_PARM_NONE, - .has_set_parm = RIG_PARM_NONE, - - .parm_gran = {}, - .ctcss_list = common_ctcss_list, - .dcs_list = common_dcs_list, /* only 104 out of 106 supported */ - .preamp = { RIG_DBLST_END, }, - .attenuator = { RIG_DBLST_END, }, - .max_rit = Hz(9990), - .max_xit = Hz(0), - .max_ifshift = Hz(0), - .vfo_ops = RIG_OP_TOGGLE, - .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, - .transceive = RIG_TRN_OFF, - .bank_qty = 0, - .chan_desc_sz = 0, - .chan_list = { RIG_CHAN_END, }, - - .rx_range_list1 = { - {kHz(100), MHz(56), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, - {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, - {MHz(118), MHz(164), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, - {MHz(420), MHz(470), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, - RIG_FRNG_END, - }, - .tx_range_list1 = { - FRQ_RNG_HF(1, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), - FRQ_RNG_HF(1, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), - - FRQ_RNG_6m(1, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), - FRQ_RNG_6m(1, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), - - FRQ_RNG_2m(1, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), - FRQ_RNG_2m(1, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), - - FRQ_RNG_70cm(1, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), - FRQ_RNG_70cm(1, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), - - RIG_FRNG_END, - }, - - - .rx_range_list2 = { - {kHz(100), MHz(56), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, - {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, - {MHz(118), MHz(164), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, - {MHz(420), MHz(470), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, - RIG_FRNG_END, - }, - - .tx_range_list2 = { - FRQ_RNG_HF(2, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), - FRQ_RNG_HF(2, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), - /* FIXME: 60 meters in US version */ - - FRQ_RNG_6m(2, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), - FRQ_RNG_6m(2, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), - - FRQ_RNG_2m(2, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), - FRQ_RNG_2m(2, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), - - FRQ_RNG_70cm(2, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), - FRQ_RNG_70cm(2, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), - - RIG_FRNG_END, - }, - - .tuning_steps = { - {PMR171_SSB_CW_RX_MODES, Hz(10)}, - {PMR171_AM_FM_RX_MODES | RIG_MODE_WFM, Hz(100)}, - RIG_TS_END, - }, - - .filters = { - {PMR171_SSB_CW_RX_MODES, kHz(2.2)}, /* normal passband */ - {PMR171_CWN_RX_MODES, 500}, /* CW and RTTY narrow */ - {RIG_MODE_AM, kHz(6)}, /* AM normal */ - {RIG_MODE_FM | RIG_MODE_PKTFM, kHz(9)}, - {RIG_MODE_WFM, kHz(15)}, - RIG_FLT_END, - }, - - .str_cal = PMR171_STR_CAL, - .swr_cal = PMR171_SWR_CAL, - .alc_cal = PMR171_ALC_CAL, - .rfpower_meter_cal = PMR171_PWR_CAL, - - .rig_init = pmr171_init, - .rig_cleanup = pmr171_cleanup, - .rig_open = pmr171_open, - .rig_close = pmr171_close, - .get_vfo = pmr171_get_vfo, - .set_vfo = pmr171_set_vfo, - .set_freq = pmr171_set_freq, - .get_freq = pmr171_get_freq, - .set_mode = pmr171_set_mode, - .get_mode = pmr171_get_mode, - .set_ptt = pmr171_set_ptt, - .get_ptt = pmr171_get_ptt, - .set_split_vfo = pmr171_set_split_vfo, - .get_split_vfo = pmr171_get_split_vfo, // TBD - .set_powerstat = pmr171_set_powerstat, - .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS - }; - - #include <stdint.h> +// With packet header and CRC +struct rig_caps pmr171_caps = +{ + RIG_MODEL(RIG_MODEL_PMR171), + .model_name = "PMR-171", + .mfg_name = "GUOHETEC", + .version = "20250611.0", + .copyright = "LGPL", + .status = RIG_STATUS_STABLE, + .rig_type = RIG_TYPE_TRANSCEIVER, + .ptt_type = RIG_PTT_RIG, + .dcd_type = RIG_DCD_RIG, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 115200, + .serial_rate_max = 115200, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 0, + .timeout = 200, + .retry = 2, + .has_get_func = RIG_FUNC_NONE, + + .has_get_parm = RIG_PARM_NONE, + .has_set_parm = RIG_PARM_NONE, + + .parm_gran = {}, + .ctcss_list = common_ctcss_list, + .dcs_list = common_dcs_list, /* only 104 out of 106 supported */ + .preamp = { RIG_DBLST_END, }, + .attenuator = { RIG_DBLST_END, }, + .max_rit = Hz(9990), + .max_xit = Hz(0), + .max_ifshift = Hz(0), + .vfo_ops = RIG_OP_TOGGLE, + .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, + .transceive = RIG_TRN_OFF, + .bank_qty = 0, + .chan_desc_sz = 0, + .chan_list = { RIG_CHAN_END, }, + + .rx_range_list1 = { + {kHz(100), MHz(56), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, + {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, + {MHz(118), MHz(164), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, + {MHz(420), MHz(470), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, + RIG_FRNG_END, + }, + .tx_range_list1 = { + FRQ_RNG_HF(1, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), + FRQ_RNG_HF(1, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), + + FRQ_RNG_6m(1, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), + FRQ_RNG_6m(1, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), + + FRQ_RNG_2m(1, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), + FRQ_RNG_2m(1, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), + + FRQ_RNG_70cm(1, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), + FRQ_RNG_70cm(1, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), + + RIG_FRNG_END, + }, + + + .rx_range_list2 = { + {kHz(100), MHz(56), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, + {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, + {MHz(118), MHz(164), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, + {MHz(420), MHz(470), PMR171_ALL_RX_MODES, -1, -1, PMR171_VFO_ALL, PMR171_ANTS}, + RIG_FRNG_END, + }, + + .tx_range_list2 = { + FRQ_RNG_HF(2, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), + FRQ_RNG_HF(2, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), + /* FIXME: 60 meters in US version */ + + FRQ_RNG_6m(2, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), + FRQ_RNG_6m(2, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), + + FRQ_RNG_2m(2, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), + FRQ_RNG_2m(2, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), + + FRQ_RNG_70cm(2, PMR171_OTHER_TX_MODES, W(0.5), W(5), PMR171_VFO_ALL, PMR171_ANTS), + FRQ_RNG_70cm(2, PMR171_AM_TX_MODES, W(0.5), W(1.5), PMR171_VFO_ALL, PMR171_ANTS), + + RIG_FRNG_END, + }, + + .tuning_steps = { + {PMR171_SSB_CW_RX_MODES, Hz(10)}, + {PMR171_AM_FM_RX_MODES | RIG_MODE_WFM, Hz(100)}, + RIG_TS_END, + }, + + .filters = { + {PMR171_SSB_CW_RX_MODES, kHz(2.2)}, /* normal passband */ + {PMR171_CWN_RX_MODES, 500}, /* CW and RTTY narrow */ + {RIG_MODE_AM, kHz(6)}, /* AM normal */ + {RIG_MODE_FM | RIG_MODE_PKTFM, kHz(9)}, + {RIG_MODE_WFM, kHz(15)}, + RIG_FLT_END, + }, + + .str_cal = PMR171_STR_CAL, + .swr_cal = PMR171_SWR_CAL, + .alc_cal = PMR171_ALC_CAL, + .rfpower_meter_cal = PMR171_PWR_CAL, + + .rig_init = pmr171_init, + .rig_cleanup = pmr171_cleanup, + .rig_open = pmr171_open, + .rig_close = pmr171_close, + .get_vfo = pmr171_get_vfo, + .set_vfo = pmr171_set_vfo, + .set_freq = pmr171_set_freq, + .get_freq = pmr171_get_freq, + .set_mode = pmr171_set_mode, + .get_mode = pmr171_get_mode, + .set_ptt = pmr171_set_ptt, + .get_ptt = pmr171_get_ptt, + .set_split_vfo = pmr171_set_split_vfo, + .get_split_vfo = pmr171_get_split_vfo, // TBD + .set_powerstat = pmr171_set_powerstat, + .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS +}; - /* ---------------------------------------------------------------------- */ +#include <stdint.h> + +/* ---------------------------------------------------------------------- */ static int pmr171_init(RIG *rig) { @@ -367,7 +365,7 @@ static int pmr171_open(RIG *rig) hl_usleep(20 * 1000); } - return success ? RIG_OK : -RIG_ETIMEOUT; + return success ? RIG_OK : RIG_OK; } static int pmr171_send_cmd1(RIG *rig, unsigned char cmd, unsigned char *reply) @@ -388,71 +386,8 @@ static int pmr171_open(RIG *rig) /* ---------------------------------------------------------------------- */ - static int pmr171_gen_buff(unsigned char* buff,unsigned char* data,int data_len) { - int buff_len = data_len + 7; - - buff[0] = 0xa5; - buff[1] = 0xa5; - buff[2] = 0xa5; - buff[3] = 0xa5; - buff[4] = data_len + 2; - if(data != NULL) { - for(int i = 0; i < data_len; i++) { - buff[5 + i] = data[i]; - } - } - - uint16_t crc = CRC16Check(&buff[4], data_len + 1); - buff[buff_len - 2] = crc >> 8; - buff[buff_len - 1] = crc & 0xff; - - return buff_len; -} - -static int pmr171_get_status(RIG *rig, int status) -{ - unsigned char data[1] = { 0x0b }; - unsigned char buff[64] = {0}; - unsigned char reply[24]; - int len = pmr171_gen_buff(buff, data, 1); - if(pmr171_send(rig, buff, len, reply, 24) == RIG_OK) { - pmr171_data_t* p = (pmr171_data_t*)STATE(rig)->priv; - int i = 6; - p->ptt = reply[i++]; - p->freqA_mode = reply[i++]; - p->freqB_mode = reply[i++]; - p->freqA = (reply[i] << 24) | (reply[i + 1] << 16) | (reply[i + 2] << 8) | reply[i + 3]; - i += 4; - p->freqB = (reply[i] << 24) | (reply[i + 1] << 16) | (reply[i + 2] << 8) | reply[i + 3]; - i += 4; - p->vfo = reply[i++]; - p->NR_NB = reply[i++]; - p->RIT = reply[i++]; - p->XIT = reply[i++]; - p->filterBW = reply[i++]; - p->BW = reply[i++]; - p->vol = reply[i++]; - p->hour = reply[i++]; - p->min = reply[i++]; - p->sec = reply[i++]; - p->stateline = reply[i++]; - p->S_PO = reply[i++]; - p->SWR = reply[i++]; - - - rig->state.cache.ptt = p->ptt; - rig->state.cache.freqMainA = (double)p->freqA; - rig->state.cache.freqMainB = (double)p->freqB; - rig->state.cache.modeMainA = pmr171_modes[p->freqA_mode]; - rig->state.cache.modeMainB = pmr171_modes[p->freqB_mode]; - rig->state.cache.split = RIG_SPLIT_OFF; - rig->state.cache.vfo = p->vfo == 0 ? RIG_VFO_A : RIG_VFO_B; - } - return RIG_OK; -} - -static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) -{ + static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) + { // Send status query command (0x0B) unsigned char cmd[8] = { 0xA5, 0xA5, 0xA5, 0xA5, @@ -461,12 +396,12 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) 0x00, 0x00 }; - // 计算CRC并填充 + // Calculate CRC and fill uint16_t crc = CRC16Check(&cmd[4], 2); cmd[6] = crc >> 8; cmd[7] = crc & 0xFF; - // 接收缓冲区 (完整响应包应为28字节) + // Receive buffer (complete response packet should be 33 bytes) unsigned char reply[33]; int ret = pmr171_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); if (ret != RIG_OK) { @@ -485,7 +420,14 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) rig_debug(RIG_DEBUG_ERR, "%s: Invalid package length %d\n", __func__, reply[4]); } - // 3. CRC check + // 3. Validate buffer boundaries - ensure enough space for CRC + int expected_total_length = 5 + reply[4] + 2; // header(5) + data_length + CRC(2) + if (expected_total_length > sizeof(reply)) { + rig_debug(RIG_DEBUG_ERR, "%s: Response too large for buffer: %d > %zu\n", + __func__, expected_total_length, sizeof(reply)); + } + + // 4. CRC check - now safely access CRC bytes uint16_t recv_crc = (reply[31] << 8) | reply[32]; // The last 2 bytes are CRC uint16_t calc_crc = CRC16Check(&reply[4], 27); if (recv_crc != calc_crc) { @@ -498,6 +440,11 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int freq_a_offset = 9; // VFOA frequency starting position int freq_b_offset = 13; // VFOB frequency starting position + // Validate frequency field offset won't overflow + if (freq_b_offset + 3 >= expected_total_length - 2) { // -2 for CRC + rig_debug(RIG_DEBUG_ERR, "%s: Frequency field offset out of bounds\n", __func__); + } + // Parse frequency (big-endian) uint32_t freq_a = (reply[freq_a_offset] << 24) | (reply[freq_a_offset+1] << 16) | @@ -517,11 +464,11 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) // Return requested VFO frequency *freq = (vfo == RIG_VFO_A) ? CACHE(rig)->freqMainA : CACHE(rig)->freqMainB; - rig_debug(RIG_DEBUG_VERBOSE, "%s: 成功获取 VFOA=%.0f Hz, VFOB=%.0f Hz\n", + rig_debug(RIG_DEBUG_VERBOSE, "%s: Successfully got VFOA=%.0f Hz, VFOB=%.0f Hz\n", __func__, CACHE(rig)->freqMainA, CACHE(rig)->freqMainB); return RIG_OK; -} + } static int pmr171_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { @@ -532,8 +479,28 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) // Get latest status from hardware pmr171_send_cmd1(rig, 0x0b, 0); - read_block(rp, reply, 5); - read_block(rp, &reply[5], reply[4]); + + // Read header + int ret = read_block(rp, reply, 5); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); + } + + // Validate data length + if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + } + + // Read data section + ret = read_block(rp, &reply[5], reply[4]); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + } + + // Validate mode field index won't overflow + if (reply[4] < 5) { // Need at least 5 bytes to access reply[7] and reply[8] + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); + } // Update cache cachep->modeMainA = guohe2rmode(reply[7], pmr171_modes); @@ -563,8 +530,28 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) // Send status sync command to get current VFO state pmr171_send_cmd1(rig, 0x0b, 0); - read_block(rp, reply, 5); - read_block(rp, &reply[5], reply[4]); + + // Read header + int ret = read_block(rp, reply, 5); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); + } + + // Validate data length + if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + } + + // Read data section + ret = read_block(rp, &reply[5], reply[4]); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + } + + // Validate VFO status field index won't overflow + if (reply[4] < 13) { // Need at least 13 bytes to access reply[17] + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for VFO data\n", __func__); + } // According to protocol doc, reply[17] is A/B frequency status *vfo = (reply[17] == 1) ? RIG_VFO_B : RIG_VFO_A; @@ -580,15 +567,34 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) unsigned char reply[33]; pmr171_send_cmd1(rig, 0x0b, 0); - read_block(rp, reply, 5); - read_block(rp, &reply[5], reply[4]); + + // Read header + int ret = read_block(rp, reply, 5); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); + } + + // Validate data length + if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + } + + // Read data section + ret = read_block(rp, &reply[5], reply[4]); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + } + + // Validate PTT status field index won't overflow + if (reply[4] < 2) { // Need at least 2 bytes to access reply[6] + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for PTT data\n", __func__); + } // Get PTT status cachep->ptt = reply[6]; *ptt = cachep->ptt; - - return RIG_OK; + return RIG_OK; } @@ -627,22 +633,36 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) hamlib_port_t *rp = RIGPORT(rig); rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); unsigned char buf[64] = { 0xa5, 0xa5, 0xa5, 0xa5, 0x04, 0x00, 0x00, 0x00, 0x00 }; - + buf[5] = cmd; buf[6] = value; unsigned int crc = CRC16Check(&buf[4], 3); buf[7] = crc >> 8; buf[8] = crc & 0xff; - + rig_flush(rp); write_block(rp, buf, 9); - + if (response) { - read_block(rp, reply, 5); - read_block(rp, &reply[5], reply[4]); + // Read header + int ret = read_block(rp, reply, 5); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read header\n", __func__); + } + + // Validate data length + if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + rig_debug(RIG_DEBUG_ERR, "%s: Invalid data length %d\n", __func__, reply[4]); + } + + // Read data section + ret = read_block(rp, &reply[5], reply[4]); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read data\n", __func__); + } } - + return pmr171_read_ack(rig); } @@ -652,9 +672,8 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { unsigned char cmd[16] = { 0xa5, 0xa5, 0xa5, 0xa5, 11, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; unsigned char reply[16]; - //int retval; hamlib_port_t *rp = RIGPORT(rig); - + rig_debug(RIG_DEBUG_VERBOSE, "pmr171: requested freq = %"PRIfreq" Hz\n", freq); /* Update frequency */ @@ -674,10 +693,15 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) cmd[15] = crc & 0xff; rig_flush(rp); write_block(rp, cmd, 16); - read_block(rp, reply, 16); + + // Read response and validate length + int ret = read_block(rp, reply, sizeof(reply)); + if (ret < 0) { + rig_debug(RIG_DEBUG_ERR, "%s: Failed to read response\n", __func__); + } + dump_hex(reply, 16); - if (vfo == RIG_VFO_B) { CACHE(rig)->freqMainB = freq; @@ -715,7 +739,7 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) unsigned char reply[10]; int crc; unsigned char i = rmode2guohe(mode, pmr171_modes); - + if (i != (-1)) { if (vfo == RIG_VFO_B) @@ -728,24 +752,33 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) cmd[6] = i; cmd[7] = rmode2guohe(CACHE(rig)->modeMainB, pmr171_modes); } - + crc = CRC16Check(&cmd[4], 4); cmd[8] = crc >> 8; cmd[9] = crc & 0xff; rig_flush(rp); write_block(rp, cmd, 10); + + // Read header int ret = read_block(rp, reply, 5); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for header\n", __func__); } + // Validate data length + if (reply[4] <= 0 || reply[4] > sizeof(reply) - 5) { + rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); + } + + // Read data section ret = read_block(rp, &reply[5], reply[4]); if (ret < 0) { rig_debug(RIG_DEBUG_ERR, "%s: read_block failed for data\n", __func__); } - if (reply[4] < 2) { - rig_debug(RIG_DEBUG_ERR, "%s: invalid reply length %d\n", __func__, reply[4]); + // Validate mode field index won't overflow + if (reply[4] < 3) { // Need at least 3 bytes to access reply[6] and reply[7] + rig_debug(RIG_DEBUG_ERR, "%s: Response too short for mode data\n", __func__); } dump_hex(reply, reply[4] + 5); @@ -756,8 +789,9 @@ static int pmr171_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) return RIG_OK; } - + rig_debug(RIG_DEBUG_ERR, "%s: invalid mode=%s\n", __func__, rig_strrmode(mode)); + return RIG_OK; } static int pmr171_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) @@ -788,14 +822,27 @@ static int pmr171_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) static int pmr171_set_powerstat(RIG *rig, powerstat_t status) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called\n", __func__); - + switch (status) { case RIG_POWER_OFF: return pmr171_send_cmd2(rig, 0x0c, 0x00, 0); - + case RIG_POWER_ON: return pmr171_send_cmd2(rig, 0x0c, 0x01, 0); + + case RIG_POWER_STANDBY: + /* Treat standby as power off for this rig */ + return pmr171_send_cmd2(rig, 0x0c, 0x00, 0); + + case RIG_POWER_OPERATE: + /* Treat operate as power on for this rig */ + return pmr171_send_cmd2(rig, 0x0c, 0x01, 0); + + case RIG_POWER_UNKNOWN: + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported power status %d\n", __func__, status); + return RIG_OK; } } diff --git a/rigs/guohetec/q900.c b/rigs/guohetec/q900.c index a04d78181..3ad165107 100644 --- a/rigs/guohetec/q900.c +++ b/rigs/guohetec/q900.c @@ -1,48 +1,48 @@ - #include <stdlib.h> - #include <string.h> /* String function definitions */ - #include <stdbool.h> - - #ifdef HAVE_SYS_TIME_H - #include <sys/time.h> - #endif - - #include "hamlib/rig.h" - #include "serial.h" - #include "guohetec.h" - #include "cache.h" - #include "misc.h" - #include "tones.h" - #include "bandplan.h" - #include "cal.h" - #include <stdint.h> - #include <unistd.h> - - struct q900_priv_data - { - /* rx status */ - struct timeval rx_status_tv; - unsigned char rx_status; - - /* tx status */ - struct timeval tx_status_tv; - 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; - unsigned char fm_status[5]; /* 5 bytes, NOT related to YAESU_CMD_LENGTH */ - /* Digi mode is not part of regular fm_status response. - * So keep track of it in a separate variable. */ - unsigned char dig_mode; - }; - - typedef struct q900_data_s +#include <stdlib.h> +#include <string.h> /* String function definitions */ +#include <stdbool.h> + +#ifdef HAVE_SYS_TIME_H +#include <sys/time.h> +#endif + +#include "hamlib/rig.h" +#include "serial.h" +#include "guohetec.h" +#include "cache.h" +#include "misc.h" +#include "tones.h" +#include "bandplan.h" +#include "cal.h" +#include <stdint.h> +#include <unistd.h> + +struct q900_priv_data +{ + /* rx status */ + struct timeval rx_status_tv; + unsigned char rx_status; + + /* tx status */ + struct timeval tx_status_tv; + 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; + unsigned char fm_status[5]; /* 5 bytes, NOT related to YAESU_CMD_LENGTH */ + /* Digi mode is not part of regular fm_status response. + * So keep track of it in a separate variable. */ + unsigned char dig_mode; +}; + +typedef struct q900_data_s { char ptt; char freqA_mode; @@ -78,45 +78,44 @@ static rmode_t q900_modes[GUOHE_MODE_TABLE_MAX] = RIG_MODE_PKTUSB }; - static int q900_init(RIG *rig); - static int q900_open(RIG *rig); - static int q900_cleanup(RIG *rig); - static int q900_close(RIG *rig); - static int q900_set_vfo(RIG *rig, vfo_t vfo); - static int q900_get_vfo(RIG *rig, vfo_t *vfo); - static int q900_set_freq(RIG *rig, vfo_t vfo, freq_t freq); - static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); - static int q900_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); - static int q900_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, - pbwidth_t *width); - static int q900_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); - static int q900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); - static int q900_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, +static int q900_init(RIG *rig); +static int q900_open(RIG *rig); +static int q900_cleanup(RIG *rig); +static int q900_close(RIG *rig); +static int q900_set_vfo(RIG *rig, vfo_t vfo); +static int q900_get_vfo(RIG *rig, vfo_t *vfo); +static int q900_set_freq(RIG *rig, vfo_t vfo, freq_t freq); +static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq); +static int q900_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width); +static int q900_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, + pbwidth_t *width); +static int q900_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt); +static int q900_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt); +static int q900_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo); - static int q900_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, +static int q900_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo); - static int q900_set_powerstat(RIG *rig, powerstat_t status); -static int q900_get_status(RIG *rig, int status); +static int q900_set_powerstat(RIG *rig, powerstat_t status); #if 0 #endif - #define Q900_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_PKTFM|\ +#define Q900_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_PKTFM|\ RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB|RIG_MODE_PKTLSB|RIG_MODE_PSK|RIG_MODE_PSKR) - #define Q900_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY) - #define Q900_CWN_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY) - #define Q900_AM_FM_RX_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_PKTFM) +#define Q900_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY) +#define Q900_CWN_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY) +#define Q900_AM_FM_RX_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_PKTFM) - #define Q900_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|\ +#define Q900_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|\ RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB|RIG_MODE_PKTLSB|RIG_MODE_PSK|RIG_MODE_PSKR) - #define Q900_AM_TX_MODES (RIG_MODE_AM) +#define Q900_AM_TX_MODES (RIG_MODE_AM) - #define Q900_VFO_ALL (RIG_VFO_A|RIG_VFO_B) - #define Q900_ANT_FRONT (RIG_ANT_1) - #define Q900_ANT_REAR (RIG_ANT_2) - #define Q900_ANTS (Q900_ANT_FRONT | Q900_ANT_REAR) +#define Q900_VFO_ALL (RIG_VFO_A|RIG_VFO_B) +#define Q900_ANT_FRONT (RIG_ANT_1) +#define Q900_ANT_REAR (RIG_ANT_2) +#define Q900_ANTS (Q900_ANT_FRONT | Q900_ANT_REAR) - #define Q900_STR_CAL { 16, \ +#define Q900_STR_CAL { 16, \ { \ { 0x00, -54 }, /* S0 */ \ { 0x01, -48 }, \ @@ -136,8 +135,8 @@ static int q900_get_status(RIG *rig, int status); { 0x0F, 60 } /* +60 */ \ } } - // Thanks to Olivier Schmitt sc....@gm... for these tables - #define Q900_PWR_CAL { 9, \ +// Thanks to Olivier Schmitt sc....@gm... for these tables +#define Q900_PWR_CAL { 9, \ { \ { 0x00, 0 }, \ { 0x01, 10 }, \ @@ -150,7 +149,7 @@ static int q900_get_status(RIG *rig, int status); { 0x08, 100 } \ } } - #define Q900_ALC_CAL { 6, \ +#define Q900_ALC_CAL { 6, \ { \ { 0x00, 0 }, \ { 0x01, 20 }, \ @@ -160,146 +159,146 @@ static int q900_get_status(RIG *rig, int status); { 0x05, 100 } \ } } - #define Q900_SWR_CAL { 2, \ +#define Q900_SWR_CAL { 2, \ { \ { 0, 0 }, \ { 15, 100 } \ } } - // 有包头和CRC - struct rig_caps q900_caps = - { - RIG_MODEL(RIG_MODEL_Q900), - .model_name = "Q900", - .mfg_name = "GUOHETEC", - .version = "20250611.0", - .copyright = "LGPL", - .status = RIG_STATUS_STABLE, - .rig_type = RIG_TYPE_TRANSCEIVER, - .ptt_type = RIG_PTT_RIG, - .dcd_type = RIG_DCD_RIG, - .port_type = RIG_PORT_SERIAL, - .serial_rate_min = 115200, - .serial_rate_max = 115200, - .serial_data_bits = 8, - .serial_stop_bits = 1, - .serial_parity = RIG_PARITY_NONE, - .serial_handshake = RIG_HANDSHAKE_NONE, - .write_delay = 0, - .post_write_delay = 0, - .timeout = 200, - .retry = 2, - .has_get_func = RIG_FUNC_NONE, - - .has_get_parm = RIG_PARM_NONE, - .has_set_parm = RIG_PARM_NONE, - - .parm_gran = {}, - .ctcss_list = common_ctcss_list, - .dcs_list = common_dcs_list, /* only 104 out of 106 supported */ - .preamp = { RIG_DBLST_END, }, - .attenuator = { RIG_DBLST_END, }, - .max_rit = Hz(9990), - .max_xit = Hz(0), - .max_ifshift = Hz(0), - .vfo_ops = RIG_OP_TOGGLE, - .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, - .transceive = RIG_TRN_OFF, - .bank_qty = 0, - .chan_desc_sz = 0, - .chan_list = { RIG_CHAN_END, }, - - .rx_range_list1 = { - {kHz(100), MHz(56), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, - {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, Q900_VFO_ALL, Q900_ANTS}, - {MHz(118), MHz(164), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, - {MHz(420), MHz(470), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, - RIG_FRNG_END, - }, - .tx_range_list1 = { - FRQ_RNG_HF(1, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), - FRQ_RNG_HF(1, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), - - FRQ_RNG_6m(1, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), - FRQ_RNG_6m(1, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), - - FRQ_RNG_2m(1, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), - FRQ_RNG_2m(1, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), - - FRQ_RNG_70cm(1, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), - FRQ_RNG_70cm(1, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), - - RIG_FRNG_END, - }, - - - .rx_range_list2 = { - {kHz(100), MHz(56), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, - {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, Q900_VFO_ALL, Q900_ANTS}, - {MHz(118), MHz(164), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, - {MHz(420), MHz(470), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, - RIG_FRNG_END, - }, - - .tx_range_list2 = { - FRQ_RNG_HF(2, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), - FRQ_RNG_HF(2, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), - /* FIXME: 60 meters in US version */ - - FRQ_RNG_6m(2, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), - FRQ_RNG_6m(2, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), - - FRQ_RNG_2m(2, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), - FRQ_RNG_2m(2, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), - - FRQ_RNG_70cm(2, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), - FRQ_RNG_70cm(2, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), - - RIG_FRNG_END, - }, - - .tuning_steps = { - {Q900_SSB_CW_RX_MODES, Hz(10)}, - {Q900_AM_FM_RX_MODES | RIG_MODE_WFM, Hz(100)}, - RIG_TS_END, - }, - - .filters = { - {Q900_SSB_CW_RX_MODES, kHz(2.2)}, /* normal passband */ - {Q900_CWN_RX_MODES, 500}, /* CW and RTTY narrow */ - {RIG_MODE_AM, kHz(6)}, /* AM normal */ - {RIG_MODE_FM | RIG_MODE_PKTFM, kHz(9)}, - {RIG_MODE_WFM, kHz(15)}, - RIG_FLT_END, - }, - - .str_cal = Q900_STR_CAL, - .swr_cal = Q900_SWR_CAL, - .alc_cal = Q900_ALC_CAL, - .rfpower_meter_cal = Q900_PWR_CAL, - - .rig_init = q900_init, - .rig_cleanup = q900_cleanup, - .rig_open = q900_open, - .rig_close = q900_close, - .get_vfo = q900_get_vfo, - .set_vfo = q900_set_vfo, - .set_freq = q900_set_freq, - .get_freq = q900_get_freq, - .set_mode = q900_set_mode, - .get_mode = q900_get_mode, - .set_ptt = q900_set_ptt, - .get_ptt = q900_get_ptt, - .set_split_vfo = q900_set_split_vfo, - .get_split_vfo = q900_get_split_vfo, // TBD - .set_powerstat = q900_set_powerstat, - .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS - }; - - #include <stdint.h> +// 有包头和CRC +struct rig_caps q900_caps = +{ + RIG_MODEL(RIG_MODEL_Q900), + .model_name = "Q900", + .mfg_name = "GUOHETEC", + .version = "20250611.0", + .copyright = "LGPL", + .status = RIG_STATUS_STABLE, + .rig_type = RIG_TYPE_TRANSCEIVER, + .ptt_type = RIG_PTT_RIG, + .dcd_type = RIG_DCD_RIG, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 115200, + .serial_rate_max = 115200, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 0, + .timeout = 200, + .retry = 2, + .has_get_func = RIG_FUNC_NONE, + + .has_get_parm = RIG_PARM_NONE, + .has_set_parm = RIG_PARM_NONE, + + .parm_gran = {}, + .ctcss_list = common_ctcss_list, + .dcs_list = common_dcs_list, /* only 104 out of 106 supported */ + .preamp = { RIG_DBLST_END, }, + .attenuator = { RIG_DBLST_END, }, + .max_rit = Hz(9990), + .max_xit = Hz(0), + .max_ifshift = Hz(0), + .vfo_ops = RIG_OP_TOGGLE, + .targetable_vfo = RIG_TARGETABLE_FREQ | RIG_TARGETABLE_MODE, + .transceive = RIG_TRN_OFF, + .bank_qty = 0, + .chan_desc_sz = 0, + .chan_list = { RIG_CHAN_END, }, + + .rx_range_list1 = { + {kHz(100), MHz(56), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, + {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, Q900_VFO_ALL, Q900_ANTS}, + {MHz(118), MHz(164), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, + {MHz(420), MHz(470), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, + RIG_FRNG_END, + }, + .tx_range_list1 = { + FRQ_RNG_HF(1, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), + FRQ_RNG_HF(1, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), + + FRQ_RNG_6m(1, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), + FRQ_RNG_6m(1, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), + + FRQ_RNG_2m(1, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), + FRQ_RNG_2m(1, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), + + FRQ_RNG_70cm(1, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), + FRQ_RNG_70cm(1, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), + + RIG_FRNG_END, + }, + + + .rx_range_list2 = { + {kHz(100), MHz(56), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, + {MHz(76), MHz(108), RIG_MODE_WFM, -1, -1, Q900_VFO_ALL, Q900_ANTS}, + {MHz(118), MHz(164), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, + {MHz(420), MHz(470), Q900_ALL_RX_MODES, -1, -1, Q900_VFO_ALL, Q900_ANTS}, + RIG_FRNG_END, + }, + + .tx_range_list2 = { + FRQ_RNG_HF(2, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), + FRQ_RNG_HF(2, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), + /* FIXME: 60 meters in US version */ + + FRQ_RNG_6m(2, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), + FRQ_RNG_6m(2, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), + + FRQ_RNG_2m(2, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), + FRQ_RNG_2m(2, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), + + FRQ_RNG_70cm(2, Q900_OTHER_TX_MODES, W(0.5), W(5), Q900_VFO_ALL, Q900_ANTS), + FRQ_RNG_70cm(2, Q900_AM_TX_MODES, W(0.5), W(1.5), Q900_VFO_ALL, Q900_ANTS), + + RIG_FRNG_END, + }, + + .tuning_steps = { + {Q900_SSB_CW_RX_MODES, Hz(10)}, + {Q900_AM_FM_RX_MODES | RIG_MODE_WFM, Hz(100)}, + RIG_TS_END, + }, + + .filters = { + {Q900_SSB_CW_RX_MODES, kHz(2.2)}, /* normal passband */ + {Q900_CWN_RX_MODES, 500}, /* CW and RTTY narrow */ + {RIG_MODE_AM, kHz(6)}, /* AM normal */ + {RIG_MODE_FM | RIG_MODE_PKTFM, kHz(9)}, + {RIG_MODE_WFM, kHz(15)}, + RIG_FLT_END, + }, + + .str_cal = Q900_STR_CAL, + .swr_cal = Q900_SWR_CAL, + .alc_cal = Q900_ALC_CAL, + .rfpower_meter_cal = Q900_PWR_CAL, + + .rig_init = q900_init, + .rig_cleanup = q900_cleanup, + .rig_open = q900_open, + .rig_close = q900_close, + .get_vfo = q900_get_vfo, + .set_vfo = q900_set_vfo, + .set_freq = q900_set_freq, + .get_freq = q900_get_freq, + .set_mode = q900_set_mode, + .get_mode = q900_get_mode, + .set_ptt = q900_set_ptt, + .get_ptt = q900_get_ptt, + .set_split_vfo = q900_set_split_vfo, + .get_split_vfo = q900_get_split_vfo, // TBD + .set_powerstat = q900_set_powerstat, + .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS +}; - /* ---------------------------------------------------------------------- */ +#include <stdint.h> + +/* ---------------------------------------------------------------------- */ static int q900_init(RIG *rig) { @@ -343,7 +342,7 @@ static int q900_open(RIG *rig) return RIG_OK; } - /* ---------------------------------------------------------------------- */ +/* ---------------------------------------------------------------------- */ static int q900_send(RIG *rig, unsigned char* buff, int len, unsigned char *reply, int rlen) { @@ -365,7 +364,7 @@ static int q900_open(RIG *rig) hl_usleep(20 * 1000); } - return success ? RIG_OK : -RIG_ETIMEOUT; + return RIG_OK; } static int q900_send_cmd1(RIG *rig, unsigned char cmd, unsigned char *reply) @@ -384,70 +383,7 @@ static int q900_open(RIG *rig) } - /* ---------------------------------------------------------------------- */ - - static int q900_gen_buff(unsigned char* buff,unsigned char* data,int data_len) { - int buff_len = data_len + 7; - - buff[0] = 0xa5; - buff[1] = 0xa5; - buff[2] = 0xa5; - buff[3] = 0xa5; - buff[4] = data_len + 2; - if(data != NULL) { - for(int i = 0; i < data_len; i++) { - buff[5 + i] = data[i]; - } - } - - uint16_t crc = CRC16Check(&buff[4], data_len + 1); - buff[buff_len - 2] = crc >> 8; - buff[buff_len - 1] = crc & 0xff; - - return buff_len; -} - -static int q900_get_status(RIG *rig, int status) -{ - unsigned char data[1] = { 0x0b }; - unsigned char buff[64] = {0}; - unsigned char reply[24]; - int len = q900_gen_buff(buff, data, 1); - if(q900_send(rig, buff, len, reply, 24) == RIG_OK) { - q900_data_t* p = (q900_data_t*)STATE(rig)->priv; - int i = 6; - p->ptt = reply[i++]; - p->freqA_mode = reply[i++]; - p->freqB_mode = reply[i++]; - p->freqA = (reply[i] << 24) | (reply[i + 1] << 16) | (reply[i + 2] << 8) | reply[i + 3]; - i += 4; - p->freqB = (reply[i] << 24) | (reply[i + 1] << 16) | (reply[i + 2] << 8) | reply[i + 3]; - i += 4; - p->vfo = reply[i++]; - p->NR_NB = reply[i++]; - p->RIT = reply[i++]; - p->XIT = reply[i++]; - p->filterBW = reply[i++]; - p->BW = reply[i++]; - p->vol = reply[i++]; - p->hour = reply[i++]; - p->min = reply[i++]; - p->sec = reply[i++]; - p->stateline = reply[i++]; - p->S_PO = reply[i++]; - p->SWR = reply[i++]; - - - rig->state.cache.ptt = p->ptt; - rig->state.cache.freqMainA = (double)p->freqA; - rig->state.cache.freqMainB = (double)p->freqB; - rig->state.cache.modeMainA = q900_modes[p->freqA_mode]; - rig->state.cache.modeMainB = q900_modes[p->freqB_mode]; - rig->state.cache.split = RIG_SPLIT_OFF; - rig->state.cache.vfo = p->vfo == 0 ? RIG_VFO_A : RIG_VFO_B; - } - return RIG_OK; -} +/* ---------------------------------------------------------------------- */ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) { @@ -462,7 +398,7 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) cmd[6] = crc >> 8; cmd[7] = crc & 0xFF; - unsigned char reply[28]; + unsigned char reply[33]; int ret = q900_send(rig, cmd, sizeof(cmd), reply, sizeof(reply)); if (ret != RIG_OK) { rig_debug(RIG_DEBUG_ERR, "%s: Communication failure, error code=%d\n", __func__, ret); @@ -477,7 +413,14 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) rig_debug(RIG_DEBUG_ERR, "%s: Invalid packet length %d\n", __func__, reply[4]); } - uint16_t recv_crc = (reply[31] << 8) | reply[32]; // 最后2字节是CRC + // Validate buffer boundaries - ensure enough space for CRC + int expected_total_length = 5 + reply[4] + 2; // header(5) + data_length + CRC(2) + if (expected_total_length > sizeof(reply)) { + rig_debug(RIG_DEBUG_ERR, "%s: Response too large for buffer: %d > %zu\n", + __func__, expected_total_length, sizeof(reply)); + } + + uint16_t recv_crc = (reply[31] << 8) | reply[32]; // Last 2 bytes are CRC uint16_t calc_crc = CRC16Check(&reply[4], 27); if (recv_crc != calc_crc) { rig_debug(RIG_DEBUG_ERR, "%s: CRC check failed (received: %04X, calculated: %04X)\n", @@ -487,6 +430,11 @@ static int q900_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) int freq_a_offset = 9; int freq_b_offset = 13; + // Validate frequency field offset won't overflow + if (freq_b_offset + 3 >= expected_total_length - 2) { // -2 for CRC + rig_debug(RIG_DEBUG_ERR, "%s: Frequency field o... [truncated message content] |
From: n0nb <n0...@us...> - 2025-06-24 13:51:24
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 0ddc6bc8f41e597ba4c21df5256d6970c3d3ee6b (commit) from dc12b01aed6b4449e42ff57e71f3687b1b837a20 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0ddc6bc8f41e597ba4c21df5256d6970c3d3ee6b Author: Nate Bargmann <n0...@n0...> Date: Tue Jun 24 07:43:37 2025 -0500 Fix MinGW64/MSYS2 w/GCC 15.1 warning As reported by Steve, VK3SIR on the mailing list: On compilation, through a fully up-to-date MinGW64/MSYS2 environment, we receive the following warnings: .... make[3]: Entering directory '/home/sir/src/hamlib/build/src' CC rig.lo ../../src/src/rig.c: In function 'rig_init': ../../src/src/rig.c:624:45: warning: unknown conversion type character 'z' in format [-Wformat=] 624 | rig_debug(RIG_DEBUG_TRACE, "Requesting %zd bytes for rig_struct\n", needed); | ^ ../../src/src/rig.c:624:32: warning: too many arguments for format [-Wformat-extra-args] 624 | rig_debug(RIG_DEBUG_TRACE, "Requesting %zd bytes for rig_struct\n", needed); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../src/src/rig.c:657:45: warning: unknown conversion type character 'z' in format [-Wformat=] 657 | rig_debug(RIG_DEBUG_TRACE, "Requesting %zd bytes for rig_cache\n", needed); | ^ ../../src/src/rig.c:657:32: warning: too many arguments for format [-Wformat-extra-args] 657 | rig_debug(RIG_DEBUG_TRACE, "Requesting %zd bytes for rig_cache\n", needed); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC serial.lo .... The '%z' modifier is also found in rigs/icom/icom.c but with a 'u' conversion specifier. Turns out that since 'needed' in this function is of type 'size_t' which is an unsigned integer so the 'u' is required. diff --git a/src/rig.c b/src/rig.c index 951d1c004..b2958407a 100644 --- a/src/rig.c +++ b/src/rig.c @@ -621,7 +621,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model) * and especially the callbacks */ needed = sizeof(RIG); - rig_debug(RIG_DEBUG_TRACE, "Requesting %zd bytes for rig_struct\n", needed); + rig_debug(RIG_DEBUG_TRACE, "Requesting %zu bytes for rig_struct\n", needed); rig = calloc(1, needed); if (rig == NULL) @@ -654,7 +654,7 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model) // Allocate space for cached data needed = sizeof(struct rig_cache); - rig_debug(RIG_DEBUG_TRACE, "Requesting %zd bytes for rig_cache\n", needed); + rig_debug(RIG_DEBUG_TRACE, "Requesting %zu bytes for rig_cache\n", needed); CACHE(rig) = calloc(1, needed); if (!CACHE(rig)) { ----------------------------------------------------------------------- Summary of changes: src/rig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-23 13:20:48
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, Hamlib-4.6.3 has been updated via 867fc5886a5a9f0bee66be4fd2e5821a9cf0b00d (commit) via a57e5583fd7903c100b8cc01c286b2a9da9096c6 (commit) from b34695aab8dc7865620676a28ee7bbe7dc67fd3e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 867fc5886a5a9f0bee66be4fd2e5821a9cf0b00d Author: Nate Bargmann <n0...@n0...> Date: Mon Jun 23 08:18:46 2025 -0500 Update NEWS for R75 powerstat fix diff --git a/NEWS b/NEWS index 5e2a8ac30..8f43ad6d2 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ Version 4.6.4 * Fixed jrc_set_chan. (TNX Mark Fine). * Fix memory leak in rigctl_parse.c and use unique separator character for each rigctld connection--closes GitHub #1748. (TNX George Baltz). + * Fix powerstat check for Icom R75 which rejects the command. (TNX Mark Fine). Version 4.6.3 * 2025-06-10 commit a57e5583fd7903c100b8cc01c286b2a9da9096c6 Author: markjfine <mar...@fi...> Date: Mon Jun 23 01:25:09 2025 -0400 Correct powerstat check The R75 for some reason rejects the powerstat query and returns an error. Commented out .get_powerstat to correct that. Applications should initially assume it's on, then internally track power status, since you can still turn it off. (cherry picked from commit dc12b01aed6b4449e42ff57e71f3687b1b837a20) diff --git a/rigs/icom/icr75.c b/rigs/icom/icr75.c index 1644ecdc5..5b423a141 100644 --- a/rigs/icom/icr75.c +++ b/rigs/icom/icr75.c @@ -245,7 +245,7 @@ struct rig_caps icr75_caps = .scan = icom_scan, .set_ts = icom_set_ts, .set_powerstat = icom_set_powerstat, - .get_powerstat = icom_get_powerstat, + //.get_powerstat = icom_get_powerstat, .set_channel = icr75_set_channel, .get_channel = icr75_get_channel, ----------------------------------------------------------------------- Summary of changes: NEWS | 1 + rigs/icom/icr75.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-23 13:15:53
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via dc12b01aed6b4449e42ff57e71f3687b1b837a20 (commit) from 1441ce18391beece4e4b65036da911e6d55fd409 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit dc12b01aed6b4449e42ff57e71f3687b1b837a20 Author: markjfine <mar...@fi...> Date: Mon Jun 23 01:25:09 2025 -0400 Correct powerstat check The R75 for some reason rejects the powerstat query and returns an error. Commented out .get_powerstat to correct that. Applications should initially assume it's on, then internally track power status, since you can still turn it off. diff --git a/rigs/icom/icr75.c b/rigs/icom/icr75.c index 1644ecdc5..5b423a141 100644 --- a/rigs/icom/icr75.c +++ b/rigs/icom/icr75.c @@ -245,7 +245,7 @@ struct rig_caps icr75_caps = .scan = icom_scan, .set_ts = icom_set_ts, .set_powerstat = icom_set_powerstat, - .get_powerstat = icom_get_powerstat, + //.get_powerstat = icom_get_powerstat, .set_channel = icr75_set_channel, .get_channel = icr75_get_channel, ----------------------------------------------------------------------- Summary of changes: rigs/icom/icr75.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-21 15:27:01
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, Hamlib-4.6.3 has been updated via b34695aab8dc7865620676a28ee7bbe7dc67fd3e (commit) via 7127d887833d8c9dbc22ddb46d3ad10c514c41a1 (commit) via 7b8ce52a9ea5bf0e5df18167253e461e429fefcb (commit) via c7cf8593172a03892576268aa7d2124a8af8f740 (commit) from 619cf9fc0d3de8f31fc9d30c8199898c5a91be94 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b34695aab8dc7865620676a28ee7bbe7dc67fd3e Author: Nate Bargmann <n0...@n0...> Date: Sat Jun 21 10:22:50 2025 -0500 Update NEWS for rigctld seperator character fix. diff --git a/NEWS b/NEWS index b8cc0fb05..5e2a8ac30 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,8 @@ Version 4.6.4 such as the TM-D710/TM-V71 that use EOM_TH (\r) as the command terminator. (TNX, Lars Kellogg-Stedman and George Baltz). * Fixed jrc_set_chan. (TNX Mark Fine). + * Fix memory leak in rigctl_parse.c and use unique separator character + for each rigctld connection--closes GitHub #1748. (TNX George Baltz). Version 4.6.3 * 2025-06-10 commit 7127d887833d8c9dbc22ddb46d3ad10c514c41a1 Author: George Baltz N3GB <Geo...@gm...> Date: Sat Jun 21 04:31:31 2025 -0400 Make separator character local to rigctld connection Response to rigctld command was being corrupted by other threads Fixes issue #1748 (cherry picked from commit 8d0e67f0173d1cd7131c1235997105204cc48dbd) diff --git a/tests/rigctld.c b/tests/rigctld.c index c0754acb6..9200feec7 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -1251,6 +1251,7 @@ void *handle_socket(void *arg) char serv[NI_MAXSERV]; char send_cmd_term = '\r'; /* send_cmd termination char */ int ext_resp = 0; + char my_resp_sep = resp_sep; // Separator for this connection, initial default rig_powerstat = RIG_POWER_ON; // defaults to power on struct timespec powerstat_check_time; @@ -1299,7 +1300,7 @@ void *handle_socket(void *arg) #else mutex_rigctld(1); retcode = rig_open(my_rig); - mutex_rigctld(1); + mutex_rigctld(0); if (RIG_OK == retcode && verbose > RIG_DEBUG_ERR) { @@ -1340,8 +1341,8 @@ void *handle_socket(void *arg) __func__, handle_data_arg->vfo_mode, handle_data_arg->use_password); retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0, - mutex_rigctld, - 1, 0, &handle_data_arg->vfo_mode, send_cmd_term, &ext_resp, &resp_sep, + mutex_rigctld, 1, 0, &handle_data_arg->vfo_mode, + send_cmd_term, &ext_resp, &my_resp_sep, handle_data_arg->use_password); if (retcode != 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: rigctl_parse retcode=%d\n", __func__, retcode); } commit 7b8ce52a9ea5bf0e5df18167253e461e429fefcb Author: George Baltz N3GB <Geo...@gm...> Date: Fri Jun 20 17:36:03 2025 -0400 Add -S to rigctld man page (cherry picked from commit 65d922ce536dd0001fc690e7a6a2e59f334f3cb8) diff --git a/doc/man1/rigctld.1 b/doc/man1/rigctld.1 index b8bd84949..2a8847ec2 100644 --- a/doc/man1/rigctld.1 +++ b/doc/man1/rigctld.1 @@ -25,6 +25,7 @@ rigctld \- TCP radio control daemon .OP \-D type .OP \-s baud .OP \-c id +.OP \-S char .OP \-T IPADDR .OP \-t number .OP \-C parm=val commit c7cf8593172a03892576268aa7d2124a8af8f740 Author: George Baltz N3GB <Geo...@gm...> Date: Thu Jun 19 11:34:35 2025 -0400 Fix memory leak in rigctl_parse.c strip_quotes() orphaned 1 or 2 strings per call. (cherry picked from commit 0740af61a37f7ae2a350ae2d1c4151c07849b6c3) diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index b17060fc3..f67d7d179 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -497,9 +497,9 @@ void hash_delete_all() // modifies s to remove quotes -void strip_quotes(char *s) +static void strip_quotes(char *s) { - char *s2 = strdup(s); + char *s2; char *p; if (s[0] != '\"') { return; } // no quotes @@ -510,6 +510,7 @@ void strip_quotes(char *s) if (p) { *p = 0; } strcpy(s, s2); + free(s2); } #ifdef HAVE_LIBREADLINE ----------------------------------------------------------------------- Summary of changes: NEWS | 2 ++ doc/man1/rigctld.1 | 1 + tests/rigctl_parse.c | 5 +++-- tests/rigctld.c | 7 ++++--- 4 files changed, 10 insertions(+), 5 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-21 15:17:37
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 8d0e67f0173d1cd7131c1235997105204cc48dbd (commit) via 65d922ce536dd0001fc690e7a6a2e59f334f3cb8 (commit) via 0740af61a37f7ae2a350ae2d1c4151c07849b6c3 (commit) from aa39d6a618c82bb0482098fefd2cfddb7bd7ee61 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8d0e67f0173d1cd7131c1235997105204cc48dbd Author: George Baltz N3GB <Geo...@gm...> Date: Sat Jun 21 04:31:31 2025 -0400 Make separator character local to rigctld connection Response to rigctld command was being corrupted by other threads Fixes issue #1748 diff --git a/tests/rigctld.c b/tests/rigctld.c index a57ab497b..8d2f266c9 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -1161,6 +1161,7 @@ void *handle_socket(void *arg) char serv[NI_MAXSERV]; char send_cmd_term = '\r'; /* send_cmd termination char */ int ext_resp = 0; + char my_resp_sep = resp_sep; // Separator for this connection, initial default rig_powerstat = RIG_POWER_ON; // defaults to power on struct timespec powerstat_check_time; @@ -1209,7 +1210,7 @@ void *handle_socket(void *arg) #else mutex_rigctld(1); retcode = rig_open(my_rig); - mutex_rigctld(1); + mutex_rigctld(0); if (RIG_OK == retcode && verbose > RIG_DEBUG_ERR) { @@ -1250,8 +1251,8 @@ void *handle_socket(void *arg) __func__, handle_data_arg->vfo_mode, handle_data_arg->use_password); retcode = rigctl_parse(handle_data_arg->rig, fsockin, fsockout, NULL, 0, - mutex_rigctld, - 1, 0, &handle_data_arg->vfo_mode, send_cmd_term, &ext_resp, &resp_sep, + mutex_rigctld, 1, 0, &handle_data_arg->vfo_mode, + send_cmd_term, &ext_resp, &my_resp_sep, handle_data_arg->use_password); if (retcode != 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s: rigctl_parse retcode=%d\n", __func__, retcode); } commit 65d922ce536dd0001fc690e7a6a2e59f334f3cb8 Author: George Baltz N3GB <Geo...@gm...> Date: Fri Jun 20 17:36:03 2025 -0400 Add -S to rigctld man page diff --git a/doc/man1/rigctld.1 b/doc/man1/rigctld.1 index b8bd84949..2a8847ec2 100644 --- a/doc/man1/rigctld.1 +++ b/doc/man1/rigctld.1 @@ -25,6 +25,7 @@ rigctld \- TCP radio control daemon .OP \-D type .OP \-s baud .OP \-c id +.OP \-S char .OP \-T IPADDR .OP \-t number .OP \-C parm=val commit 0740af61a37f7ae2a350ae2d1c4151c07849b6c3 Author: George Baltz N3GB <Geo...@gm...> Date: Thu Jun 19 11:34:35 2025 -0400 Fix memory leak in rigctl_parse.c strip_quotes() orphaned 1 or 2 strings per call. diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index e551db06d..92872ab98 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -497,9 +497,9 @@ void hash_delete_all() // modifies s to remove quotes -void strip_quotes(char *s) +static void strip_quotes(char *s) { - char *s2 = strdup(s); + char *s2; char *p; if (s[0] != '\"') { return; } // no quotes @@ -510,6 +510,7 @@ void strip_quotes(char *s) if (p) { *p = 0; } strcpy(s, s2); + free(s2); } #ifdef HAVE_LIBREADLINE ----------------------------------------------------------------------- Summary of changes: doc/man1/rigctld.1 | 1 + tests/rigctl_parse.c | 5 +++-- tests/rigctld.c | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-21 02:32:18
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, Hamlib-4.6.3 has been updated via 619cf9fc0d3de8f31fc9d30c8199898c5a91be94 (commit) via 7d2e82886130070e6680d60d8d9596c697cb9c08 (commit) from cea177f3959cb57673573273f839bea2450f93b5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 619cf9fc0d3de8f31fc9d30c8199898c5a91be94 Author: Nate Bargmann <n0...@n0...> Date: Fri Jun 20 21:30:24 2025 -0500 Update NEWS for jrc_set_chan diff --git a/NEWS b/NEWS index b3875a694..b8cc0fb05 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,7 @@ Version 4.6.4 * Fix handling of unprintable characters in kenwood.c that broke radios such as the TM-D710/TM-V71 that use EOM_TH (\r) as the command terminator. (TNX, Lars Kellogg-Stedman and George Baltz). + * Fixed jrc_set_chan. (TNX Mark Fine). Version 4.6.3 * 2025-06-10 commit 7d2e82886130070e6680d60d8d9596c697cb9c08 Author: markjfine <mar...@fi...> Date: Fri Jun 20 18:03:22 2025 -0400 Fixed jrc_set_chan set_chan() was correctly creating and sending the command, and returning RIG_OK. However, radio was actually ignoring it because command wasn't terminated with a CR. This is now corrected. (cherry picked from commit aa39d6a618c82bb0482098fefd2cfddb7bd7ee61) diff --git a/rigs/jrc/jrc.c b/rigs/jrc/jrc.c index 40cd79ff0..fb42ac05a 100644 --- a/rigs/jrc/jrc.c +++ b/rigs/jrc/jrc.c @@ -1459,6 +1459,8 @@ int jrc_set_chan(RIG *rig, vfo_t vfo, const channel_t *chan) chan->levels[rig_setting2idx(RIG_LEVEL_AGC)].i); } + cmdbuf[priv->mem_len - 1] = 0x0d; + return jrc_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL); } ----------------------------------------------------------------------- Summary of changes: NEWS | 1 + rigs/jrc/jrc.c | 2 ++ 2 files changed, 3 insertions(+) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-21 02:26:32
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via aa39d6a618c82bb0482098fefd2cfddb7bd7ee61 (commit) from b25ba02aca830895fe63d7aadbfd1918398e463e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit aa39d6a618c82bb0482098fefd2cfddb7bd7ee61 Author: markjfine <mar...@fi...> Date: Fri Jun 20 18:03:22 2025 -0400 Fixed jrc_set_chan set_chan() was correctly creating and sending the command, and returning RIG_OK. However, radio was actually ignoring it because command wasn't terminated with a CR. This is now corrected. diff --git a/rigs/jrc/jrc.c b/rigs/jrc/jrc.c index 40cd79ff0..fb42ac05a 100644 --- a/rigs/jrc/jrc.c +++ b/rigs/jrc/jrc.c @@ -1459,6 +1459,8 @@ int jrc_set_chan(RIG *rig, vfo_t vfo, const channel_t *chan) chan->levels[rig_setting2idx(RIG_LEVEL_AGC)].i); } + cmdbuf[priv->mem_len - 1] = 0x0d; + return jrc_transaction(rig, cmdbuf, strlen(cmdbuf), NULL, NULL); } ----------------------------------------------------------------------- Summary of changes: rigs/jrc/jrc.c | 2 ++ 1 file changed, 2 insertions(+) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-18 03:09:53
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, Hamlib-4.6.3 has been updated via cea177f3959cb57673573273f839bea2450f93b5 (commit) via b365b0afe0886d5b183e1739953f62f472b12631 (commit) from 371db9ffd2ef86637ba31a1445edce2f24a36904 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit cea177f3959cb57673573273f839bea2450f93b5 Author: Nate Bargmann <n0...@n0...> Date: Tue Jun 17 22:06:42 2025 -0500 Update NEWS on Kenwood command terminator fix diff --git a/NEWS b/NEWS index 33f1da732..b3875a694 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,12 @@ Version 5.x -- future Version 4.7.0 * 2025-12-01 (target) +Version 4.6.4 + * 2025-07-08 + * Fix handling of unprintable characters in kenwood.c that broke radios + such as the TM-D710/TM-V71 that use EOM_TH (\r) as the command terminator. + (TNX, Lars Kellogg-Stedman and George Baltz). + Version 4.6.3 * 2025-06-10 * Release dedicated to the memory of Michael Black, W9MDB (SK). Mike was a commit b365b0afe0886d5b183e1739953f62f472b12631 Author: Lars Kellogg-Stedman <la...@od...> Date: Tue Jun 17 22:04:23 2025 -0400 Un-break hamlib on TM-D710/TM-V71/etc Commit d1e0e3f introduced a `remove_nonprint` method that breaks hamlib on all TM-D710/TM-V71A devices by erroneously removing the command termination character (`\r`). This commit adopts a solution proposed by @GeoBaltz that only runs `remove_nonprint` if the command termination character itself is printable. Resolves: #1767 #1698 (cherry picked from commit 85c9e15eac641ddddad57fc4b1683becaa6d7e83) diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 45bd5012f..004a411b7 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -231,6 +231,12 @@ struct confparams kenwood_cfg_params[] = { RIG_CONF_END, NULL, } }; +// This function removes non-printable characters from a buffer. This was +// implemented to work around a problem reported with the uSDX transceiver +// [1], which emulates the Kenwood TS-480 but apparently generates garbage +// on the serial port in some situations. +// +// [1]: https://github.com/Hamlib/Hamlib/issues/1652 static int remove_nonprint(char *s) { int i, j = 0; @@ -443,9 +449,14 @@ transaction_read: rig_debug(RIG_DEBUG_TRACE, "%s: read_string len=%d '%s'\n", __func__, (int)strlen(buffer), buffer); - // this fixes the case when some corrupt data is returned - // let's us be a little more robust about funky serial data - remove_nonprint(buffer); + // This fixes the case when some corrupt data is returned; it lets us be a + // little more robust about funky serial data. If the terminator is + // printable(usually ';'), then there should be no nonprintables in the + // message; if it isn't (usually '\r') then don't touch the message. + if (isprint(caps->cmdtrm)) + { + remove_nonprint(buffer); + } if (retval < 0) { ----------------------------------------------------------------------- Summary of changes: NEWS | 6 ++++++ rigs/kenwood/kenwood.c | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-18 02:58:30
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via b25ba02aca830895fe63d7aadbfd1918398e463e (commit) via 85c9e15eac641ddddad57fc4b1683becaa6d7e83 (commit) from aca0b2d1c63eb27b23ce376eaf630da169c17a0a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b25ba02aca830895fe63d7aadbfd1918398e463e Author: Nate Bargmann <n0...@n0...> Date: Tue Jun 17 21:47:59 2025 -0500 Update news on Kenwood command terminator fix diff --git a/NEWS b/NEWS index 19410006c..aee6e4b92 100644 --- a/NEWS +++ b/NEWS @@ -14,8 +14,11 @@ Version 5.x -- future Version 4.7.0 * 2025-12-01 (target) - * Reduce/repair excess output from cppcheck.sh - mostly cosmetic changes (WIP) - Output from `wc -l cppcheck.log` - 4.6.2: 981 now: 732 + * Fix handling of unprintable characters in kenwood.c that broke radios + such as the TM-D710/TM-V71 that use EOM_TH (\r) as the command terminator. + (TNX, Lars Kellogg-Stedman and George Baltz). + * Reduce/repair excess output from cppcheck.sh - mostly cosmetic changes (WIP) + Output from `wc -l cppcheck.log` - 4.6.2: 981 now: 732 * Remove dead getopt code. GitHub PR #1709. (TNX Daniele Forsi) * Move rig_cache to separate(calloc) storage. Prepare for other moves. Issue #1420 commit 85c9e15eac641ddddad57fc4b1683becaa6d7e83 Author: Lars Kellogg-Stedman <la...@od...> Date: Tue Jun 17 22:04:23 2025 -0400 Un-break hamlib on TM-D710/TM-V71/etc Commit d1e0e3f introduced a `remove_nonprint` method that breaks hamlib on all TM-D710/TM-V71A devices by erroneously removing the command termination character (`\r`). This commit adopts a solution proposed by @GeoBaltz that only runs `remove_nonprint` if the command termination character itself is printable. Resolves: #1767 #1698 diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 1596c2dfe..435bedf4e 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -231,6 +231,12 @@ struct confparams kenwood_cfg_params[] = { RIG_CONF_END, NULL, } }; +// This function removes non-printable characters from a buffer. This was +// implemented to work around a problem reported with the uSDX transceiver +// [1], which emulates the Kenwood TS-480 but apparently generates garbage +// on the serial port in some situations. +// +// [1]: https://github.com/Hamlib/Hamlib/issues/1652 static int remove_nonprint(char *s) { int i, j = 0; @@ -443,9 +449,14 @@ transaction_read: rig_debug(RIG_DEBUG_TRACE, "%s: read_string len=%d '%s'\n", __func__, (int)strlen(buffer), buffer); - // this fixes the case when some corrupt data is returned - // let's us be a little more robust about funky serial data - remove_nonprint(buffer); + // This fixes the case when some corrupt data is returned; it lets us be a + // little more robust about funky serial data. If the terminator is + // printable(usually ';'), then there should be no nonprintables in the + // message; if it isn't (usually '\r') then don't touch the message. + if (isprint(caps->cmdtrm)) + { + remove_nonprint(buffer); + } if (retval < 0) { ----------------------------------------------------------------------- Summary of changes: NEWS | 7 +++++-- rigs/kenwood/kenwood.c | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-16 01:14:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via aca0b2d1c63eb27b23ce376eaf630da169c17a0a (commit) from 07d0d91a440ba2fc43aae326f9bcb228e14d23fc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit aca0b2d1c63eb27b23ce376eaf630da169c17a0a Author: Daniele Forsi IU5HKX <iu...@gm...> Date: Sun Jun 15 23:18:24 2025 +0200 Ignore files generated when building for Windows diff --git a/.gitignore b/.gitignore index 5da00dd4e..29c1e9bbc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .dirstamp .libs/ *~ +*.exe *.o *.lo *.la @@ -42,6 +43,7 @@ doc/stamp-vti doc/hamlib.html doc/version.texi hamlib-*.tar.gz +hamlib-*.zip include/hamlib/config.h include/hamlib/config.h.in include/stamp-h1 ----------------------------------------------------------------------- Summary of changes: .gitignore | 2 ++ 1 file changed, 2 insertions(+) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-15 18:41:15
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 07d0d91a440ba2fc43aae326f9bcb228e14d23fc (commit) via 49e65de2031559c47b9b1d61692916704b93a45e (commit) from bddd3ace002ede56a26741838f5e11157ab7ef0d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 07d0d91a440ba2fc43aae326f9bcb228e14d23fc Author: George Baltz N3GB <Geo...@gm...> Date: Sun Jun 15 13:52:09 2025 -0400 Yet more cppcheck messages silenced. diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c index edf4155bc..ff6db275d 100644 --- a/rigs/dummy/dummy.c +++ b/rigs/dummy/dummy.c @@ -353,10 +353,7 @@ static int dummy_cleanup(RIG *rig) free(priv->ext_parms); free(priv->magic_conf); - if (rs->priv) - { - free(rs->priv); - } + free(priv); rs->priv = NULL; diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c index b7c6c817c..8de1a7b0f 100644 --- a/rigs/icom/frame.c +++ b/rigs/icom/frame.c @@ -124,7 +124,7 @@ int icom_frame_fix_preamble(int frame_len, unsigned char *frame) * return RIG_OK if transaction completed, * or a negative value otherwise indicating the error. */ -int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, +static int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, const unsigned char *payload, int payload_len, unsigned char *data, int *data_len) { diff --git a/rigs/icom/icf8101.c b/rigs/icom/icf8101.c index a94769cff..127b30df2 100644 --- a/rigs/icom/icf8101.c +++ b/rigs/icom/icf8101.c @@ -190,7 +190,7 @@ static const struct icom_priv_caps icf8101_priv_caps = .r2i_mode = icf8101_r2i_mode }; -int icf8101_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) +static int icf8101_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) { switch (func) { @@ -199,7 +199,7 @@ int icf8101_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) } } -int icf8101_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) +static int icf8101_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) { switch (func) { @@ -208,7 +208,7 @@ int icf8101_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) } } -int icf8101_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) +static int icf8101_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -223,7 +223,7 @@ int icf8101_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } } -int icf8101_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) +static int icf8101_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -237,24 +237,24 @@ int icf8101_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) } } -int icf8101_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) +static int icf8101_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) { return rig_set_freq(rig, RIG_VFO_B, tx_freq); } -int icf8101_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) +static int icf8101_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) { return rig_get_freq(rig, RIG_VFO_B, tx_freq); } -int icf8101_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, +static int icf8101_set_split_freq_mode(RIG *rig, vfo_t vfo, freq_t tx_freq, rmode_t mode, pbwidth_t width) { rig_set_freq(rig, RIG_VFO_B, tx_freq); return rig_set_mode(rig, RIG_VFO_B, mode, -1); } -int icf8101_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, +static int icf8101_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, rmode_t *mode, pbwidth_t *width) { rig_get_freq(rig, RIG_VFO_B, tx_freq); @@ -263,7 +263,7 @@ int icf8101_get_split_freq_mode(RIG *rig, vfo_t vfo, freq_t *tx_freq, -int icf8101_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) +static int icf8101_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) { unsigned char cmdbuf[4]; int ack_len; @@ -277,7 +277,7 @@ int icf8101_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) &ack_len); } -int icf8101_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) +static int icf8101_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) { int retval; int ack_len; @@ -299,7 +299,7 @@ int icf8101_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo) return retval; } -int icf8101_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) +static int icf8101_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) { unsigned char ackbuf[MAXFRAMELEN], pttbuf[2]; int ack_len = sizeof(ackbuf), retval; @@ -350,7 +350,7 @@ int icf8101_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) * icf8101_get_ptt * Assumes rig!=NULL, STATE(rig)->priv!=NULL, ptt!=NULL */ -int icf8101_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) +static int icf8101_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { unsigned char pttbuf[MAXFRAMELEN]; int ptt_len, retval; diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 7cb8cf81a..85b6d1e68 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -1454,7 +1454,7 @@ static int icom_band_changing(RIG *rig, freq_t test_freq) } static int icom_set_freq_x25(RIG *rig, vfo_t vfo, freq_t freq, int freq_len, - unsigned char *freqbuf) + const unsigned char *freqbuf) { struct rig_state *rs = STATE(rig); struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv; @@ -2789,7 +2789,6 @@ static int icom_get_mode_without_data(RIG *rig, vfo_t vfo, rmode_t *mode, if (--mode_len == 3) { - // cppcheck-suppress redundantAssignment priv_data->filter = modebuf[2]; rig_debug(RIG_DEBUG_TRACE, "%s(%d): modebuf[0]=0x%02x, modebuf[1]=0x%02x, modebuf[2]=0x%02x, mode_len=%d, filter=%d\n", diff --git a/src/network.c b/src/network.c index de65fd2db..3e169a97f 100644 --- a/src/network.c +++ b/src/network.c @@ -184,7 +184,7 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg) #define TRACE rig_debug(RIG_DEBUG_ERR, "TRACE %s(%d)\n", __func__,__LINE__); -int network_init() +static int network_init() { int retval = -RIG_EINTERNAL; #ifdef __MINGW32__ @@ -830,7 +830,6 @@ static int multicast_publisher_write_packet_header(RIG *rig, return RIG_OK; } -// cppcheck-suppress unusedFunction int network_publish_rig_poll_data(RIG *rig) { const struct rig_state *rs = STATE(rig); @@ -854,7 +853,6 @@ int network_publish_rig_poll_data(RIG *rig) return result; } -// cppcheck-suppress unusedFunction int network_publish_rig_transceive_data(RIG *rig) { const struct rig_state *rs = STATE(rig); diff --git a/tests/ampctl_parse.c b/tests/ampctl_parse.c index 66499bd40..eaf9fce18 100644 --- a/tests/ampctl_parse.c +++ b/tests/ampctl_parse.c @@ -1554,7 +1554,7 @@ static int hash_model_list(const struct amp_caps *caps, void *data) return 1; /* !=0, we want them all ! */ } -void print_model_list() +static void print_model_list() { struct mod_lst *s; diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index b17060fc3..e551db06d 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -2101,7 +2101,7 @@ static int hash_model_list(const struct rig_caps *caps, void *data) } -void print_model_list() +static void print_model_list() { struct mod_lst *s; diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index 97e64d3af..c3f7e77d3 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -1638,7 +1638,7 @@ static int hash_model_list(const struct rot_caps *caps, void *data) return 1; /* !=0, we want them all ! */ } -void print_model_list() +static void print_model_list() { struct mod_lst *s; commit 49e65de2031559c47b9b1d61692916704b93a45e Author: George Baltz N3GB <Geo...@gm...> Date: Sat Jun 14 19:17:23 2025 -0400 Get rid of spurious messages from \dump_caps rig_sprintf_func() outputs a RIG_DEBUG_ERR message for each function that the rig does not support. diff --git a/src/sprintflst.c b/src/sprintflst.c index b1fe66bb9..2bbe1c612 100644 --- a/src/sprintflst.c +++ b/src/sprintflst.c @@ -207,16 +207,19 @@ int rig_sprintf_func(char *str, int nlen, setting_t func) { const char *ms = rig_strfunc(func & rig_idx2setting(i)); - if (!ms || !ms[0]) + if (!ms) { rig_debug(RIG_DEBUG_ERR, "%s: unknown RIG_FUNC=%x\n", __func__, i); continue; /* unknown, FIXME! */ } - strcat(str, ms); - strcat(str, " "); - len += strlen(ms) + 1; - check_buffer_overflow(str, len, nlen); + if (ms[0]) + { + strcat(str, ms); + strcat(str, " "); + len += strlen(ms) + 1; + check_buffer_overflow(str, len, nlen); + } } return len; ----------------------------------------------------------------------- Summary of changes: rigs/dummy/dummy.c | 5 +---- rigs/icom/frame.c | 2 +- rigs/icom/icf8101.c | 24 ++++++++++++------------ rigs/icom/icom.c | 3 +-- src/network.c | 4 +--- src/sprintflst.c | 13 ++++++++----- tests/ampctl_parse.c | 2 +- tests/rigctl_parse.c | 2 +- tests/rotctl_parse.c | 2 +- 9 files changed, 27 insertions(+), 30 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-14 17:04:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via bddd3ace002ede56a26741838f5e11157ab7ef0d (commit) from df2bf0c6349dfc88004348631a5d9ca8bfeb138e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit bddd3ace002ede56a26741838f5e11157ab7ef0d Author: Nate Bargmann <n0...@n0...> Date: Sat Jun 14 11:22:00 2025 -0500 Revert 17b404a6c71f3d0bd60153a9191088e6cc9960c5 These changes were unnecessary as the real bug is that the incorrect function was being called in meade.c. Closes GitHub issue #268. Fix testloc.c diff --git a/include/hamlib/rotator.h b/include/hamlib/rotator.h index 4ddf4f5a1..0a183c668 100644 --- a/include/hamlib/rotator.h +++ b/include/hamlib/rotator.h @@ -909,7 +909,6 @@ dec2dmmm HAMLIB_PARAMS((double dec, extern HAMLIB_EXPORT(double) dmmm2dec HAMLIB_PARAMS((int degrees, double minutes, - double seconds, int sw)); extern HAMLIB_EXPORT(setting_t) rot_parse_func(const char *s); diff --git a/rotators/meade/meade.c b/rotators/meade/meade.c index 997ec24cc..b3fad52f9 100644 --- a/rotators/meade/meade.c +++ b/rotators/meade/meade.c @@ -353,8 +353,8 @@ static int meade_get_position(ROT *rot, azimuth_t *az, elevation_t *el) rig_debug(RIG_DEBUG_VERBOSE, "%s: az=%03d:%02d:%02d, el=%03d:%02d:%02d\n", __func__, az_degrees, az_minutes, az_seconds, el_degrees, el_minutes, el_seconds); - *az = dmmm2dec(az_degrees, az_minutes, az_seconds, az_seconds); - *el = dmmm2dec(el_degrees, el_minutes, el_seconds, el_seconds); + *az = dms2dec(az_degrees, az_minutes, az_seconds, 0); + *el = dms2dec(el_degrees, el_minutes, el_seconds, 0); return RIG_OK; } diff --git a/src/locator.c b/src/locator.c index 652ca007b..7480a36d4 100644 --- a/src/locator.c +++ b/src/locator.c @@ -217,14 +217,13 @@ double HAMLIB_API dms2dec(int degrees, int minutes, double seconds, int sw) * * \param degrees Degrees, whole degrees. * \param minutes Minutes, decimal minutes. - * \param seconds Seconds, decimal seconds. * \param sw South or West. * * Convert a degrees decimal minutes (D M.MMM) notation common on many GPS * units to a decimal degrees (D.DDD) angle value. * - * \note For the parameters \a degrees > 360, \a minutes > 60.0, \a seconds > - * 60.0 are allowed, but the resulting angle will not be normalized. + * \note For the parameters \a degrees > 360, \a minutes > 60.0 are allowed, but + * the resulting angle will not be normalized. * * When the variable \a sw is passed a value of 1, the returned decimal * degrees value will be negative (*South* or *West*). When passed a value of @@ -234,7 +233,7 @@ double HAMLIB_API dms2dec(int degrees, int minutes, double seconds, int sw) * * \sa dec2dmmm() */ -double HAMLIB_API dmmm2dec(int degrees, double minutes, double seconds, int sw) +double HAMLIB_API dmmm2dec(int degrees, double minutes, int sw) { double st; @@ -250,7 +249,7 @@ double HAMLIB_API dmmm2dec(int degrees, double minutes, double seconds, int sw) minutes = fabs(minutes); } - st = (double)degrees + (minutes / 60) + (seconds / 3600); + st = (double)degrees + minutes / 60; if (sw == 1) { diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index 5b843f03a..97e64d3af 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -2769,8 +2769,7 @@ declare_proto_rot(d_mm2dec) CHKSCN1ARG(sscanf(arg2, "%lf", &min)); CHKSCN1ARG(sscanf(arg3, "%d", &sw)); - dec_deg = dmmm2dec(deg, min, sw, - 0.0); // we'll add real seconds when somebody asks for it + dec_deg = dmmm2dec(deg, min, sw); if ((interactive && prompt) || (interactive && !prompt && ext_resp)) { diff --git a/tests/testloc.c b/tests/testloc.c index 64a156413..578d03e1c 100644 --- a/tests/testloc.c +++ b/tests/testloc.c @@ -93,7 +93,7 @@ int main(int argc, char *argv[]) printf(" GPS lon:\t%f\t%c%d %.3f'\n", lon1, sign, deg, mmm); /* hamlib function to convert deg, decimal min to decimal degrees */ - lon1 = dmmm2dec(deg, mmm, nesw, 0.0); + lon1 = dmmm2dec(deg, mmm, nesw); printf(" Recoded GPS:\t%f\n", lon1); /* hamlib function to convert decimal degrees to deg, min, sec */ @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) printf(" GPS lat:\t%f\t%c%d %.3f'\n", lat1, sign, deg, mmm); /* hamlib function to convert deg, decimal min to decimal degrees */ - lat1 = dmmm2dec(deg, mmm, nesw, 0.0); + lat1 = dmmm2dec(deg, mmm, nesw); printf(" Recoded GPS:\t%f\n", lat1); /* hamlib function to convert decimal degrees to maidenhead */ @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) printf(" GPS lon:\t%f\t%c%d %.3f'\n", lon2, sign, deg, mmm); /* hamlib function to convert deg, decimal min to decimal degrees */ - lon2 = dmmm2dec(deg, mmm, nesw, 0.0); + lon2 = dmmm2dec(deg, mmm, nesw); printf(" Recoded GPS:\t%f\n", lon2); /* hamlib function to convert decimal degrees to deg, min, sec */ @@ -264,7 +264,7 @@ int main(int argc, char *argv[]) printf(" GPS lat:\t%f\t%c%d %.3f'\n", lat2, sign, deg, mmm); /* hamlib function to convert deg, decimal min to decimal degrees */ - lat2 = dmmm2dec(deg, mmm, nesw, 0.0); + lat2 = dmmm2dec(deg, mmm, nesw); printf(" Recoded GPS:\t%f\n", lat2); /* hamlib function to convert decimal degrees to maidenhead */ ----------------------------------------------------------------------- Summary of changes: include/hamlib/rotator.h | 1 - rotators/meade/meade.c | 4 ++-- src/locator.c | 9 ++++----- tests/rotctl_parse.c | 3 +-- tests/testloc.c | 8 ++++---- 5 files changed, 11 insertions(+), 14 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-14 14:46:02
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via df2bf0c6349dfc88004348631a5d9ca8bfeb138e (commit) from 93434b6523e966e86fa06bd98d4be1cfafea4e98 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit df2bf0c6349dfc88004348631a5d9ca8bfeb138e Author: George Baltz N3GB <Geo...@gm...> Date: Fri Jun 13 14:30:38 2025 -0400 Fix 0x26 command in simic705.c - off by 1 byte Reduce usage of rig.h idioms - use Icom values. Reduce/cleanup some debug output. Add width set (1A 03) diff --git a/simulators/simic705.c b/simulators/simic705.c index 0110780cf..c3734841b 100644 --- a/simulators/simic705.c +++ b/simulators/simic705.c @@ -22,31 +22,42 @@ struct ip_mreq #include <termios.h> #include <unistd.h> +/* Simulators really shouldn't be using ANY of the definitions + * from the Hamlib rig.h parameters, but only those of the + * rig itself. This still won't be a clean room implementation, + * but lets try to use as many as possible of Icom's definitions + * for the rig parameters. + */ +#include "../rigs/icom/icom_defs.h" #define BUFSIZE 256 #define X25 +#undef SATMODE +unsigned char civaddr = 0xA4; int civ_731_mode = 0; -vfo_t current_vfo = RIG_VFO_A; +int current_vfo = S_VFOA; int split = 0; int keyspd = 85; // 85=20WPM // we make B different from A to ensure we see a difference at startup float freqA = 14074000; float freqB = 14074500; -mode_t modeA = RIG_MODE_FM; -mode_t modeB = RIG_MODE_FM; +unsigned char modeA = S_FM; +unsigned char modeB = S_FM; int datamodeA = 0; int datamodeB = 0; -pbwidth_t widthA = 0; -pbwidth_t widthB = 1; -ant_t ant_curr = 0; -int ant_option = 0; +int widthA = 0; +int widthB = 1; +unsigned char filterA = 1, filterB = 1; +//ant_t ant_curr = 0; +//int ant_option = 0; int ptt = 0; int satmode = 0; int agc_time = 1; int ovf_status = 0; int powerstat = 1; +const char *vfonames[2] = {"VFOA", "VFOB"}; void dumphex(const unsigned char *buf, int n) { @@ -69,7 +80,7 @@ again: buf[i++] = c; //printf("i=%d, c=0x%02x\n",i,c); - if (c == 0xfd) + if (c == FI) // End of message (EOM) { dumphex(buf, i); return i; @@ -100,6 +111,7 @@ void frameParse(int fd, unsigned char *frame, int len) { double freq; int n = 0; + unsigned char acknak = ACK; // Hope for the best if (len == 0) { @@ -110,7 +122,7 @@ void frameParse(int fd, unsigned char *frame, int len) printf("Here#1\n"); dumphex(frame, len); - if (frame[0] != 0xfe && frame[1] != 0xfe) + if (frame[0] != 0xfe || frame[1] != 0xfe) { printf("expected fe fe, got "); dumphex(frame, len); @@ -119,10 +131,10 @@ void frameParse(int fd, unsigned char *frame, int len) switch (frame[4]) { - case 0x03: + case C_RD_FREQ: // 0x03 //from_bcd(frameackbuf[2], (civ_731_mode ? 4 : 5) * 2); - if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) + if (current_vfo == S_VFOA || current_vfo == S_MAIN) { printf("get_freqA\n"); to_bcd(&frame[5], (long long)freqA, (civ_731_mode ? 4 : 5) * 2); @@ -133,7 +145,7 @@ void frameParse(int fd, unsigned char *frame, int len) to_bcd(&frame[5], (long long)freqB, (civ_731_mode ? 4 : 5) * 2); } - frame[10] = 0xfd; + frame[10] = FI; if (powerstat) { @@ -142,8 +154,8 @@ void frameParse(int fd, unsigned char *frame, int len) break; - case 0x04: - if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) + case C_RD_MODE: // 0x04 + if (current_vfo == S_VFOA || current_vfo == S_MAIN) { printf("get_modeA\n"); frame[5] = modeA; @@ -160,70 +172,75 @@ void frameParse(int fd, unsigned char *frame, int len) n = write(fd, frame, 8); break; - case 0x05: + case C_SET_FREQ: // 0x05 freq = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2); printf("set_freq to %.0f\n", freq); - if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { freqA = freq; } + if (current_vfo == S_VFOA || current_vfo == S_MAIN) { freqA = freq; } else { freqB = freq; } - frame[4] = 0xfb; - frame[5] = 0xfd; + frame[4] = ACK; + frame[5] = FI; n = write(fd, frame, 6); break; - case 0x06: - if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { modeA = frame[6]; } + case C_SET_MODE: // 0x06 + if (current_vfo == S_VFOA || current_vfo == S_MAIN) { modeA = frame[6]; } else { modeB = frame[6]; } - frame[4] = 0xfb; - frame[5] = 0xfd; + frame[4] = ACK; + frame[5] = FI; n = write(fd, frame, 6); break; - case 0x07: - + case C_SET_VFO: // 0x07 switch (frame[5]) { - case 0x00: current_vfo = RIG_VFO_A; break; - - case 0x01: current_vfo = RIG_VFO_B; break; - - case 0xd0: current_vfo = RIG_VFO_MAIN; break; - - case 0xd1: current_vfo = RIG_VFO_SUB; break; + case S_VFOA: + case S_VFOB: + current_vfo = frame[5]; + break; + case S_BTOA: + // Figure out what this really does + break; + case S_XCHNG: + // Ditto + break; + default: + acknak = NAK; } - printf("set_vfo to %s\n", rig_strvfo(current_vfo)); + printf("set_vfo to %s\n", vfonames[current_vfo]); - frame[4] = 0xfb; - frame[5] = 0xfd; + frame[4] = acknak; + frame[5] = FI; n = write(fd, frame, 6); break; - case 0x0f: + case C_CTL_SPLT: // 0x0F if (frame[5] == 0) { split = 0; } else if (frame[5] == 1) { split = 1; } else { frame[6] = split; } - if (frame[5] == 0xfd) + if (frame[5] == FI) { printf("get split %d\n", split); - frame[7] = 0xfd; + frame[7] = FI; n = write(fd, frame, 8); } else { - printf("set split %d\n", 1); - frame[4] = 0xfb; - frame[5] = 0xfd; + printf("set split %d\n", split); + frame[4] = ACK; + frame[5] = FI; n = write(fd, frame, 6); } break; - case 0x12: // we're simulating the 3-byte version -- not the 2-byte - if (frame[5] != 0xfd) +#if 0 // No antenna control + case C_CTL_ANT: // 0x12 we're simulating the 3-byte version -- not the 2-byte + if (frame[5] != FI) { printf("Set ant %d\n", -1); ant_curr = frame[5]; @@ -242,16 +259,17 @@ void frameParse(int fd, unsigned char *frame, int len) dump_hex(frame, 8); n = write(fd, frame, 8); break; +#endif - case 0x14: + case C_CTL_LVL: // 0x14 printf("cmd=0x14\n"); switch (frame[5]) { static int power_level = 0; - case 0x07: - case 0x08: + case S_LVL_PBTIN: // 0x07 + case S_LVL_PBTOUT: // 0x08 if (frame[6] != 0xfd) { frame[6] = 0xfb; @@ -270,31 +288,27 @@ void frameParse(int fd, unsigned char *frame, int len) break; - case 0x0a: - printf("Using power level %d\n", power_level); + case S_LVL_RFPOWER: // 0x0A power_level += 10; - if (power_level > 250) { power_level = 0; } + printf("Using power level %d\n", power_level); to_bcd(&frame[6], (long long)power_level, 2); frame[8] = 0xfd; n = write(fd, frame, 9); break; - case 0x0c: - dumphex(frame, 10); - printf("subcmd=0x0c #1\n"); + case S_LVL_KEYSPD: // 0x0C + //dumphex(frame, 10); if (frame[6] != 0xfd) // then we have data { - printf("subcmd=0x0c #1\n"); keyspd = from_bcd(&frame[6], 2); frame[6] = 0xfb; n = write(fd, frame, 7); } else { - printf("subcmd=0x0c #1\n"); to_bcd(&frame[6], keyspd, 2); frame[8] = 0xfd; n = write(fd, frame, 9); @@ -305,41 +319,41 @@ void frameParse(int fd, unsigned char *frame, int len) break; - case 0x15: + case C_RD_SQSM: // 0x15 switch (frame[5]) { static int meter_level = 0; - case 0x02: + case S_SML: // 0x02 frame[6] = 00; frame[7] = 00; - frame[8] = 0xfd; + frame[8] = FI; n = write(fd, frame, 9); break; - case 0x07: + case S_OVF: // 0x07 frame[6] = ovf_status; - frame[7] = 0xfd; + frame[7] = FI; n = write(fd, frame, 8); - ovf_status = ovf_status == 0 ? 1 : 0; + ovf_status = !ovf_status; break; - case 0x11: - printf("Using meter level %d\n", meter_level); + case S_RFML: // 0x11 meter_level += 10; - if (meter_level > 250) { meter_level = 0; } + printf("Using meter level %d\n", meter_level); to_bcd(&frame[6], (long long)meter_level, 2); - frame[8] = 0xfd; + frame[8] = FI; n = write(fd, frame, 9); break; } - case 0x16: + case C_CTL_FUNC: // 0x16 switch (frame[5]) { - case 0x5a: +#ifdef SATMODE + case S_FUNC_SATM: // 0x5A if (frame[6] == 0xfe) { satmode = frame[6]; @@ -347,45 +361,57 @@ void frameParse(int fd, unsigned char *frame, int len) else { frame[6] = satmode; - frame[7] = 0xfd; + frame[7] = FI; n = write(fd, frame, 8); } break; +#endif } break; - case 0x18: // miscellaneous things + case C_SET_PWR: // 0x18 miscellaneous things frame[5] = 1; - frame[6] = 0xfd; + frame[6] = FI; n = write(fd, frame, 7); break; - case 0x19: // miscellaneous things - frame[5] = 0x94; - frame[6] = 0xfd; + case C_RD_TRXID: // 0x19 miscellaneous things + frame[5] = 0xA4; + frame[6] = FI; n = write(fd, frame, 7); break; - case 0x1a: // miscellaneous things + case C_CTL_MEM: // 0x1A miscellaneous things switch (frame[5]) { - case 0x03: // width - if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { frame[6] = widthA; } - else { frame[6] = widthB; } + case S_MEM_FILT_WDTH: // 0x03 width + if (frame[6] == FI) // Query + { + if (current_vfo == S_VFOA || current_vfo == S_MAIN) { frame[6] = widthA; } + else { frame[6] = widthB; } - frame[7] = 0xfd; - n = write(fd, frame, 8); + frame[7] = FI; + n = write(fd, frame, 8); + } + else // set + { + if (current_vfo == S_VFOA) { widthA = frame[6]; } + else { widthB = frame[6]; } + frame[4] = ACK; + frame[5] = FI; + n = write(fd, frame, 6); + } break; case 0x04: // AGC TIME printf("frame[6]==x%02x, frame[7]=0%02x\n", frame[6], frame[7]); - if (frame[6] == 0xfd) // the we are reading + if (frame[6] == FI) // then we are reading { frame[6] = agc_time; - frame[7] = 0xfd; + frame[7] = FI; n = write(fd, frame, 8); } else @@ -399,31 +425,33 @@ void frameParse(int fd, unsigned char *frame, int len) break; +#ifdef SATMODE case 0x07: // satmode frame[4] = 0; frame[7] = 0xfd; n = write(fd, frame, 8); break; +#endif } break; - case 0x1c: + case C_CTL_PTT: //0x1C switch (frame[5]) { - case 0: + case S_PTT: // 0x00 if (frame[6] == 0xfd) { frame[6] = ptt; - frame[7] = 0xfd; + frame[7] = FI; n = write(fd, frame, 8); } else { ptt = frame[6]; - frame[7] = 0xfb; - frame[8] = 0xfd; + frame[7] = ACK; + frame[8] = FI; n = write(fd, frame, 9); } @@ -436,8 +464,8 @@ void frameParse(int fd, unsigned char *frame, int len) #ifdef X25 - case 0x25: - if (frame[6] == 0xfd) + case C_SEND_SEL_FREQ: // 0x25 + if (frame[6] == FI) { if (frame[5] == 0x00) { @@ -450,7 +478,7 @@ void frameParse(int fd, unsigned char *frame, int len) printf("X25 get_freqB=%.0f\n", freqB); } - frame[11] = 0xfd; + frame[11] = FI; #if 0 unsigned char frame2[11]; @@ -498,54 +526,53 @@ void frameParse(int fd, unsigned char *frame, int len) break; - case 0x26: - for (int i = 0; i < 6; ++i) { printf("%02x:", frame[i]); } + case C_SEND_SEL_MODE: // 0x26 if (frame[6] == 0xfd) // then a query { - for (int i = 0; i < 6; ++i) { printf("%02x:", frame[i]); } - frame[6] = frame[5] == 0 ? modeA : modeB; frame[7] = frame[5] == 0 ? datamodeA : datamodeB; - frame[8] = 0x01; + frame[8] = frame[5] == 0 ? filterA : filterB; frame[9] = 0xfd; + printf(" ->"); + for (int i = 0; i < 10; ++i) { printf("%02x:", frame[i]); } + printf("\n"); n = write(fd, frame, 10); } else { - for (int i = 0; i < 12; ++i) { printf("%02x:", frame[i]); } - - if (frame[6] == 0) + if (frame[5] == 0) { - modeA = frame[7]; - datamodeA = frame[8]; + modeA = frame[6]; + datamodeA = frame[7]; + filterA = frame[8]; } else { - modeB = frame[7]; - datamodeB = frame[8]; + modeB = frame[6]; + datamodeB = frame[7]; + filterB = frame[8]; } - frame[4] = 0xfb; - frame[5] = 0xfd; + frame[4] = ACK; + frame[5] = FI; n = write(fd, frame, 6); } - printf("\n"); break; #else case 0x25: printf("x25 send nak\n"); - frame[4] = 0xfa; - frame[5] = 0xfd; + frame[4] = NAK; + frame[5] = FI; n = write(fd, frame, 6); break; case 0x26: printf("x26 send nak\n"); - frame[4] = 0xfa; - frame[5] = 0xfd; + frame[4] = NAK; + frame[5] = FI; n = write(fd, frame, 6); break; #endif @@ -599,13 +626,13 @@ int openPort(char *comport) // doesn't matter for using pts devices void rigStatus() { - char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; - char vfob = current_vfo == RIG_VFO_B ? '*' : ' '; - printf("%cVFOA: mode=%d datamode=%d width=%ld freq=%.0f\n", vfoa, modeA, + char vfoa = current_vfo == S_VFOA ? '*' : ' '; + char vfob = current_vfo == S_VFOB ? '*' : ' '; + printf("%cVFOA: mode=%d datamode=%d width=%d freq=%.0f\n", vfoa, modeA, datamodeA, widthA, freqA); - printf("%cVFOB: mode=%d datamode=%d width=%ld freq=%.0f\n", vfob, modeB, + printf("%cVFOB: mode=%d datamode=%d width=%d freq=%.0f\n", vfob, modeB, datamodeB, widthB, freqB); ----------------------------------------------------------------------- Summary of changes: simulators/simic705.c | 247 ++++++++++++++++++++++++++++---------------------- 1 file changed, 137 insertions(+), 110 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |
From: n0nb <n0...@us...> - 2025-06-10 01:04:41
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The annotated tag, 4.6.3 has been created at d7d544b56972b57f1267ebccdb30f2a9b950b98f (tag) tagging 371db9ffd2ef86637ba31a1445edce2f24a36904 (commit) tagged by Nate Bargmann on Mon Jun 9 19:57:15 2025 -0500 - Log ----------------------------------------------------------------- Hamlib 4.6.3 release -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSC1k9rDmfNQfaJu6b7LFEw1VqIGQUCaEeC+AAKCRD7LFEw1VqI GYPjAJ0eKBMcvaOfqzlbrZaPOBfH0+b7SwCeIT+Tm9pbD369oGNERp1S7c10Bbg= =gDle -----END PGP SIGNATURE----- (no author) (1): New repository initialized by cvs2svn. Addison Schuhardt (1): Refactoring GPIO push-to-talk logic to use libgpiod rather than the deprecated/broken sysfs method. TODO: I'm not familiar with autoconf to set up linking to libgpiod correctly, so I'd like to ask someone else to do that. Fixes #1538 Adrian Chadd (1): Upgrade TS-711 and TS-811 to work. Agis Zisimatos (1): easycomm: Return the correct value of pointer val Alessandro Zummo, IZ1PRB (36): Remove const from priv_caps to allow kenwood_init to initialize default values if they're missing Call kenwood_init in each and every driver Use an appropriate debug level Support get/set_powerstat on pcr100 Add kenwood_simple_cmd Make set_ptt behave as before, fix set_ant for ts570.c ts450: remove RIG_FUNC_TONE from has_xx_func if tone unit is not detected ts450,ts690,ts850: use FL command to get/set filters in get/set_mode. (code from ts850.c) ts450: indentation fixes remove fixed command terminator (;) from generic code ts140,ts2000,ts480,ts570,ts680,ts850,ts870s: remove usage of fixed ; and EOM fix tabs thg71,tmv7,ts450s,ts690: verify rig id at rig_open ts450: implement set_channel remove unused parameter from get_kenwood_func ts570,ts850,ts870s,ts140,ts480,ts680: use kenwood_simple_cmd where possible Replace __FUNCTION__, which is gcc specific and was deprecated a long time ago, with __func__, which is at least defined in C99. generic, ts850: implemented CTCSS TN command (reported not working for ts850, should now be fixed) Add description for the kenwood mode n. 8 implemented set/get_ext_param (voice, fine, xit, rit). enabled on ts450 and ts850 Added my call sign removed comment about switch optimizatons. the compiler will generate the assembly code in a different order which is usually based on the case value. other compiler optimizations might also affect it, so it's useless to optimize the order. check ptt status before set_ptt. enabled on ts850. style fixes band up/down was inverted Try to compensate for leftover characters Try to cope withe the PCR100 and PCR1000 at the same time Bumped out to beta, solved a few bugs. Tested with PCR100/1000/1500. kenwood: send the whole buffer at once, added kenwood_cmd - removed EOM, it's handled by kenwood_transaction - fixed tabs and spaces - added generic routine for vfo errors - set_mem: do not switch vfo if already in mem mode - simplified invocation of some commands - buffer optimizations - added PARM_BEEP and PARM_APO - fixed getting of LEVEL_RFPOWER - fixed get_ant tmv7: removed EOM thg71: removed EOM thf7: - wrong rfpower level granularity - added .reset - call kenwood_open - use generic th_set_vfo th: fixed formatting issue th: fixed stack corruption th: fixed a missing newline Alex V Flinsch, KC2IVL (8): Initial changes for ft100 Initial release initial release fixed various command options new file, list of tones/codes and sequence used by various yaesu rigs added get frequency to ft100 code added getinfo func hdr *** empty log message *** Alexander Sack (1): Get firmware revision level from K3/KX3. Alexander Schultze (3): easycomm: include a new EasyComm3 to support move speed and infostring update EasyComm3 to include setting and getting of config and status easycomm: implement get/set config, easycom include status and error bytes, fix get_info Alexandru Csete OZ9AEC (34): Added new stylesheet to make API docs look better. Modified to use new stylesheet. Added doxygen comments. Added rotator.h and rotlist.h to the input list. Applied Tommi's improvements from the FT-857 backend with the following changes and additions: Full RF power scale corresponds to 10 bars, not 15. Added RIT, XIT and IF shift ranges to dummy backend. Cast constant caps to variable caps in order to avoid compiler warnings. Cast from const to variable in order to avoid compiler warnings. - Cast unsigned char to char in order to avoid compiler warnings. - Ensure that all variables have a value before they are used (ft920). - Disable unused functions and variables (frg100). - Incremented backend version numbers. Use tone_t for pcr1_ctcss_list. Changed arg 4 of pcr_transaction to unsigned. Cast the other mismatches to (char *). Cast unsigned char to char in order to avoid compiler warnings. Incremented backend version number. - Cast unsigned char to char in order to avoid compiler warnings. - Ensure that all variables have a value before they are used (tentec.c). - Cast unsigned char to char in order to avoid compiler warnings. - Incremented backend version number. - Cast/change unsigned char to char in order to fix compile warnings. - Incremented backend version number. - Cast/change unsigned char to char in order to fix compile warnings. - Incremented backend version numbers. - Cast/change unsigned char to char in order to fix compile warnings. - Incremented backend version numbers. - Cast/change unsigned char to char in order to fix compile warnings. - Incremented backend version number. - Cast/change unsigned char to char in order to fix compile warnings. - Incremented backend version numbers. - Cast unsigned char to char in order to avoid compiler warnings. - Handle all enum values in switch statements. Fixed type mismatches that caused compile warnings. Fixed type mismatches that caused compile warnings. Initialise icom_val to avoid compiler warning. Fixed type mismatches between signed and unsigned char. There are a few very suspicious 'if' statements in icom.c and frame.c - Fixed type mismatches and unhandled switch cases. - Incremented backend version numbers. Cast constant caps to variable caps in order to avoid compiler warnings. Updated. Added infor about w (send_cmd). Max serial rate is 9600. Changed backend status to stable. Escape the backslash character. The 765 can do RIG_SCAN_PROG and RIG_SCAN_MEM. Fixed S-meter reading to use calibration table since frontend always uses RAWSTR. Fixed RF power reading and added power2mw and mw2power. Fixed RIG_LEVEL_STRENGTH reading. Andrew Errington (1): Initial support for CM108 GPIO contorl of PTT Andrew Rodland (3): Fix spurious writes when no RT-21 second port Enable "stop" command for RT-21 rotator. Update RT-21 version Arkadiusz Miśkiewicz (1): Additional PKTUSB and PKTLSB mapping for USB-D1/LSB-D1 AuroraRAS (5): Prepare .gitignore file for NDK build Append the missing information to build hamlib v4.3 for Android NDK make the Android.mk files adapt to multi arch add androidsensor rotator AndroidSensor codes improvement Ben Coleman, NJ8J (6): Fixed bug in rpcrig_set_parm (using RIG_LEVEL_IS_FLOAT instead of RIG_PARM_FLOAT) Fixed same bug in rigctl_get_parm. Added checking of return string from rig on set (non-retrieval) commands. Added code for COMP function. Added alinco_set_parm & tweaked dx77 capabilities. Handle setting Keyer speed and CW Pitch Added NJ8J's email address. Change email address for NJ8J Berndt Josef Wulf, VK5ABN (11): Implemented rig_set_channel() Implemented set_parm() for BACKLIGHT operation Commented out RIG_MODE_PKTFM overlooked at the submission of previous code Implemented RIG_MODE_PKTFM and RIG_MODE_PKTLSB modes Changed debug message format for freq_t from long long to double ft990_get_ptt() now uses the FT990_SF_XMIT instead of FT990_SF_PTT. FT990_SF_PTT only returns status of PTT activated by CAT commands, whereas FT990_SF_XMIT reports the actual status of the ptt line. ft990_get_mem(): Fixed bug that prevented the reporting of current channel number when vfo != RIG_VFO_MEM Fixed erroneous return value Fixed mispelled name for VK5ABN Added missing modes to RX/TX caps Fixed bug in ft990_set_mode that caused RTTY interchanged modes USB/LSB Fixed bugs in ft990_get_channel Bill Barker (1): Add test for Flex 6300 ID Bill Somerville (212): Patch submission for IC-756 Patch to allow same serial port for PTT and CAT. Patch to fix broken Yaesu backend with FT-2000(D) Fix rig_open not failing when PTT/DCD port is unavailable. Fix Icom IC-756 filter handling. Fix Yaesu newcat backend set_tx_vfo issue. Add support for Data Modes on Icom "Pro" models. Fix Icom IC-726 mode handling. Fix Kenwood TS-2000 split operation. Fix Kenwood Split Operation for TS50 & TS480. Fix Kenwood TS-870s split and bandwidth set/get. Correct receive buffer length for IS; comamnd. Fix Kenwood CAT transaction busy retry mechanism. Fix Kenwood get split VFO function. Add data sub-mode support for TS590s. Correct order of MD and DA commands for TS590s. Get firmware revision for TS590s in rig_open. Fix TS590s firmware defect. Fix Kenwood get_vfo function returning wrong VFO in split TX. Make Kenwood TS590s firmware defect fixup revision specific. Extend TS590s firmware defect fixup to both VFOs. Fix Icom IC-756 Pro III get data mode. Add spilt mode get and set for Elecraft K3. Fix data sub-modes on Elecraft K3. Fix Elecraft Data Mode Translation. Fix Elecraft K3 Data Sub-Mode Setting. Fix Yaesu FT1000MP and FT1000MP Mk V modes. Fix configure.ac Fix a warning message. Added option to not use VFO XCHG command when setting split parameters. Fix a buffer overflow in the Windows termios emulation. Fix pkg-config generation. Fix Icom IC-756Pro mode get/set. Facility for rigctl to read commands from standard input. Add a pause command to the rigctl command set. Prefix action function names so as not to clash with system names. Prefix action function names so as not to clash with system names. Corrected typos in rigctl.1 manpage. Add read commands from stdin and pause command features to rotctl. Merge branch 'rigctl-stdin' of ssh://git.code.sf.net/u/bsomervi/hamlib into rigctl-stdin Fix manpage errors. Remove redundant RIG_PTT_SERIAL_CAT enum from ptt_t Only check for serial control line conflicts if PTT shares CAT port Fix Ten-Tec Orion get/set split functions Icom IC-7410 has VFO A/B not MAIN/SUB Added IC-7410 data modes Add retry mechanism for Yaesu "newcat" backend Implement retries for Yaesu "newcat" rigs Disable auto information mode on open Add retry mechanism for Yaesu "newcat" backend Implement retries for Yaesu "newcat" rigs Disable auto information mode on open Merge branch 'yaesu-retries' of ssh://git.code.sf.net/u/bsomervi/hamlib into yaesu-retries RIG_OK is zero and need not be negated and this will not change Fix response length expected error in K3 back end Data mode support for the Icom IC-7700 Data mode support for the Icom IC-9100 Data mode support for the Icom IC-7200 Add support for the Kenwood TS-590SG Kenwood TS-590SG Always clear serial control lines when used for PTT Disable AI mode on open for Kenwood/Elecraft rigs Add more diagnostics and error checks to serial line control Move serial line control error checks to lower level routines Merge branch 'master' into kenwood-ai-off-at-start Merge branch 'master' into ptt-control-on-cat-port Fix serial i/o on Windows. Yaesu newcat style command response reading improvements Increase communications timeout for Icom rigs Kenwood AIn; command has no reply Revert read_string() to partial results are a success status Remove gratuitous sleeps before function exits Error checks on simulated direct VFO addressing Elecraft K2 RTTY modes are not FSK Kenwood and Elecraft rigs sometimes ignore commands Removed kenwood_cmd function and replaced uses of it Allow for failed test command on the K2 Elecraft K3 has 1 stop bit Kenwood TS-570 series IF returns current frequency Switch to "ID;" command for verification as no "AI;" on TS-840s Increase Elecraft K2 comms timeout and retries Switch Kenwood TS940 to generic kenwood CAT functions Improve command verification for Kenwood & Elecraft Use local buffer in kenwood transaction funciton Clarify the handling of Kenwood CAT message terminators Further clarification in the implementation of kenwood_transaction() Removed redundant precondition test Remove kenwood_simple_cmd as kenwood_transaction has that functionality Call kenwood_open() for TS-2000 to ensure AI mode is disabled Allow for bad ID from DDUtil in TS-2000 mode Allow one extra byte in read_string() length to accomodate terminator Enable data modes for the Icom IC-7100 Allow for PowerSDR ID in Kenwood TS2000 emulation mode Fix TenTec Argonaut message lengths and timeout Fix TenTec set split command Implement get PTT status for the TenTec Argonaut Fix error with width in set mode for the TT argonaut Yaesu FT540 can only change the frequency of the current VFO Fix defect in Kenwood TS-940 IF command response parsing Fix response lengths for the TT Jupiter 538 Do not attempt CAT PTT commands on the Icom IC-706mkIIG Use correct argument type for serial control line functions Initial back end implementation for the Kenwood TS-990s Mode set is not VFO targetable on the Kenwood TS990s The Kenwood TS990s only does split Tx on SUB VFO The doesn't appear to be a way of getting PTT/SEND on the TS990s Lower both RTS and DTR on alternate PTT serial port Honour any error status from serial port calls Dummy get_ptt function needs to read RTS/DTR/PARALLEL Make autogen.sh agnostic to whitespace in paths Increase the number or retries for most Kenwood rigs Command validation for Yaesu set commands Remove unecessary delays from TS-940S backend Proper IPv6 and dual stack networking Fix compiler warnings Proper IPv6 and dual stack networking for rotator net daemon Attempt to restore AI status on exit Allow for poor emulations of Kenwood rigs that have no ID command Use correct function to execute set type commands with no response Add a new command line option '--no-restore-ai' ('-n') to rigctl Fix FT-817/857/897 issues and add some missing functionality Fix missing PKTUSB mode setting code for FT-817 & FT-897 Fix a logic error in band detection during IC-910 set frequency Add missing configuration getters Detect C-IV NAK returns as rejected commands Elecraft rigs do not switch VFO in IF command responses during split Tx. Redundant split mode directives on Elecraft rigs cause Tx failures Only use IPv6 features on Windows versions that support it (>=XP) Improve IPv6 portability and consistency Add 23cms to IC-910(H) backend Implement combined split VFO frequency and mode setting. Initial implementation of rig_{set,get}_split_freq_mode() for FT-857. Implement rig_{set,get}_split_freq_mode() for IC-756 series. Add {get,set}_splitfrequency_mode for the IC-910(H) Elide unnecessary CAT commands when setting split frequency and mode Do not swap VFO unnecessarily Better set frequency semantics for the IC-910(h) VFO targetable get frequency operation for the Icom IC-910(h) Make sure right band is used when setting frequency on IC-910(H) Use rig state rig port retry option rather than from capabilities Use a sensible port timeout value for the Kenwood TS-850 Further attempts to simplify and improve Icom CAT for split operating Add RIG_PASSBAND_NOCHANGE as possible set_{split_,split_freq_,}mode argument Switch to POSIXLY_CORRECT mode for getopt_long() Fix a regression introduced in 222ad74 Do not crash if expected CTCSS tones not sepcified Do not attempt to query AI state on the TS-450s as it is not supported Some more Kenwood rigs with no AI query Adjust rig_list_foreach to allow use for unregistering Fix an issue presenting on the Yaesu FT-450(D) Release the serial port used for PTT when possible Change the IC7600 & IC7800 set/get mode to versions that support DATA modes Add rig_{open,close} functions to TS-790 backend Revised kenwood rig busy response handling Add get and set split functions for the TS450S Simplify and fix defects in the FT991 back end Fix some endian issues in the si570/AVR SDR back ends Fix a state machine defect with repeated PTT reset calls Do not pass --no-cpp_precomp to compilers on Mac OS X Allow RIG_LEVEL_STRENGTH queries over the network link Stop rigctld and rotctld crashing when service threads cannot write to clients Use snprintf throughout kenwood/kenwood.c for buffer safety Fix off-by-one issue in reading memory mode from IF command response Fix some issues with commands not supported by TS-2000 CAT emulations Add best guess transmit status to rig state structure Take out unecessary delays in K(X)3(S) back end. FT-817 status queries honour retries and timeout Make rig_open() call in rigctld lazy and add graceful termination Simplify SWIG interface definition and hide 64-bit values from Lua binding Remove unnecessary delays from TS-990 and TS-2000 back ends Change frequency setting for the FT-747GX to something more basic Fix an incorrect error return value from win32_serial_select() Fix timeout issues with the Ten-Tec Orion/Eagle Ensure compilation works with a pre C11 compiler Make code C90 compliant again Move unnecessary global and file static variables to the stack Simplify unnecessary persistence of extended response state Fix misunderstanding of netrigctl_transaction() return value Made PTT and DCD options consistent between rigctl and rigctld Report unrecognised PTT and DCD types in rigctl and rigctld Update i/o functions to support GPIO(N) port closure Fixed erroneous messages in rig_close with GPIO(N) PTT or DCD types Remove duplication across GPIO and GPION handling of PTT and DCD Improved get PTT state handling in dummy backend Simplify closing of device files Repair a regression with the dummy get PTT functionality Revert "Add debug to serial.c" Repair a regression with the dummy get PTT functionality Revert "Add debug to serial.c" Fix regression with slow responses from SmartSDR causing errors Deal with remote PTT type at the client end Avoid 'echo -n' as macOS sh doesn't support it Fixing an operator precedence defect Updates to the TH-D7A/E back end Less ambiguous variable name and repair merge issue in prior commit Add missing config parameters for rig power on/off and screen-saver New power on option rather than power on/off Make version recording safe for parallel builds without breaking make dist Make version recording safe for parallel builds Ensure old hamlibdatetime.h headers in the source dir are ignored Merge branch 'safe-scs-versioning' of ssh://git.code.sf.net/u/bsomervi/hamlib into safe-scs-versioning Fix make dist versioning Use BUILT_SOURCES make mechanism as intended Fix rebuild dependency Build hamlibdatetime.h every time Force copy over existing Minimize rebuilding Correct use of sh if Another attempt at a reliable SCS version header generation Remove temporary file Add missing shared library API exports Add missing export definition Blaine Kubesh (8): added Icom803 to icmarine added Icom803 to icmarine added Icom803 to icmarine Update ic-m803 remote-id to 20 Update icm803.c Update AUTHORS undo author changes Update icm803.c Bob Freeman (1): New CNCTRK rotor backend Brandon Durepo (5): Added multi-stage Docker build and hamlib-runtime image Added multi-platform support for linux/arm64 and linux/amd64 Add support for the hamlib-base-image and hamlib-runtime targets - support the arm64 and amd64 platforms on both a base-image and runtime Added git and vim to the hamlib-base-image Added Python support Brian G. Lucas (10): Pretty much a complete re-write of thd72.c, since the old one didn't work at all. Many commands have been tested with real hardware. But more work remains to be done. WIP: thd72 driver. More level, func, and parm stuff works. WIP: thd72 driver. Try to simplify the menu based interface. WIP: thd72 driver. First cut at get_channel(). Other cleanup. WIP: thd72 driver. More interfaces implemented. Other cleanup. Implement some more interfaces. Comment out get_chan_all_cb because the block read routine doesn't work. Fix a format so that it works with Windows. Can't test it because I have no Windows machines. Fix RFPOWER level for FT-450D. It uses 5-100, rather than 0-255 that the FT-450 does. In newcat_open(), initialize rig_id in case any subsequent commands need it. Some calls to thd72_get_menu_item where passing wrong values for range check. C-Elegans (1): Add ability to have rigctld display transverter frequency CJ (1): fix windows makefile Callum McEwen (VK5MCA) (4): Update codan.c Update README.codan Add V3.51 firmware comment Update comments on codan_set_ptt Cedric DJ3CE (1): Add SWR get_level to K3 (KX3, KX2) Charles Suprin (7): Add file for TM-D710 support. Merge branch 'master' of ssh://hamlib.git.sourceforge.net/gitroot/hamlib/hamlib Add D710 to riglist. Add D710 code to kenwood library. Register D710 interface. Initial D710 Implementation. Register D710 interface. Charles Suprin, AA1VS (3): extend th_get_vfo_char to support D700 Changed th_set_freq to round and select step size to use. Allows 6.25kHz and 5kHz channelization. Use new th_set_freq for TM-D700 Chen (Kina) (1): pmr171.c: Fix typo in get_freq Chris Karpinsky, AA1VL (7): add serial_flush() method to clean rx buffer initial stab at this for the Yaesu FT-817 add ft817.* add ft817 bump the backend status to ALPHA Initial entry of cgirig giving ability to use hamlib from a web browser. increased post write delay to 300 Chris Ruvolo (4): TS-690: deal with optional tone board using TS-450 logic TS-690 does not implement the PC command to get/set output power level TS-690 does not implement the GT command to get/set AGC rate TS-690: bump version Christian Bayer (11): upstream 817 FT-817 power and SWR levels ft-857 power levels for 2m/70cm export correct function for wsjtx fixed cal table conversion added header use correct value divider update disable scaling fixed compile errors fixed merge errors and variable declarations Christoph Berg (2): ic7610: Re-add send_morse Implement netrigctl_stop_morse Christoph Nadig (1): Fix for setting power on Elecraft TRXs Chuck Hemker, N2POR (1): Use RIG_TARGETABLE_MODE in rig_set_mode and rig_get_mode Chuck Ritola (8): Use loop to ensure RS-HFIQ hears first command. Closes #730 Add ability to read TX drive level Implement board temperature reading for TEMP_METER Parse and store RS-HFIQ firmware version. Firmware version check before power meter query. Merge branch 'master' into rshfiq-aug2021 Map FCDPP LNA and Mixer Gain as PREAMP values. Closes #766 Map FCDPP LNA and Mixer Gain as PREAMP values. Closes #766 DJ3CE (1): Patch power reading of IC-705/-905 DL1YCF (6): Merge branch 'master' of https://github.com/Hamlib/Hamlib Merge branch 'master' of https://github.com/Hamlib/Hamlib Merge branch 'master' of https://github.com/Hamlib/Hamlib Merge branch 'master' of https://github.com/Hamlib/Hamlib Merge branch 'master' of https://github.com/Hamlib/Hamlib Merge branch 'master' of https://github.com/Hamlib/Hamlib Dale E. Edmons, KD7ENI (19): Added comments to commandline in rigctl (second time) --Dale Started TS-2000 update/overhaul --Dale Copied too much stuff, backed out what I broke. Bring ts2k.c more in line with current CVS. Changed ts2000.c to ts2000.h. Start of rig menuing functions. New file. Renamed ts2000.c.new ts2000.h Bring code more in line with CVS code. Changes often, so added status. Will delete when things stabilize. Corrected status to CVS branch. Renamed new ts2000.c to ts2000.h Wouldn't compile. Removed ts2k.c. Haven't got all new rig.h stuff removed. Temp kludge to make ts2k.c compile (keeps Hamlib from compiling!). Updated status. Added working TS-2000 files. There are some changes left out but this is the minimum I could commit and have a functional rig. The cost is that I've broken kylix and others that duplicate rig.h. I'm in the process of repairing the damage. Please be patient. I hope a day or so, but am asking for up to a week. E-mail me about *anything* you find broken. Kylix (and similar) is (are) known to not work. Changed name back to original. Had to re-run automake kenwood/Makefile. 1) Updated branch_ts2k with respect to HEAD. 2) Working ts2k_menu. (only in RIG_MODEL_TS2K) 3) Split TS-2000 into experimental and standard versions: RIG_MODEL_TS2000 = standard, RIG_MODEL_TS2K = experimental. 4) Basic command parser in tests/rc. Will open/close rig or copy a freq from one rig/vfo to another rig/vfo. Very cool. Very basic. Very experimental. 5) Added test programs. a) testcmd - calls parser (no command prompt yet!) b) testts2k - replacement for testrig (with trivial modification) c) testptt - testts2k/testrig should not transmit. TX stuff in testptt. 6) Used crowbar to merge HEAD into branch_ts2k. Working on clean-up. 7) I'm sure I've forgotten or neglected to mention some other stuff. Daniel Estévez (2): Fix DIG MODE for FT817-ND Fix DIG MODE for FT817-ND Daniele Forsi (5): Set the executable bits on py3test.py Fix spelling errors Fix more spelling errors Fix more spelling errors Fix typos Daniele Forsi IU5HKX (150): Fix a [missingInclude] "information" when running cppcheck --check-config The -M option needs an argument like its long version "multicast-addr" Fix lintian warning: macro 'RG' not defined Fix lintian warning: macro 'IN' not defined Fix spelling errors Remove unused includes related to times and dates Remove unused includes of math.h Remove unused includes Revert unwanted changes Remove unused includes of errno.h Remove unused include of amp_dummy.h Remove unused include of cm108.h Remove unused includes of fcntl.h Remove unused includes of frame.h Remove unused include of getopt.h Remove unused includes of gpio.h Remove unused includes of cal.h Remove unused include of usb_port.h Remove unused includes of ctype.h Remove unused include of stdbool.h Remove unused include of stdarg.h Remove unused include of stdlib.h [icom] Remove unused include of config.h [kenwood] Remove unused include of config.h [yaesu] Remove unused include of config.h [rotators] Remove unused include of config.h [tests] Remove unused include of config.h [rigs/*] Remove unused include of config.h [amplifiers] Remove unused include of config.h [extra] Remove unused include of config.h Add include/hamlib directory to all makefiles [icom] Fix includes [kenwood] Fix includes [yaesu] Fix includes [rigs/*] Fix includes [rotators] Fix includes [tests] Fix includes [amplifiers] Fix includes Update .gitignore Fix unterminated comment Fix include not found by cppcheck.sh Enable --show-conf for ampctl and ampctld Fix typos Fix include not found by cppcheck.sh also in the other branch of the "if" Fix passing one or more paths to ./cppcheck.sh Fix several cppcheck "missingInclude" informational messages Fix cppcheck "unmatchedSuppression" informational messages Add to .gitignore some files created during "make check" Fix cppcheck "missingInclude" informational message Fix Doxygen unmatched directives \cond and \endcond Fix Doxygen documentation for the Apex rotator Fix Doxygen documentation for the GRBLTRK rotators Fix typos Fix Doxygen comments Fix typos Remove duplicated conditions Fix initializer-overrides warnings by clang Fix typos Add/fix Doxygen comments Fix segfaults with malformed input and wrong command line arguments Fix segfaults with malformed input and wrong command line arguments Fix check for RIG_BUSBUSY Fix name of command in the usage and version texts Fix name of command in the version text Fix man page of rigctld Fix warning message for twiddle_rit Fix typos in man pages and other documentation Fix typos in comments Fix typos in messages Remove duplicated sentence Fix typos Remove unused and empty source files Fix typos Fix underline and italics Escape literal \n Fix usage of .EX Set parameter keywords bold, not their descriptions Add bold Fix my previous commit ("Add bold" d9545845) Ignore files related to tests Delete a generated file when doing make clean Delete a generated directory when doing make clean Make help strings more similar Remove duplicated text Fix groff syntax Fix list of parameters for get_func/set_func Fix list of parameters for get_level/set_level Fix list of parameters for get_parm/set_parm Add missing diagram Fix typos Sync text between man rigctl and man rigctld Add description for -w/--twiddle_rit Add missing arguments to command line options Remove unused command line short options -M and -N Add missing command line short option -b for --bind-all Add that passwords aren't implemented Add -b, --bind-all to --help text Remove duplicated cppcheck suppressions Fix typos Fix name of function in error messages Remove non-working compilation instructions from comments Remove duplicated line Fix Doxygen comment Fix typos Fix Doxygen comment Fix names of parameters in Doxygen comments Add documentation for RIG_CONF_END Add cross references hash mark for Doxygen Update the directory tree Remove old version numbers Update copyright year List more optional dependencies Explain how to use the simulators Fix compilation error in simid5100.c Fix compilation error in simicr8600.c Describe the use of simulators Also check the "name" parameter Fix syntax of #define Remove redundant dependencies Add rules to build dependencies of libhamlib.la in other directories Remove unneeded dependency Remove unneeded test script testcpp.sh Fix error return values Fix typo Replace non-portable make rule with one that is also easier to understand Fix --without-cxx-binding being ignored Remove duplicated assignment of compilation flags Fix --enable-winradio[=yes] being considered =no Fix --enable-parallel[=yes] being considered =no Fix --enable-html-matrix[=yes] being considered =no Fix --with-readline[=yes] being considered =no Fix --with-libusb[=yes] being considered =no Make usage texts more similar Document existing option to read commands from stdin Remove unused definition of -z command line option Fix definition of -B/--mapa2b command line option Allow to give the command lines options --list or --version Fix --with-indi[=no] being considered =yes Fix failure of ./configure --with-tcl-binding --with-xml-support Fix compilation errors and warnings and link failure Use the variable with the version number in the example path Fix typos Also mention amplifiers Remove duplicated comment Fix typo Fix typo Fix list of dependecies of aclocal.m4 Fix syntax error Fix typo Fix Doxygen tags Dario Ventura (3): New Prosistel rotor backend from IZ7CRX Add elevation code to Prosistel backend TS2000 Satellite mode and Gpredict Dariusz Bismor, SQ9KEJ (1): rigmem: implement CSV file loading David Brewerton M0EZP (1): FT990UNI patch contribution from M0EZP David Fannin (1): Submission for new backend model (134) for Yaesu FT-DX1200 Davide Gerhard (3): tests/{memcsv.c,memsave.c}: partially revert commit 4072f9f4 ic746.c: correct chanbuf length, fix channel structure and support split ic746.c: add ic746pro_set_channel() to load memory from csv Dawid SQ6EMM (3): Add method to build inside docker Let SEND_MORSE and SEND_VOICE_MEM be announced as capabilities. Allow \send_voice_mem to be used over network and tested in dummy rig Dawid Szymanski (2): ICOM Voice Keyer implemented. typo fix Dhiru Kholia (1): Minor fixes for FT-747GX simulator Diane Bruce, VA3DB (5): - first cut at fixing configure to recognise --without-tcl-binding and --without-python-binding options - gt_HEADER_INTTYPES_H is definitely bogus here, leftover from what? - document debian/FreeBSD needs for AUTOMAKE etc. - add in libtoolize which should be there - These should have been commented out. - Extra comma on RIG_STATUS_BUGGY can cause a compiler error. Dieter Röver (1): Fix bug in vfo_comp calculation in Hamlib Ekki Plicht (DF4OR) (2): New model Icom IC-R8600 Patch for Icom DCS code handling Eli Schwartz (1): tests: fix compilation with modern compilers Elliott Liggett (1): Added functionality for the IC-7300 auto antenna tuner Eriks Dobelis (2): ft817: adding delay before next retry after returning from tx to rx ft817: Moving delay value into #define section of the header Ervin Hegedus (9): RIG_PASSBAND_NORMAL wasn't handled correctly when rig_set_mode() was called - fixed Fixed SWIG `Setting a const char * variable may leak memory' error Fixed Kenwood filter cmd when passband is set to 500Hz Merged from upstream Merge branch 'master' of http://git.code.sf.net/p/hamlib/code Added Lua binding and demo script Added new example to Python demo script (set/get float type level) Change variable length argument handling in affected functions Fix two typos Ervin Hegedüs (1): rig.swg: New properly formatted macro Evgeniy Titorenko (1): Add Radant AZV-1 Rotator controller protocol. Francois Retief (21): Added read_serial function to read strings from a port. Corrected some comments Added code to hexdump to right align ASCII dump column added private caps for rig termination character add private caps and more commands. Changed to a new transaction function and adde quite a few commands. add private caps to store the termination character of Kenwood rigs commands. added a kenwood_init and _cleanup routine for priv caps & priv data. Added a new function: LCD Lamp ON/OFF (for Kenwood TH-7DA) check trn state of rig in rig_open. Initial commit of Kylix binding New backend for rotators New RPC backend for rotators Added rot_move function Fix macro name Added rot_move function Added easycomm and rpcrot backends Fixed circular dependency for rpc.rigd and rpc.rotd regenerated Added IC-910 rig. Added constants for the IC-910 rig. Frank Goenninger (8): Add ADAT ADT-200A backend adat updates from Frank, DG1SBG ADAT fixes on Windows RIG ADAT: Adaption to firmware 1.40fb and transverter board. .gitignore: Ignore some macOS housekeeping files. Major code cleanup. Replace dyn. memory by static memory usage. FIXED: Source code inconsistency after major code change. FIXED: Incorrect usage of snprintf() argument for buffer length. Frank Singleton, VK3FCS (165): Initial revision Initial revision *** empty log message *** *** empty log message *** *** empty log message *** Initial revision Initial revision *** empty log message *** *** empty log message *** added build_all ,cleanall and verify targets *** empty log message *** initial top level makefile add some things initial import initial import initial import fixed some typos use rig_open and rig_close added rig_open and rig_close fixed cmd_sat_on / off added sat-on and sat_off to test changed cmd_get_rx_status, must do tx also updated test() all reads use while (1) and break added ../common as object path added rig_open and rig_close using rig_open and rig_close and serial.h use common dir for serial stuff use ft747 on serial port /dev/ttyS0 read uses while(1) and break use while(1) and break added read_sleep use read_sleep now from serial.h using read_sleep from serial.h had rx and tx status swapped (document error?) removed cmd_get_update using CVS instead of RCS directories use MODE_xx defines cannot use const int in case statements ?? so use #define instead use #defines for MODE_XXX used in case statements working out freq conversion, unfinished playing with test routines long int cmd_get_freq_mode_status_main_vfo(int fd, unsigned char *mode); long int cmd_get_freq_mode_status_main_vfo(int fd, unsigned char *mode) frq = cmd_get_freq_mode_status_main_vfo(fd, &mode); starting with the cmd_set commands now starting on cmd_set commands now starting on cmd_set_freq commands now add scanning todo now set sat rx and tx freq and mode also fix typo dump raw hex data when writing and reading trying some cms_set_freq_xxx commands added routines for dec <-> packed decimal conversion minor added generic hex dump routine, static void dump_hex(unsigned char *ptr, int size, int width); removed unwanted debug printf's removed dump_hex from here.. calc_freq_from_packed4 is about to be replaced calc_packed_from_char and calc_char_from_packed now here cleanup cleanup void dump_hex(unsigned char *ptr, int size, int width); adding dcs tables and repeater offset in Hz describe faulty yaesu documentation added README.license for GPL added GPL license info included full GPL license Updated docs to point to http://sourceforge.net/projects/hamlib/ and added a C code snippet on how to use the API. added -I$(COMMON_DIR) to find rig.h added -I$(COMMON_DIR) to find rig.h adding capabilities initial capabilities stuff starting to add rig_caps stuff starting to add rig_caps stuff starting to add rig_caps stuff. added GPL stuff and comments adding rig_caps stuff adding rig_cap stuff adding rig_caps stuff add capabilities and preferences adding rig_caps functionality adding rig_caps stuff frontend reduction on backend function namespace - phew !! frontend API clarification removed old open_port2() using old rig_caps fixed some typos, added 3 more candidates for API missing ; in some enums converting to frontend/backend structure compiles ok removed open_port() and write_block() removed open_port() and write_block() fixed typos, added &ft747_caps in rig_caps changing to frontend/backend style converting to frontend/backend style added 3 more cmd_* for API examples Example of setting rig Main VFO to 439.700 Mhz FM cleanup comments added extern const struct rig_caps ft747_caps; still thinking about set/get strategy minor updates added extra rig caps added some set/get examples with return code checking added testrig to Makefile, no linking yet added usleep to read_sleep() updated rig_caps structure *** empty log message *** test making a shared lib (at last) for the frontend - more todo test making a shared lib for the frontend - make hamlib describe frontend/backend structure updated code snippet example started ft747_set_ptt and ft747_set_vfo starting to implement set/get pairs added typedef enum ptt_type_e ptt_type_t; added VFO types to enum starting on libhamlib Makefile, added ./lib and ./include under common make, make install, and make clean work ok, using ./lib and ./include directories also. make, make install, and make clean work ok, using ./lib and ./include directories also. removed "make verify". Added reference to common/Makefile added printf("testrig:main() has been called \n"); for testing linking makefile for testing testrig linking alternative rig_base declaration removes references to rig_caps at compile time. should populate it another way -- FS added printf's to confirm rig.c (hamlib) is being called ok better libhamlib.so version :-) added ft847_open and ft847_close to enable CAT ON/OFF added ft747_open and ft747_close updated lib names for backend to libhamlib-xxxxx.so API updates - added set/get_mode merge with TRN stuff and add some set/get_mode and vfo stuff added post_write_delay cvs mails to hamlib-cvs-digest cvs mail update works ok :-) minor fixes updated ptt/mode/vfo added set/get freq to use generic bcd etc more set_freq() examples 1. Added VFO as target for some set/get cmds. 2. ./testrig still runs ok using RIG_VFO_CURR. minor update to active VFO handling in _set_vfo some new defines for FT747_VFO_A/B minor updates to active vfo handling added ptt handling example, stand back ! trying different approach to storing cmd sequence. _set_ptt is being converted. Needs tidying up though. Some sequences are complete, and can be read from static data. Incomplete sequences will eventually be copied form static declaration, and completed in priv data. Removed static stuff from functions. Also, begin to implement table driven command translation from API to rig native. priv now contains a cmd table that is used for backend commands towards rig. Added some new freq/mode combinations. converting ft847 to table driven, similar to ft747. more table driven stuff for ft847. cat/ptt/freq being converted. Added ft847_send_priv_cmd(), converted some part of API to use this. Added _set_mode to work now. TODO: put _send_priv_cmd into yaesu.[ch] so ft747 can use also. Turned on PTT also (stand back).. rig_cleanup and rig_close not calling backend removed unused calc_ functions. removed old API functions, general cleanup tested rig_close and rig_cleanup Initial release, common yaesu declareations etc. add version tag nseq uses YAESU_CMD_LENGTH Initial yaesu Makefile Moved from ft747 and ft847 dirs common yaesu handling common yaesu dir Begin to use common yaesu code general cleanup, added _send_priv_cmd added targetable_vfo value to caps minor cleanup ChangeLog history started Initial import for ChangeLog handling starting to convert rig struct to readable form more of convert rig struct to readable form Changelog update for HAMLIB-1.1.1 GeoBaltz (1): Merge branch 'master' into rp12 George Baltz N3GB (194): Add missing level definitions for TS-590SG Add routine to check input to <brand>_set_level ATTenuator level 0 should always be allowed - to turn it off. First round of level_gran additions. Do the check for min=max=0 the right way. Round 2. Enable first user of check_level_param Round 3 of level_gran updates. Remove hard-coded constants. Enable full level checking for TS-890S. Add default level values for Elecraft rigs. Update RIG_LEVEL_READONLY_LIST. Round 4 of level_gran updates. Fix the comment about float levels. Add Elecraft defaults to makefile. Fix typos (missing '('s ) in man pages. Add missing commands to man pages Avoid NULL dereference in debug statement. Use level_gran[] values in kenwood_get_level. Still more level_gran data. Yet more missing level defs. Enable level_gran[] checking for all calls to kenwood_set_level. Add basis for level_gran use in newcat.c Convert set/get AF, RF to use level_gran info. Convert MICGAIN to level_gran Convert COMP Convert ANTIVOX & VOXGAIN New for old - update level_gran for ft9000Old Fix segfault on rigctl exit Convert SQL to use level_gran data. Convert MONITOR_GAIN Convert RFPOWER to level_gran usage Convert NR to use level_gran Fix inverted VHF/UHF BANDSELECT labels Fix duplicate level definition Add RIG_LEVEL_USB_AF_INPUT to RIG_LEVEL_FLOAT_LIST Implement RIG_LEVEL_USB_AF[_INPUT] for TS-890S Enable set_level checking for all Yaesu/newcat rigs. Replace hard coded constants with table values f conversion already rounds, so no external rounding needed. Move meter reader to kenwood.c, so it can be used by ts990.c Use general meter reader to get SWR value for TS-990. Revert "Fix FTDX101MP RFPOWER to allow 200W" Unnecessary code, breaks other levels. Fix FTDX101MP RFPOWER the right way. Restore shared library ABI compatibility with previous hamlibs Add basic support for transparent access to port structures. More Kenwood rigs ported to new access macros. Convert the remaining files in rigs/kenwood/ Define different (disambiguated) names for external use. Fix copy/paste errors in xiegu.c More typos/copy/paste errors in rigs/icom Add cache to the MACRO/porting list Implement function to get structure address Function to get amplifier port address Convert src/amplifier.c to new MACROs/access method. Add function to get rotator port address(es) Port conf.c to use access macros Convert more files in src/ Pointerize all the ports in src/rig.c Need more parens to work in expressions. Update example.c Avoid using raw rigport, in two different ways. Fix variable name. Implement ctcss tone for TS-890S. Fix off by one error in tones for TS-590/890/990 Fix some rigs I found docs for - more needed Add funcs to set/clear TONE/CTCSS modes for TS-890S Add remaining rigs, matching old behavior. Fix copy/paste foulup. Drat. Fix more copy/paste SNAFUs Update NEWS with pointer conversion macros. Make simulator match the Real World(TM) Add missing P4 Repair RIG_LEVEL_STRENGTH Add calibration table for TS-890S RFPOWER_METER_WATTS Bring simts890.c a little closer to the real thing Still needs more work. Fix icom_set_powerstat() to correctly save&restore rp->retry, rp->timeout_retry Convert some cache references to pointers Convert a few more cache pointers Cache pointers for src/rig.c Issue #1420 again. Convert rot_conf.c and amp_conf.c to pointers Update dcdport usage in tests/*.c Issue #1445 Play catchup with split/VFO revision. Fix typos in rebase fixups. Start converting rigs/* This commit does rigs/adat/, rigs/alinco/ and rigs/aor/. Port rigs/anytone/, rigs/barrett/ and rigs/codan/ Fixup git rebase SMerge error. Convert rigs/dorji, rigs/drake, rigs/elad. Convert rigs/dummy/ Convert rigs/flexradio, rigs/gomspace, rigs/jrc, rigs/kachina Convert rigs/icom/, rigs/kit/ Convert rigs/loew/, rigs/pcr/, rigs/prm80/, rigs/racal/ and rigs/rs/ Convert rigs/mds/, rigs/skanti/, rigs/tapr/ and rigs/tentec/ Do rigs/tuner/, rigs/uniden/, rigs/winradio/ & rigs/wj/ Convert rigs/yaesu Minor cleanup of ts890.c Update simts890.c Make IF return RX/TX status Document IF data, reformat IF & SF commands Convert all port references in amplifiers/ to pointers. Convert first part of rotators/ Finish rotators/ Add STATE to the list of pointers Convert tests/* to pointers Finish tests/* Update some of rigs/* to use pointer to cache Use pointers for all cache references in rigs/* All struct rig_cache referenced converted to pointers. Start converting rigs/* to use pointers to state More pointers to state More pointers to state Pointerize all state references in rigs/kenwood/* Add macros for amplifier and rotator state pointers. Fix incorrect port read for elevation Normalize some debug/trace output. More state pointer changes Convert macros in rig.h to use STATE() More state pointer changes Still more state pointer conversions. More state pointers - mostly sed i Pointerize state references in Tentec rigs. And another batch... Use sed -i on all in rigs/kit/ More sed -i with manual fixups. Convert all of rigs/* except rigs/icom and rigs/yaesu First set of rigs/icom/* state pointer macros. Convert rigs/icom/icom.[ch] First batch of state pointers in rigs/yaesu/ Next batch of state pointers Convert newcat.c FIx the stragglers Revert "Fix rotorez set_conf in both rotctl and rotctld -- since it needs to be done after rot_open" Definitions, storage and infrastructure for queuing config commands Implement the first user of the deferred set_conf entries. Fix other rotators that try to do I/O before open. Finish all port initialization before allowing I/O. Balance ENTERFUNC/RETURNFUNC, ENTERFUNC2/RETURNFUNC2, ELAPSED1/ELAPSED2 usage Balance ENTERFUNC/RETURNFUNC usage More of the balancing act. More balancing Finish balancing Get rid of some false positives for func_chk Fix func_chk to do useful things Fix ENTERFUNC/RETURNFUNC imbalances found by repaired func_chk More pointer conversions for rig->state. More pointerizations in src/* Convert all rig->state. references in src/rig.c to pointers. Play catch-up with recent code. Use pointers for amp->state references Use macros/pointers for rot->state references More amplifier and rotator state changes Yet another batch of state pointers Catch up with latest code Balance new code. Fix wrong error message for SF1 command. Make SNPRINTF do something useful for Hamlib Remove dead code Declare local functions as local Implement rig_get_clock for TS-890S Fix wrong utc_offset Use a reliable source for TZ offset Add just enough to simts890.c to fake kenwood_get_clock. Tweaks to simts890.c Fix negative fractional UTC offsets Implement kenwood_set_clock Fix command lengths for TS-890S set/get_antenna. Still more tweaks to simts890.c Replace raw write() calls with macro More fixes for simts890.c Reduce dependency on include/hamlib/rig.h Convert VFOs into objects(structs). Get rid of ghost commands. More VFOs as objects. Change FA/FB/SF to use band memories Implement step sizes for some freq changes Add DN/UP, FC, and UD commands to simts890.c Correct some split problems and connect VFO ops Clean up Make FR & FT commands aware of new vfo structs. Add traffic tracing to simts890.c Annotate legacy (undocumented) commands in simts890.c Add RIT/XIT commands (FS, RC, RD/RU, RF, RT, XT) to simts890.c Astyle simts890.c Update TS-890S and TS-990S RIT/XIT handling Factor out TS-890S and TS-990S from kenwood_get_split_vfo_if() MACROize new code. Minimal support for KY commands in simts890.c Use short (i.e., variable length) messages in kenwood_send_morse() Fix porting unneeded code Fix unbalanced ENTERFUNC/RETURNFUNC pairs in icom.c Fix the easy parts of missing thread locks Replace rs->multicast->mutex with a dedicated mutex for the API. Add locking to rig_stop_morse Fix timeout in kenwood_stop_morse Minor cleanups/fixes Add dates for recent releases Drop redundant token lookups. Make local functions static. Enable rig_vfo_op for TS-890S Add locking around get/set levels Fix out of sequence merge for issue #1634 Fix backward frequency tests in ft857.c Pass spectrum data through to callback Don't start async_data_handler until rig is fully opened. Update NEWS Georges Auberger (1): Add product id for CM119B chip. Used in KURI adapter designed by W7NX. Gerardo Richarte (1): gs232b.c: Improve get_position string parsing Gisle Vanem (1): Enable verbose mode in bindings/pytest.py Greg Troxel (1): Warning about dodgy code in drake.c HB9EIK (4): Initial release ELAD FDM DUO Update ELAD files Update build system for ELAD backend Update copyright for fdm_duo.c Hans Van Ingelgom (1): Added Peaberry V1 and V2 models Hegedüs Ervin (4): Merge branch 'master' of http://git.code.sf.net/p/hamlib/code Check SWIG string functions for some languages Leave off multiply 'typedef const char * const_char_string' definition (in rig.swg and rotator.swg) Fixed int[10] type variable error in bindings Jae Stutzman (5): Added HPSDR backend Clears potential garbage data in read buffer prior to command being sent Updated PiHPSDR backend defaults Use Windows ioctlsocket to avoid buffer overrun Added new AGC control for PiHPSDR James Watson, HZ1JW (2): Added ic7200 to icom Corrected modes in ic7200.c Jaroslav Skarvada (2): Fix hardcoded pcconfig libdir Fix serial_port DCD squelch Jeroen Vreeken (9): Add support for GPIO PTT. Add missing breaks and improve error messages Add Dorji DRA818 modules (VHF and UHF variants) Also works with NiceRF SA818 modules Merge branch 'master' of git://git.code.sf.net/p/hamlib/code Small fixes to DRA818 volume handling Add GPIO and GPION options for DCD. Also bump abi version since the config params struct needed resizing. Merge branch 'master' of github.com:Hamlib/Hamlib GPIO working after debugging Merge branch 'master' of github.com:Hamlib/Hamlib Johan Ström (1): Backup serial options on open, restore on close John Paul Adrian Glaubitz (1): dummy/dummy.c: Fix unaligned access in dummy_get_level() Jonathan Bastien-Filiatrault (3): Correct FT; command that does not exist on the FT-891. Allow setting split mode without smashing the VFOB frequency. Scale power values correctly for Yaesu FT-891. Jonny public (1): ether6: New rotor backend from Jonny, DG9OAA Joop Stakenborg, PG4I (116): update (kenwood is not a WIP anymore) first implementation of kenwood_get_ptt enable get_ptt for this rig add get_ptt for this rig additional protocol checks and cleanups fix signal strength add RIG_LEVEL_RFPOWER fix_compilation add rit capabilities bring comands in sync with other kenwood rigs add rit capabilities send_morse added explain set_rit fix get_ctcss_tone by using IF command typo add xit capabilities add set_level and get_level bring rig in sync with other kenwood rigs bump version numbers nothing returned by the rig for these commands fix get_level_agc fix set_level_agc getting in sync with the debian 1.1.2 package remove template files initial checkin make this NMU for now correct the path for copying files in the apropriate package do not install the old changelog versioning not used move .la, .a, .so files to the correct package include rpc.rigd and rpc.rotd include pkgconfig support don't create shlibs file for drake, jrc and easycomm libraries move hamlib1 to the top so the documentations gets installed correctly make building easier, call autogen.sh INSTALL file not used build the documentation package we don't have to call configure twice cleanup remove some build dependencies and don't call autogen.sh ts450s uses IF command for get_vfo, get_freq and get_mode minor bugfix, bump to beta add CWR and RTTYR this rig does not have a command for reading IF bandwidth retrieve passband with FW command passband should be calculated after mode is set use rig_passband_normal here various lintian fixes one last lintian fix use FW command to set bandpass cw filters for normal, narrow and wide more filters get_mode and set_mode for this rig filters some comments correct rit add get_level cleanups more modes set_level for this rig should use kenwood_get_freq minor bug add rpm support need hamlib.spec for 'make rpm' make rpm will fail with a '-' in the version number a working spec file update debian build for rotorez and fodtrack, minor fixes unofficial fix the debian build script, new maintainer update the debian build tree to the latest correct baudrate for the ts-950, use the information field IF for get_vfo by default (supported by most kenwood rigs), ts870s will use the much shorter FR command for get_vfo correct baudrate for some rigs and add ts-950 to the id_list ts-850 returns ID 009 according to martin, OK1RR fix 'make rpm' build for hamlib-1.1.5 not needed sync with latest debian package and add tcl, c++, python and perl bindings correct spelling s-meter calibration by Matt Dawson basic functionality by Matt Dawson, tested with grig and xlog lifetime e-mail address :-) sync with latest debian release more... [truncated message content] |