[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 0d6958781ded6093395b0
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2021-01-28 20:27:32
|
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 0d6958781ded6093395b0e31ea57ecaf3f9d8dd3 (commit) via 7838539a3b963eb1238d7407713a7669b57f280c (commit) via 4b41c0dbfc195cf4088cb82e8230490611f90c99 (commit) via 7b04640cea96e44c50b98b1b1d247c9d51fca0b8 (commit) via 03924db38cc37f2f766dae96d717f5567c254792 (commit) via 58feda1a4ae329e9a146c6c5eaf9a76d3821f0ec (commit) via b5a18c17320222ff5283e1718a95732b0721eb9a (commit) via 887b289920014a92787e01de634a736c3921d251 (commit) from f2b7893a2b81c00e7a9998b376b846a34bab1205 (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 0d6958781ded6093395b0e31ea57ecaf3f9d8dd3 Merge: 7838539a 58feda1a Author: Michael Black W9MDB <mdb...@ya...> Date: Thu Jan 28 14:25:42 2021 -0600 Merge branch 'master' of http://github.com/Hamlib/Hamlib commit 7838539a3b963eb1238d7407713a7669b57f280c Author: Michael Black W9MDB <mdb...@ya...> Date: Thu Jan 28 14:25:26 2021 -0600 Add __FILENAME__ macro diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index c90b5dbd..733bf5ac 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -24,6 +24,8 @@ #ifndef _RIG_H #define _RIG_H 1 +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) + #include <stdio.h> #include <stdarg.h> #include <inttypes.h> commit 4b41c0dbfc195cf4088cb82e8230490611f90c99 Author: Michael Black W9MDB <mdb...@ya...> Date: Thu Jan 28 12:24:22 2021 -0600 Let flrig use 5 second timeout from rig instead of overriding it diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index 9c452cc7..11a5b2a9 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -404,8 +404,6 @@ static int read_transaction(RIG *rig, char *xml, int xml_len) rig_debug(RIG_DEBUG_TRACE, "%s\n", __func__); - rs->rigport.timeout = 1000; // 1 second read string timeout - retry = 2; delims = "\n"; xml[0] = 0; diff --git a/rigs/dummy/flrig.h b/rigs/dummy/flrig.h index 70c84b0d..bcd35b6b 100644 --- a/rigs/dummy/flrig.h +++ b/rigs/dummy/flrig.h @@ -28,7 +28,7 @@ #include <sys/time.h> #endif -#define BACKEND_VER "20210123" +#define BACKEND_VER "20210128" #define EOM "\r" #define TRUE 1 commit 7b04640cea96e44c50b98b1b1d247c9d51fca0b8 Author: Michael Black W9MDB <mdb...@ya...> Date: Thu Jan 28 12:22:52 2021 -0600 Fix read_string timeout display value diff --git a/src/iofunc.c b/src/iofunc.c index 060b9d1c..c4eb2b35 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -713,10 +713,10 @@ int HAMLIB_API read_string(hamlib_port_t *p, dump_hex((unsigned char *) rxbuffer, total_count); rig_debug(RIG_DEBUG_WARN, - "%s(): Timed out %d.%d seconds after %d chars\n", + "%s(): Timed out %d.%03d seconds after %d chars\n", __func__, (int)elapsed_time.tv_sec, - (int)elapsed_time.tv_usec, + (int)elapsed_time.tv_usec/1000, total_count); return -RIG_ETIMEOUT; commit 03924db38cc37f2f766dae96d717f5567c254792 Author: Michael Black W9MDB <mdb...@ya...> Date: Thu Jan 28 10:25:05 2021 -0600 Modify __FILE__ to use __FILENAME__ macro to avoid full path in misc.c diff --git a/src/misc.h b/src/misc.h index d4ff18e2..085ceb62 100644 --- a/src/misc.h +++ b/src/misc.h @@ -138,10 +138,11 @@ extern HAMLIB_EXPORT(int) parse_hoststr(char *host, char hoststr[256], char port # endif #endif +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) void errmsg(int err, char *s, const char *func, const char *file, int line); -#define ERRMSG(err, s) errmsg(err, s, __func__, __FILE__, __LINE__) -#define ENTERFUNC rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s entered\n", __FILE__, __LINE__, __func__) -#define RETURNFUNC(rc) {rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s return\n", __FILE__, __LINE__, __func__);return rc;} +#define ERRMSG(err, s) errmsg(err, s, __func__, __FILENAME__, __LINE__) +#define ENTERFUNC rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s entered\n", __FILENAME__, __LINE__, __func__) +#define RETURNFUNC(rc) {rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s return\n", __FILENAME__, __LINE__, __func__);return rc;} #define CACHE_RESET {\ elapsed_ms(&rig->state.cache.time_freq, HAMLIB_ELAPSED_INVALIDATE);\ commit 58feda1a4ae329e9a146c6c5eaf9a76d3821f0ec Merge: f2b7893a b5a18c17 Author: Michael Black <mdb...@ya...> Date: Wed Jan 27 12:59:43 2021 -0600 Merge pull request #519 from code-posse/master SatEL motion bugfix commit b5a18c17320222ff5283e1718a95732b0721eb9a Merge: 887b2899 f2b7893a Author: Joshua Lynch <jo...@co...> Date: Wed Jan 27 12:44:07 2021 -0600 merged upstream/master into master commit 887b289920014a92787e01de634a736c3921d251 Author: Joshua Lynch <jo...@co...> Date: Wed Jan 27 12:40:18 2021 -0600 fixed state bug. reconnecting would disable motion every other connect. diff --git a/rotators/satel/satel.c b/rotators/satel/satel.c index 6a0e12db..e350a1f7 100644 --- a/rotators/satel/satel.c +++ b/rotators/satel/satel.c @@ -115,25 +115,64 @@ struct satel_stat }; -static int satel_read_status(ROT *rot, satel_stat_t *stat) +static int satel_cmd(ROT *rot, char *cmd, int cmdlen, char *res, int reslen) { - char resbuf[BUF_SIZE]; - char *p; int ret; struct rot_state *rs; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + rs = &rot->state; - - // XXX skip for now - for (int i = 0; i < 3; i++) + rig_flush(&rs->rotport); + + ret = write_block(&rs->rotport, cmd, cmdlen); + if (ret != RIG_OK) + return ret; + + if (reslen > 0 && res != NULL) { - ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1); + ret = read_string(&rs->rotport, res, reslen, "\n", 1); if (ret < 0) return ret; } + + return RIG_OK; +} + + +static int satel_read_status(ROT *rot, satel_stat_t *stat) +{ + char resbuf[BUF_SIZE]; + char *p; + int ret; + struct rot_state *rs; + + + rs = &rot->state; + + + + // read motion state + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1); + if (ret < 0) + return ret; + + stat->motion_enabled = strcmp(resbuf, "Motion ENABLED") == 0 ? true : false; + + // XXX skip mode + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1); + if (ret < 0) + return ret; + + // XXX skip time + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1); + if (ret < 0) + return ret; + // read azimuth line ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1); if (ret < 0) @@ -152,44 +191,32 @@ static int satel_read_status(ROT *rot, satel_stat_t *stat) p[3] = '\0'; stat->el = (int)strtof(p, NULL); - // XXX skip for now - for (int i = 0; i < 2; i++) - { - ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1); - if (ret < 0) - return ret; - } + // skip blank line + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1); + if (ret < 0) + return ret; + + // XXX skip stored position count + ret = read_string(&rs->rotport, resbuf, BUF_SIZE, "\n", 1); + if (ret < 0) + return ret; + return RIG_OK; } -static int satel_cmd(ROT *rot, char *cmd, int cmdlen, char *res, int reslen) +static int satel_get_status(ROT *rot, satel_stat_t *stat) { int ret; - struct rot_state *rs; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - - rs = &rot->state; - - rig_flush(&rs->rotport); - - ret = write_block(&rs->rotport, cmd, cmdlen); + ret = satel_cmd(rot, "z", 1, NULL, 0); if (ret != RIG_OK) return ret; - if (reslen > 0 && res != NULL) - { - ret = read_string(&rs->rotport, res, reslen, "\n", 1); - if (ret < 0) - return ret; - } - - return RIG_OK; + return satel_read_status(rot, stat); } @@ -217,11 +244,6 @@ static int satel_rot_open(ROT *rot) if (ret != RIG_OK) return ret; - // enable motion - ret = satel_cmd(rot, "g", 1, NULL, 0); - if (ret != RIG_OK) - return ret; - return RIG_OK; } @@ -236,6 +258,17 @@ static int satel_rot_set_position(ROT *rot, azimuth_t az, elevation_t el) rig_debug(RIG_DEBUG_VERBOSE, "%s called: %.2f %.2f\n", __func__, az, el); + + ret = satel_get_status(rot, &stat); + if (ret < 0) + return ret; + + if (stat.motion_enabled == false) + { + ret = satel_cmd(rot, "g", 1, NULL, 0); + if (ret != RIG_OK) + return ret; + } snprintf(cmdbuf, BUF_SIZE, "p%d %d\r\n", (int)az, (int)el); ret = satel_cmd(rot, cmdbuf, strlen(cmdbuf), NULL, 0); @@ -261,11 +294,7 @@ static int satel_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - ret = satel_cmd(rot, "z", 1, NULL, 0); - if (ret != RIG_OK) - return ret; - - ret = satel_read_status(rot, &stat); + ret = satel_get_status(rot, &stat); if (ret < 0) return ret; ----------------------------------------------------------------------- Summary of changes: include/hamlib/rig.h | 2 + rigs/dummy/flrig.c | 2 - rigs/dummy/flrig.h | 2 +- rotators/satel/satel.c | 113 +++++++++++++++++++++++++++++++------------------ src/iofunc.c | 4 +- src/misc.h | 7 +-- 6 files changed, 80 insertions(+), 50 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |