[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 7f60e1fcb036551e7bae1
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2021-05-04 19:35:59
|
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 7f60e1fcb036551e7bae101f13414f5fe3e58086 (commit) via 78a697e58204b6e951a8b1f80a7c8b1e0bae61fe (commit) via 5bafde9ae64c277202fba92955a855a4a555670f (commit) via 231f9faad8feaa761298c8595afa63379a077023 (commit) via c1b2131d9460637c8647626430a913304946a671 (commit) from 4108c0b57169060a2c2743d39ba4471e87e70f83 (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 7f60e1fcb036551e7bae101f13414f5fe3e58086 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue May 4 14:34:51 2021 -0500 Fix dummy rig to recognize Main/Sub VFOS -- this fixes "M CW 500" Fix rig.c set_mode to recognize curr_vfo correctly https://github.com/Hamlib/Hamlib/issues/689 diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c index b5da2d1e..1d6b5b55 100644 --- a/rigs/dummy/dummy.c +++ b/rigs/dummy/dummy.c @@ -469,15 +469,23 @@ static int dummy_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s %s %s\n", __func__, rig_strvfo(vfo), rig_strrmode(mode), buf); + vfo = vfo_fixup(rig, vfo); switch (vfo) { + case RIG_VFO_MAIN: case RIG_VFO_A: priv->vfo_a.mode = mode; priv->vfo_a.width = width; break; + case RIG_VFO_SUB: case RIG_VFO_B: priv->vfo_b.mode = mode; priv->vfo_b.width = width; break; case RIG_VFO_C: priv->vfo_c.mode = mode; priv->vfo_c.width = width; break; + default: + rig_debug(RIG_DEBUG_ERR, "%s: unknown VFO=%s\n", __func__, rig_strvfo(vfo)); + RETURNFUNC(-RIG_EINVAL); } + vfo = vfo_fixup(rig, vfo); + if (RIG_PASSBAND_NOCHANGE == width) { RETURNFUNC(RIG_OK); } if (width == RIG_PASSBAND_NORMAL) @@ -2127,7 +2135,7 @@ struct rig_caps dummy_caps = RIG_MODEL(RIG_MODEL_DUMMY), .model_name = "Dummy", .mfg_name = "Hamlib", - .version = "20210428.0", + .version = "20210504.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_OTHER, @@ -2292,7 +2300,7 @@ struct rig_caps dummy_no_vfo_caps = RIG_MODEL(RIG_MODEL_DUMMY_NOVFO), .model_name = "Dummy No VFO", .mfg_name = "Hamlib", - .version = "20210428.0", + .version = "20210504.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_OTHER, diff --git a/src/rig.c b/src/rig.c index 25161ce9..eb1e099e 100644 --- a/src/rig.c +++ b/src/rig.c @@ -2154,8 +2154,9 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) RETURNFUNC(-RIG_ENAVAIL); } + if (vfo == RIG_VFO_CURR) vfo = rig->state.current_vfo; + if ((caps->targetable_vfo & RIG_TARGETABLE_MODE) - || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) { TRACE; diff --git a/tests/simyaesu.c b/tests/simyaesu.c index dababa68..fb9c0fff 100644 --- a/tests/simyaesu.c +++ b/tests/simyaesu.c @@ -1,6 +1,9 @@ // can run this using rigctl/rigctld and socat pty devices -// socat -d -d pty,raw,echo=0 pty,raw,echo=0 +// gcc -o simyaesu simyaesu.c +#define _XOPEN_SOURCE 600 #include <stdio.h> +#include <stdlib.h> +#include <fcntl.h> #include <string.h> #include <unistd.h> @@ -31,13 +34,13 @@ typedef enum nc_rigid_e } nc_rigid_t; int -getmyline(FILE *fp, char *buf) +getmyline(int fd, char *buf) { int c; int i = 0; memset(buf, 0, BUFSIZE); - while ((c = fgetc(fp)) != EOF) + while (read(fd, &c, 1) > 0) { buf[i++] = c; @@ -46,63 +49,101 @@ getmyline(FILE *fp, char *buf) return strlen(buf); } -int main() + +#if defined(WIN32) || defined(_WIN32) +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd; + fd = open(comport, O_RDWR); + + if (fd < 0) + { + perror(comport); + } + + return fd; +} + +#else +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd = posix_openpt(O_RDWR); + char *name = ptsname(fd); + + if (name == NULL) + { + perror("pstname"); + return -1; + } + + printf("name=%s\n", name); + + if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) + { + perror("posix_openpt"); + return -1; + } + + return fd; +} +#endif + + + +int main(int argc, char *argv[]) { char buf[256]; + char *pbuf; int n; - FILE *fp = fopen("/dev/pts/3", "r+"); + int fd = openPort(argv[1]); - //,while(getmyline(fp,buf)) while (1) { - getmyline(fp, buf); + getmyline(fd, buf); + printf("Cmd:%s\n", buf); if (strcmp(buf, "RM5;") == 0) { printf("%s\n", buf); usleep(50 * 1000); - n = fprintf(fp, "%s", "RM5100000;"); + pbuf = "RM5100000;"; + n = write(fd, pbuf, strlen(pbuf)); printf("n=%d\n", n); if (n <= 0) { perror("RM5"); } - - fflush(fp); } if (strcmp(buf, "AN0;") == 0) { printf("%s\n", buf); usleep(50 * 1000); - n = fprintf(fp, "%s", "AN030;"); + pbuf = "AN030;"; + n = write(fd, pbuf, strlen(pbuf)); printf("n=%d\n", n); if (n <= 0) { perror("AN"); } - - fflush(fp); } else if (strcmp(buf, "IF;") == 0) { printf("%s\n", buf); usleep(50 * 1000); - n = fprintf(fp, "%s", "IF059014200000+000000700000;"); + pbuf = "IF059014200000+000000700000;"; + n = write(fd, pbuf, strlen(pbuf)); printf("n=%d\n", n); if (n <= 0) { perror("IF"); } - - fflush(fp); } else if (strcmp(buf, "ID;") == 0) { printf("%s\n", buf); usleep(50 * 1000); - int id = NC_RIGID_FTDX101D; -// int id = NC_RIGID_FTDX3000; - n = fprintf(fp, "ID%03d;", id); + int id = NC_RIGID_FTDX3000; + snprintf(buf,sizeof(buf),"ID%03d;", id); + n = snprintf(buf, sizeof(buf), "ID%03d;", id); + n = write(fd, buf, strlen(buf)); printf("n=%d\n", n); if (n <= 0) { perror("ID"); } - - fflush(fp); } #if 0 @@ -116,8 +157,6 @@ int main() printf("n=%d\n", n); if (n <= 0) { perror("AI"); } - - fflush(fp); } } @@ -126,12 +165,11 @@ int main() { printf("%s\n", buf); usleep(50 * 1000); - n = fprintf(fp, "%s", "VS0;"); + pbuf = "VS0;"; + n = write(fd, pbuf, strlen(pbuf)); printf("n=%d\n", n); if (n < 0) { perror("VS"); } - - fflush(fp); } else if (strcmp(buf, "EX032;") == 0) { @@ -139,12 +177,11 @@ int main() ant = (ant + 1) % 3; printf("%s\n", buf); usleep(50 * 1000); - n = fprintf(fp, "EX032%1d;", ant); + snprintf(buf, sizeof(buf), "EX032%1d;", ant); + n = write(fd, buf, strlen(buf)); printf("n=%d\n", n); if (n < 0) { perror("EX032"); } - - fflush(fp); } else if (strlen(buf) > 0) commit 78a697e58204b6e951a8b1f80a7c8b1e0bae61fe Author: Mike Black W9MDB <mdb...@ya...> Date: Mon May 3 15:35:56 2021 -0500 Add rig_get_mode_bandwidths -- see NEWS Return token set of bandwidths for given mode diff --git a/NEWS b/NEWS index 9fa94ca9..683d706c 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,12 @@ Please send Hamlib bug reports to ham...@li... Version 4.2 * 2021-04-27 + * New rig_get_mode_bandwidths -- returns token set for bandwidths for given mode + Rig command: \get_mode_bandwidths CW + Mode=CW + Normal=500Hz + Narrow=50Hz + Wide=2400Hz * New rig_get_info -- returns token set for all vfos where order does not matter This is a string return to allow for easy future expansion without changing the API New tokens may be introduced and can be skipped if not used by clients diff --git a/src/rig.c b/src/rig.c index 66bf6d4e..25161ce9 100644 --- a/src/rig.c +++ b/src/rig.c @@ -2367,6 +2367,10 @@ pbwidth_t HAMLIB_API rig_passband_normal(RIG *rig, rmode_t mode) rs = &rig->state; + // return CW for CWR and RTTY for RTTYR + if (mode == RIG_MODE_CWR) mode = RIG_MODE_CW; + if (mode == RIG_MODE_RTTYR) mode = RIG_MODE_RTTY; + for (i = 0; i < HAMLIB_FLTLSTSIZ && rs->filters[i].modes; i++) { if (rs->filters[i].modes & mode) diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 303b5f66..69df31ab 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -165,6 +165,7 @@ declare_proto_rig(get_xit); declare_proto_rig(set_mode); declare_proto_rig(get_mode); declare_proto_rig(get_modes); +declare_proto_rig(get_mode_bandwidths); declare_proto_rig(set_vfo); declare_proto_rig(get_vfo); declare_proto_rig(get_rig_info); @@ -336,8 +337,9 @@ static struct test_table test_list[] = { 0xf2, "set_vfo_opt", ACTION(set_vfo_opt), ARG_NOVFO | ARG_IN, "Status" }, /* turn vfo option on/off */ { 0xf3, "get_vfo_info", ACTION(get_vfo_info), ARG_NOVFO | ARG_IN1 | ARG_OUT4, "Freq", "Mode", "Width", "Split", "SatMode" }, /* get several vfo parameters at once */ { 0xf5, "get_rig_info", ACTION(get_rig_info), ARG_NOVFO | ARG_OUT, "RigInfo" }, /* get several vfo parameters at once */ - { 0xf4, "get_vfo_list", ACTION(get_vfo_list), ARG_OUT | ARG_NOVFO, "VFOs" }, - { 0xf6, "get_modes", ACTION(get_modes), ARG_OUT | ARG_NOVFO, "Modes" }, + { 0xf4, "get_vfo_list", ACTION(get_vfo_list), ARG_OUT | ARG_NOVFO, "VFOs" }, + { 0xf6, "get_modes", ACTION(get_modes), ARG_OUT | ARG_NOVFO, "Modes" }, + { 0xf7, "get_mode_bandwidths", ACTION(get_mode_bandwidths), ARG_IN | ARG_NOVFO, "Mode" }, { 0xf1, "halt", ACTION(halt), ARG_NOVFO }, /* rigctld only--halt the daemon */ { 0x8c, "pause", ACTION(pause), ARG_IN, "Seconds" }, { 0x00, "", NULL }, @@ -2340,6 +2342,48 @@ declare_proto_rig(get_modes) RETURNFUNC(RIG_OK); } +declare_proto_rig(get_mode_bandwidths) +{ + int i; + char freqbuf[32]; + + ENTERFUNC; + + rmode_t mode = rig_parse_mode(arg1); + + for (i = 1; i < RIG_MODE_TESTS_MAX; i <<= 1) + { + if (i != mode) { continue; } + + if (mode == RIG_MODE_CWR) { mode = RIG_MODE_CW; } + + if (mode == RIG_MODE_RTTYR) { mode = RIG_MODE_RTTY; } + + pbwidth_t pbnorm = rig_passband_normal(rig, i); + + if (pbnorm == 0) + { + continue; + } + +// sprintf_freq(freqbuf, sizeof(freqbuf), pbnorm); + snprintf(freqbuf, sizeof(freqbuf), "%ldHz", pbnorm); + fprintf(fout, "Mode=%s\n", rig_strrmode(i)); + fprintf(fout, "Normal=%s\n", freqbuf); + + snprintf(freqbuf, sizeof(freqbuf), "%ldHz", rig_passband_narrow(rig, i)); + fprintf(fout, "Narrow=%s\n", freqbuf); + + snprintf(freqbuf, sizeof(freqbuf), "%ldHz", rig_passband_wide(rig, i)); + fprintf(fout, "Wide=%s", freqbuf); + } + + + RETURNFUNC(RIG_OK); +} + + + /* 'T' */ declare_proto_rig(set_ptt) commit 5bafde9ae64c277202fba92955a855a4a555670f Author: Mike Black W9MDB <mdb...@ya...> Date: Mon May 3 11:26:41 2021 -0500 Add bandwidths to get_modes diff --git a/tests/dumpcaps.c b/tests/dumpcaps.c index afc74e48..b44b625b 100644 --- a/tests/dumpcaps.c +++ b/tests/dumpcaps.c @@ -665,7 +665,7 @@ int dumpcaps(RIG *rig, FILE *fout) if (pbnorm == 0) { - continue; +// continue; } sprintf_freq(freqbuf, sizeof(freqbuf), pbnorm); diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 4143eb40..303b5f66 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -2301,6 +2301,8 @@ declare_proto_rig(get_vfo_list) declare_proto_rig(get_modes) { static char prntbuf[1024]; + int i; + char freqbuf[32]; ENTERFUNC; @@ -2313,6 +2315,28 @@ declare_proto_rig(get_modes) fprintf(fout, "%s%c", prntbuf[0] ? prntbuf : "None", ext_resp); + fprintf(fout, "\nBandwidths:"); + + for (i = 1; i < RIG_MODE_TESTS_MAX; i <<= 1) + { + pbwidth_t pbnorm = rig_passband_normal(rig, i); + + if (pbnorm == 0) + { + continue; + } + + sprintf_freq(freqbuf, sizeof(freqbuf), pbnorm); + fprintf(fout, "\n\t%s\tNormal: %s,\t", rig_strrmode(i), freqbuf); + + sprintf_freq(freqbuf, sizeof(freqbuf), rig_passband_narrow(rig, i)); + fprintf(fout, "Narrow: %s,\t", freqbuf); + + sprintf_freq(freqbuf, sizeof(freqbuf), rig_passband_wide(rig, i)); + fprintf(fout, "Wide: %s", freqbuf); + } + + RETURNFUNC(RIG_OK); } commit 231f9faad8feaa761298c8595afa63379a077023 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon May 3 09:24:02 2021 -0500 Add get_modes call to return list of rig modes diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 0ede3fc6..4143eb40 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -164,6 +164,7 @@ declare_proto_rig(set_xit); declare_proto_rig(get_xit); declare_proto_rig(set_mode); declare_proto_rig(get_mode); +declare_proto_rig(get_modes); declare_proto_rig(set_vfo); declare_proto_rig(get_vfo); declare_proto_rig(get_rig_info); @@ -336,6 +337,7 @@ static struct test_table test_list[] = { 0xf3, "get_vfo_info", ACTION(get_vfo_info), ARG_NOVFO | ARG_IN1 | ARG_OUT4, "Freq", "Mode", "Width", "Split", "SatMode" }, /* get several vfo parameters at once */ { 0xf5, "get_rig_info", ACTION(get_rig_info), ARG_NOVFO | ARG_OUT, "RigInfo" }, /* get several vfo parameters at once */ { 0xf4, "get_vfo_list", ACTION(get_vfo_list), ARG_OUT | ARG_NOVFO, "VFOs" }, + { 0xf6, "get_modes", ACTION(get_modes), ARG_OUT | ARG_NOVFO, "Modes" }, { 0xf1, "halt", ACTION(halt), ARG_NOVFO }, /* rigctld only--halt the daemon */ { 0x8c, "pause", ACTION(pause), ARG_IN, "Seconds" }, { 0x00, "", NULL }, @@ -2295,6 +2297,25 @@ declare_proto_rig(get_vfo_list) RETURNFUNC(RIG_OK); } +/* '\get_modes' */ +declare_proto_rig(get_modes) +{ + static char prntbuf[1024]; + + ENTERFUNC; + + rig_strrmodes(rig->state.mode_list, prntbuf, sizeof(prntbuf)); + + if ((interactive && prompt) || (interactive && !prompt && ext_resp)) + { + fprintf(fout, "%s: ", cmd->arg1); + } + + fprintf(fout, "%s%c", prntbuf[0] ? prntbuf : "None", ext_resp); + + RETURNFUNC(RIG_OK); +} + /* 'T' */ declare_proto_rig(set_ptt) commit c1b2131d9460637c8647626430a913304946a671 Author: Mike Black W9MDB <mdb...@ya...> Date: Sun May 2 17:33:37 2021 -0500 Update NEWS diff --git a/NEWS b/NEWS index f00cbfed..9fa94ca9 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,7 @@ Version 4.2 Split: 0 SatMode: 0 + * FILPATHLEN has changed to HAMLIB_FILPATHLEN * USRP lib and gnuradio are deprecated and will be removed in 5.0 * Added Radan rotator ----------------------------------------------------------------------- Summary of changes: NEWS | 7 ++++ rigs/dummy/dummy.c | 12 +++++-- src/rig.c | 7 +++- tests/dumpcaps.c | 2 +- tests/rigctl_parse.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++- tests/simyaesu.c | 95 ++++++++++++++++++++++++++++++++++++---------------- 6 files changed, 180 insertions(+), 34 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |