[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 5817096b00b64e30a19f0
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2021-03-20 03:57:37
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via 5817096b00b64e30a19f000c879ec7fb913eeacf (commit) via 6eee309b56f1815cc291051254e2de66447bf480 (commit) via 7662a6235ab2170c8a9ac4c2c1f837efa315ffea (commit) via dee6bd652463e40cbc7ae5cef6afa3a130fcd904 (commit) via 8cd4a2e3c4cf2ae8fa35418e59e89663100ab2c7 (commit) via ab0ae7d6b13aec5237ccadfeb2d075a7522449f0 (commit) via 42ebd658113adaad956c19e660498607a45a4f5e (commit) via 257ae409d2ca53089c33cd78d2f7c6d2be08344e (commit) from c1277b170e0444b1de1d55012e6024c983a5e24e (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 5817096b00b64e30a19f000c879ec7fb913eeacf Merge: 6eee309b 7662a623 Author: Michael Black W9MDB <mdb...@ya...> Date: Fri Mar 19 22:57:08 2021 -0500 Merge branch 'master' of https://github.com/Hamlib/Hamlib commit 6eee309b56f1815cc291051254e2de66447bf480 Author: Michael Black W9MDB <mdb...@ya...> Date: Fri Mar 19 22:56:18 2021 -0500 Improve rig_get_version and hamlib_version2 information to include commit information https://github.com/Hamlib/Hamlib/issues/617 diff --git a/src/rig.c b/src/rig.c index aa788610..1452d96f 100644 --- a/src/rig.c +++ b/src/rig.c @@ -72,6 +72,7 @@ #include "gpio.h" #include "misc.h" #include "sprintflst.h" +#include "../tests/hamlibdatetime.h" /** * \brief Hamlib release number @@ -86,7 +87,7 @@ const char *hamlib_license = "LGPL"; //! @cond Doxygen_Suppress const char hamlib_version[21] = "Hamlib " PACKAGE_VERSION; -const char *hamlib_version2 = "Hamlib " PACKAGE_VERSION; +const char *hamlib_version2 = "Hamlib " PACKAGE_VERSION " " HAMLIBDATETIME; //! @endcond struct rig_caps caps_test; diff --git a/tests/ampctl.c b/tests/ampctl.c index 787cbbde..5efeacfd 100644 --- a/tests/ampctl.c +++ b/tests/ampctl.c @@ -278,8 +278,7 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); - rig_debug(RIG_DEBUG_VERBOSE, "ampctl %s\nLast commit was %s\n", hamlib_version, - HAMLIBDATETIME); + rig_debug(RIG_DEBUG_VERBOSE, "ampctl %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to <ham...@li...>\n\n"); diff --git a/tests/ampctl_parse.c b/tests/ampctl_parse.c index 4c7eee00..21f7beae 100644 --- a/tests/ampctl_parse.c +++ b/tests/ampctl_parse.c @@ -1436,7 +1436,7 @@ int ampctl_parse(AMP *my_amp, FILE *fin, FILE *fout, char *argv[], int argc) void version() { - printf("ampctl(d), %s\n\n", hamlib_version); + printf("ampctl(d), %s\n\n", hamlib_version2); printf("%s\n", hamlib_copyright); } diff --git a/tests/ampctld.c b/tests/ampctld.c index 730c086e..12b6e2a5 100644 --- a/tests/ampctld.c +++ b/tests/ampctld.c @@ -309,7 +309,7 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); - rig_debug(RIG_DEBUG_VERBOSE, "ampctld, %s\n", hamlib_version); + rig_debug(RIG_DEBUG_VERBOSE, "ampctld, %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to <ham...@li...>\n\n"); diff --git a/tests/rigctl.c b/tests/rigctl.c index e982dbce..126f5275 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -177,7 +177,7 @@ int main(int argc, char *argv[]) exit(0); case 'V': - printf("rigctl %s\nLast commit was %s\n", hamlib_version, HAMLIBDATETIME); + printf("rigctl %s\n", hamlib_version2); exit(0); case 'm': @@ -433,8 +433,7 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); - rig_debug(RIG_DEBUG_VERBOSE, "rigctl %s\nLast commit was %s\n", hamlib_version, - HAMLIBDATETIME); + rig_debug(RIG_DEBUG_VERBOSE, "rigctl %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to <ham...@li...>\n\n"); diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 729382ba..d136de7d 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -1732,7 +1732,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, void version() { - printf("rigctl(d), %s\n\n", hamlib_version); + printf("rigctl(d), %s\n\n", hamlib_version2); printf("%s\n", hamlib_copyright); } diff --git a/tests/rigctld.c b/tests/rigctld.c index 46ba0275..2cc7c262 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -286,7 +286,7 @@ int main(int argc, char *argv[]) exit(0); case 'V': - printf("rigctl %s\nLast commit was %s\n", hamlib_version, HAMLIBDATETIME); + printf("rigctl %s\n", hamlib_version2); exit(0); case 'm': @@ -556,8 +556,7 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); - rig_debug(RIG_DEBUG_VERBOSE, "rigctld %s\nLast commit was %s\n", hamlib_version, - HAMLIBDATETIME); + rig_debug(RIG_DEBUG_VERBOSE, "rigctld %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to <ham...@li...>\n\n"); diff --git a/tests/rigmem.c b/tests/rigmem.c index c8ab19a3..4d422747 100644 --- a/tests/rigmem.c +++ b/tests/rigmem.c @@ -233,7 +233,7 @@ int main(int argc, char *argv[]) rig_set_debug(verbose < 2 ? RIG_DEBUG_WARN : verbose); - rig_debug(RIG_DEBUG_VERBOSE, "rigmem, %s\n", hamlib_version); + rig_debug(RIG_DEBUG_VERBOSE, "rigmem, %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to " "<ham...@li...>\n\n"); @@ -406,7 +406,7 @@ int main(int argc, char *argv[]) void version() { - printf("rigmem, %s\n\n", hamlib_version); + printf("rigmem, %s\n\n", hamlib_version2); printf("%s\n", hamlib_copyright); } diff --git a/tests/rigsmtr.c b/tests/rigsmtr.c index 4a99570f..b992dd91 100644 --- a/tests/rigsmtr.c +++ b/tests/rigsmtr.c @@ -242,7 +242,7 @@ int main(int argc, char *argv[]) rig_set_debug(verbose < 2 ? RIG_DEBUG_WARN : verbose); - rig_debug(RIG_DEBUG_VERBOSE, "rigsmtr, %s\n", hamlib_version); + rig_debug(RIG_DEBUG_VERBOSE, "rigsmtr, %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to <ham...@li...>\n\n"); @@ -409,7 +409,7 @@ int main(int argc, char *argv[]) void version() { - printf("rigsmtr, %s\n\n", hamlib_version); + printf("rigsmtr, %s\n\n", hamlib_version2); printf("%s\n", hamlib_copyright); } diff --git a/tests/rigswr.c b/tests/rigswr.c index 88d89d4c..6ceec705 100644 --- a/tests/rigswr.c +++ b/tests/rigswr.c @@ -231,7 +231,7 @@ int main(int argc, char *argv[]) rig_set_debug(verbose < 2 ? RIG_DEBUG_WARN : verbose); - rig_debug(RIG_DEBUG_VERBOSE, "rigswr, %s\n", hamlib_version); + rig_debug(RIG_DEBUG_VERBOSE, "rigswr, %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to <ham...@li...>\n\n"); @@ -351,7 +351,7 @@ int main(int argc, char *argv[]) void version() { - printf("rigswr, %s\n\n", hamlib_version); + printf("rigswr, %s\n\n", hamlib_version2); printf("%s\n", hamlib_copyright); } diff --git a/tests/rotctl.c b/tests/rotctl.c index 633d052c..9a222dc0 100644 --- a/tests/rotctl.c +++ b/tests/rotctl.c @@ -305,8 +305,7 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); - rig_debug(RIG_DEBUG_VERBOSE, "rotctl %s\nLast commit was %s\n", hamlib_version, - HAMLIBDATETIME); + rig_debug(RIG_DEBUG_VERBOSE, "rotctl %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to <ham...@li...>\n\n"); diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index 1c960280..6f14a808 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -1507,7 +1507,7 @@ int rotctl_parse(ROT *my_rot, FILE *fin, FILE *fout, char *argv[], int argc, void version() { - printf("rotctl(d), %s\n\n", hamlib_version); + printf("rotctl(d), %s\n\n", hamlib_version2); printf("%s\n", hamlib_copyright); } diff --git a/tests/rotctld.c b/tests/rotctld.c index 8b28c3bb..e7f81f9f 100644 --- a/tests/rotctld.c +++ b/tests/rotctld.c @@ -322,7 +322,7 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); - rig_debug(RIG_DEBUG_VERBOSE, "rotctld, %s\n", hamlib_version); + rig_debug(RIG_DEBUG_VERBOSE, "rotctld, %s\n", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to <ham...@li...>\n\n"); commit 7662a6235ab2170c8a9ac4c2c1f837efa315ffea Merge: dee6bd65 8cd4a2e3 Author: Michael Black <mdb...@ya...> Date: Fri Mar 19 15:02:36 2021 -0500 Merge pull request #619 from fillods/prm80_FW_V5 Prm80 fw v5 commit dee6bd652463e40cbc7ae5cef6afa3a130fcd904 Author: Michael Black W9MDB <mdb...@ya...> Date: Fri Mar 19 14:59:42 2021 -0500 Add SA command handling to rigctlcom.c https://github.com/Hamlib/Hamlib/issues/620 diff --git a/tests/rigctlcom.c b/tests/rigctlcom.c index f7b1d77f..e78e2b4c 100644 --- a/tests/rigctlcom.c +++ b/tests/rigctlcom.c @@ -878,6 +878,11 @@ static int handle_ts2000(void *arg) return write_block2((void *)__func__, &my_com, response, strlen(response)); } // Now some commands to set things + else if (strncmp(arg,"SA",2) == 0) + { + // todo -- make rigs changes based on TS-2000 bit flags + return RIG_OK; + } else if (strcmp(arg, "TX;") == 0) { return rig_set_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A), 1); commit 8cd4a2e3c4cf2ae8fa35418e59e89663100ab2c7 Author: Stephane Fillod <fi...@us...> Date: Fri Mar 19 20:51:54 2021 +0100 prm80: remove the "A" command that won't make it into FW V5 diff --git a/rigs/prm80/pysimulprm80.py b/rigs/prm80/pysimulprm80.py index 0a2627a6..dbb50c50 100755 --- a/rigs/prm80/pysimulprm80.py +++ b/rigs/prm80/pysimulprm80.py @@ -51,7 +51,6 @@ class Prm80Simul: 'C' : self.tch_Chanlist, 'R' : self.tch_Rfreq, 'E' : self.tch_Estate, - 'A' : self.tch_Astatus, '#' : self.tch_diese, '*' : self.tch_autre, } @@ -187,10 +186,6 @@ class Prm80Simul: rssi ).encode()) - def tch_Astatus(self): - """ Print value of RSSI, squelch and transmit status. V5. """ - self.pty_write(b'1801') - def tch_Chanlist(self): """ Print channels list """ self.pty_write(b'Channels list :\r\n00 : 8464 84\r\n01 : 81B0 00\r\n02 : 8464 0C') commit ab0ae7d6b13aec5237ccadfeb2d075a7522449f0 Author: Michael Black W9MDB <mdb...@ya...> Date: Fri Mar 19 11:19:15 2021 -0500 https://github.com/Hamlib/Hamlib/issues/618 diff --git a/tests/rigctlcom.c b/tests/rigctlcom.c index 370d774f..f7b1d77f 100644 --- a/tests/rigctlcom.c +++ b/tests/rigctlcom.c @@ -221,7 +221,7 @@ int main(int argc, char *argv[]) char conf_parms[MAXCONFLEN] = ""; int status; - printf("rigctlcom Version 1.1\n"); + printf("rigctlcom Version 1.2\n"); while (1) { @@ -464,7 +464,7 @@ int main(int argc, char *argv[]) rig_set_debug(verbose); - rig_debug(RIG_DEBUG_VERBOSE, "%s, %s\n", "rigctlcom", hamlib_version); + rig_debug(RIG_DEBUG_VERBOSE, "%s, %s\n", "rigctlcom", hamlib_version2); rig_debug(RIG_DEBUG_VERBOSE, "%s", "Report bugs to <ham...@li...>\n\n"); @@ -873,6 +873,7 @@ static int handle_ts2000(void *arg) { char response[32]; + rig_set_ptt(my_rig, vfo_fixup(my_rig, RIG_VFO_A), 0); snprintf(response, sizeof(response), "RX0;"); return write_block2((void *)__func__, &my_com, response, strlen(response)); } commit 42ebd658113adaad956c19e660498607a45a4f5e Author: Stephane Fillod <fi...@us...> Date: Mon Mar 15 15:13:55 2021 +0100 prm80: protcol evolution in firmware V5 - RSSI appended to system state ("E" command) - new ranging for the volume value - implement a cache handling for the system state (not V5 specific) diff --git a/rigs/prm80/prm80.c b/rigs/prm80/prm80.c index 7a05250c..4f13dcd7 100644 --- a/rigs/prm80/prm80.c +++ b/rigs/prm80/prm80.c @@ -48,6 +48,12 @@ #define CHAN_MIN 0 #define CHAN_MAX 99 +// "E" system state is cached for this time (ms) +#define PRM80_CACHE_TIMEOUT 200 + +// Length (in bytes) of the response to the "E" command +#define CMD_E_RSP_LEN 22 + #define RX_IF_OFFSET MHz(21.4) // The rig's PLL only deals with freq in Hz divided by this value @@ -72,7 +78,7 @@ MessageAide: DB "H",0Dh,0Ah DB " [1] a [5] = Show 80c552 port state P1 to P5.",0Dh,0Ah DB " [C] = Print channels list.",0Dh,0Ah DB " [D] = Set system byte.",0Dh,0Ah - DB " [E] = Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq).",0Dh,0Ah + DB " [E] = Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq,RSSI).",0Dh,0Ah DB " [F] = Set squelch.",0Dh,0Ah DB " [H] = Print this help page.",0Dh,0Ah DB " [I] = Erase and init RAM and EEPROM.",0Dh,0Ah @@ -98,7 +104,7 @@ MessageAide: DB "H",0Dh,0Ah [D] = Set system byte. [E] = Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX - freq). + freq-RSSI). [F] = Set squelch. [H] = Print this help page. [K] = Set lock byte. @@ -139,6 +145,13 @@ MessageAide: DB "H",0Dh,0Ah * ********************************************************************* */ +static void prm80_force_cache_timeout(RIG *rig) +{ + struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv; + + rig_force_cache_timeout(&priv->status_tv); +} + /* * Read a prompt terminated by delimiter, then write an optional string s. */ @@ -319,6 +332,8 @@ int prm80_reset(RIG *rig, reset_t reset) return retval; } + prm80_force_cache_timeout(rig); + return RIG_OK; } @@ -395,6 +410,8 @@ int prm80_set_freq(RIG *rig, vfo_t vfo, freq_t freq) priv->rx_freq = freq; } + prm80_force_cache_timeout(rig); + return rc; } @@ -416,6 +433,8 @@ int prm80_set_split_freq(RIG *rig, vfo_t vfo, freq_t tx_freq) priv->tx_freq = tx_freq; } + prm80_force_cache_timeout(rig); + return rc; } @@ -526,6 +545,8 @@ int prm80_set_mem(RIG *rig, vfo_t vfo, int ch) sprintf(chbuf, "%02u", (unsigned)ch); + prm80_force_cache_timeout(rig); + // Send command, no answer expected from rig except ">" prompt return prm80_transaction(rig, "N", chbuf, 1); @@ -579,7 +600,7 @@ static unsigned hhtoi(const char *p) /** * Get system state [E] from rig into \a statebuf */ -static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf) +static int prm80_do_read_system_state(hamlib_port_t *rigport, char *statebuf) { char *p; int ret; @@ -596,7 +617,7 @@ static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf) } // The response length is fixed - ret = read_block(rigport, statebuf, 20); + ret = read_block(rigport, statebuf, CMD_E_RSP_LEN); if (ret < 0) { @@ -608,10 +629,10 @@ static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf) statebuf[ret] = '\0'; } - if (ret < 20) + if (ret < CMD_E_RSP_LEN) { - rig_debug(RIG_DEBUG_ERR, "%s: len=%d < 20, statebuf='%s'\n", __func__, - ret, statebuf); + rig_debug(RIG_DEBUG_ERR, "%s: len=%d < %d, statebuf='%s'\n", __func__, + ret, CMD_E_RSP_LEN, statebuf); RETURNFUNC(-RIG_EPROTO); } @@ -620,8 +641,9 @@ static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf) if (p) { int left_to_read = (p - statebuf) + 1; - memmove(statebuf, p + 1, 20 - left_to_read); - ret = read_block(rigport, statebuf + 20 - left_to_read, left_to_read); + memmove(statebuf, p + 1, CMD_E_RSP_LEN - left_to_read); + ret = read_block(rigport, statebuf + CMD_E_RSP_LEN - left_to_read, + left_to_read); if (ret < 0) { @@ -629,16 +651,45 @@ static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf) } else { - statebuf[20] = '\0'; + statebuf[CMD_E_RSP_LEN] = '\0'; } rig_debug(RIG_DEBUG_WARN, "%s: len=%d, statebuf='%s'\n", __func__, ret, statebuf); } + prm80_wait_for_prompt(rigport); + return RIG_OK; } +/* + * Layer to handle the cache to Get system state [E] + */ +static int prm80_read_system_state(RIG *rig, char *statebuf) +{ + struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv; + int ret = RIG_OK; + + if (rig_check_cache_timeout(&priv->status_tv, PRM80_CACHE_TIMEOUT)) + { + ret = prm80_do_read_system_state(&rig->state.rigport, statebuf); + + if (ret == RIG_OK) + { + strcpy(priv->cached_statebuf, statebuf); + + /* update cache date */ + gettimeofday(&priv->status_tv, NULL); + } + } + else + { + strcpy(statebuf, priv->cached_statebuf); + } + + return ret; +} /* * prm80_get_channel @@ -647,7 +698,6 @@ static int prm80_read_system_state(hamlib_port_t *rigport, char *statebuf) int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) { struct prm80_priv_data *priv = (struct prm80_priv_data *)rig->state.priv; - struct rig_state *rs = &rig->state; char statebuf[BUFSZ]; int ret, chanstate, mode_byte, lock_byte; @@ -661,15 +711,15 @@ int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) } } - ret = prm80_read_system_state(&rs->rigport, statebuf); + ret = prm80_read_system_state(rig, statebuf); if (ret != RIG_OK) { return ret; } - /* (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq). */ - /* Examples: 1240080AFF0033F02D40 or 14000C00FD0079708020 */ + /* (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq-RSSI). */ + /* Examples: 1240080AFF0033F02D40__ or 14000C00FD0079708020__ */ /* Current mode: ; b0: Squelch b1: power @@ -698,10 +748,13 @@ int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) // squelch is in low nibble chan->levels[LVL_SQL].f = ((float)(hhtoi(statebuf + 6) & 0x0F)) / 15.; - // (remote control) volume is in high nibble - chan->levels[LVL_AF].f = ((float)(hhtoi(statebuf + 8) >> 4)) / 15.; + // volume is hex "00" .. "10" + chan->levels[LVL_AF].f = ((float)hhtoi(statebuf + 8)) / 16.; chan->levels[LVL_RFPOWER].f = (mode_byte & 0x02) ? 1.0 : 0.0; + // new in FW V5 + chan->levels[LVL_RAWSTR].i = hhtoi(statebuf + 20); + chan->funcs = 0; chan->funcs |= (chanstate & 0x02) ? RIG_FUNC_REV : 0; @@ -734,8 +787,6 @@ int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) //return -RIG_ENIMPL; } - prm80_wait_for_prompt(&rs->rigport); - return RIG_OK; } @@ -904,6 +955,8 @@ int prm80_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan) } } + prm80_force_cache_timeout(rig); + return RIG_OK; } @@ -929,6 +982,8 @@ int prm80_set_func(RIG *rig, vfo_t vfo, setting_t func, int status) ret = -RIG_EINVAL; } + prm80_force_cache_timeout(rig); + return ret; } @@ -974,7 +1029,8 @@ int prm80_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) switch (level) { case RIG_LEVEL_AF: - sprintf(buf, "%02u", (unsigned)(val.f * 15)); + // Unlike system state, volume decimal + sprintf(buf, "%02u", (unsigned)(val.f * 16)); return prm80_transaction(rig, "O", buf, 1); @@ -991,15 +1047,13 @@ int prm80_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) ; b6: Debouncing in effect b7: LCD refresh */ // Perform a "Read-Modify-Write" of the mode_byte - ret = prm80_read_system_state(&rig->state.rigport, buf); + ret = prm80_read_system_state(rig, buf); if (ret != RIG_OK) { return ret; } - prm80_wait_for_prompt(&rig->state.rigport); - mode_byte = hhtoi(buf); mode_byte &= ~0x02; mode_byte |= (val.f == 0.) ? 0 : 0x02; @@ -1013,6 +1067,8 @@ int prm80_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) return -RIG_EINVAL; } + prm80_force_cache_timeout(rig); + return RIG_OK; } @@ -1078,48 +1134,6 @@ static int prm80_get_rawstr_RAM(RIG *rig, value_t *val) } #endif -/* - * get_level RIG_LEVEL_RAWSTR - * - * NB : requires a V5 firmware! - */ -static int prm80_get_rawstr(RIG *rig, value_t *val) -{ - char buf[BUFSZ]; - struct rig_state *rs = &rig->state; - int ret; - - // Get rid of possible prompt sent by the rig - rig_flush(&rs->rigport); - - /* [A] = RSSI */ - ret = write_block(&rs->rigport, "A", 1); - - if (ret < 0) - { - RETURNFUNC(ret); - } - - // The response length is fixed - ret = read_block(&rs->rigport, buf, 4); - - if (ret < 0) - { - return ret; - } - - if (ret >= 0) - { - buf[ret] = '\0'; - } - - val->i = hhtoi(buf); - - prm80_wait_for_prompt(&rs->rigport); - - return RIG_OK; -} - /* * prm80_get_level * Assumes rig!=NULL @@ -1129,12 +1143,6 @@ int prm80_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) int ret; channel_t chan; - // Get rawstr apart, it is not read from system state - if (level == RIG_LEVEL_RAWSTR) - { - return prm80_get_rawstr(rig, val); - } - memset(&chan, 0, sizeof(chan)); chan.vfo = RIG_VFO_CURR; @@ -1147,6 +1155,11 @@ int prm80_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) switch (level) { + case RIG_LEVEL_RAWSTR: + val->i = chan.levels[LVL_RAWSTR].i; + + break; + case RIG_LEVEL_AF: val->f = chan.levels[LVL_AF].f; @@ -1176,8 +1189,7 @@ int prm80_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) char statebuf[BUFSZ]; int ret, mode_byte; - // TODO use command 'A' which is faster, but not in V4 - ret = prm80_read_system_state(&rig->state.rigport, statebuf); + ret = prm80_read_system_state(rig, statebuf); if (ret != RIG_OK) { @@ -1189,8 +1201,6 @@ int prm80_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) // TX mode on? *ptt = (mode_byte & 0x08) ? RIG_PTT_ON : RIG_PTT_OFF; - prm80_wait_for_prompt(&rig->state.rigport); - return RIG_OK; } @@ -1199,8 +1209,7 @@ int prm80_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) char statebuf[BUFSZ]; int ret, mode_byte; - // TODO use command 'A' which is faster, but not in V4 - ret = prm80_read_system_state(&rig->state.rigport, statebuf); + ret = prm80_read_system_state(rig, statebuf); if (ret != RIG_OK) { @@ -1212,8 +1221,6 @@ int prm80_get_dcd(RIG *rig, vfo_t vfo, dcd_t *dcd) // Squelch open? *dcd = (mode_byte & 0x04) ? RIG_DCD_ON : RIG_DCD_OFF; - prm80_wait_for_prompt(&rig->state.rigport); - return RIG_OK; } diff --git a/rigs/prm80/prm80.h b/rigs/prm80/prm80.h index 4728b7c9..c2c33f04 100644 --- a/rigs/prm80/prm80.h +++ b/rigs/prm80/prm80.h @@ -24,7 +24,7 @@ #include <hamlib/rig.h> -#define BACKEND_VER "20210306" +#define BACKEND_VER "20210315" #define PRM80_MEM_CAP { \ .freq = 1, \ @@ -37,6 +37,8 @@ struct prm80_priv_data freq_t rx_freq; /* last RX freq set */ freq_t tx_freq; /* last TX freq set */ split_t split; /* emulated split on/off */ + struct timeval status_tv; /* date of last "E" command */ + char cached_statebuf[32]; /* response of last "E" command */ }; int prm80_init(RIG *rig); diff --git a/rigs/prm80/pysimulprm80.py b/rigs/prm80/pysimulprm80.py index 6ed1e8d6..0a2627a6 100755 --- a/rigs/prm80/pysimulprm80.py +++ b/rigs/prm80/pysimulprm80.py @@ -59,7 +59,7 @@ class Prm80Simul: self.ChanNum = 0 self.LockByte = 0 self.Squelch = 0 - self.Volume = 0xff + self.Volume = 0x10 self.ModeByte = 0x16 self.ChanState = 0x0c self.MaxChan = 80 @@ -172,17 +172,19 @@ class Prm80Simul: self.pty_write(b'\r\n') def tch_Estate(self): - """ Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq) """ - #self.pty_write(b'16000C00FF0079708020') - self.pty_write('{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}{:04X}{:04X}'.format( + """ Show system state (Mode-Chan-Chanstate-Sql-Vol-Lock-RX freq-TX freq-RSSI) (FW V5)""" + #self.pty_write(b'16000C0010007970802018') + rssi=24 + self.pty_write('{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}{:04X}{:04X}{:02X}'.format( self.ModeByte, self.ChanNum, self.ChanState, - self.Squelch, + self.Squelch, # low nibble self.Volume, self.LockByte, self.RxPLL, - self.TxPLL + self.TxPLL, + rssi ).encode()) def tch_Astatus(self): commit 257ae409d2ca53089c33cd78d2f7c6d2be08344e Author: Stephane Fillod <fi...@us...> Date: Mon Mar 15 14:54:40 2021 +0100 prm80: fix SQL parsing diff --git a/rigs/prm80/prm80.c b/rigs/prm80/prm80.c index 506a7c6f..7a05250c 100644 --- a/rigs/prm80/prm80.c +++ b/rigs/prm80/prm80.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> /* String function definitions */ #include <unistd.h> /* UNIX standard function definitions */ +#include <ctype.h> #include <math.h> #include "hamlib/rig.h" @@ -557,15 +558,22 @@ int prm80_get_mem(RIG *rig, vfo_t vfo, int *ch) /* * Convert first two hexadecimal digit to integer */ -static int hhtoi(const char *p) +static unsigned hhtoi(const char *p) { char buf[4]; + // it has to be hex digits + if (!isxdigit(p[0]) || !isxdigit(p[1])) + { + rig_debug(RIG_DEBUG_ERR, "%s: unexpected content '%s'\n", __func__, p); + return 0; + } + buf[0] = p[0]; buf[1] = p[1]; buf[2] = '\0'; - return (int)strtol(buf, NULL, 16); + return (unsigned)strtol(buf, NULL, 16); } /** @@ -688,8 +696,9 @@ int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) (chanstate & 0x04) ? RIG_RPT_SHIFT_PLUS : RIG_RPT_SHIFT_NONE; chan->flags = (chanstate & 0x08) ? RIG_CHFLAG_SKIP : 0; - // cppcheck-suppress * - chan->levels[LVL_SQL].f = ((float)(hhtoi(statebuf + 6) >> 4)) / 15.; + // squelch is in low nibble + chan->levels[LVL_SQL].f = ((float)(hhtoi(statebuf + 6) & 0x0F)) / 15.; + // (remote control) volume is in high nibble chan->levels[LVL_AF].f = ((float)(hhtoi(statebuf + 8) >> 4)) / 15.; chan->levels[LVL_RFPOWER].f = (mode_byte & 0x02) ? 1.0 : 0.0; ----------------------------------------------------------------------- Summary of changes: rigs/prm80/prm80.c | 178 ++++++++++++++++++++++++--------------------- rigs/prm80/prm80.h | 4 +- rigs/prm80/pysimulprm80.py | 19 ++--- src/rig.c | 3 +- tests/ampctl.c | 3 +- tests/ampctl_parse.c | 2 +- tests/ampctld.c | 2 +- tests/rigctl.c | 5 +- tests/rigctl_parse.c | 2 +- tests/rigctlcom.c | 10 ++- tests/rigctld.c | 5 +- tests/rigmem.c | 4 +- tests/rigsmtr.c | 4 +- tests/rigswr.c | 4 +- tests/rotctl.c | 3 +- tests/rotctl_parse.c | 2 +- tests/rotctld.c | 2 +- 17 files changed, 135 insertions(+), 117 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |