From fc0fc1c67a5332a8ad2b55caddf288f2797a4b4e Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 10 Nov 2022 17:51:44 -0600 Subject: [PATCH] Fix rotctld dumpcaps to expose client rot_type instead of Other --- rigs/dummy/netrotctl.c | 19 ++++++++++++++++++- tests/rotctl.c | 16 ++++++++-------- tests/rotctl_parse.c | 17 ++++++++++++++++- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/rigs/dummy/netrotctl.c b/rigs/dummy/netrotctl.c index 16b6c22e6..aaf657ef1 100644 --- a/rigs/dummy/netrotctl.c +++ b/rigs/dummy/netrotctl.c @@ -144,7 +144,7 @@ static int netrotctl_open(ROT *rot) } rs->max_el = rot->caps->max_el = atof(buf); - + ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", sizeof("\n"), 0, 1); @@ -155,6 +155,23 @@ static int netrotctl_open(ROT *rot) rs->south_zero = atoi(buf); + // Prot 1 is tag=value format + if (prot_ver >= 1) + { + ret = read_string(&rot->state.rotport, (unsigned char *) buf, BUF_MAX, "\n", + sizeof("\n"), 0, 1); + + if (ret <= 0) + { + return (ret < 0) ? ret : -RIG_EPROTO; + } + + if (strstr(buf, "AzEl")) { rot->caps->rot_type = ROT_TYPE_AZEL; } + else if (strstr(buf, "Az")) { rot->caps->rot_type = ROT_TYPE_AZIMUTH; } + else if (strstr(buf, "El")) { rot->caps->rot_type = ROT_TYPE_ELEVATION; } + } + + return RIG_OK; } diff --git a/tests/rotctl.c b/tests/rotctl.c index f7c74c45c..f8dd99aa3 100644 --- a/tests/rotctl.c +++ b/tests/rotctl.c @@ -369,6 +369,14 @@ int main(int argc, char *argv[]) rot_token_foreach(my_rot, print_conf_list, (rig_ptr_t)my_rot); } + retcode = rot_open(my_rot); + + if (retcode != RIG_OK) + { + fprintf(stderr, "rot_open: error = %s \n", rigerror(retcode)); + exit(2); + } + /* * Print out capabilities, and exits immediately as we may be interested * only in caps, and rig_open may fail. @@ -380,14 +388,6 @@ int main(int argc, char *argv[]) exit(0); } - retcode = rot_open(my_rot); - - if (retcode != RIG_OK) - { - fprintf(stderr, "rot_open: error = %s \n", rigerror(retcode)); - exit(2); - } - my_rot->state.az_offset = az_offset; my_rot->state.el_offset = el_offset; diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index 1a7c03d60..daeff767d 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -2363,7 +2363,7 @@ declare_proto_rot(dump_state) /* * - Protocol version */ -#define ROTCTLD_PROT_VER 0 +#define ROTCTLD_PROT_VER 1 if ((interactive && prompt) || (interactive && !prompt && ext_resp)) { @@ -2414,6 +2414,21 @@ declare_proto_rot(dump_state) fprintf(fout, "%d%c", rs->south_zero, resp_sep); + char *rtype = "Unknown"; + + switch (rot->caps->rot_type) + { + case ROT_TYPE_OTHER: rtype = "Other"; break; + + case ROT_TYPE_AZIMUTH : rtype = "Az"; break; + + case ROT_TYPE_ELEVATION : rtype = "El"; break; + + case ROT_TYPE_AZEL : rtype = "AzEl"; break; + } + + fprintf(fout, "rot_type=%s%c", rtype, resp_sep); + return RIG_OK; }