[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 9318df8e7511694c5652a
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: n0nb <n0...@us...> - 2023-04-29 20:57: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, master has been updated via 9318df8e7511694c5652a91029ad1245328452cc (commit) via a349c3e07bcc40f30c43a1c465cd8b4030a1055f (commit) via e5a6055d5727b42f03307d0c2e2489482dfc8392 (commit) via 215aa6b92c76eab5e17e811e6c070bd68b00b48a (commit) via e82f127965fba7f5852f59ead3abc45ebe5e1548 (commit) via addee81f43a6ef9223f712cd30612141cc20c035 (commit) via 07ba41d551e96fe3498ec8355d4d1e93d913a7d6 (commit) via da94c8b77074720d64b335df28d98a75c964b6c0 (commit) via 1db6487b8d30a2cb0d315c21d24692f31986fb3e (commit) via 1c1b9e75116916ef11e18a78a43af4e3455608ea (commit) via 6fadbfb1122ebc11694406303071a069d1eb43ca (commit) via 44807be556b8264eca8fb40a6f79318336944461 (commit) via f1533984802a9959bd357dc55dd9a562b152c126 (commit) via 6422bc51d5197e4e2c0a302b15a77cc719b5b86b (commit) via 4ba3a025124669776f88e29af6d84e035ac903cc (commit) via 2af9f2c5b3355d8806ea9e7d6f34eec720b40057 (commit) via 6c410f164e489ca30e101eab91d63d21a098003b (commit) via 72266a677dd35c9ce789bd0cf22b8efa535f6b94 (commit) via c02ded5b494341242a231bb1fffaa39eeed8daed (commit) via 6eee376cbfb429b4055667b69fe3c600d8ca64c6 (commit) via f390aa499d171e4e6f91c8f5bfaf7d7ec298c9de (commit) via 3b66959f4e3289e343e9911d203cb5216f744a15 (commit) via 1a59ce2ae2b42585ceb140eb713f87945531b87c (commit) via 4551199de1756d9eaf651b7c6a106d7e52686346 (commit) via 6f0efd59e61ebc2a6b96fcb9414cd2b240a9157e (commit) via 6c197dbc1cba336490e10914f2af3c3b0c0594b6 (commit) via 1c72440c5173c5f2c7e592cb6ace5ed6dd75c5a7 (commit) via e11b4bd01c64688bdf3714470f81a7e9fddd09aa (commit) via 905c9fff95f4dcaabfb2cfba4a821c895894051a (commit) from 6c1d83ed8684c8b3ff806c07e8c465d41c502685 (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 9318df8e7511694c5652a91029ad1245328452cc Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Apr 29 12:56:00 2023 -0500 Update NEWS diff --git a/NEWS b/NEWS index 4982e4e6..5e39dc19 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,7 @@ Version 4.6 Version 4.5.6 * Fix rigctld/rigctltcp information + * Fix FT817 get/set_vfo Version 4.5.5 * 2023-04-05 commit a349c3e07bcc40f30c43a1c465cd8b4030a1055f Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Apr 29 07:57:07 2023 -0500 Change ft817 startup timeout to 1500ms to avoid a timeout https://github.com/Hamlib/Hamlib/issues/1278 diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index c81b6be0..19c4da6b 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -292,7 +292,7 @@ const struct rig_caps ft817_caps = RIG_MODEL(RIG_MODEL_FT817), .model_name = "FT-817", .mfg_name = "Yaesu", - .version = "20230429.0", + .version = "20230429.1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -623,7 +623,7 @@ static int ft817_cleanup(RIG *rig) static int ft817_open(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); - hl_usleep(100*1000); // rig needs a bit to allow commands to come through + hl_usleep(1500*1000); // rig needs a bit to allow commands to come through on startup return RIG_OK; } commit e5a6055d5727b42f03307d0c2e2489482dfc8392 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Apr 28 22:30:07 2023 -0500 Another attempt to fix ft817_get_vfo https://github.com/Hamlib/Hamlib/issues/1278 diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 08e9583c..c81b6be0 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -292,7 +292,7 @@ const struct rig_caps ft817_caps = RIG_MODEL(RIG_MODEL_FT817), .model_name = "FT-817", .mfg_name = "Yaesu", - .version = "20230428.0", + .version = "20230429.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -696,7 +696,14 @@ static int ft817_read_eeprom(RIG *rig, unsigned short addr, unsigned char *out) return -RIG_EIO; } - *out = data[addr % 2]; + if (addr == 0x55) // for some reason VFO returns high byte + { + *out = data[0]; + } + else + { + *out = data[addr % 2]; + } rig_debug(RIG_DEBUG_VERBOSE, "%s: data[0]=%02x, data[1]=%02x, out=%02x\n", __func__, data[0], data[1], *out); @@ -1398,7 +1405,7 @@ static int ft817_get_vfo(RIG *rig, vfo_t *vfo) rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); - if (ft817_read_eeprom(rig, 0x54, &c) < 0) /* get vfo status */ + if (ft817_read_eeprom(rig, 0x55, &c) < 0) /* get vfo status */ { return -RIG_EPROTO; } commit 215aa6b92c76eab5e17e811e6c070bd68b00b48a Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Apr 28 08:20:57 2023 -0500 Try to fix ft817 get_vfo to return the valid status bye https://github.com/Hamlib/Hamlib/issues/1278 diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index 98caf300..08e9583c 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -292,7 +292,7 @@ const struct rig_caps ft817_caps = RIG_MODEL(RIG_MODEL_FT817), .model_name = "FT-817", .mfg_name = "Yaesu", - .version = "20230424.0", + .version = "20230428.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -698,6 +698,8 @@ static int ft817_read_eeprom(RIG *rig, unsigned short addr, unsigned char *out) *out = data[addr % 2]; + rig_debug(RIG_DEBUG_VERBOSE, "%s: data[0]=%02x, data[1]=%02x, out=%02x\n", __func__, data[0], data[1], *out); + return RIG_OK; } @@ -1396,7 +1398,7 @@ static int ft817_get_vfo(RIG *rig, vfo_t *vfo) rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); - if (ft817_read_eeprom(rig, 0x55, &c) < 0) /* get vfo status */ + if (ft817_read_eeprom(rig, 0x54, &c) < 0) /* get vfo status */ { return -RIG_EPROTO; } commit e82f127965fba7f5852f59ead3abc45ebe5e1548 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Apr 26 15:38:08 2023 -0500 Allow icom read_frame to return when bus collision occurs https://github.com/Hamlib/Hamlib/issues/1280 diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c index 973b7047..ad644457 100644 --- a/rigs/icom/frame.c +++ b/rigs/icom/frame.c @@ -540,7 +540,8 @@ static int read_icom_frame_generic(hamlib_port_t *p, && (rxbuffer[read - 1] != COL)); // Check that we have a valid frame preamble (which might be just a single preable character) - if (rxbuffer[0] != PR) + // Or an error code + if (rxbuffer[0] != PR && rxbuffer[0] != COL) { return -RIG_EPROTO; } diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 477e2598..5aced162 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -35,7 +35,7 @@ #include <sys/time.h> #endif -#define BACKEND_VER "20230425" +#define BACKEND_VER "20230426" #define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31) #define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51) commit addee81f43a6ef9223f712cd30612141cc20c035 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Apr 25 22:27:38 2023 -0500 Fix rigctld sending an extra space in front of send_morse string Single space still works https://github.com/Hamlib/Hamlib/issues/1281 diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 61820ffb..9405c373 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -958,12 +958,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, { *nl = '\0'; /* chomp */ } - - if (cmd == 'b') - { - p1 = arg1; /* CW must accept a space argument */ - } - else /* skip a space arg if first arg...but why? */ + /* skip a space arg if first arg...happens parsing rigctld commands */ { p1 = arg1[0] == ' ' ? arg1 + 1 : arg1; } commit 07ba41d551e96fe3498ec8355d4d1e93d913a7d6 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Apr 25 11:07:25 2023 -0500 Add a retry in icom frame.c in case of collision https://github.com/Hamlib/Hamlib/issues/1280 diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c index 81cc7fe9..973b7047 100644 --- a/rigs/icom/frame.c +++ b/rigs/icom/frame.c @@ -138,6 +138,7 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, unsigned char sendbuf[MAXFRAMELEN]; int frm_len, frm_data_len, retval; unsigned char ctrl_id; + int collision_retry = 0; ENTERFUNC; memset(buf, 0, 200); @@ -156,6 +157,7 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, */ set_transaction_active(rig); +collision_retry: rig_flush(&rs->rigport); if (data_len) { *data_len = 0; } @@ -223,6 +225,13 @@ int icom_one_transaction(RIG *rig, unsigned char cmd, int subcmd, { case COL: /* Collision */ + // IC746 for example responds 0xfc when tuning is active so we will retry + if (collision_retry++ < 20) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: collision retry#%d\n", __func__, collision_retry); + hl_usleep(500*1000); // 500ms 20 times for ~15 second max before we back out for a retry if needed + goto collision_retry; + } set_transaction_inactive(rig); RETURNFUNC(-RIG_BUSBUSY); commit da94c8b77074720d64b335df28d98a75c964b6c0 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Apr 25 08:52:42 2023 -0500 Change ft817.c to not mask the low bit on eepromp reads -- hopefully this doesn't break everything https://github.com/Hamlib/Hamlib/issues/1278 diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index efc84ea6..98caf300 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -292,7 +292,7 @@ const struct rig_caps ft817_caps = RIG_MODEL(RIG_MODEL_FT817), .model_name = "FT-817", .mfg_name = "Yaesu", - .version = "20230422.0", + .version = "20230424.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -442,7 +442,7 @@ const struct rig_caps ft818_caps = RIG_MODEL(RIG_MODEL_FT818), .model_name = "FT-818", .mfg_name = "Yaesu", - .version = "20220419.0", + .version = "20220424.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -682,7 +682,7 @@ static int ft817_read_eeprom(RIG *rig, unsigned short addr, unsigned char *out) YAESU_CMD_LENGTH); data[0] = addr >> 8; - data[1] = addr & 0xfe; + data[1] = addr & 0xff; write_block(&rig->state.rigport, data, YAESU_CMD_LENGTH); @@ -1418,7 +1418,7 @@ static int ft817_set_vfo(RIG *rig, vfo_t vfo) vfo_t curvfo; int retval; - rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); + rig_debug(RIG_DEBUG_VERBOSE, "%s: called vfo=%s\n", __func__, rig_strvfo(vfo)); retval = ft817_get_vfo(rig, &curvfo); commit 1db6487b8d30a2cb0d315c21d24692f31986fb3e Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Apr 25 08:26:12 2023 -0500 Add simspid.c diff --git a/simulators/Makefile.am b/simulators/Makefile.am index 73ca41c1..982e6a82 100644 --- a/simulators/Makefile.am +++ b/simulators/Makefile.am @@ -8,7 +8,7 @@ DISTCLEANFILES = bin_PROGRAMS = -check_PROGRAMS = simelecraft simicom simkenwood simyaesu simicom9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez +check_PROGRAMS = simelecraft simicom simkenwood simyaesu simicom9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simelecraft_SOURCES = simelecraft.c simicom_SOURCES = simicom.c diff --git a/simulators/simspid.c b/simulators/simspid.c new file mode 100644 index 00000000..6c1d0ac1 --- /dev/null +++ b/simulators/simspid.c @@ -0,0 +1,116 @@ +// can run this using rigctl/rigctld and socat pty devices +// gcc -o simspid simspid.c +#define _XOPEN_SOURCE 600 +#include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> +#include "../include/hamlib/rig.h" + +#define BUFSIZE 256 + +float freqA = 14074000; +float freqB = 14074500; +char tx_vfo = '0'; +char rx_vfo = '0'; +char modeA = '1'; +char modeB = '1'; +int width_main = 500; +int width_sub = 700; + + +int +getmyline(int fd, unsigned char *buf) +{ + unsigned char c; + int i = 0; + int n = 0; + memset(buf, 0, BUFSIZE); + + while (i < 5 && read(fd, &c, 1) > 0) + { + buf[i++] = c; + n++; + } + + printf("n=%d %02x %02x %02x %02x %02x\n", n, buf[0], buf[1], buf[2], buf[3], + buf[4]); + return n; +} + +#if defined(WIN32) || defined(_WIN32) +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd; + fd = open(comport, O_RDWR); + + if (fd < 0) + { + perror(comport); + } + + return fd; +} + +#else +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd = posix_openpt(O_RDWR); + char *name = ptsname(fd); + + if (name == NULL) + { + perror("pstname"); + return -1; + } + + printf("name=%s\n", name); + + if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) + { + perror("posix_openpt"); + return -1; + } + + return fd; +} +#endif + + + +int main(int argc, char *argv[]) +{ + unsigned char buf[256]; + + +again: + int fd = openPort(argv[1]); + + while (1) + { + int bytes = getmyline(fd, buf); + + if (bytes == 0) + { + close(fd); + goto again; + } + + if (bytes != 5) + { + printf("Not 5 bytes? bytes=%d\n", bytes); + } + + switch (buf[0]) + { + case '?': printf("Query %c\n", buf[1]); break; + + case '*': printf("Set %c\n", buf[1]); break; + + default: printf("Unknown cmd=%02x\n", buf[4]); + } + } + + return 0; +} commit 1c1b9e75116916ef11e18a78a43af4e3455608ea Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Apr 25 08:13:03 2023 -0500 Enable async_io for IC-746 and IC-746PRO https://github.com/Hamlib/Hamlib/issues/1280 diff --git a/rigs/icom/ic746.c b/rigs/icom/ic746.c index b6370141..2231987b 100644 --- a/rigs/icom/ic746.c +++ b/rigs/icom/ic746.c @@ -181,7 +181,7 @@ const struct rig_caps ic746_caps = RIG_MODEL(RIG_MODEL_IC746), .model_name = "IC-746", .mfg_name = "Icom", - .version = BACKEND_VER ".3", + .version = BACKEND_VER ".4", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -286,6 +286,11 @@ const struct rig_caps ic746_caps = }, .str_cal = IC746_STR_CAL, + .async_data_supported = 1, + .read_frame_direct = icom_read_frame_direct, + .is_async_frame = icom_is_async_frame, + .process_async_frame = icom_process_async_frame, + .cfgparams = icom_cfg_params, .set_conf = icom_set_conf, .get_conf = icom_get_conf, @@ -413,7 +418,7 @@ const struct rig_caps ic746pro_caps = RIG_MODEL(RIG_MODEL_IC746PRO), .model_name = "IC-746PRO", .mfg_name = "Icom", - .version = BACKEND_VER ".2", + .version = BACKEND_VER ".3", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -532,6 +537,11 @@ const struct rig_caps ic746pro_caps = }, .str_cal = IC746_STR_CAL, + .async_data_supported = 1, + .read_frame_direct = icom_read_frame_direct, + .is_async_frame = icom_is_async_frame, + .process_async_frame = icom_process_async_frame, + .cfgparams = icom_cfg_params, .set_conf = icom_set_conf, .get_conf = icom_get_conf, commit 6fadbfb1122ebc11694406303071a069d1eb43ca Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Apr 25 08:00:43 2023 -0500 Change Icom 0x25 logic to only allow one detection https://github.com/Hamlib/Hamlib/issues/1277 diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 592ba0f0..6dd9dc36 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -682,7 +682,7 @@ int icom_init(RIG *rig) priv->rx_vfo = RIG_VFO_NONE; rig->state.current_vfo = RIG_VFO_NONE; priv->filter = RIG_PASSBAND_NOCHANGE; - priv->x25cmdfails = 0; + priv->x25cmdfails = -1; priv->x1cx03cmdfails = 0; // we can add rigs here that will never use the 0x25 cmd @@ -1652,7 +1652,7 @@ int icom_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) if (retval != RIG_OK) { - priv->x25cmdfails = 1; + if (priv->x25cmdfails < 0) priv->x25cmdfails = 1; rig_debug(RIG_DEBUG_WARN, "%s: rig probe shows 0x25 CI-V cmd not available\n", __func__); } @@ -5758,7 +5758,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) RETURNFUNC2(retval); } - priv->x25cmdfails = 1; + if (priv->x25cmdfails < 0) priv->x25cmdfails = 1; } } else // we're in satmode so we try another command diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index c2d970b0..477e2598 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -35,7 +35,7 @@ #include <sys/time.h> #endif -#define BACKEND_VER "20230122" +#define BACKEND_VER "20230425" #define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31) #define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51) commit 44807be556b8264eca8fb40a6f79318336944461 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Apr 25 07:58:55 2023 -0500 Add simrotorez diff --git a/simulators/Makefile.am b/simulators/Makefile.am index 811db29a..73ca41c1 100644 --- a/simulators/Makefile.am +++ b/simulators/Makefile.am @@ -8,7 +8,7 @@ DISTCLEANFILES = bin_PROGRAMS = -check_PROGRAMS = simelecraft simicom simkenwood simyaesu simicom9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 +check_PROGRAMS = simelecraft simicom simkenwood simyaesu simicom9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simelecraft_SOURCES = simelecraft.c simicom_SOURCES = simicom.c diff --git a/simulators/simrotorez.c b/simulators/simrotorez.c new file mode 100644 index 00000000..2fdfa142 --- /dev/null +++ b/simulators/simrotorez.c @@ -0,0 +1,127 @@ +// can run this using rigctl/rigctld and socat pty devices +// gcc -o simspid simspid.c +#define _XOPEN_SOURCE 600 +#include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> +#include <string.h> +#include <unistd.h> +#include "../include/hamlib/rig.h" + +#define BUFSIZE 256 + +float az = 0; +float el = 0; + +int +getmyline(int fd, char *buf) +{ + unsigned char c; + int i = 0; + int n = 0; + memset(buf, 0, BUFSIZE); + + while (read(fd, &c, 1) > 0 && c!=';') + { + buf[i++] = c; + n++; + for(int i=0;i<strlen(buf);++i) printf("%02x ", buf[i]); + printf("\n"); + } + + return n; +} + +#if defined(WIN32) || defined(_WIN32) +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd; + fd = open(comport, O_RDWR); + + if (fd < 0) + { + perror(comport); + } + + return fd; +} + +#else +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd = posix_openpt(O_RDWR); + char *name = ptsname(fd); + + if (name == NULL) + { + perror("pstname"); + return -1; + } + + printf("name=%s\n", name); + + if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) + { + perror("posix_openpt"); + return -1; + } + + return fd; +} +#endif + + + +int main(int argc, char *argv[]) +{ + char buf[256]; + int n; + +again: + int fd = openPort(argv[1]); + int fd2 = openPort(argv[2]); + int flag = 0; + + while (1) + { + int bytes; + if (!flag) bytes = getmyline(fd, buf); + else bytes = getmyline(fd2, buf); + flag = !flag; + + if (bytes == 0) + { + //close(fd); + goto again; + } + printf("line=%s\n", buf); + + if (strncmp(buf,"BI1",3) == 0) + { + sprintf(buf,"%3.1f;", az); + n = write(fd, buf, strlen(buf)); + printf("n=%d\n", n); + } + else if (strncmp(buf,"AP1",3) == 0) + { + sscanf(buf,"AP1%f", &az); + } + else + { + printf("Unknown cmd=%s\n", buf); + } + +#if 0 + switch (buf[0]) + { + case '?': printf("Query %c\n", buf[1]); break; + + case '*': printf("Set %c\n", buf[1]); break; + + default: printf("Unknown cmd=%02x\n", buf[4]); + } +#endif + } + + return 0; +} commit f1533984802a9959bd357dc55dd9a562b152c126 Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Apr 22 12:09:33 2023 -0500 Update NEWS diff --git a/NEWS b/NEWS index 1556473a..4982e4e6 100644 --- a/NEWS +++ b/NEWS @@ -30,6 +30,9 @@ Version 4.6 * Add FLIR PTU-D48, E46, D100, D300 rotors * Fix FTDX3000 rig split +Version 4.5.6 + * Fix rigctld/rigctltcp information + Version 4.5.5 * 2023-04-05 * Add park to rotorez.c commit 6422bc51d5197e4e2c0a302b15a77cc719b5b86b Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Apr 22 11:39:03 2023 -0500 Add version to rig_init debug info diff --git a/src/rig.c b/src/rig.c index 8768d9af..555a3b23 100644 --- a/src/rig.c +++ b/src/rig.c @@ -509,8 +509,8 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model) return (NULL); } - rig_debug(RIG_DEBUG_VERBOSE, "%s: rig_model=%s %s\n", __func__, caps->mfg_name, - caps->model_name); + rig_debug(RIG_DEBUG_VERBOSE, "%s: rig_model=%s %s %s\n", __func__, caps->mfg_name, + caps->model_name, caps->version); if (caps->hamlib_check_rig_caps != NULL) { commit 4ba3a025124669776f88e29af6d84e035ac903cc Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Apr 22 11:22:16 2023 -0500 FT-817 add 100ms delay during ft817_open to avoid initial cmd error during startup https://github.com/Hamlib/Hamlib/issues/1278 diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index d87efa05..efc84ea6 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -292,7 +292,7 @@ const struct rig_caps ft817_caps = RIG_MODEL(RIG_MODEL_FT817), .model_name = "FT-817", .mfg_name = "Yaesu", - .version = "20230421.0", + .version = "20230422.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -623,6 +623,7 @@ static int ft817_cleanup(RIG *rig) static int ft817_open(RIG *rig) { rig_debug(RIG_DEBUG_VERBOSE, "%s: called \n", __func__); + hl_usleep(100*1000); // rig needs a bit to allow commands to come through return RIG_OK; } commit 2af9f2c5b3355d8806ea9e7d6f34eec720b40057 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Apr 21 22:05:42 2023 -0500 For FT-817 add sleep after set_vfo to allow vfo swap to occur https://github.com/Hamlib/Hamlib/issues/1278 diff --git a/rigs/yaesu/ft817.c b/rigs/yaesu/ft817.c index d912535b..d87efa05 100644 --- a/rigs/yaesu/ft817.c +++ b/rigs/yaesu/ft817.c @@ -292,7 +292,7 @@ const struct rig_caps ft817_caps = RIG_MODEL(RIG_MODEL_FT817), .model_name = "FT-817", .mfg_name = "Yaesu", - .version = "20220419.0", + .version = "20230421.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1432,8 +1432,10 @@ static int ft817_set_vfo(RIG *rig, vfo_t vfo) { return RIG_OK; } + retval = ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_VFOAB); + hl_usleep(50 * 1000); // can take a little while for vfo swap to happen -- otherwise we get errors trying to read eeprom to quickly - return ft817_send_cmd(rig, FT817_NATIVE_CAT_SET_VFOAB); + return retval; } static int ft817_set_freq(RIG *rig, vfo_t vfo, freq_t freq) commit 6c410f164e489ca30e101eab91d63d21a098003b Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Apr 21 16:04:04 2023 -0500 This did not solve the problem with Win4Yaesu Revert "https://github.com/Hamlib/Hamlib/issues/1275" This reverts commit c02ded5b494341242a231bb1fffaa39eeed8daed. diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index db9e2b29..eb206647 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -10827,7 +10827,7 @@ int newcat_set_cmd_validate(RIG *rig) } else if (strncmp(priv->cmd_str, "ST", 2) == 0) { - strcpy(valcmd, "X;"); + strcpy(valcmd, ";"); } else { @@ -10855,7 +10855,7 @@ int newcat_set_cmd_validate(RIG *rig) case RIG_MODEL_FT991: case RIG_MODEL_FTDX101MP: case RIG_MODEL_FTDX3000: - strcpy(valcmd, "X;"); + strcpy(valcmd, ";"); break; // these models do not work with a single ; case RIG_MODEL_FT897: diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 72980d2a..441914ca 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20230419" +#define NEWCAT_VER "20230328" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 commit 72266a677dd35c9ce789bd0cf22b8efa535f6b94 Merge: c02ded5b 6eee376c Author: Michael Black <mdb...@ya...> Date: Thu Apr 20 17:19:14 2023 -0500 Merge pull request #1276 from dforsi/fix/typos Fix name of command in --version and usage outputs commit c02ded5b494341242a231bb1fffaa39eeed8daed Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Apr 19 15:15:56 2023 -0500 https://github.com/Hamlib/Hamlib/issues/1275 diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index eb206647..db9e2b29 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -10827,7 +10827,7 @@ int newcat_set_cmd_validate(RIG *rig) } else if (strncmp(priv->cmd_str, "ST", 2) == 0) { - strcpy(valcmd, ";"); + strcpy(valcmd, "X;"); } else { @@ -10855,7 +10855,7 @@ int newcat_set_cmd_validate(RIG *rig) case RIG_MODEL_FT991: case RIG_MODEL_FTDX101MP: case RIG_MODEL_FTDX3000: - strcpy(valcmd, ";"); + strcpy(valcmd, "X;"); break; // these models do not work with a single ; case RIG_MODEL_FT897: diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 441914ca..72980d2a 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20230328" +#define NEWCAT_VER "20230419" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 commit 6eee376cbfb429b4055667b69fe3c600d8ca64c6 Author: Daniele Forsi IU5HKX <iu...@gm...> Date: Wed Apr 19 21:48:32 2023 +0200 Fix name of command in the version text diff --git a/tests/rigctld.c b/tests/rigctld.c index b9c6dbc6..a2e32820 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -309,7 +309,7 @@ int main(int argc, char *argv[]) exit(0); case 'V': - printf("rigctl %s\n", hamlib_version2); + printf("rigctld %s\n", hamlib_version2); exit(0); case 'R': commit f390aa499d171e4e6f91c8f5bfaf7d7ec298c9de Author: Daniele Forsi IU5HKX <iu...@gm...> Date: Wed Apr 19 21:34:44 2023 +0200 Fix name of command in the usage and version texts diff --git a/tests/rigctltcp.c b/tests/rigctltcp.c index 3ee212bc..e23cc0ea 100644 --- a/tests/rigctltcp.c +++ b/tests/rigctltcp.c @@ -312,7 +312,7 @@ int main(int argc, char *argv[]) exit(0); case 'V': - printf("rigctl %s\n", hamlib_version2); + printf("rigctltcp %s\n", hamlib_version2); exit(0); case 'R': @@ -656,7 +656,7 @@ int main(int argc, char *argv[]) rig_debug(RIG_DEBUG_VERBOSE, "%s\n", rigstartup); - rig_debug(RIG_DEBUG_VERBOSE, "rigctld %s\n", hamlib_version2); + rig_debug(RIG_DEBUG_VERBOSE, "rigctltcp %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to <ham...@li...>\n\n"); rig_debug(RIG_DEBUG_VERBOSE, "Max# of rigctld client services=%d\n", @@ -1513,7 +1513,7 @@ handle_exit: void usage(void) { - printf("Usage: rigctld [OPTION]...\n" + printf("Usage: rigctltcp [OPTION]...\n" "Daemon serving COMMANDs to a connected radio transceiver or receiver.\n\n"); commit 3b66959f4e3289e343e9911d203cb5216f744a15 Merge: 4551199d 1a59ce2a Author: Michael Black <mdb...@ya...> Date: Mon Apr 17 07:21:10 2023 -0500 Merge pull request #1274 from mikaelnousiainen/ts590sg-fixes Fix and extend TS-590(S/SG) backend commit 1a59ce2ae2b42585ceb140eb713f87945531b87c Author: Mikael Nousiainen <mik...@ik...> Date: Sat Apr 15 00:25:29 2023 +0300 Fix and extend TS-590(S/SG) backend diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index c691b46a..d8d5ad3f 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -1323,6 +1323,11 @@ typedef uint64_t rmode_t; */ #define RIG_MODE_SSB (RIG_MODE_USB|RIG_MODE_LSB) +/** + * \brief macro for backends, not to be used by rig_set_mode et al. + */ +#define RIG_MODE_PKTSSB (RIG_MODE_PKTUSB|RIG_MODE_PKTLSB) + /** * \brief macro for backends, not to be used by rig_set_mode et al. */ diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 2f5b0c81..3bd3723c 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -322,7 +322,13 @@ transaction_write: rig_flush(&rs->rigport); // PS command may need to wake up serial port - if (strncmp(cmd, "PS", 2) == 0) { write_block(&rs->rigport, (unsigned char *) ";;;;", 4); } + if (priv->ps_cmd_wakeup_data) + { + if (strncmp(cmd, "PS", 2) == 0) + { + write_block(&rs->rigport, (unsigned char *) ";;;;", 4); + } + } retval = write_block(&rs->rigport, (unsigned char *) cmd, len); @@ -484,6 +490,24 @@ transaction_read: case '?': + /* The ? response is an ambiguous response, but for get commands it seems to + * indicate that the rig rejected the command because the state of the rig is not valid for the command + * or that the command parameter is invalid. Retrying the command does not fix the issue, + * as the error is caused by the an invalid combination of rig state. + * + * For example, the following cases have been observed: + * - NL (NB level) and RL (NR level) commands fail if NB / NR are not enabled on TS-590SG + * - SH and SL (filter width) fail in CW mode on TS-590SG + * - GT (AGC) fails in FM mode on TS-590SG + * + * There are more cases like these and they vary by rig model. + */ + if (priv->question_mark_response_means_rejected) + { + rig_debug(RIG_DEBUG_ERR, "%s: Command rejected by the rig (get): '%s'\n", __func__,cmdstr); + RETURNFUNC(-RIG_ERJCTED); + } + /* Command not understood by rig or rig busy */ if (cmdstr) { @@ -519,8 +543,18 @@ transaction_read: */ if (datasize) { - // we ignore the special ;;;;PS; command - if (cmdstr && strcmp(cmdstr, ";;;;PS") != 0 && (buffer[0] != cmdstr[0] + char *ps_cmd; + if (priv->ps_cmd_wakeup_data) + { + ps_cmd = ";;;;PS"; + } + else + { + ps_cmd = "PS"; + } + + // we ignore the special PS command + if (cmdstr && strcmp(cmdstr, ps_cmd) != 0 && (buffer[0] != cmdstr[0] || (cmdstr[1] && buffer[1] != cmdstr[1]))) { /* @@ -836,6 +870,8 @@ int kenwood_open(RIG *rig) id[0] = 0; rig->state.rigport.retry = 0; + priv->question_mark_response_means_rejected = 0; + if (rig->state.auto_power_on) { // Ensure rig is on @@ -3102,7 +3138,7 @@ static int kenwood_find_slope_filter_for_value(RIG *rig, vfo_t vfo, int kenwood_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) { char levelbuf[16]; - int i, kenwood_val, len; + int i, kenwood_val, len, result; struct kenwood_priv_data *priv = rig->state.priv; struct kenwood_priv_caps *caps = kenwood_caps(rig); @@ -3311,6 +3347,7 @@ int kenwood_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } SNPRINTF(levelbuf, sizeof(levelbuf), "SH%02d", kenwood_val); + priv->question_mark_response_means_rejected = 1; break; case RIG_LEVEL_SLOPE_LOW: @@ -3329,6 +3366,7 @@ int kenwood_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } SNPRINTF(levelbuf, sizeof(levelbuf), "SL%02d", kenwood_val); + priv->question_mark_response_means_rejected = 1; break; case RIG_LEVEL_CWPITCH: @@ -3404,7 +3442,10 @@ int kenwood_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) RETURNFUNC(-RIG_EINVAL); } - RETURNFUNC(kenwood_transaction(rig, levelbuf, NULL, 0)); + result = kenwood_transaction(rig, levelbuf, NULL, 0); + priv->question_mark_response_means_rejected = 0; + + RETURNFUNC(result); } int get_kenwood_level(RIG *rig, const char *cmd, float *fval, int *ival) @@ -3824,7 +3865,9 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) RETURNFUNC(ret); case RIG_LEVEL_SLOPE_LOW: + priv->question_mark_response_means_rejected = 1; retval = kenwood_transaction(rig, "SL", lvlbuf, sizeof(lvlbuf)); + priv->question_mark_response_means_rejected = 0; if (retval != RIG_OK) { @@ -3852,7 +3895,9 @@ int kenwood_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) break; case RIG_LEVEL_SLOPE_HIGH: + priv->question_mark_response_means_rejected = 1; retval = kenwood_transaction(rig, "SH", lvlbuf, sizeof(lvlbuf)); + priv->question_mark_response_means_rejected = 0; if (retval != RIG_OK) { @@ -4661,6 +4706,10 @@ int kenwood_set_ant(RIG *rig, vfo_t vfo, ant_t ant, value_t option) SNPRINTF(cmd, sizeof(cmd), "AN0%c%c99", c, a); } + else if (RIG_IS_TS590S || RIG_IS_TS590SG) + { + SNPRINTF(cmd, sizeof(cmd), "AN%c99", a); + } else { SNPRINTF(cmd, sizeof(cmd), "AN%c", a); @@ -4723,6 +4772,11 @@ int kenwood_get_ant(RIG *rig, vfo_t vfo, ant_t dummy, value_t *option, retval = kenwood_safe_transaction(rig, "AN0", ackbuf, sizeof(ackbuf), 7); offs = 4; } + else if (RIG_IS_TS590S || RIG_IS_TS590SG) + { + retval = kenwood_safe_transaction(rig, "AN", ackbuf, sizeof(ackbuf), 5); + offs = 2; + } else { retval = kenwood_safe_transaction(rig, "AN", ackbuf, sizeof(ackbuf), 3); @@ -5068,7 +5122,17 @@ int kenwood_get_powerstat(RIG *rig, powerstat_t *status) RETURNFUNC(-RIG_EINVAL); } - retval = kenwood_safe_transaction(rig, ";;;;PS", pwrbuf, 6, 3); + char *ps_cmd; + if (priv->ps_cmd_wakeup_data) + { + ps_cmd = ";;;;PS"; + } + else + { + ps_cmd = "PS"; + } + + retval = kenwood_safe_transaction(rig, ps_cmd, pwrbuf, 6, 3); if (retval != RIG_OK) { diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index 7604b95a..f071c8f1 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -28,7 +28,7 @@ #include "token.h" #include "idx_builtin.h" -#define BACKEND_VER "20230318" +#define BACKEND_VER "20230414" #define EOM_KEN ';' #define EOM_TH '\r' @@ -175,6 +175,8 @@ struct kenwood_priv_data rmode_t modeB; int datamodeA; // datamode status from get_mode or set_mode int datamodeB; // datamode status from get_mode or set_mode + int ps_cmd_wakeup_data; // PS command requires wakeup characters (;) + int question_mark_response_means_rejected; /* the question mark response has multiple meanings */ }; diff --git a/rigs/kenwood/level_gran_kenwood.h b/rigs/kenwood/level_gran_kenwood.h index 44b668f9..826499f6 100644 --- a/rigs/kenwood/level_gran_kenwood.h +++ b/rigs/kenwood/level_gran_kenwood.h @@ -7,7 +7,6 @@ [LVL_PREAMP] = { .min = { .i = 10 }, .max = { .i = 20 }, .step = { .i = 10 } }, [LVL_ATT] = { .min = { .i = 0 }, .max = { .i = 12 }, .step = { .i = 0 } }, [LVL_STRENGTH] = { .min = { .i = 0 }, .max = { .i = 60 }, .step = { .i = 0 } }, - [LVL_NB] = { .min = { .f = 0 }, .max = { .f = 10 }, .step = { .f = 1 } }, /* levels with WPM units */ [LVL_KEYSPD] = { .min = { .i = 4 }, .max = { .i = 60 }, .step = { .i = 1 } }, /* levels with Hz units */ @@ -25,6 +24,7 @@ [LVL_BAND_SELECT] = { .min = { .i = 0 }, .max = { .i = 16 }, .step = { .i = 1 } }, /* levels with 0-1 values -- increment based on rig's range */ [LVL_NR] = { .min = { .f = 0 }, .max = { .f = 1 }, .step = { .f = 1.0f/10.0f } }, + [LVL_NB] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/10.0f } }, [LVL_AF] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/255.0f } }, [LVL_RF] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/255.0f } }, [LVL_RFPOWER] = { .min = { .f = .05 }, .max = { .f = 1 }, .step = { .f = 1.0f/100.0f } }, diff --git a/rigs/kenwood/ts480.c b/rigs/kenwood/ts480.c index 781434d7..9fc5247d 100644 --- a/rigs/kenwood/ts480.c +++ b/rigs/kenwood/ts480.c @@ -42,7 +42,7 @@ #define TS480_LEVEL_GET (RIG_LEVEL_RFPOWER|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_SQL|RIG_LEVEL_AGC|RIG_LEVEL_MICGAIN|RIG_LEVEL_STRENGTH|RIG_LEVEL_KEYSPD|RIG_LEVEL_CWPITCH| \ RIG_LEVEL_MONITOR_GAIN|RIG_LEVEL_NB|RIG_LEVEL_NR|RIG_LEVEL_PREAMP|RIG_LEVEL_COMP|RIG_LEVEL_ATT|RIG_LEVEL_VOXDELAY|RIG_LEVEL_VOXGAIN|RIG_LEVEL_BKIN_DLYMS| \ - RIG_LEVEL_METER|RIG_LEVEL_SWR|RIG_LEVEL_COMP_METER|RIG_LEVEL_ALC|RIG_LEVEL_RFPOWER_METER|RIG_LEVEL_SLOPE_HIGH|RIG_LEVEL_SLOPE_LOW) + RIG_LEVEL_SWR|RIG_LEVEL_COMP_METER|RIG_LEVEL_ALC|RIG_LEVEL_RFPOWER_METER|RIG_LEVEL_SLOPE_HIGH|RIG_LEVEL_SLOPE_LOW) #define TS480_LEVEL_SET (RIG_LEVEL_RFPOWER|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_SQL|RIG_LEVEL_AGC|RIG_LEVEL_MICGAIN|RIG_LEVEL_KEYSPD|RIG_LEVEL_CWPITCH| \ RIG_LEVEL_MONITOR_GAIN|RIG_LEVEL_NB|RIG_LEVEL_NR|RIG_LEVEL_PREAMP|RIG_LEVEL_COMP|RIG_LEVEL_ATT|RIG_LEVEL_VOXDELAY|RIG_LEVEL_VOXGAIN|RIG_LEVEL_BKIN_DLYMS| \ @@ -658,42 +658,6 @@ kenwood_ts480_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) val->i = ackbuf[3] == '1' ? 12 : 0; break; - case RIG_LEVEL_METER: - { - int raw_value; - - // TODO: Read all meters at the same time: RM10000;RM20000;RM30000; - - retval = kenwood_safe_transaction(rig, "RM", ackbuf, sizeof(ackbuf), 7); - - if (retval != RIG_OK) - { - RETURNFUNC(retval); - } - - sscanf(ackbuf, "RM%1d", &raw_value); - - switch (raw_value) - { - case 1: - val->i = RIG_METER_SWR; - break; - - case 2: - val->i = RIG_METER_COMP; - break; - - case 3: - val->i = RIG_METER_ALC; - break; - - default: - val->i = RIG_METER_NONE; - } - - break; - } - case RIG_LEVEL_SWR: case RIG_LEVEL_COMP_METER: case RIG_LEVEL_ALC: @@ -1205,7 +1169,7 @@ static struct kenwood_slope_filter ts480_slope_filter_low[] = { RIG_MODE_SSB | RIG_MODE_FM | RIG_MODE_RTTY | RIG_MODE_RTTYR, 0, 8, 700 }, { RIG_MODE_SSB | RIG_MODE_FM | RIG_MODE_RTTY | RIG_MODE_RTTYR, 0, 9, 800 }, { RIG_MODE_SSB | RIG_MODE_FM | RIG_MODE_RTTY | RIG_MODE_RTTYR, 0, 10, 900 }, - { RIG_MODE_SSB | RIG_MODE_FM | RIG_MODE_RTTY | RIG_MODE_RTTYR, 10, 1, 1000 }, + { RIG_MODE_SSB | RIG_MODE_FM | RIG_MODE_RTTY | RIG_MODE_RTTYR, 0, 11, 1000 }, { RIG_MODE_AM, 0, 0, 0 }, { RIG_MODE_AM, 0, 1, 100 }, { RIG_MODE_AM, 0, 2, 200 }, @@ -1247,6 +1211,7 @@ int ts480_init(RIG *rig) priv->ag_format = 2; priv->micgain_min = 0; priv->micgain_max = 100; + priv->ps_cmd_wakeup_data = 1; RETURNFUNC(RIG_OK); } diff --git a/rigs/kenwood/ts590.c b/rigs/kenwood/ts590.c index 285b8d11..e37bb2a1 100644 --- a/rigs/kenwood/ts590.c +++ b/rigs/kenwood/ts590.c @@ -1,7 +1,7 @@ /* - * Hamlib Kenwood backend - TS590 description + * Hamlib Kenwood backend - TS-590(S/SG) description * Copyright (c) 2010 by Stephane Fillod - * + * Copyright (c) 2023 by Mikael Nousiainen OH3BHX * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,74 +21,1389 @@ #include <stdio.h> #include <string.h> +#include <stdlib.h> + +#include "hamlib/rig.h" +#include "kenwood.h" +#include "misc.h" +#include "cal.h" +#include "iofunc.h" + +#define TS590_ALL_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_PKTFM|RIG_MODE_PKTUSB|RIG_MODE_PKTLSB|RIG_MODE_PKTAM) +#define TS590_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_SSB|RIG_MODE_FM|RIG_MODE_RTTY) +#define TS590_AM_TX_MODES (RIG_MODE_AM|RIG_MODE_PKTAM) +#define TS590_VFO (RIG_VFO_A|RIG_VFO_B|RIG_VFO_MEM) + +#define TS590_LEVEL_GET (RIG_LEVEL_RFPOWER|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_SQL|RIG_LEVEL_AGC|RIG_LEVEL_MICGAIN|RIG_LEVEL_STRENGTH|RIG_LEVEL_KEYSPD|RIG_LEVEL_CWPITCH| \ + RIG_LEVEL_MONITOR_GAIN|RIG_LEVEL_NB|RIG_LEVEL_NR|RIG_LEVEL_PREAMP|RIG_LEVEL_COMP|RIG_LEVEL_ATT|RIG_LEVEL_VOXDELAY|RIG_LEVEL_VOXGAIN|RIG_LEVEL_BKIN_DLYMS| \ + RIG_LEVEL_SWR|RIG_LEVEL_COMP_METER|RIG_LEVEL_ALC|RIG_LEVEL_RFPOWER_METER|RIG_LEVEL_SLOPE_HIGH|RIG_LEVEL_SLOPE_LOW) + +#define TS590_LEVEL_SET (RIG_LEVEL_RFPOWER|RIG_LEVEL_AF|RIG_LEVEL_RF|RIG_LEVEL_SQL|RIG_LEVEL_AGC|RIG_LEVEL_MICGAIN|RIG_LEVEL_KEYSPD|RIG_LEVEL_CWPITCH| \ + RIG_LEVEL_MONITOR_GAIN|RIG_LEVEL_NB|RIG_LEVEL_NR|RIG_LEVEL_PREAMP|RIG_LEVEL_COMP|RIG_LEVEL_ATT|RIG_LEVEL_VOXDELAY|RIG_LEVEL_VOXGAIN|RIG_LEVEL_BKIN_DLYMS| \ + RIG_LEVEL_METER|RIG_LEVEL_SLOPE_HIGH|RIG_LEVEL_SLOPE_LOW) + +#define TS590_FUNC_ALL (RIG_FUNC_NB|RIG_FUNC_COMP|RIG_FUNC_VOX|RIG_FUNC_NR|RIG_FUNC_NR|RIG_FUNC_BC|RIG_FUNC_BC2|RIG_FUNC_RIT|RIG_FUNC_XIT| \ + RIG_FUNC_TUNER|RIG_FUNC_MON|RIG_FUNC_FBKIN|RIG_FUNC_LOCK) + +#define TS590_VFO_OPS (RIG_OP_UP|RIG_OP_DOWN|RIG_OP_CPY|RIG_OP_TUNE) + +#define TS590_SCAN_OPS (RIG_SCAN_VFO) + +#define TS590_ANTS (RIG_ANT_1|RIG_ANT_2) + +#define TS590_CHANNEL_CAPS { \ + .freq=1,\ + .mode=1,\ + .tx_freq=1,\ + .tx_mode=1,\ + .split=1,\ + .funcs=RIG_FUNC_TONE, \ + .flags=RIG_CHFLAG_SKIP \ + } + +#define TS590_STR_CAL {9, {\ + { 0, -60},\ + { 3, -48},\ + { 6, -36},\ + { 9, -24},\ + {12, -12},\ + {15, 0},\ + {20, 20},\ + {25, 40},\ + {30, 60}}\ + } + +#define TS590_SWR_CAL { 5, \ + { \ + { 0, 1.0f }, \ + { 6, 1.5f }, \ + { 12, 2.0f }, \ + { 18, 3.0f }, \ + { 30, 10.0f } \ + } } + +#define TOK_FUNC_NOISE_REDUCTION_2 TOKEN_BACKEND(102) +#define TOK_LEVEL_DSP_RX_EQUALIZER TOKEN_BACKEND(104) +#define TOK_LEVEL_DSP_TX_EQUALIZER TOKEN_BACKEND(105) +#define TOK_LEVEL_BEEP_VOLUME TOKEN_BACKEND(107) +#define TOK_LEVEL_TX_SIDETONE_VOLUME TOKEN_BACKEND(108) +#define TOK_LEVEL_ACC2_AUDIO_INPUT_LEVEL TOKEN_BACKEND(109) +#define TOK_LEVEL_ACC2_AUDIO_OUTPUT_LEVEL TOKEN_BACKEND(110) +#define TOK_LEVEL_USB_AUDIO_INPUT_LEVEL TOKEN_BACKEND(113) +#define TOK_LEVEL_USB_AUDIO_OUTPUT_LEVEL TOKEN_BACKEND(114) +#define TOK_LEVEL_DSP_TX_SSB_AM_LOW_CUT_FILTER TOKEN_BACKEND(115) +#define TOK_LEVEL_DSP_TX_SSB_AM_HIGH_CUT_FILTER TOKEN_BACKEND(116) +#define TOK_LEVEL_DSP_TX_SSB_DATA_LOW_CUT_FILTER TOKEN_BACKEND(117) +#define TOK_LEVEL_DSP_TX_SSB_DATA_HIGH_CUT_FILTER TOKEN_BACKEND(118) + +int ts590_ext_tokens[] = +{ + TOK_FUNC_NOISE_REDUCTION_2, + TOK_LEVEL_DSP_RX_EQUALIZER, TOK_LEVEL_DSP_TX_EQUALIZER, + TOK_LEVEL_BEEP_VOLUME, TOK_LEVEL_TX_SIDETONE_VOLUME, + TOK_LEVEL_ACC2_AUDIO_INPUT_LEVEL, TOK_LEVEL_ACC2_AUDIO_OUTPUT_LEVEL, + TOK_LEVEL_USB_AUDIO_INPUT_LEVEL, TOK_LEVEL_USB_AUDIO_OUTPUT_LEVEL, + TOK_LEVEL_DSP_TX_SSB_AM_LOW_CUT_FILTER, TOK_LEVEL_DSP_TX_SSB_AM_HIGH_CUT_FILTER, + TOK_LEVEL_DSP_TX_SSB_DATA_LOW_CUT_FILTER, TOK_LEVEL_DSP_TX_SSB_DATA_HIGH_CUT_FILTER, + + TOK_BACKEND_NONE, +}; + +const struct confparams ts590_ext_funcs[] = +{ + { + TOK_FUNC_NOISE_REDUCTION_2, "NR2", "Noise reduction 2", "Noise reduction 2", + NULL, RIG_CONF_CHECKBUTTON, + }, + { RIG_CONF_END, NULL, } +}; + +const struct confparams ts590_ext_levels[] = +{ + { + TOK_LEVEL_DSP_RX_EQUALIZER, "DSP_RX_EQUALIZER", "DSP RX equalizer", "DSP RX equalizer type", + NULL, RIG_CONF_COMBO, { .c = { .combostr = { "OFF", "Hb1", "Hb2", "FP", "bb1", "bb2", "c", "U", NULL } } } + }, + { + TOK_LEVEL_DSP_TX_EQUALIZER, "DSP_TX_EQUALIZER", "DSP TX equalizer", "DSP TX equalizer type", + NULL, RIG_CONF_COMBO, { .c = { .combostr = { "OFF", "Hb1", "Hb2", "FP", "bb1", "bb2", "flat", "U", NULL } } } + }, + { + TOK_LEVEL_BEEP_VOLUME, "BEEP_VOLUME", "Beep volume", "Beep volume", + NULL, RIG_CONF_NUMERIC, { .n = { .min = 0, .max = 20, .step = 1 } } + }, + { + TOK_LEVEL_TX_SIDETONE_VOLUME, "TX_SIDETONE_VOLUME", "TX sidetone volume", "TX sidetone volume", + NULL, RIG_CONF_NUMERIC, { .n = { .min = 0, .max = 20, .step = 1 } } + }, + { + TOK_LEVEL_ACC2_AUDIO_INPUT_LEVEL, "ACC2_AUDIO_INPUT_LEVEL", "ACC2 audio input level", "ACC2 audio input level", + NULL, RIG_CONF_NUMERIC, { .n = { .min = 0, .max = 9, .step = 1 } } + }, + { + TOK_LEVEL_ACC2_AUDIO_OUTPUT_LEVEL, "ACC2_AUDIO_OUTPUT_LEVEL", "ACC2 audio output level", "ACC2 audio output level", + NULL, RIG_CONF_NUMERIC, { .n = { .min = 0, .max = 9, .step = 1 } } + }, + { + TOK_LEVEL_USB_AUDIO_INPUT_LEVEL, "USB_AUDIO_INPUT_LEVEL", "USB audio input level", "USB audio input level", + NULL, RIG_CONF_NUMERIC, { .n = { .min = 0, .max = 9, .step = 1 } } + }, + { + TOK_LEVEL_USB_AUDIO_OUTPUT_LEVEL, "USB_AUDIO_OUTPUT_LEVEL", "USB audio output level", "USB audio output level", + NULL, RIG_CONF_NUMERIC, { .n = { .min = 0, .max = 9, .step = 1 } } + }, + { + TOK_LEVEL_DSP_TX_SSB_AM_LOW_CUT_FILTER, "DSP_TX_SSB_AM_LOW_CUT_FILTER", "DSP TX SSB/AM low-cut", "DSP TX low-cut filter for SSB and AM", + NULL, RIG_CONF_COMBO, { .c = { .combostr = { "10 Hz", "100 Hz", "200 Hz", "300 Hz", "400 Hz", "500 Hz", NULL } } } + }, + { + TOK_LEVEL_DSP_TX_SSB_AM_HIGH_CUT_FILTER, "DSP_TX_SSB_AM_HIGH_CUT_FILTER", "DSP TX SSB/AM high-cut", "DSP TX high-cut filter for SSB and AM", + NULL, RIG_CONF_COMBO, { .c = { .combostr = { "2500 Hz", "2600 Hz", "2700 Hz", "2800 Hz", "2900 Hz", "3000 Hz", NULL } } } + }, + { + TOK_LEVEL_DSP_TX_SSB_DATA_LOW_CUT_FILTER, "DSP_TX_SSB_DATA_LOW_CUT_FILTER", "DSP TX SSB data low-cut", "DSP TX low-cut filter for SSB data", + NULL, RIG_CONF_COMBO, { .c = { .combostr = { "10 Hz", "100 Hz", "200 Hz", "300 Hz", "400 Hz", "500 Hz", NULL } } } + }, + { + TOK_LEVEL_DSP_TX_SSB_DATA_HIGH_CUT_FILTER, "DSP_TX_SSB_DATA_HIGH_CUT_FILTER", "DSP TX SSB data high-cut", "DSP TX high-cut filter for SSB data", + NULL, RIG_CONF_COMBO, { .c = { .combostr = { "2500 Hz", "2600 Hz", "2700 Hz", "2800 Hz", "2900 Hz", "3000 Hz", NULL } } } + }, + { RIG_CONF_END, NULL, } +}; + + +/* + * ts590_get_info + * This is not documented in the manual as of 3/11/15 but confirmed from Kenwood + * "TY" produces "TYK 00" for example + */ +const char *ts590_get_info(RIG *rig) +{ + char firmbuf[10]; + int retval; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + retval = kenwood_safe_transaction(rig, "TY", firmbuf, 10, 6); + + if (retval != RIG_OK) + { + return NULL; + } + + switch (firmbuf[2]) + { + case 'K': return "Firmware: USA version"; + + case 'E': return "Firmware: European version"; + + default: return "Firmware: unknown"; + } +} + +static int ts590_set_ex_menu(RIG *rig, int number, int value_len, int value) +{ + char buf[20]; + + ENTERFUNC; + + SNPRINTF(buf, sizeof(buf), "EX%03d0000%0*d", number, value_len, value); + + RETURNFUNC(kenwood_transaction(rig, buf, NULL, 0)); +} + +static int ts590_get_ex_menu(RIG *rig, int number, int value_len, int *value) +{ + int retval; + char buf[20]; + char ackbuf[20]; + + rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); + + SNPRINTF(buf, sizeof(buf), "EX%03d0000", number); + + retval = kenwood_safe_transaction(rig, buf, ackbuf, sizeof(ackbuf), + 9 + value_len); + + if (retval != RIG_OK) + { + RETURNFUNC2(retval); + } + + sscanf(ackbuf + 9, "%d", value); + + RETURNFUNC2(RIG_OK); +} + +static int ts590_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) +{ + char buf[20]; + + rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); + + switch (func) + { + case RIG_FUNC_MON: + SNPRINTF(buf, sizeof(buf), "ML00%c", (status == 0) ? '0' : '1'); + RETURNFUNC(kenwood_transaction(rig, buf, NULL, 0)); + + case RIG_FUNC_LOCK: + SNPRINTF(buf, sizeof(buf), "LK%c0", (status == 0) ? '0' : '1'); + RETURNFUNC(kenwood_transaction(rig, buf, NULL, 0)); + + case RIG_FUNC_TUNER: + SNPRINTF(buf, sizeof(buf), "AC%c%c0", (status == 0) ? '0' : '1', (status == 0) ? '0' : '1'); + RETURNFUNC(kenwood_transaction(rig, buf, NULL, 0)); + + default: + return kenwood_set_func(rig, vfo, func, status); + } +} + +static int ts590_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) +{ + char buf[20]; + int retval; + + ENTERFUNC; + + switch (func) + { + case RIG_FUNC_MON: + { + int raw_value; + retval = kenwood_safe_transaction(rig, "ML", buf, sizeof(buf), 5); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + sscanf(buf, "ML%d", &raw_value); + + *status = (raw_value > 0); + break; + } + + case RIG_FUNC_LOCK: + retval = kenwood_safe_transaction(rig, "LK", buf, sizeof(buf), 4); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + *status = buf[2] != '0'; + break; + + case RIG_FUNC_TUNER: + retval = kenwood_safe_transaction(rig, "AC", buf, sizeof(buf), 5); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + *status = buf[3] != '0' ? 1 : 0; + RETURNFUNC(RIG_OK); + + default: + return kenwood_get_func(rig, vfo, func, status); + } + + RETURNFUNC(RIG_OK); +} + +static int ts590_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) +{ + struct kenwood_priv_data *priv = rig->state.priv; + char levelbuf[16]; + int kenwood_val; + int result; + + rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); + + switch (level) + { + case RIG_LEVEL_RF: + kenwood_val = val.f * 255; + SNPRINTF(levelbuf, sizeof(levelbuf), "RG%03d", kenwood_val); + break; + + case RIG_LEVEL_AF: + return kenwood_set_level(rig, vfo, level, val); + + case RIG_LEVEL_SQL: + kenwood_val = val.f * 255; + SNPRINTF(levelbuf, sizeof(levelbuf), "SQ0%03d", kenwood_val); + break; + + case RIG_LEVEL_AGC: + /* Possible values for TS-2000 are 0(=off)-020(=slow) */ + + switch (val.i) + { + case RIG_AGC_OFF: + kenwood_val = 0; + break; + + case RIG_AGC_SUPERFAST: + kenwood_val = 1; + break; + + case RIG_AGC_FAST: + kenwood_val = 5; + break; + + case RIG_AGC_MEDIUM: + kenwood_val = 10; + break; + + case RIG_AGC_SLOW: + kenwood_val = 20; + break; + + default: + rig_debug(RIG_DEBUG_ERR, "%s: unsupported agc value", __func__); + return -RIG_EINVAL; + } + + SNPRINTF(levelbuf, sizeof(levelbuf), "GT%02d", kenwood_val); + break; + + case RIG_LEVEL_MONITOR_GAIN: + if (rig->caps->rig_model == RIG_MODEL_TS590S) + { + kenwood_val = val.f * 9.0f; + } + else + { + kenwood_val = val.f * 20.0f; + } + SNPRINTF(levelbuf, sizeof(levelbuf), "ML%03d", kenwood_val); + break; + + case RIG_LEVEL_NB: + priv->question_mark_response_means_rejected = 1; + kenwood_val = val.f * 10.0; + SNPRINTF(levelbuf, sizeof(levelbuf), "NL%03d", kenwood_val); + break; + + case RIG_LEVEL_NR: + priv->question_mark_response_means_rejected = 1; + kenwood_val = val.f * 9.0; + SNPRINTF(levelbuf, sizeof(levelbuf), "RL%02d", kenwood_val); + break; + + case RIG_LEVEL_PREAMP: + if (val.i != 12 && val.i != 0) + { + RETURNFUNC(-RIG_EINVAL); + } + + SNPRINTF(levelbuf, sizeof(levelbuf), "PA%c", (val.i == 12) ? '1' : '0'); + break; + + case RIG_LEVEL_ATT: + if (val.i != 12 && val.i != 0) + { + RETURNFUNC(-RIG_EINVAL); + } + + SNPRINTF(levelbuf, sizeof(levelbuf), "RA%02d", (val.i == 12) ? 1 : 0); + break; + + case RIG_LEVEL_METER: + switch (val.i) + { + case RIG_METER_SWR: + kenwood_val = 1; + break; + + case RIG_METER_COMP: + kenwood_val = 2; + break; + + case RIG_METER_ALC: + kenwood_val = 3; + break; + + default: + RETURNFUNC(-RIG_EINVAL); + } + + SNPRINTF(levelbuf, sizeof(levelbuf), "RM%d", kenwood_val); + break; + + case RIG_LEVEL_CWPITCH: + if (val.i > 1000 || val.i < 300) + { + RETURNFUNC(-RIG_EINVAL); + } + + RETURNFUNC(ts590_set_ex_menu(rig, 40, 2, (val.i - 300) / 50)); + + default: + RETURNFUNC(kenwood_set_level(rig, vfo, level, val)); + } + + result = kenwood_transaction(rig, levelbuf, NULL, 0); + priv->question_mark_response_means_rejected = 0; + + RETURNFUNC(result); +} + +static int ts590_read_meters(RIG *rig, int *swr, int *comp, int *alc) +{ + int retval; + char *cmd = "RM;"; + struct rig_state *rs = &rig->state; + char ackbuf[32]; + int expected_len = 24; + + ENTERFUNC; + + retval = write_block(&rs->rigport, (unsigned char *) cmd, strlen(cmd)); + + rig_debug(RIG_DEBUG_TRACE, "%s: write_block retval=%d\n", __func__, retval); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + // TS-590 returns values for all meters at the same time, for example: RM10000;RM20000;RM30000; + + retval = read_string(&rs->rigport, (unsigned char *) ackbuf, expected_len + 1, + NULL, 0, 0, 1); + + rig_debug(RIG_DEBUG_TRACE, "%s: read_string retval=%d\n", __func__, retval); + + if (retval < 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: failed to read rig response\n", __func__); + RETURNFUNC(retval); + } + + if (retval != expected_len) + { + rig_debug(RIG_DEBUG_ERR, "%s: expected %d bytes, got %d in '%s'\n", __func__, + expected_len, retval, ackbuf); + RETURNFUNC(-RIG_EPROTO); + } + + retval = sscanf(ackbuf, "RM1%d;RM2%d;RM3%d;", swr, comp, alc); + + if (retval != 3) + { + rig_debug(RIG_DEBUG_ERR, + "%s: expected 3 meter values to parse, got %d in '%s'\n", __func__, retval, + ackbuf); + RETURNFUNC(-RIG_EPROTO); + } + + RETURNFUNC(RIG_OK); +} + +static int ts590_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) +{ + struct kenwood_priv_data *priv = rig->state.priv; + char ackbuf[50]; + size_t ack_len, ack_len_expected; + int levelint; + int retval; + + ENTERFUNC; + + switch (level) + { + case RIG_LEVEL_AF: + return kenwood_get_level(rig, vfo, level, val); + + case RIG_LEVEL_RF: + retval = kenwood_transaction(rig, "RG", ackbuf, sizeof(ackbuf)); + + if (RIG_OK != retval) + { + return retval; + } + + ack_len = strlen(ackbuf); + + if (5 != ack_len) + { + return -RIG_EPROTO; + } + + if (1 != sscanf(&ackbuf[2], "%d", &levelint)) + { + return -RIG_EPROTO; + } + + val->f = levelint / (float) 255; + return RIG_OK; + + case RIG_LEVEL_SQL: + retval = kenwood_transaction(rig, "SQ0", ackbuf, sizeof(ackbuf)); + ack_len_expected = 6; + + if (RIG_OK != retval) + { + return retval; + } + + ack_len = strlen(ackbuf); + + if (ack_len != ack_len_expected) + { + return -RIG_EPROTO; + } + + if (1 != sscanf(&ackbuf[ack_len_expected - 3], "%d", &levelint)) + { + return -RIG_EPROTO; + } + + val->f = (float) levelint / 255.; + return RIG_OK; + + case RIG_LEVEL_AGC: + priv->question_mark_response_means_rejected = 1; + retval = kenwood_transaction(rig, "GT", ackbuf, sizeof(ackbuf)); + priv->question_mark_response_means_rejected = 0; + ack_len_expected = 4; + + if (RIG_OK != retval) + { + return retval; + } + + ack_len = strlen(ackbuf); + + if (ack_len != ack_len_expected) + { + return -RIG_EPROTO; + } + + if (1 != sscanf(&ackbuf[ack_len_expected - 2], "%d", &levelint)) + { + return -RIG_EPROTO; + } + + if (levelint == 0) + { + val->i = RIG_AGC_OFF; + } + else if (levelint <= 1) + { + val->i = RIG_AGC_SUPERFAST; + } + else if (levelint <= 5) + { + val->i = RIG_AGC_FAST; + } + else if (levelint <= 10) + { + val->i = RIG_AGC_MEDIUM; + } + else + { + val->i = RIG_AGC_SLOW; + } + + return RIG_OK; + + case RIG_LEVEL_STRENGTH: + if (rig->state.cache.ptt != RIG_PTT_OFF) + { + val->i = -9 * 6; + break; ... [truncated message content] |