[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 8d1eacc9cb1aa6c18f445
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: n0nb <n0...@us...> - 2023-01-25 02:39:39
|
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 8d1eacc9cb1aa6c18f44533c292022280f02b897 (commit) via 267184ad44eb703eaea274e612408739aae5faa5 (commit) via a47eba7ce4102f332842e79cfeb64b08c69335d4 (commit) via 76a3ab19eb78ef2df4ae4e65dff2e33274ac6a70 (commit) via 3fd698d063906b1fbda4db75d38692202dbd322c (commit) via b977858da94b3e1e88706f2be9d6ebc5ce8fc4b6 (commit) via d68c218a3d249d14313086cb9c1c2312cdbba0d0 (commit) via 79129087e0ed550dc19b7c435dc46ad948c61751 (commit) via af941307495d3616ff78cc1fb37b96b87109a765 (commit) via 907560270eca870606ed6002efaa69577f50c7ab (commit) via 52bed765eff14c752aafd4814f5cf3b7e6ac3d41 (commit) via 9626894029686803544cae7860f34b362dd7a19b (commit) via 9b89a99f9985b90acfcb462647e0b9348cc9930f (commit) via d16b52e414c7e2862dab145dee30eda3487ba04f (commit) via 407b0fcc5414989d6032d845d139fb7b701ddfdc (commit) via 344779eaf199fdfeea750db88820aab537835270 (commit) via 18a2d91f59e0a04042bcaf68e47417f5d9695dbe (commit) via 0c2426c800b754de0aa14a89421354e39473546f (commit) via cdbd517228cf11d5a9e90d82fa534abc53d95eb4 (commit) via cfde2c8a92105da471056fa70194ee10658c201f (commit) via eb1d46723616ec3d94b453f0c1fed94bc977cfe5 (commit) via 50a14bb08fdcccc59fc1f7cf803cd6866ee369f3 (commit) via 13d27a3567c7c632eabded6e1c23f0a96c5053bc (commit) via c78371353c704eb3c16da02b511e6f647ade4190 (commit) via 268f44eb7d64a1ee0ca3489b8edd0188ce1fc69e (commit) via 3daed948a8cfa9f02bb1e8035f6e3355eb31a22e (commit) via 9d096c4ac95fae1c8fd235648874bc27d979d2bc (commit) via ac220815c4ec81f20dc22ca051dc19e3c98cfa9d (commit) via 57b063a44ce257e139633cd82f0e8245f15e4721 (commit) via 9861d1f87ba92667f52558b76349b331620fd13f (commit) via 6f6379e547772755368c35fc117b0ce57bd911ab (commit) via b38739bcabf2a24bbde4315a70d6cbe551879b6c (commit) from f392cc4c1804f06fe16f7e326c879e2ba0f20e1d (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 8d1eacc9cb1aa6c18f44533c292022280f02b897 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Jan 24 11:28:33 2023 -0600 Update NEWS diff --git a/NEWS b/NEWS index 7f618af6..8662ce99 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,7 @@ Version 4.6 * Fix FTDX3000 rig split Version 4.5.5 - * Fix QRP QDX PTT to new TQ command + * Fix QRP QDX PTT to new TQ command due to firmware changes * Remove EX103 check for FTDX5000 * Fix K3/K3S VFOB setting of mode/width * Fix AGC level display in rigctld commit 267184ad44eb703eaea274e612408739aae5faa5 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Jan 24 11:26:22 2023 -0600 Change QRP QDX PTT command to TQ instead of TX -- more incompability with TS-480 commands diff --git a/NEWS b/NEWS index 378ee292..7f618af6 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ Version 4.6 * Fix FTDX3000 rig split Version 4.5.5 + * Fix QRP QDX PTT to new TQ command * Remove EX103 check for FTDX5000 * Fix K3/K3S VFOB setting of mode/width * Fix AGC level display in rigctld commit a47eba7ce4102f332842e79cfeb64b08c69335d4 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Jan 24 11:25:49 2023 -0600 Revert "Update NEWS" This reverts commit 76a3ab19eb78ef2df4ae4e65dff2e33274ac6a70. diff --git a/NEWS b/NEWS index 7f618af6..378ee292 100644 --- a/NEWS +++ b/NEWS @@ -25,7 +25,6 @@ Version 4.6 * Fix FTDX3000 rig split Version 4.5.5 - * Fix QRP QDX PTT to new TQ command * Remove EX103 check for FTDX5000 * Fix K3/K3S VFOB setting of mode/width * Fix AGC level display in rigctld diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c index c4e90efb..b69e04b6 100644 --- a/rigs/dummy/netrigctl.c +++ b/rigs/dummy/netrigctl.c @@ -2065,9 +2065,6 @@ static int netrigctl_get_powerstat(RIG *rig, powerstat_t *status) // also a problem with Flex 6xxx and Log4OM not working due to lack of PS command rig_debug(RIG_DEBUG_VERBOSE, "%s: PS command failed (ret=%d) so returning RIG_POWER_ON\n", __func__, ret); - if (ret == -RIG_EPOWER) - *status = RIG_POWER_OFF; - else *status = RIG_POWER_ON; } diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index b491a1c9..10ea9b1f 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -3622,7 +3622,7 @@ int newcat_get_powerstat(RIG *rig, powerstat_t *status) // when not powered on need a dummy byte to wake it up // then sleep from 1 to 2 seconds so we'll do 1.5 secs - write_block(&state->rigport, (unsigned char *) ";;;", 3); + write_block(&state->rigport, (unsigned char *) "PS;", 3); hl_usleep(1200000); SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", command, cat_term); diff --git a/simulators/simft991.c b/simulators/simft991.c index 49f61d17..965deb4f 100644 --- a/simulators/simft991.c +++ b/simulators/simft991.c @@ -104,11 +104,11 @@ int main(int argc, char *argv[]) while (1) { - start: if (getmyline(fd, buf)) { printf("Cmd:%s\n", buf); } + else { continue; } if (strcmp(buf, "RM5;") == 0) { @@ -172,10 +172,8 @@ int main(int argc, char *argv[]) } else if (strcmp(buf, "PS;") == 0) { -#if 0 - SNPRINTF(buf, sizeof(buf), "PS0;"); + SNPRINTF(buf, sizeof(buf), "PS1;"); n = write(fd, buf, strlen(buf)); -#endif } else if (strcmp(buf, "AI;") == 0) { diff --git a/src/rig.c b/src/rig.c index 68104894..65927287 100644 --- a/src/rig.c +++ b/src/rig.c @@ -6079,7 +6079,6 @@ int HAMLIB_API rig_get_powerstat(RIG *rig, powerstat_t *status) if (rig->caps->get_powerstat == NULL) { - rig_debug(RIG_DEBUG_VERBOSE, "%s: Rig does not have get_powerstat to assume RIG_POWER_ON\n", __func__); *status = RIG_POWER_ON; // default to power if not available RETURNFUNC(RIG_OK); } @@ -6087,7 +6086,6 @@ int HAMLIB_API rig_get_powerstat(RIG *rig, powerstat_t *status) *status = RIG_POWER_OFF; // default now to power off until proven otherwise in get_powerstat HAMLIB_TRACE; retcode = rig->caps->get_powerstat(rig, status); - if (retcode == -RIG_ETIMEOUT) status = RIG_POWER_OFF; RETURNFUNC(retcode); } diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 9cefcb0a..02c80195 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -4741,7 +4741,7 @@ declare_proto_rig(get_powerstat) if (status != RIG_OK) { - stat = status; + RETURNFUNC(status); } if ((interactive && prompt) || (interactive && !prompt && ext_resp)) commit 76a3ab19eb78ef2df4ae4e65dff2e33274ac6a70 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Jan 24 11:23:47 2023 -0600 Update NEWS diff --git a/NEWS b/NEWS index 378ee292..7f618af6 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ Version 4.6 * Fix FTDX3000 rig split Version 4.5.5 + * Fix QRP QDX PTT to new TQ command * Remove EX103 check for FTDX5000 * Fix K3/K3S VFOB setting of mode/width * Fix AGC level display in rigctld diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c index b69e04b6..c4e90efb 100644 --- a/rigs/dummy/netrigctl.c +++ b/rigs/dummy/netrigctl.c @@ -2065,6 +2065,9 @@ static int netrigctl_get_powerstat(RIG *rig, powerstat_t *status) // also a problem with Flex 6xxx and Log4OM not working due to lack of PS command rig_debug(RIG_DEBUG_VERBOSE, "%s: PS command failed (ret=%d) so returning RIG_POWER_ON\n", __func__, ret); + if (ret == -RIG_EPOWER) + *status = RIG_POWER_OFF; + else *status = RIG_POWER_ON; } diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 10ea9b1f..b491a1c9 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -3622,7 +3622,7 @@ int newcat_get_powerstat(RIG *rig, powerstat_t *status) // when not powered on need a dummy byte to wake it up // then sleep from 1 to 2 seconds so we'll do 1.5 secs - write_block(&state->rigport, (unsigned char *) "PS;", 3); + write_block(&state->rigport, (unsigned char *) ";;;", 3); hl_usleep(1200000); SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", command, cat_term); diff --git a/simulators/simft991.c b/simulators/simft991.c index 965deb4f..49f61d17 100644 --- a/simulators/simft991.c +++ b/simulators/simft991.c @@ -104,11 +104,11 @@ int main(int argc, char *argv[]) while (1) { + start: if (getmyline(fd, buf)) { printf("Cmd:%s\n", buf); } - else { continue; } if (strcmp(buf, "RM5;") == 0) { @@ -172,8 +172,10 @@ int main(int argc, char *argv[]) } else if (strcmp(buf, "PS;") == 0) { - SNPRINTF(buf, sizeof(buf), "PS1;"); +#if 0 + SNPRINTF(buf, sizeof(buf), "PS0;"); n = write(fd, buf, strlen(buf)); +#endif } else if (strcmp(buf, "AI;") == 0) { diff --git a/src/rig.c b/src/rig.c index 65927287..68104894 100644 --- a/src/rig.c +++ b/src/rig.c @@ -6079,6 +6079,7 @@ int HAMLIB_API rig_get_powerstat(RIG *rig, powerstat_t *status) if (rig->caps->get_powerstat == NULL) { + rig_debug(RIG_DEBUG_VERBOSE, "%s: Rig does not have get_powerstat to assume RIG_POWER_ON\n", __func__); *status = RIG_POWER_ON; // default to power if not available RETURNFUNC(RIG_OK); } @@ -6086,6 +6087,7 @@ int HAMLIB_API rig_get_powerstat(RIG *rig, powerstat_t *status) *status = RIG_POWER_OFF; // default now to power off until proven otherwise in get_powerstat HAMLIB_TRACE; retcode = rig->caps->get_powerstat(rig, status); + if (retcode == -RIG_ETIMEOUT) status = RIG_POWER_OFF; RETURNFUNC(retcode); } diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 02c80195..9cefcb0a 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -4741,7 +4741,7 @@ declare_proto_rig(get_powerstat) if (status != RIG_OK) { - RETURNFUNC(status); + stat = status; } if ((interactive && prompt) || (interactive && !prompt && ext_resp)) commit 3fd698d063906b1fbda4db75d38692202dbd322c Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Jan 24 11:22:19 2023 -0600 Change QRP QRDX PTT to use TQ instead TX...more incompability with TS-480 standard diff --git a/rigs/kenwood/ts480.c b/rigs/kenwood/ts480.c index 1d4fb807..59eb9d7a 100644 --- a/rigs/kenwood/ts480.c +++ b/rigs/kenwood/ts480.c @@ -1251,6 +1251,30 @@ int ts480_init(RIG *rig) RETURNFUNC(RIG_OK); } +int qdx_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) +{ + const char *ptt_cmd; + + ENTERFUNC; + rig_debug(RIG_DEBUG_VERBOSE, "%s: ptt=%d\n", __func__, ptt); + + switch (ptt) + { + case RIG_PTT_ON: ptt_cmd = "TQ1"; break; + + case RIG_PTT_OFF: ptt_cmd = "TQ0"; break; + + default: RETURNFUNC(-RIG_EINVAL); + } + + int retval = kenwood_transaction(rig, ptt_cmd, NULL, 0); + + //if (ptt == RIG_PTT_OFF) { hl_usleep(100 * 1000); } // a little time for PTT to turn off + + RETURNFUNC(retval); +} + + /* * TS-480 rig capabilities * Notice that some rigs share the same functions. @@ -1457,7 +1481,7 @@ const struct rig_caps qrplabs_caps = RIG_MODEL(RIG_MODEL_QRPLABS), .model_name = "QCX/QDX", .mfg_name = "QRPLabs", - .version = BACKEND_VER ".0", + .version = BACKEND_VER ".1", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1780,7 +1804,7 @@ const struct rig_caps pt8000a_caps = .set_split_vfo = kenwood_set_split_vfo, .get_split_vfo = kenwood_get_split_vfo_if, .get_ptt = kenwood_get_ptt, - .set_ptt = kenwood_set_ptt, + .set_ptt = qdx_set_ptt, .get_dcd = kenwood_get_dcd, .set_powerstat = kenwood_set_powerstat, .get_powerstat = kenwood_get_powerstat, commit b977858da94b3e1e88706f2be9d6ebc5ce8fc4b6 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Jan 23 14:50:59 2023 -0600 Update NEWS diff --git a/NEWS b/NEWS index ff9b3656..378ee292 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ Version 4.6 * Fix FTDX3000 rig split Version 4.5.5 + * Remove EX103 check for FTDX5000 * Fix K3/K3S VFOB setting of mode/width * Fix AGC level display in rigctld * Change FTDX10 to no serial handshake commit d68c218a3d249d14313086cb9c1c2312cdbba0d0 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Jan 23 14:49:06 2023 -0600 ERemove EX103 get/set for FTDX5000 diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 39d94072..10ea9b1f 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -641,6 +641,7 @@ int newcat_open(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s: disabling FTDX3000 band select\n", __func__); } +#if 0 // this apparently does not work if (is_ftdx5000) { // Remember EX103 status @@ -663,6 +664,7 @@ int newcat_open(RIG *rig) if (priv->ret_data[6] == ';') { priv->front_rear_status = priv->ret_data[5]; } } +#endif RETURNFUNC(RIG_OK); } @@ -695,6 +697,7 @@ int newcat_close(RIG *rig) priv->poweron = 0; } +#if 0 // this apparently does not work -- we can't query EX103 if (is_ftdx5000) { // Restore EX103 status @@ -703,6 +706,7 @@ int newcat_close(RIG *rig) rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, priv->cmd_str); newcat_set_cmd(rig); // don't care about the return } +#endif RETURNFUNC(RIG_OK); } diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index db1d64c4..60b2c9ad 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20230115" +#define NEWCAT_VER "20230123" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 commit 79129087e0ed550dc19b7c435dc46ad948c61751 Merge: af941307 90756027 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Jan 23 09:12:48 2023 -0600 Merge branch 'master' of https://github.com/Hamlib/Hamlib commit af941307495d3616ff78cc1fb37b96b87109a765 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Jan 23 09:10:58 2023 -0600 Update NEWS diff --git a/NEWS b/NEWS index a1b4ac1c..ff9b3656 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ Version 4.6 * Fix FTDX3000 rig split Version 4.5.5 + * Fix K3/K3S VFOB setting of mode/width * Fix AGC level display in rigctld * Change FTDX10 to no serial handshake * Add TS2000 to has_ps exception commit 907560270eca870606ed6002efaa69577f50c7ab Author: Michael Black <mdb...@ya...> Date: Mon Jan 23 08:34:58 2023 -0600 Update test.json Add WidthUpper/Lower to json draft diff --git a/bindings/csharp/multicast/test.json b/bindings/csharp/multicast/test.json index d417acce..488fbaa5 100644 --- a/bindings/csharp/multicast/test.json +++ b/bindings/csharp/multicast/test.json @@ -7,6 +7,8 @@ "Freq": 14074000, "Mode": "USB", "Width": 5000, + "WidthLower": 200, + "WidthUpper": 3000, "RX": true, "TX": false }, @@ -15,8 +17,10 @@ "Freq": 14076000, "Mode": "USB", "Width": 5000, + "WidthLower": 200, + "WidthUpper": 3000, "RX": false, - "TX": false + "TX": true }], "__comment_spectrum__": "Rigs that have spectrum output may include this data", commit 52bed765eff14c752aafd4814f5cf3b7e6ac3d41 Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Jan 22 23:41:21 2023 -0600 Clean up rig power on/off sequencing for Kenwood/Elecraft rigs Note that the K3/K3S cannot power on via CAT control https://github.com/Hamlib/Hamlib/issues/1225 diff --git a/rigs/kenwood/elecraft.c b/rigs/kenwood/elecraft.c index 077a4aa4..4d93369c 100644 --- a/rigs/kenwood/elecraft.c +++ b/rigs/kenwood/elecraft.c @@ -97,11 +97,19 @@ int elecraft_open(RIG *rig) char buf[KENWOOD_MAX_BUF_LEN]; struct kenwood_priv_data *priv = rig->state.priv; char *model = "Unknown"; + struct rig_state *rs = &rig->state; rig_debug(RIG_DEBUG_VERBOSE, "%s called, rig version=%s\n", __func__, rig->caps->version); + if (rs->auto_power_on && priv->poweron == 0) + { + rig_set_powerstat(rig, 1); + priv->poweron = 1; + } + + /* Actual read extension levels from radio. * * The value stored in the k?_ext_lvl variables map to diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index a82fc261..e3da638d 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -342,6 +342,8 @@ transaction_write: skip |= strncmp(cmdstr, "RU", 2) == 0; skip |= strncmp(cmdstr, "RD", 2) == 0; skip |= strncmp(cmdstr, "KYW", 3) == 0; + skip |= strncmp(cmdstr, "PS1", 3) == 0; + skip |= strncmp(cmdstr, "PS0", 3) == 0; if (skip) { @@ -825,6 +827,14 @@ int kenwood_open(RIG *rig) id[0] = 0; rig->state.rigport.retry = 0; + + if (rig->state.auto_power_on) + { + // Ensure rig is on + rig_set_powerstat(rig, 1); + sleep(1); + } + err = kenwood_get_id(rig, id); if (err != RIG_OK) @@ -857,14 +867,6 @@ int kenwood_open(RIG *rig) err = RIG_OK; // reset our err back to OK for later checks } - if (err == -RIG_ETIMEOUT && rig->state.auto_power_on) - { - // Ensure rig is on - rig_set_powerstat(rig, 1); - /* Try get id again */ - err = kenwood_get_id(rig, id); - } - if (RIG_OK != err) { rig_debug(RIG_DEBUG_ERR, @@ -1069,6 +1071,8 @@ int kenwood_close(RIG *rig) ENTERFUNC; + if (priv->poweron == 0) { RETURNFUNC(RIG_OK); } // nothing to do + if (!no_restore_ai && priv->trn_state >= 0) { /* restore AI state */ @@ -4825,9 +4829,16 @@ int kenwood_get_trn(RIG *rig, int *trn) */ int kenwood_set_powerstat(RIG *rig, powerstat_t status) { - int retval = kenwood_transaction(rig, - (status == RIG_POWER_ON) ? ";;;;PS1;" : "PS0", - NULL, 0); + int retval; + struct kenwood_priv_data *priv = rig->state.priv; + + if ((priv->is_k3 || priv->is_k3s) && status == RIG_POWER_ON) + { + rig_debug(RIG_DEBUG_ERR, + "%s: K3/K3S must use aux I/O jack pulled low to power on\n", __func__); + return -RIG_EPOWER; + } + int i = 0; int retry_save = rig->state.rigport.retry; @@ -4835,6 +4846,10 @@ int kenwood_set_powerstat(RIG *rig, powerstat_t status) rig->state.rigport.retry = 0; + retval = kenwood_transaction(rig, + (status == RIG_POWER_ON) ? ";;;;PS1;" : "PS0", + NULL, 0); + if (status == RIG_POWER_ON) // wait for wakeup only { for (i = 0; i < 8; ++i) // up to ~10 seconds including the timeouts diff --git a/src/rig.c b/src/rig.c index 2aa101ab..65927287 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1267,6 +1267,19 @@ int HAMLIB_API rig_open(RIG *rig) if (caps->rig_open != NULL) { + if (caps->get_powerstat != NULL) + { + powerstat_t powerflag; + status = rig_get_powerstat(rig, &powerflag); + if (status == RIG_OK && powerflag == RIG_POWER_OFF) return (-RIG_EPOWER); + // don't need auto_power_on if power is already on + if (status == RIG_OK && powerflag == RIG_POWER_ON) rig->state.auto_power_on = 0; + if (status == -RIG_ETIMEOUT) { + rig_debug(RIG_DEBUG_ERR, "%s: Some rigs cannot get_powerstat while off\n", __func__); + rig_debug(RIG_DEBUG_ERR, "%s: Known rigs: K3, K3S\n", __func__); + return (-RIG_EPOWER); + } + } status = caps->rig_open(rig); if (status != RIG_OK) diff --git a/tests/rigctl.c b/tests/rigctl.c index f29defe9..081f25d7 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -565,8 +565,8 @@ int main(int argc, char *argv[]) if (retcode != RIG_OK) { - fprintf(stderr, "rig_open: error = %s %s \n", rig_file, - strerror(errno)); +// fprintf(stderr, "rig_open: error = %s %s \n", rig_file, +// rigerror(retcode)); if (!ignore_rig_open_error) { exit(2); } } commit 9626894029686803544cae7860f34b362dd7a19b Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Jan 22 16:45:22 2023 -0600 Fix K3/K3S VFOB mode/bandwidth setting https://github.com/Hamlib/Hamlib/issues/1224 diff --git a/rigs/kenwood/k3.c b/rigs/kenwood/k3.c index 336b30bc..0956e575 100644 --- a/rigs/kenwood/k3.c +++ b/rigs/kenwood/k3.c @@ -190,7 +190,7 @@ const struct rig_caps k3_caps = RIG_MODEL(RIG_MODEL_K3), .model_name = "K3", .mfg_name = "Elecraft", - .version = BACKEND_VER ".25", + .version = BACKEND_VER ".26", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -343,7 +343,7 @@ const struct rig_caps k3s_caps = RIG_MODEL(RIG_MODEL_K3S), .model_name = "K3S", .mfg_name = "Elecraft", - .version = BACKEND_VER ".20", + .version = BACKEND_VER ".21", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -960,15 +960,21 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) int err; rmode_t temp_m; pbwidth_t temp_w; - char *cmd_mode = "DT"; + char *cmd_data = "DT"; char *cmd_bw = "BW"; int cmd_bw_len = 6; + struct kenwood_priv_data *priv = rig->state.priv; rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo)); - if (vfo == RIG_VFO_B && rig->caps->rig_model == RIG_MODEL_K4) + if ((priv->is_k3 || priv->is_k3s || priv->is_k4 || priv->is_k4d + || priv->is_k4hd) && vfo == RIG_VFO_B) { - cmd_mode = "DT$"; + if (!(priv->is_k3 || priv->is_k3s)) + { + cmd_data = "DT$"; + } + cmd_bw = "BW$"; cmd_bw_len = 7; @@ -993,8 +999,8 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) if (temp_m == RIG_MODE_RTTY) { - err = kenwood_safe_transaction(rig, cmd_mode, buf, KENWOOD_MAX_BUF_LEN, - strlen(cmd_mode) + 1); + err = kenwood_safe_transaction(rig, cmd_data, buf, KENWOOD_MAX_BUF_LEN, + strlen(cmd_data) + 1); if (err != RIG_OK) { @@ -1021,8 +1027,8 @@ int k3_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } else if (temp_m == RIG_MODE_RTTYR) { - err = kenwood_safe_transaction(rig, cmd_mode, buf, KENWOOD_MAX_BUF_LEN, - strlen(cmd_mode) + 1); + err = kenwood_safe_transaction(rig, cmd_data, buf, KENWOOD_MAX_BUF_LEN, + strlen(cmd_data) + 1); if (err != RIG_OK) { diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c index 1abad7a1..a82fc261 100644 --- a/rigs/kenwood/kenwood.c +++ b/rigs/kenwood/kenwood.c @@ -2640,8 +2640,8 @@ int kenwood_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) } else { - if (vfo == RIG_VFO_B - && rig->caps->rig_model == RIG_MODEL_K4) // K4 new MD$ command for VFOB + if ((priv->is_k3 || priv->is_k3s || priv->is_k4 || priv->is_k4d + || priv->is_k4hd) && vfo == RIG_VFO_B) { SNPRINTF(cmd, sizeof(cmd), "MD$"); offs = 3; diff --git a/rigs/kenwood/kenwood.h b/rigs/kenwood/kenwood.h index d0c077a0..45494637 100644 --- a/rigs/kenwood/kenwood.h +++ b/rigs/kenwood/kenwood.h @@ -29,7 +29,7 @@ #include "misc.h" #include "idx_builtin.h" -#define BACKEND_VER "20230115" +#define BACKEND_VER "20230222" #define EOM_KEN ';' #define EOM_TH '\r' commit 9b89a99f9985b90acfcb462647e0b9348cc9930f Merge: d16b52e4 407b0fcc Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Jan 22 10:49:45 2023 -0600 Merge branch 'master' of https://github.com/Hamlib/Hamlib commit d16b52e414c7e2862dab145dee30eda3487ba04f Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Jan 22 10:43:58 2023 -0600 Fix IC7300 5 second sleep during poweron Reverse ID-5100 logic for dual watch mode https://github.com/Hamlib/Hamlib/issues/1220 diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 3a700127..76929d4c 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -6620,7 +6620,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) if (priv_caps->dualwatch_split) { - int wvfo = tx_vfo & (RIG_VFO_A | RIG_VFO_MAIN) ? S_MAIN : S_SUB; + int wvfo = tx_vfo & (RIG_VFO_A | RIG_VFO_MAIN) ? S_SUB : S_MAIN; if (RIG_OK != (retval = icom_set_func(rig, RIG_VFO_CURR, RIG_FUNC_DUAL_WATCH, split_sc))) @@ -8020,6 +8020,11 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) priv->serial_USB_echo_off = 1; retval = icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len); + if (rig->caps->rig_model == RIG_MODEL_IC7300) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: waiting 5 seconds for rig to wake up\n", __func__); + sleep(5); // IC7300 is slow to start up -- may need to add more rigs + } // poweron == 0 means never powered -- == 2 means CAT turned off if (priv->poweron == 0 || priv->poweron == 2) @@ -8051,11 +8056,6 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) if (status == RIG_POWER_ON) // wait for wakeup only { - if (rig->caps->rig_model == RIG_MODEL_IC7300) - { - rig_debug(RIG_DEBUG_VERBOSE, "%s: waiting 5 seconds for rig to wake up\n", __func__); - sleep(5); // IC7300 is slow to start up -- may need to add more rigs - } for (i = 0; i < retry; ++i) // up to 10 attempts { freq_t freq; diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index a72ba5ed..6157453c 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -31,7 +31,7 @@ #include <sys/time.h> #endif -#define BACKEND_VER "20230121" +#define BACKEND_VER "20230122" #define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31) #define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51) commit 407b0fcc5414989d6032d845d139fb7b701ddfdc Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Jan 22 10:43:58 2023 -0600 Fix IC7300 5 second sleep during poweron https://github.com/Hamlib/Hamlib/issues/1220 diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 3a700127..76929d4c 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -6620,7 +6620,7 @@ int icom_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) if (priv_caps->dualwatch_split) { - int wvfo = tx_vfo & (RIG_VFO_A | RIG_VFO_MAIN) ? S_MAIN : S_SUB; + int wvfo = tx_vfo & (RIG_VFO_A | RIG_VFO_MAIN) ? S_SUB : S_MAIN; if (RIG_OK != (retval = icom_set_func(rig, RIG_VFO_CURR, RIG_FUNC_DUAL_WATCH, split_sc))) @@ -8020,6 +8020,11 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) priv->serial_USB_echo_off = 1; retval = icom_transaction(rig, C_SET_PWR, pwr_sc, NULL, 0, ackbuf, &ack_len); + if (rig->caps->rig_model == RIG_MODEL_IC7300) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: waiting 5 seconds for rig to wake up\n", __func__); + sleep(5); // IC7300 is slow to start up -- may need to add more rigs + } // poweron == 0 means never powered -- == 2 means CAT turned off if (priv->poweron == 0 || priv->poweron == 2) @@ -8051,11 +8056,6 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) if (status == RIG_POWER_ON) // wait for wakeup only { - if (rig->caps->rig_model == RIG_MODEL_IC7300) - { - rig_debug(RIG_DEBUG_VERBOSE, "%s: waiting 5 seconds for rig to wake up\n", __func__); - sleep(5); // IC7300 is slow to start up -- may need to add more rigs - } for (i = 0; i < retry; ++i) // up to 10 attempts { freq_t freq; diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index a72ba5ed..6157453c 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -31,7 +31,7 @@ #include <sys/time.h> #endif -#define BACKEND_VER "20230121" +#define BACKEND_VER "20230122" #define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31) #define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51) commit 344779eaf199fdfeea750db88820aab537835270 Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Jan 22 10:02:46 2023 -0600 Add draft HamlibGUI controller using dotnet and GTK. Should compile on Windows, Linux, and MacOS with appropriate dotnet package installed See README.TXT in directory https://github.com/Hamlib/Hamlib/issues/1223 diff --git a/bindings/csharp/hamlibgui/MainWindow.cs b/bindings/csharp/hamlibgui/MainWindow.cs new file mode 100644 index 00000000..82701193 --- /dev/null +++ b/bindings/csharp/hamlibgui/MainWindow.cs @@ -0,0 +1,48 @@ +using System; +using Gtk; +using UI = Gtk.Builder.ObjectAttribute; + +namespace hamlibgui +{ +class MainWindow : Window +{ + [UI] private Label _label1 = null; + [UI] private Button _button1 = null; + + private bool connectFlag; + + public MainWindow() : this(new Builder("MainWindow.glade")) { } + + private MainWindow(Builder builder) : base( + builder.GetRawOwnedObject("MainWindow")) + { + builder.Autoconnect(this); + + DeleteEvent += Window_DeleteEvent; + _button1.Clicked += Button1_Clicked; + } + + private void Window_DeleteEvent(object sender, DeleteEventArgs a) + { + Application.Quit(); + } + + private void Button1_Clicked(object sender, EventArgs a) + { + connectFlag = !connectFlag; + + if (connectFlag) + { + String mytext = "Rig Connected (not really)"; + _label1.Text = mytext; + _button1.Label = "Disconnect Rig"; + } + else + { + String mytext = "Rig not Connected "; + _label1.Text = mytext; + _button1.Label = "Connect to Rig"; + } + } +} +} diff --git a/bindings/csharp/hamlibgui/MainWindow.glade b/bindings/csharp/hamlibgui/MainWindow.glade new file mode 100755 index 00000000..abc5b731 --- /dev/null +++ b/bindings/csharp/hamlibgui/MainWindow.glade @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.38.2 --> +<interface> + <requires lib="gtk+" version="3.18"/> + <object class="GtkWindow" id="MainWindow"> + <property name="can-focus">False</property> + <property name="title" translatable="yes">Hamlib Control</property> + <property name="default-width">480</property> + <property name="default-height">240</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-left">4</property> + <property name="margin-right">4</property> + <property name="margin-top">4</property> + <property name="margin-bottom">4</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel" id="_label1"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes">Hamlib controller to go here</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="_button1"> + <property name="label" translatable="yes">Connect to Rig</property> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="receives-default">True</property> + <property name="tooltip-markup" translatable="yes">Click to connect/disconnect rig</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/bindings/csharp/hamlibgui/Program.cs b/bindings/csharp/hamlibgui/Program.cs new file mode 100755 index 00000000..1bad8e7a --- /dev/null +++ b/bindings/csharp/hamlibgui/Program.cs @@ -0,0 +1,23 @@ +using System; +using Gtk; + +namespace hamlibgui +{ + class Program + { + [STAThread] + public static void Main(string[] args) + { + Application.Init(); + + var app = new Application("org.hamlibgui.hamlibgui", GLib.ApplicationFlags.None); + app.Register(GLib.Cancellable.Current); + + var win = new MainWindow(); + app.AddWindow(win); + + win.Show(); + Application.Run(); + } + } +} diff --git a/bindings/csharp/hamlibgui/README.txt b/bindings/csharp/hamlibgui/README.txt new file mode 100644 index 00000000..4020be1e --- /dev/null +++ b/bindings/csharp/hamlibgui/README.txt @@ -0,0 +1,18 @@ +This is a test of creating a portable Hamlib GUI controller using dotnet and GTK +Should be able to compile on Windows, Linux, and MacOS +No guarante this will go anywhere depending on ability to talk to Hamlib via C# + +On Windows +dotnet new install GtkSharp.Template.CSharp +dotnet build + + + + +On Ubuntu I don't see the GtkSharp package -- but you can build the code generated on the Windows side. +apt install dotnet-sdk-6.0 +dotnet build + + +Note: On Windows you can create a skeleton GTK app +dotnet new gtkapp diff --git a/bindings/csharp/hamlibgui/hamlibgui.csproj b/bindings/csharp/hamlibgui/hamlibgui.csproj new file mode 100755 index 00000000..459dedc8 --- /dev/null +++ b/bindings/csharp/hamlibgui/hamlibgui.csproj @@ -0,0 +1,19 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <OutputType>WinExe</OutputType> + <TargetFramework>net6.0</TargetFramework> + </PropertyGroup> + + <ItemGroup> + <None Remove="**\*.glade" /> + <EmbeddedResource Include="**\*.glade"> + <LogicalName>%(Filename)%(Extension)</LogicalName> + </EmbeddedResource> + </ItemGroup> + + <ItemGroup> + <PackageReference Include="GtkSharp" Version="3.24.24.*" /> + </ItemGroup> + +</Project> commit 18a2d91f59e0a04042bcaf68e47417f5d9695dbe Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Jan 21 22:49:51 2023 -0600 Add HAMLIB_VERSION_MAJOR, HAMLIB_VERSION_MINOR, and HAMLIB_VERSION_PATCH #defines https://github.com/Hamlib/Hamlib/issues/1209 diff --git a/configure.ac b/configure.ac index 0af90a70..ff777d51 100644 --- a/configure.ac +++ b/configure.ac @@ -59,11 +59,15 @@ dnl See README.release on setting these values # Set them here to keep c++/Makefile and src/Makefile in sync. ABI_VERSION=4 ABI_REVISION=6 +ABI_PATCH=0 ABI_AGE=0 AC_DEFINE_UNQUOTED([ABI_VERSION], [$ABI_VERSION], [Frontend ABI version]) AC_DEFINE_UNQUOTED([ABI_REVISION], [$ABI_REVISION], [Frontend ABI revision]) AC_DEFINE_UNQUOTED([ABI_AGE], [$ABI_AGE], [Frontend ABI age]) +AC_DEFINE_UNQUOTED([ABI_VERSION_MAJOR], [$ABI_VERSION], [Frontend Major version]) +AC_DEFINE_UNQUOTED([ABI_VERSION_MINOR], [$ABI_REVISION], [Frontend Minor version]) +AC_DEFINE_UNQUOTED([ABI_VERSION_PATCH], [$ABI_PATCH], [Frontend Patch version]) AC_SUBST([ABI_VERSION]) AC_SUBST([ABI_REVISION]) commit 0c2426c800b754de0aa14a89421354e39473546f Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Jan 21 17:21:04 2023 -0600 Add 5 second sleep during power on for IC7300 https://github.com/Hamlib/Hamlib/issues/1220 diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 7cc67e52..3a700127 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -8051,6 +8051,11 @@ int icom_set_powerstat(RIG *rig, powerstat_t status) if (status == RIG_POWER_ON) // wait for wakeup only { + if (rig->caps->rig_model == RIG_MODEL_IC7300) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: waiting 5 seconds for rig to wake up\n", __func__); + sleep(5); // IC7300 is slow to start up -- may need to add more rigs + } for (i = 0; i < retry; ++i) // up to 10 attempts { freq_t freq; diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index 6629fcad..a72ba5ed 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -31,7 +31,7 @@ #include <sys/time.h> #endif -#define BACKEND_VER "20230118" +#define BACKEND_VER "20230121" #define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31) #define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51) commit cdbd517228cf11d5a9e90d82fa534abc53d95eb4 Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Jan 21 12:55:44 2023 -0600 Remove double execution of get_powerstat -- was causing rigctld to give an error https://github.com/Hamlib/Hamlib/issues/1220 diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 2c417b47..02c80195 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -1731,23 +1731,6 @@ readline_repeat: else { - if (my_rig->caps->get_powerstat && (rig_powerstat == RIG_POWER_OFF - || rig_powerstat == RIG_POWER_STANDBY)) - { - // Update power status - powerstat_t stat = RIG_POWER_ON; - retcode = rig_get_powerstat(my_rig, &stat); - - if (retcode == RIG_OK) { rig_powerstat = stat; } - - if (rig_powerstat != RIG_POWER_ON) - { - rig_debug(RIG_DEBUG_ERR, - "%s: rig_powerstat is not on = %d\n", __func__, - rig_powerstat); - } - } - // Allow only certain commands when the rig is powered off if (retcode == RIG_OK && (rig_powerstat == RIG_POWER_OFF || rig_powerstat == RIG_POWER_STANDBY) commit cfde2c8a92105da471056fa70194ee10658c201f Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Jan 20 16:53:42 2023 -0600 Add ability for set_vfo_opt 0/1 so rigctl can control VFO option diff --git a/src/rig.c b/src/rig.c index 5eb5767f..2aa101ab 100644 --- a/src/rig.c +++ b/src/rig.c @@ -6917,10 +6917,14 @@ int HAMLIB_API rig_set_vfo_opt(RIG *rig, int status) RETURNFUNC(-RIG_EINVAL); } + // Only netrigctl has this function + // We allow the status to be set for rigctl use if (rig->caps->set_vfo_opt == NULL) { ELAPSED2; - RETURNFUNC(-RIG_ENAVAIL); + rig->state.vfo_opt = status; + //RETURNFUNC(-RIG_ENAVAIL); + RETURNFUNC(RIG_OK); } retcode = rig->caps->set_vfo_opt(rig, status); commit eb1d46723616ec3d94b453f0c1fed94bc977cfe5 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Jan 20 15:39:23 2023 -0600 Fix segfault in aclog.c diff --git a/rigs/dummy/aclog.c b/rigs/dummy/aclog.c index d5a5a828..b3a95524 100644 --- a/rigs/dummy/aclog.c +++ b/rigs/dummy/aclog.c @@ -301,7 +301,7 @@ static int aclog_transaction(RIG *rig, char *cmd, char *value, // we get an unknown response if function does not exist if (strstr(xml, "UNKNOWN")) { set_transaction_inactive(rig); RETURNFUNC(RIG_ENAVAIL); } - strncpy(value, xml, value_len); + if (value) strncpy(value, xml, value_len); } while (((value && strlen(value) == 0)) commit 50a14bb08fdcccc59fc1f7cf803cd6866ee369f3 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Jan 20 12:47:52 2023 -0600 Add ACLog rig -- should work with WSJT_X and Fake It mode -- mode setting is a bit odd though might need None for mode in WSJT-X and manually set rig diff --git a/include/hamlib/riglist.h b/include/hamlib/riglist.h index 9acb9a22..6d730595 100644 --- a/include/hamlib/riglist.h +++ b/include/hamlib/riglist.h @@ -71,7 +71,7 @@ #define RIG_MODEL_TRXMANAGER_RIG RIG_MAKE_MODEL(RIG_DUMMY, 5) #define RIG_MODEL_DUMMY_NOVFO RIG_MAKE_MODEL(RIG_DUMMY, 6) #define RIG_MODEL_TCI1X RIG_MAKE_MODEL(RIG_DUMMY, 7) - +#define RIG_MODEL_ACLOG RIG_MAKE_MODEL(RIG_DUMMY, 8) /* * Yaesu @@ -128,7 +128,6 @@ #define RIG_MODEL_FT990UNI RIG_MAKE_MODEL(RIG_YAESU, 48) #define RIG_MODEL_FT710 RIG_MAKE_MODEL(RIG_YAESU, 49) - /* * Kenwood */ @@ -274,7 +273,6 @@ #define RIG_MODEL_G90 RIG_MAKE_MODEL(RIG_ICOM, 88) /* Xiegu G90 */ #define RIG_MODEL_X5105 RIG_MAKE_MODEL(RIG_ICOM, 89) /* Xiegu X5105 -- G90 compatible */ - /* * Optoelectronics (CI-V) */ @@ -283,7 +281,6 @@ #define RIG_MODEL_OS535 RIG_MAKE_MODEL(RIG_ICOM, 52) #define RIG_MODEL_OS456 RIG_MAKE_MODEL(RIG_ICOM, 53) - /* * TenTec (CI-V) */ @@ -292,7 +289,6 @@ #define RIG_MODEL_PARAGON2 RIG_MAKE_MODEL(RIG_ICOM, 59) #define RIG_MODEL_DELTAII RIG_MAKE_MODEL(RIG_ICOM, 64) - /* * Icom PCR */ @@ -303,7 +299,6 @@ #define RIG_MODEL_PCR1500 RIG_MAKE_MODEL(RIG_PCR, 3) #define RIG_MODEL_PCR2500 RIG_MAKE_MODEL(RIG_PCR, 4) - /* * AOR */ @@ -326,7 +321,6 @@ #define RIG_MODEL_AR7030P RIG_MAKE_MODEL(RIG_AOR, 15) #define RIG_MODEL_SR2200 RIG_MAKE_MODEL(RIG_AOR, 16) - /* * JRC */ @@ -340,7 +334,6 @@ #define RIG_MODEL_NRD535 RIG_MAKE_MODEL(RIG_JRC, 6) #define RIG_MODEL_NRD545 RIG_MAKE_MODEL(RIG_JRC, 7) - /* * Radio Shack * Actually, they might be either Icom or Uniden. TBC --SF @@ -354,7 +347,6 @@ #define RIG_MODEL_RS2042 RIG_MAKE_MODEL(RIG_RADIOSHACK, 5) /* w/ OptoElectronics OS435 Board */ #define RIG_MODEL_RS2041 RIG_MAKE_MODEL(RIG_RADIOSHACK, 6) /* PRO-2041 */ - /* * Uniden */ @@ -373,7 +365,6 @@ #define RIG_MODEL_BCD996T RIG_MAKE_MODEL(RIG_UNIDEN, 11) #define RIG_MODEL_BC898 RIG_MAKE_MODEL(RIG_UNIDEN, 12) - /* * Drake */ @@ -383,7 +374,6 @@ #define RIG_MODEL_DKR8A RIG_MAKE_MODEL(RIG_DRAKE, 2) #define RIG_MODEL_DKR8B RIG_MAKE_MODEL(RIG_DRAKE, 3) - /* * Lowe */ @@ -394,7 +384,6 @@ #define RIG_MODEL_HF250 RIG_MAKE_MODEL(RIG_LOWE, 3) #define RIG_MODEL_HF235 RIG_MAKE_MODEL(RIG_LOWE, 4) - /* * Racal */ @@ -406,7 +395,6 @@ #define RIG_MODEL_RA3710 RIG_MAKE_MODEL(RIG_RACAL, 4) #define RIG_MODEL_RA3702 RIG_MAKE_MODEL(RIG_RACAL, 5) - /* * Watkins-Johnson */ @@ -417,7 +405,6 @@ #define RIG_MODEL_WJ8711 RIG_MAKE_MODEL(RIG_WJ, 3) #define RIG_MODEL_WJ8888 RIG_MAKE_MODEL(RIG_WJ, 4) - /* * Rohde & Schwarz--ek */ @@ -429,7 +416,6 @@ #define RIG_MODEL_EK895 RIG_MAKE_MODEL(RIG_EK, 4) #define RIG_MODEL_EK070 RIG_MAKE_MODEL(RIG_EK, 5) - /* * Skanti */ @@ -440,7 +426,6 @@ #define RIG_MODEL_TRP9000 RIG_MAKE_MODEL(RIG_SKANTI, 3) #define RIG_MODEL_TRP8255 RIG_MAKE_MODEL(RIG_SKANTI, 4) - /* * WiNRADiO/LinRADiO */ @@ -458,7 +443,6 @@ #define RIG_MODEL_G305 RIG_MAKE_MODEL(RIG_WINRADIO, 10) #define RIG_MODEL_G315 RIG_MAKE_MODEL(RIG_WINRADIO, 11) - /* * Ten Tec */ @@ -477,7 +461,6 @@ #define RIG_MODEL_RX331 RIG_MAKE_MODEL(RIG_TENTEC, 12) #define RIG_MODEL_TT599 RIG_MAKE_MODEL(RIG_TENTEC, 13) /* Eagle */ - /* * Alinco */ @@ -486,7 +469,6 @@ #define RIG_MODEL_DX77 RIG_MAKE_MODEL(RIG_ALINCO, 1) #define RIG_MODEL_DXSR8 RIG_MAKE_MODEL(RIG_ALINCO, 2) - /* * Kachina */ @@ -494,7 +476,6 @@ #define RIG_BACKEND_KACHINA "kachina" #define RIG_MODEL_505DSP RIG_MAKE_MODEL(RIG_KACHINA, 1) - /* * Gnuradio backend */ @@ -506,7 +487,6 @@ #define RIG_MODEL_GRAUDIOIQ RIG_MAKE_MODEL(RIG_GNURADIO, 4) /* I&Q stereo sound card source */ #define RIG_MODEL_USRP_G RIG_MAKE_MODEL(RIG_GNURADIO, 5) /* Universal Software Radio Peripheral */ - /* * Microtune tuners */ @@ -516,7 +496,6 @@ #define RIG_MODEL_MICROTUNE_4702 RIG_MAKE_MODEL(RIG_MICROTUNE, 2) /* Alan's */ #define RIG_MODEL_MICROTUNE_4707 RIG_MAKE_MODEL(RIG_MICROTUNE, 3) - /* * TAPR */ @@ -524,7 +503,6 @@ #define RIG_BACKEND_TAPR "tapr" #define RIG_MODEL_DSP10 RIG_MAKE_MODEL(RIG_TAPR, 1) - /* * Flex-radio */ @@ -535,7 +513,6 @@ #define RIG_MODEL_DTTSP RIG_MAKE_MODEL(RIG_FLEXRADIO, 3) #define RIG_MODEL_DTTSP_UDP RIG_MAKE_MODEL(RIG_FLEXRADIO, 4) - /* * VEB Funkwerk Köpenick RFT */ @@ -543,7 +520,6 @@ #define RIG_BACKEND_RFT "rft" #define RIG_MODEL_EKD500 RIG_MAKE_MODEL(RIG_RFT, 1) - /* * Various kits */ @@ -569,7 +545,6 @@ #define RIG_MODEL_FUNCUBEDONGLEPLUS RIG_MAKE_MODEL(RIG_KIT, 18) /* FunCUBE Dongle Pro+ */ #define RIG_MODEL_RSHFIQ RIG_MAKE_MODEL(RIG_KIT, 19) /* RS-HFIQ */ - /* * SW/FM/TV tuner cards supported by Video4Linux,*BSD, .. */ @@ -578,7 +553,6 @@ #define RIG_MODEL_V4L RIG_MAKE_MODEL(RIG_TUNER, 1) #define RIG_MODEL_V4L2 RIG_MAKE_MODEL(RIG_TUNER, 2) - /* * Rohde & Schwarz--rs */ @@ -589,7 +563,6 @@ #define RIG_MODEL_XK2100 RIG_MAKE_MODEL(RIG_RS, 3) #define RIG_MODEL_EK89X RIG_MAKE_MODEL(RIG_RS, 4) - /* * Phillips/Simoco PRM80 */ @@ -598,7 +571,6 @@ #define RIG_MODEL_PRM8060 RIG_MAKE_MODEL(RIG_PRM80, 1) #define RIG_MODEL_PRM8070 RIG_MAKE_MODEL(RIG_PRM80, 2) - /* * ADAT by HB9CBU * @@ -608,7 +580,6 @@ #define RIG_BACKEND_ADAT "adat" #define RIG_MODEL_ADT_200A RIG_MAKE_MODEL(RIG_ADAT, 1) - /* * ICOM Marine */ @@ -619,7 +590,6 @@ #define RIG_MODEL_IC_M710 RIG_MAKE_MODEL(RIG_ICMARINE, 3) #define RIG_MODEL_IC_M803 RIG_MAKE_MODEL(RIG_ICMARINE, 4) - /* * Dorji transceiver modules */ diff --git a/rigs/dummy/Makefile.am b/rigs/dummy/Makefile.am index 7a60bdce..5a419d3f 100644 --- a/rigs/dummy/Makefile.am +++ b/rigs/dummy/Makefile.am @@ -1,4 +1,4 @@ -DUMMYSRC = dummy_common.c dummy_common.h dummy.c dummy.h rot_dummy.c rot_dummy.h netrigctl.c netrotctl.c flrig.c flrig.h trxmanager.c trxmanager.h amp_dummy.c amp_dummy.h netampctl.c tci1x.c +DUMMYSRC = dummy_common.c dummy_common.h dummy.c dummy.h rot_dummy.c rot_dummy.h netrigctl.c netrotctl.c flrig.c flrig.h trxmanager.c trxmanager.h amp_dummy.c amp_dummy.h netampctl.c tci1x.c aclog.c noinst_LTLIBRARIES = libhamlib-dummy.la libhamlib_dummy_la_SOURCES = $(DUMMYSRC) diff --git a/rigs/dummy/aclog.c b/rigs/dummy/aclog.c new file mode 100644 index 00000000..d5a5a828 --- /dev/null +++ b/rigs/dummy/aclog.c @@ -0,0 +1,994 @@ +/* +* Hamlib ACLog backend - main file +* Copyright (c) 2023 by Michael Black W9MDB +* +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ +#include <hamlib/config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <hamlib/rig.h> +#include <serial.h> +#include <misc.h> +#include <token.h> +#include <register.h> +#include <network.h> + +#include "dummy_common.h" + +#define DEBUG 1 +#define DEBUG_TRACE DEBUG_VERBOSE +#define TRUE 1 +#define FALSE 0 + + +#define MAXCMDLEN 8192 +#define MAXXMLLEN 8192 +#define MAXARGLEN 128 +#define MAXBANDWIDTHLEN 4096 + +#define DEFAULTPATH "127.0.0.1:1100" + +#define ACLOG_VFOS (RIG_VFO_A) + +#define ACLOG_MODES (RIG_MODE_AM | RIG_MODE_PKTAM | RIG_MODE_CW | RIG_MODE_CWR |\ + RIG_MODE_RTTY | RIG_MODE_RTTYR |\ + RIG_MODE_PKTLSB | RIG_MODE_PKTUSB |\ + RIG_MODE_SSB | RIG_MODE_LSB | RIG_MODE_USB |\ + RIG_MODE_FM | RIG_MODE_WFM | RIG_MODE_FMN | RIG_MODE_PKTFM |\ + RIG_MODE_C4FM) + +#define streq(s1,s2) (strcmp(s1,s2)==0) + +struct aclog_priv_data +{ + vfo_t curr_vfo; + char bandwidths[MAXBANDWIDTHLEN]; /* pipe delimited set returned from aclog */ + int nbandwidths; + char info[8192]; + ptt_t ptt; + split_t split; + rmode_t curr_modeA; + rmode_t curr_modeB; + freq_t curr_freqA; + freq_t curr_freqB; + pbwidth_t curr_widthA; + pbwidth_t curr_widthB; + int has_get_modeA; /* True if this function is available */ + int has_get_bwA; /* True if this function is available */ + int has_set_bwA; /* True if this function is available */ + float powermeter_scale; /* So we can scale power meter to 0-1 */ + value_t parms[RIG_SETTING_MAX]; + struct ext_list *ext_parms; +}; + +//Structure for mapping aclog dynmamic modes to hamlib modes +//aclog displays modes as the rig displays them +struct s_modeMap +{ + rmode_t mode_hamlib; + char *mode_aclog; +}; + +//ACLog will provide us the modes for the selected rig +//We will then put them in this struct +static struct s_modeMap modeMap[] = +{ + {RIG_MODE_USB, "|USB|"}, + {RIG_MODE_USB, "|SSB|"}, + {RIG_MODE_LSB, "|LSB|"}, + {RIG_MODE_PKTUSB, NULL}, + {RIG_MODE_PKTLSB, NULL}, + {RIG_MODE_AM, "|AM|"}, + {RIG_MODE_FM, "|FM|"}, + {RIG_MODE_FMN, NULL}, + {RIG_MODE_WFM, NULL}, + {RIG_MODE_CW, "|CW|"}, + {RIG_MODE_CWR, "|CWR|"}, + {RIG_MODE_RTTY, "|RTTY|"}, + {RIG_MODE_RTTYR, "|RTTYR|"}, + {RIG_MODE_C4FM, "|C4FM|"}, + {0, NULL} +}; + +/* +* check_vfo +* No assumptions +*/ +static int check_vfo(vfo_t vfo) +{ + switch (vfo) + { + case RIG_VFO_A: + break; + + case RIG_VFO_TX: + case RIG_VFO_B: + break; + + case RIG_VFO_CURR: + break; // will default to A in which_vfo + + default: + return (FALSE); + } + + return (TRUE); +} + +/* +* read_transaction +* Assumes rig!=NULL, xml!=NULL, xml_len>=MAXXMLLEN +*/ +static int read_transaction(RIG *rig, char *xml, int xml_len) +{ + int retval; + int retry; + char *delims; + char *terminator = "</CMD>\r\n"; + struct rig_state *rs = &rig->state; + + ENTERFUNC; + + retry = 2; + delims = "\n"; + xml[0] = 0; + + do + { + char tmp_buf[MAXXMLLEN]; // plenty big for expected aclog responses hopefully + + if (retry < 2) + { + rig_debug(RIG_DEBUG_WARN, "%s: retry needed? retry=%d\n", __func__, retry); + } + + int len = read_string(&rs->rigport, (unsigned char *) tmp_buf, sizeof(tmp_buf), + delims, + strlen(delims), 0, 1); + rig_debug(RIG_DEBUG_TRACE, "%s: string='%s'\n", __func__, tmp_buf); + + // if our first response we should see the HTTP header + if (strlen(xml) == 0 && strstr(tmp_buf, "<CMD>") == NULL) + { + rig_debug(RIG_DEBUG_ERR, "%s: Expected '</CMD>', got '%s'\n", __func__, + tmp_buf); + continue; // we'll try again + } + + if (len > 0) { retry = 3; } + + if (len <= 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: read_string error=%d\n", __func__, len); + continue; + } + + if (strlen(xml) + strlen(tmp_buf) < xml_len - 1) + { + strncat(xml, tmp_buf, xml_len - 1); + } + else + { + rig_debug(RIG_DEBUG_ERR, + "%s: xml buffer overflow!!\nTrying to add len=%d\nTo len=%d\n", __func__, + (int)strlen(tmp_buf), (int)strlen(xml)); + RETURNFUNC(-RIG_EPROTO); + } + } + while (retry-- > 0 && strstr(xml, terminator) == NULL); + + if (retry == 0) + { + rig_debug(RIG_DEBUG_WARN, "%s: retry timeout\n", __func__); + RETURNFUNC(-RIG_ETIMEOUT); + } + + if (strstr(xml, terminator)) + { + rig_debug(RIG_DEBUG_TRACE, "%s: got %s\n", __func__, terminator); + retval = RIG_OK; + } + else + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: did not get %s\n", __func__, terminator); + retval = -(101 + RIG_EPROTO); + } + + RETURNFUNC(retval); +} + +/* +* write_transaction +* Assumes rig!=NULL, xml!=NULL, xml_len=total size of xml for response +*/ +static int write_transaction(RIG *rig, char *xml, int xml_len) +{ + + int try = rig->caps->retry; + + int retval = -RIG_EPROTO; + + struct rig_state *rs = &rig->state; + + ENTERFUNC; + + // This shouldn't ever happen...but just in case + // We need to avoid an empty write as rigctld replies with blank line + if (xml_len == 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: len==0??\n", __func__); + RETURNFUNC(retval); + } + + // appears we can lose sync if we don't clear things out + // shouldn't be anything for us now anyways + rig_flush(&rig->state.rigport); + + while (try-- >= 0 && retval != RIG_OK) + { + retval = write_block(&rs->rigport, (unsigned char *) xml, strlen(xml)); + + if (retval < 0) + { + RETURNFUNC(-RIG_EIO); + } + } + + RETURNFUNC(retval); +} + +static int aclog_transaction(RIG *rig, char *cmd, char *value, + int value_len) +{ + char xml[MAXXMLLEN]; + int retry = 3; + + ENTERFUNC; + ELAPSED1; + + set_transaction_active(rig); + + if (value) + { + value[0] = 0; + } + + do + { + int retval; + + if (retry != 3) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s, retry=%d\n", __func__, cmd, retry); + } + + retval = write_transaction(rig, cmd, strlen(cmd)); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: write_transaction error=%d\n", __func__, retval); + + // if we get RIG_EIO the socket has probably disappeared + // so bubble up the error so port can re re-opened + if (retval == -RIG_EIO) { set_transaction_inactive(rig); RETURNFUNC(retval); } + + hl_usleep(50 * 1000); // 50ms sleep if error + } + + if (value) + { + read_transaction(rig, xml, sizeof(xml)); // this might time out -- that's OK + } + + // we get an unknown response if function does not exist + if (strstr(xml, "UNKNOWN")) { set_transaction_inactive(rig); RETURNFUNC(RIG_ENAVAIL); } + + strncpy(value, xml, value_len); + + } + while (((value && strlen(value) == 0)) + && retry--); // we'll do retries if needed + + if (value && strlen(value) == 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: no value returned\n", __func__); + set_transaction_inactive(rig); RETURNFUNC(RIG_EPROTO); + } + + ELAPSED2; + set_transaction_inactive(rig); + RETURNFUNC(RIG_OK); +} + +/* +* aclog_init +* Assumes rig!=NULL +*/ +static int aclog_init(RIG *rig) +{ + struct aclog_priv_data *priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s version %s\n", __func__, rig->caps->version); + + rig->state.priv = (struct aclog_priv_data *)calloc(1, sizeof( + struct aclog_priv_data)); + + if (!rig->state.priv) + { + RETURNFUNC(-RIG_ENOMEM); + } + + priv = rig->state.priv; + + memset(priv, 0, sizeof(struct aclog_priv_data)); + memset(priv->parms, 0, RIG_SETTING_MAX * sizeof(value_t)); + + /* + * set arbitrary initial status + */ + rig->state.current_vfo = RIG_VFO_A; + priv->split = 0; + priv->ptt = 0; + priv->curr_modeA = -1; + priv->curr_modeB = -1; + priv->curr_widthA = -1; + priv->curr_widthB = -1; + + if (!rig->caps) + { + RETURNFUNC(-RIG_EINVAL); + } + + strncpy(rig->state.rigport.pathname, DEFAULTPATH, + sizeof(rig->state.rigport.pathname)); + + RETURNFUNC(RIG_OK); +} + +/* +* modeMapGet +* Assumes mode!=NULL +* Return the string for ACLog for the given hamlib mode +*/ +static const char *modeMapGet(rmode_t modeHamlib) +{ + int i; + + rig_debug(RIG_DEBUG_TRACE, "%s: called\n", __func__); + + for (i = 0; modeMap[i].mode_hamlib != 0; ++i) + { + if (modeMap[i].mode_aclog == NULL) { continue; } + + rig_debug(RIG_DEBUG_TRACE, + "%s: checking modeMap[%d]=%.0f to modeHamlib=%.0f, mode_aclog='%s'\n", __func__, + i, (double)modeMap[i].mode_hamlib, (double)modeHamlib, modeMap[i].mode_aclog); + + if (modeMap[i].mode_hamlib == modeHamlib && strlen(modeMap[i].mode_aclog) > 0) + { + rig_debug(RIG_DEBUG_TRACE, "%s matched mode=%.0f, returning '%s'\n", __func__, + (double)modeHamlib, modeMap[i].mode_aclog); + return (modeMap[i].mode_aclog); + } + } + + rig_debug(RIG_DEBUG_ERR, "%s: ACLog does not have mode: %s\n", __func__, + rig_strrmode(modeHamlib)); + return ("ERROR"); +} + +/* +* modeMapGetHamlib +* Assumes mode!=NULL +* Return the hamlib mode from the given ACLog string +*/ +static rmode_t modeMapGetHamlib(const char *modeACLog) +{ + int i; + char modeCheck[64]; + + SNPRINTF(modeCheck, sizeof(modeCheck), "|%s|", modeACLog); + + for (i = 0; modeMap[i].mode_hamlib != 0; ++i) + { + rig_debug(RIG_DEBUG_TRACE, "%s: find '%s' in '%s'\n", __func__, + modeCheck, modeMap[i].mode_aclog); + + if (modeMap[i].mode_aclog + && strcmp(modeMap[i].mode_aclog, modeCheck) == 0) + { + return (modeMap[i].mode_hamlib); + } + } + + rig_debug(RIG_DEBUG_TRACE, "%s: mode requested: %s, not in modeMap\n", __func__, + modeACLog); + return (RIG_MODE_NONE); +} + +/* +* aclog_get_freq +* Assumes rig!=NULL, rig->state.priv!=NULL, freq!=NULL +*/ +static int aclog_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) +{ + char value[MAXARGLEN]; + struct aclog_priv_data *priv = (struct aclog_priv_data *) rig->state.priv; + + ENTERFUNC; + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, + rig_strvfo(vfo)); + + + if (check_vfo(vfo) == FALSE) + { + rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", + __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); + } + + if (vfo == RIG_VFO_CURR) + { + vfo = rig->state.current_vfo; + rig_debug(RIG_DEBUG_TRACE, "%s: get_freq2 vfo=%s\n", + __func__, rig_strvfo(vfo)); + } + + char *cmd = "<CMD><READBMF></CMD>\r\n"; + int retval; + + retval = aclog_transaction(rig, cmd, value, sizeof(value)); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: READBMF failed retval=%s\n", __func__, + rigerror(retval)); + RETURNFUNC(retval); + } + + char *p = strstr(value, "<FREQ>"); + *freq = 0; + + if (p) { sscanf(p, "<FREQ>%lf", freq); } + + *freq *= 1e6; // convert from MHz to Hz + + if (*freq == 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: freq==0??\nvalue=%s\n", __func__, + value); + RETURNFUNC(-RIG_EPROTO); + } + else + { + rig_debug(RIG_DEBUG_TRACE, "%s: freq=%.0f\n", __func__, *freq); + } + + if (vfo == RIG_VFO_A) + { + priv->curr_freqA = *freq; + } + else // future support in ACL... [truncated message content] |