[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 5473249e9ad75a3028398
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2021-04-28 22:50:08
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 5473249e9ad75a302839804a0811039245f13c04 (commit) via 0b203c7e8f80f3190940d58a8df1f7a677db107b (commit) from 906b6e62d8f0eb07e3df5a029bc0f589c7eb1b1f (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 5473249e9ad75a302839804a0811039245f13c04 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Apr 28 17:39:08 2021 -0500 Add power2mW and mW2power to netrigctl.c diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c index 6afc37b2..20c7cd50 100644 --- a/rigs/dummy/netrigctl.c +++ b/rigs/dummy/netrigctl.c @@ -512,6 +512,7 @@ static int netrigctl_open(RIG *rig) rig->caps->has_get_level = rs->has_get_level = strtoll(buf, NULL, 0); +#if 0 // don't think we need this anymore if (rs->has_get_level & RIG_LEVEL_RAWSTR) { /* include STRENGTH because the remote rig may be able to @@ -520,6 +521,7 @@ static int netrigctl_open(RIG *rig) rs->has_get_level |= RIG_LEVEL_STRENGTH; rig->caps->has_get_level |= RIG_LEVEL_STRENGTH; } +#endif ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1); @@ -645,6 +647,44 @@ static int netrigctl_open(RIG *rig) if (!has) { rig->caps->get_freq = NULL; } } + else if (strcmp(setting, "has_set_conf") == 0) + { + int has = strtol(value, NULL, 0); + + if (!has) { rig->caps->set_conf = NULL; } + } + else if (strcmp(setting, "has_get_conf") == 0) + { + int has = strtol(value, NULL, 0); + + if (!has) { rig->caps->get_conf = NULL; } + } +#if 0 // for the future + else if (strcmp(setting, "has_set_trn") == 0) + { + int has = strtol(value, NULL, 0); + + if (!has) { rig->caps->set_trn = NULL; } + } + else if (strcmp(setting, "has_get_trn") == 0) + { + int has = strtol(value, NULL, 0); + + if (!has) { rig->caps->get_trn = NULL; } + } +#endif + else if (strcmp(setting, "has_power2mW") == 0) + { + int has = strtol(value, NULL, 0); + + if (!has) { rig->caps->power2mW = NULL; } + } + else if (strcmp(setting, "has_mw2power") == 0) + { + int has = strtol(value, NULL, 0); + + if (!has) { rig->caps->mW2power = NULL; } + } else if (strcmp(setting, "timeout") == 0) { // use the rig's timeout value pluse 200ms for potential network delays @@ -2319,6 +2359,99 @@ static int netrigctl_set_vfo_opt(RIG *rig, int status) return RIG_OK; } +#if 0 // for the futurem -- would have to poll to get the pushed data +static int netrigctl_set_trn(RIG *rig, int trn) +{ + char cmdbuf[32]; + char buf[BUF_MAX]; + int ret; + + sprintf(cmdbuf, "\\set_trn %s\n", trn ? "ON" : "OFF"); + ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf); + + if (ret < 0) + { + return -RIG_EPROTO; + } + + return RIG_OK; +} + + +static int netrigctl_get_trn(RIG *rig, int *trn) +{ + char cmdbuf[32]; + char buf[BUF_MAX]; + int ret; + + ENTERFUNC; + sprintf(cmdbuf, "\\get_trn\n"); + ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf); + + if (ret <= 0) + { + return -RIG_EPROTO; + } + + if (strstr(buf,"OFF")) *trn = RIG_TRN_OFF; + else if (strstr(buf,"RIG")) *trn = RIG_TRN_RIG; + else if (strstr(buf,"POLL")) *trn = RIG_TRN_POLL; + else { + rig_debug(RIG_DEBUG_ERR, "%s: Expected OFF, RIG, or POLL, got '%s'\n", __func__, buf); + ret = -RIG_EINVAL; + } + + RETURNFUNC(ret); +} +#endif + +static int netrigctl_mW2power(RIG *rig, float *power, unsigned int mwpower, + freq_t freq, rmode_t mode) +{ + char cmdbuf[32]; + char buf[BUF_MAX]; + int ret; + + ENTERFUNC; + + sprintf(cmdbuf, "\\mW2power %u %.0f %s\n", mwpower, freq, rig_strrmode(mode)); + ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf); + + if (ret <= 0) + { + return -RIG_EPROTO; + } + + *power = atof(buf); + + RETURNFUNC(RIG_OK); +} + + +static int netrigctl_power2mW(RIG *rig, unsigned int *mwpower, float power, + freq_t freq, rmode_t mode) +{ + char cmdbuf[32]; + char buf[BUF_MAX]; + int ret; + + ENTERFUNC; + + sprintf(cmdbuf, "\\power2mW %f %.0f %s\n", power, freq, rig_strrmode(mode)); + ret = netrigctl_transaction(rig, cmdbuf, strlen(cmdbuf), buf); + + if (ret <= 0) + { + return -RIG_EPROTO; + } + + *mwpower = atof(buf); + + RETURNFUNC(RIG_OK); +} + + + /* * Netrigctl rig capabilities. */ @@ -2328,7 +2461,7 @@ struct rig_caps netrigctl_caps = RIG_MODEL(RIG_MODEL_NETRIGCTL), .model_name = "NET rigctl", .mfg_name = "Hamlib", - .version = "20210409.0", + .version = "20210428.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_OTHER, @@ -2427,4 +2560,9 @@ struct rig_caps netrigctl_caps = .set_channel = netrigctl_set_channel, .get_channel = netrigctl_get_channel, .set_vfo_opt = netrigctl_set_vfo_opt, + //.set_trn = netrigctl_set_trn, + //.get_trn = netrigctl_get_trn, + .power2mW = netrigctl_power2mW, + .mW2power = netrigctl_mW2power, + }; diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index e1b9a65a..2e6813b4 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -4342,6 +4342,13 @@ declare_proto_rig(dump_state) fprintf(fout, "has_get_vfo=%d\n", rig->caps->get_vfo != NULL); fprintf(fout, "has_set_freq=%d\n", rig->caps->set_freq != NULL); fprintf(fout, "has_get_freq=%d\n", rig->caps->get_freq != NULL); + fprintf(fout, "has_set_conf=%d\n", rig->caps->set_conf != NULL); + fprintf(fout, "has_get_conf=%d\n", rig->caps->get_conf != NULL); + // for the future +// fprintf(fout, "has_set_trn=%d\n", rig->caps->set_trn != NULL); +// fprintf(fout, "has_get_trn=%d\n", rig->caps->get_trn != NULL); + fprintf(fout, "has_power2mW=%d\n", rig->caps->power2mW != NULL); + fprintf(fout, "has_mW2power=%d\n", rig->caps->mW2power != NULL); fprintf(fout, "timeout=%d\n", rig->caps->timeout); fprintf(fout, "done\n"); } commit 0b203c7e8f80f3190940d58a8df1f7a677db107b Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Apr 28 17:38:54 2021 -0500 Add transceive ability to dummy rig diff --git a/rigs/dummy/dummy.c b/rigs/dummy/dummy.c index 4cb66af5..b5da2d1e 100644 --- a/rigs/dummy/dummy.c +++ b/rigs/dummy/dummy.c @@ -67,6 +67,7 @@ struct dummy_priv_data int bank; value_t parms[RIG_SETTING_MAX]; int ant_option[4]; /* simulate 4 antennas */ + int trn; /* transceive */ channel_t *curr; /* points to vfo_a, vfo_b or mem[] */ @@ -1988,7 +1989,9 @@ static int dummy_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, static int dummy_set_trn(RIG *rig, int trn) { - ENTERFUNC; + struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; + + priv->trn = trn; RETURNFUNC(RIG_OK); } @@ -1996,8 +1999,9 @@ static int dummy_set_trn(RIG *rig, int trn) static int dummy_get_trn(RIG *rig, int *trn) { - ENTERFUNC; - *trn = RIG_TRN_OFF; + struct dummy_priv_data *priv = (struct dummy_priv_data *)rig->state.priv; + + *trn = priv->trn; RETURNFUNC(RIG_OK); } @@ -2123,7 +2127,7 @@ struct rig_caps dummy_caps = RIG_MODEL(RIG_MODEL_DUMMY), .model_name = "Dummy", .mfg_name = "Hamlib", - .version = "20210313.0", + .version = "20210428.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_OTHER, @@ -2288,7 +2292,7 @@ struct rig_caps dummy_no_vfo_caps = RIG_MODEL(RIG_MODEL_DUMMY_NOVFO), .model_name = "Dummy No VFO", .mfg_name = "Hamlib", - .version = "20210218.0", + .version = "20210428.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_OTHER, @@ -2313,7 +2317,7 @@ struct rig_caps dummy_no_vfo_caps = }, .scan_ops = DUMMY_SCAN, .vfo_ops = DUMMY_VFO_OP, - .transceive = RIG_TRN_OFF, + .transceive = RIG_TRN_RIG, .attenuator = { 10, 20, 30, RIG_DBLST_END, }, .preamp = { 10, RIG_DBLST_END, }, .rx_range_list1 = { { ----------------------------------------------------------------------- Summary of changes: rigs/dummy/dummy.c | 16 +++--- rigs/dummy/netrigctl.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++- tests/rigctl_parse.c | 7 +++ 3 files changed, 156 insertions(+), 7 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |