[Hamlib-commits] Hamlib -- Ham radio control libraries branch Hamlib-4.0 updated. 42f9c05c81728cf11
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Nate B. <n0...@us...> - 2020-12-04 18:40:03
|
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, Hamlib-4.0 has been updated via 42f9c05c81728cf1137367a3e1954d8948958b19 (commit) via 05d21d830e22242c3bb5476ed7dc64cb612a02a8 (commit) via bd9432a45d2f98f3e1bdee33fefdb6f982926c6d (commit) via aa9caf574ec623f73d6595123698e643b47ac144 (commit) via 2e9922b824761ca39e05ab449f0a3bfa3390d8f9 (commit) via 9bf5db46d820ce54d4aa5d4c0b3ae8c366a34f72 (commit) via 989048e6e5f046d99d49ebef1a4276a372d90569 (commit) via 031f3ef0accb250f19a1298447642c7851dbcc9f (commit) via be9e49df15c960628186705705a5e6b44f9641ba (commit) via ef15cf25301ebdd91b3e0155d2bf8d1b7be3a055 (commit) via 6acb08d62af9d6e2d9e363152230664e435c7a01 (commit) via 948a26198988d3ce7d4d8af7bc1be03618ac1a37 (commit) via d167061fe5903dd3f53be8fedea2e111763a5a3a (commit) via b3aa00511938207c2d0c5adcd91a476e27fba16f (commit) via cd0a993dcadfaac65b1cd21bce483008cd058185 (commit) via 3a9b4ca027795c5fd6e05349cf2ef81437113607 (commit) via 9ea46c07c217f57c6c1dbc98c170c8abdc86e855 (commit) via a9b2907c76de16a1b770d5df49643b6ac4602736 (commit) via 39d9b016c15b61e731cf7c4d2237b0b5e5f3332f (commit) via 5b2fa8dc529d36d38af5842a53f0b3c5aa05c3a2 (commit) via da2dac8b72bcf433e1c69f375bac03bdfd82e09b (commit) via bdbf64091028a734c5c4e616b84a3f694735aa09 (commit) via 8954ecf9d4c3afebde8eb82eca0e8c713dffb6b5 (commit) via a00cc49e10e9a8ab26e71eb94d6fcf1c9ed819de (commit) via be72027f9a3c54b2ac086d3aca456edd503d7ecf (commit) via 5725fcb76f6abb217aca6ea2d0b722e5bc97e50b (commit) via 6faee5c6f7df57bb055e3f3d00011c1b358484ee (commit) via 1bea95992264366a69392f328f880ed05ba7f7c6 (commit) via eea905d14f0f743854fbaac53a5690bcafc34783 (commit) via 1c895f9f81ccc67cd545f374396090038d276f05 (commit) via a1f1fd161b963185e789d5c57a8b2b5d0c604d40 (commit) via 290d8905af6d33c896b0a57b49937736c8635054 (commit) via b040b51603f94df80478eccf2b5acb906772e5df (commit) via 6174d9f9519980edd59f05e880e5496a95483a17 (commit) via d86b0f03b734afcd09d329499090c590778bcf37 (commit) via a76fac7be66f0d68f70ca4bf4155ddd536992528 (commit) via e741e854412d39ce4110da2e4f603f6949325a1f (commit) via cfba9f18cf25ee31b73c815c2b5e26c3a69ea2eb (commit) from c76bf379e79df2f79880e3fefd8e7a05b251217f (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 42f9c05c81728cf1137367a3e1954d8948958b19 Author: Nate Bargmann <n0...@n0...> Date: Fri Dec 4 12:18:10 2020 -0600 Fix release version from botched cherry-pick diff --git a/configure.ac b/configure.ac index cea90ff5..fab6da24 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ dnl however, the use of '~' should be fine as apt (others?) will treat dnl it as an earlier version than the actual release. TNX KA6MAL dnl PACKAGE_NAME + " " + PACKAGE_VERSION must not exceed 20 chars! AC_INIT([Hamlib], - [4.1~git], + [4.0~rc3], [ham...@li...], [hamlib], [http://www.hamlib.org]) @@ -60,7 +60,7 @@ dnl See README.release on setting these values # Values given to -version-info when linking. See libtool documentation. # Set them here to keep c++/Makefile and src/Makefile in sync. ABI_VERSION=4 -ABI_REVISION=1 +ABI_REVISION=0 ABI_AGE=0 AC_DEFINE_UNQUOTED([ABI_VERSION], [$ABI_VERSION], [Frontend ABI version]) commit 05d21d830e22242c3bb5476ed7dc64cb612a02a8 Author: Mikael Nousiainen <mik...@ik...> Date: Thu Dec 3 23:21:57 2020 +0200 Comments (cherry picked from commit 472293cd57d518f96879168d2e95388e2a22c7eb) diff --git a/include/hamlib/rotator.h b/include/hamlib/rotator.h index 0cff2267..52f22f13 100644 --- a/include/hamlib/rotator.h +++ b/include/hamlib/rotator.h @@ -238,7 +238,7 @@ typedef enum { */ enum rot_level_e { ROT_LEVEL_NONE = 0, /*!< '' -- No Level */ - ROT_LEVEL_SPEED = (1 << 0), /*!< \c SPEED -- Rotation speed, arg int (1-100) */ + ROT_LEVEL_SPEED = (1 << 0), /*!< \c SPEED -- Rotation speed, arg int (default range 1-100 if not specified) */ ROT_LEVEL_63 = CONSTANT_64BIT_FLAG(63), /*!< \c Future use, last level */ }; diff --git a/rigs/dummy/dummy_common.h b/rigs/dummy/dummy_common.h index 84c9bdc9..eba06538 100644 --- a/rigs/dummy/dummy_common.h +++ b/rigs/dummy/dummy_common.h @@ -1,5 +1,5 @@ /* - * Hamlib Dummy backend - shard routines + * Hamlib Dummy backend - shared routines * Copyright (c) 2020 by Mikael Nousiainen * * commit bd9432a45d2f98f3e1bdee33fefdb6f982926c6d Author: Mikael Nousiainen <mik...@ik...> Date: Thu Dec 3 23:07:08 2020 +0200 Add support for ROT_LEVEL_SPEED level in rotator backends that support setting the rotator speed via the move command. Add azimuth-only and elevation-only versions of generic GS-232A and GS-232B backends. (cherry picked from commit 81a0c521e7a1c5979b9f25c40a8e247c52c96fce) diff --git a/include/hamlib/rotlist.h b/include/hamlib/rotlist.h index 2dfd0120..5151013c 100644 --- a/include/hamlib/rotlist.h +++ b/include/hamlib/rotlist.h @@ -261,6 +261,10 @@ #define ROT_MODEL_GS232 ROT_MAKE_MODEL(ROT_GS232A, 6) /* Not A or B */ #define ROT_MODEL_LVB ROT_MAKE_MODEL(ROT_GS232A, 7) #define ROT_MODEL_ST2 ROT_MAKE_MODEL(ROT_GS232A, 8) +#define ROT_MODEL_GS232A_AZ ROT_MAKE_MODEL(ROT_GS232A, 9) +#define ROT_MODEL_GS232A_EL ROT_MAKE_MODEL(ROT_GS232A, 10) +#define ROT_MODEL_GS232B_AZ ROT_MAKE_MODEL(ROT_GS232A, 11) +#define ROT_MODEL_GS232B_EL ROT_MAKE_MODEL(ROT_GS232A, 12) /** * \def ROT_MODEL_PCROTOR diff --git a/rotators/easycomm/easycomm.c b/rotators/easycomm/easycomm.c index 7e691e19..e2955c11 100644 --- a/rotators/easycomm/easycomm.c +++ b/rotators/easycomm/easycomm.c @@ -35,9 +35,12 @@ #include "serial.h" #include "misc.h" #include "register.h" +#include "idx_builtin.h" #include "easycomm.h" +#define EASYCOMM3_LEVELS ROT_LEVEL_SPEED + /* ************************************************************************* */ /** * easycomm_transaction @@ -247,8 +250,7 @@ easycomm_rot_move(ROT *rot, int direction, int speed) return RIG_OK; } -static int -easycomm_rot_move_velocity(ROT *rot, int direction, int speed) +static int easycomm_rot_move_velocity(ROT *rot, int direction, int speed) { struct rot_state *rs = &rot->state; char cmdstr[24]; @@ -258,7 +260,7 @@ easycomm_rot_move_velocity(ROT *rot, int direction, int speed) rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); if (speed == ROT_SPEED_NOCHANGE) { - easycomm_speed = ((rs->current_speed - 1) * 100); + easycomm_speed = rs->current_speed; } else { if (speed < 1 || speed > 100) { @@ -267,8 +269,8 @@ easycomm_rot_move_velocity(ROT *rot, int direction, int speed) return -RIG_EINVAL; } - rs->current_speed = speed; easycomm_speed = ((speed - 1) * 100); + rs->current_speed = easycomm_speed; } /* Speed for EasyComm 3 */ @@ -306,6 +308,49 @@ easycomm_rot_move_velocity(ROT *rot, int direction, int speed) return RIG_OK; } +static int easycomm_rot_get_level(ROT *rot, setting_t level, value_t *val) +{ + struct rot_state *rs = &rot->state; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); + + switch (level) { + case ROT_LEVEL_SPEED: + val->i = rs->current_speed; + break; + default: + return -RIG_ENAVAIL; + } + + return RIG_OK; +} + + +static int easycomm_rot_set_level(ROT *rot, setting_t level, value_t val) +{ + struct rot_state *rs = &rot->state; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); + + switch (level) { + case ROT_LEVEL_SPEED: { + int speed = val.i; + if (speed < 0) { + speed = 0; + } else if (speed > 9999) { + speed = 9999; + } + + rs->current_speed = speed; + break; + } + default: + return -RIG_ENAVAIL; + } + + return RIG_OK; +} + /* * Get Info * returns the model name string @@ -441,6 +486,19 @@ static int easycomm_rot_set_conf(ROT *rot, token_t token, const char *val) return RIG_OK; } + +static int easycomm_rot_init(ROT *rot) +{ + struct rot_state *rs = &rot->state; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + // Set default speed to half of maximum + rs->current_speed = 5000; + + return RIG_OK; +} + /* ************************************************************************* */ /* * Easycomm rotator capabilities. @@ -537,7 +595,7 @@ const struct rot_caps easycomm3_rot_caps = ROT_MODEL(ROT_MODEL_EASYCOMM3), .model_name = "EasycommIII", .mfg_name = "Hamlib", - .version = "20201118.0", + .version = "20201203.0", .copyright = "LGPL", .status = RIG_STATUS_ALPHA, .rot_type = ROT_TYPE_OTHER, @@ -560,7 +618,12 @@ const struct rot_caps easycomm3_rot_caps = .priv = NULL, /* priv */ - .rot_init = NULL, + .has_get_level = EASYCOMM3_LEVELS, + .has_set_level = ROT_LEVEL_SET(EASYCOMM3_LEVELS), + + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 0 }, .max = { .i = 9999 }, .step = { .i = 1 } } }, + + .rot_init = easycomm_rot_init, .rot_cleanup = NULL, .rot_open = NULL, .rot_close = NULL, @@ -571,6 +634,8 @@ const struct rot_caps easycomm3_rot_caps = .park = easycomm_rot_park, .reset = easycomm_rot_reset, .move = easycomm_rot_move_velocity, + .get_level = easycomm_rot_get_level, + .set_level = easycomm_rot_set_level, .set_conf = easycomm_rot_set_conf, .get_conf = easycomm_rot_get_conf, .get_info = easycomm_rot_get_info, diff --git a/rotators/ether6/ether6.c b/rotators/ether6/ether6.c index 0e90275d..2a5c121a 100644 --- a/rotators/ether6/ether6.c +++ b/rotators/ether6/ether6.c @@ -35,12 +35,15 @@ #include "serial.h" #include "misc.h" #include "register.h" +#include "idx_builtin.h" #include "ether6.h" #define CMD_MAX 32 #define BUF_MAX 64 +#define ETHER_LEVELS ROT_LEVEL_SPEED + /* * Helper function with protocol return code parsing */ @@ -306,6 +309,51 @@ static int ether_rot_move(ROT *rot, int direction, int speed) } +static int ether_rot_get_level(ROT *rot, setting_t level, value_t *val) +{ + struct rot_state *rs = &rot->state; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); + + switch (level) { + case ROT_LEVEL_SPEED: + val->i = rs->current_speed; + break; + default: + return -RIG_ENAVAIL; + } + + return RIG_OK; +} + + +static int ether_rot_set_level(ROT *rot, setting_t level, value_t val) +{ + struct rot_state *rs = &rot->state; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); + + switch (level) { + case ROT_LEVEL_SPEED: { + int speed = val.i; + if (speed < 1) { + speed = 1; + } else if (speed > 100) { + speed = 100; + } + + rs->current_speed = speed; + break; + } + default: + return -RIG_ENAVAIL; + } + + return RIG_OK; +} + + + static const char *ether_rot_get_info(ROT *rot) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -314,6 +362,18 @@ static const char *ether_rot_get_info(ROT *rot) } +static int ether_rot_init(ROT *rot) +{ + struct rot_state *rs = &rot->state; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + // Set default speed to half of maximum + rs->current_speed = 00; + + return RIG_OK; +} + /* * Dummy rotator capabilities. @@ -324,7 +384,7 @@ const struct rot_caps ether6_rot_caps = ROT_MODEL(ROT_MODEL_ETHER6), .model_name = "Ether6 (via ethernet)", .mfg_name = "DG9OAA", - .version = "20200106.0", + .version = "20201203.0", .copyright = "LGPL", .status = RIG_STATUS_BETA, .rot_type = ROT_FLAG_AZIMUTH, @@ -339,8 +399,13 @@ const struct rot_caps ether6_rot_caps = .priv = NULL, /* priv */ - /* .rot_init = ether_rot_init, */ - /* .rot_cleanup = ether_rot_cleanup, */ + .has_get_level = ETHER_LEVELS, + .has_set_level = ROT_LEVEL_SET(ETHER_LEVELS), + + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 0 }, .max = { .i = 9999 }, .step = { .i = 1 } } }, + + .rot_init = ether_rot_init, + .rot_cleanup = NULL, .rot_open = ether_rot_open, .rot_close = ether_rot_close, @@ -351,6 +416,8 @@ const struct rot_caps ether6_rot_caps = .stop = ether_rot_stop, .reset = ether_rot_reset, .move = ether_rot_move, + .get_level = ether_rot_get_level, + .set_level = ether_rot_set_level, .get_info = ether_rot_get_info, }; diff --git a/rotators/gs232a/gs232a.c b/rotators/gs232a/gs232a.c index 29bf8dd7..9647e0f0 100644 --- a/rotators/gs232a/gs232a.c +++ b/rotators/gs232a/gs232a.c @@ -38,6 +38,7 @@ #include "serial.h" #include "misc.h" #include "register.h" +#include "idx_builtin.h" #include "gs232a.h" @@ -46,6 +47,8 @@ #define BUFSZ 64 +#define GS232A_LEVELS ROT_LEVEL_SPEED + /** * gs232a_transaction * @@ -236,36 +239,85 @@ gs232a_rot_stop(ROT *rot) } -static int -gs232a_rot_move(ROT *rot, int direction, int speed) +static int gs232a_rot_get_level(ROT *rot, setting_t level, value_t *val) +{ + struct rot_state *rs = &rot->state; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); + + switch (level) { + case ROT_LEVEL_SPEED: + val->i = rs->current_speed; + break; + default: + return -RIG_ENAVAIL; + } + + return RIG_OK; +} + + +static int gs232a_rot_set_level(ROT *rot, setting_t level, value_t val) { struct rot_state *rs = &rot->state; char cmdstr[24]; int retval; - unsigned x_speed; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); + + switch (level) { + case ROT_LEVEL_SPEED: { + int speed = val.i; + if (speed < 1) { + speed = 1; + } else if (speed > 4) { + speed = 4; + } + + /* between 1 (slowest) and 4 (fastest) */ + sprintf(cmdstr, "X%u" EOM, speed); + retval = gs232a_transaction(rot, cmdstr, NULL, 0, 1); + + if (retval != RIG_OK) { + return retval; + } + + rs->current_speed = speed; + break; + } + default: + return -RIG_ENAVAIL; + } + + return RIG_OK; +} + + +static int gs232a_rot_move(ROT *rot, int direction, int speed) +{ + char cmdstr[24]; + int retval; rig_debug(RIG_DEBUG_TRACE, "%s called %d %d\n", __func__, direction, speed); if (speed != ROT_SPEED_NOCHANGE) { + value_t gs232a_speed; + if (speed < 1 || speed > 100) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid speed value (1-100)! (%d)\n", __func__, speed); return -RIG_EINVAL; } - x_speed = (3 * speed) / 100 + 1; + gs232a_speed.i = (3 * speed) / 100 + 1; - /* between 1 (slowest) and 4 (fastest) */ - sprintf(cmdstr, "X%u" EOM, x_speed); - retval = gs232a_transaction(rot, cmdstr, NULL, 0, 1); + retval = gs232a_rot_set_level(rot, ROT_LEVEL_SPEED, gs232a_speed); if (retval != RIG_OK) { return retval; } - - rs->current_speed = speed; } switch (direction) @@ -302,6 +354,20 @@ gs232a_rot_move(ROT *rot, int direction, int speed) return RIG_OK; } + +static int gs232a_rot_init(ROT *rot) +{ + struct rot_state *rs = &rot->state; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + // Set default speed to half of maximum + rs->current_speed = 3; + + return RIG_OK; +} + + /* ************************************************************************* */ /* * Generic GS23 rotator capabilities. @@ -312,7 +378,7 @@ const struct rot_caps gs23_rot_caps = ROT_MODEL(ROT_MODEL_GS23), .model_name = "GS-23", .mfg_name = "Yaesu/Kenpro", - .version = "20201202.0", + .version = "20201203.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_AZEL, @@ -333,9 +399,17 @@ const struct rot_caps gs23_rot_caps = .min_el = 0.0, .max_el = 180.0, + .has_get_level = GS232A_LEVELS, + .has_set_level = ROT_LEVEL_SET(GS232A_LEVELS), + + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, + + .rot_init = gs232a_rot_init, .get_position = gs232a_rot_get_position, .set_position = gs232a_rot_set_position, - .stop = gs232a_rot_stop, + .stop = gs232a_rot_stop, + .get_level = gs232a_rot_get_level, + .set_level = gs232a_rot_set_level, }; /* ************************************************************************* */ @@ -348,7 +422,7 @@ const struct rot_caps gs232_rot_caps = ROT_MODEL(ROT_MODEL_GS232), .model_name = "GS-232", .mfg_name = "Yaesu/Kenpro", - .version = "20201202.0", + .version = "20201203.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_AZEL, @@ -369,9 +443,17 @@ const struct rot_caps gs232_rot_caps = .min_el = 0.0, .max_el = 180.0, + .has_get_level = GS232A_LEVELS, + .has_set_level = ROT_LEVEL_SET(GS232A_LEVELS), + + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, + + .rot_init = gs232a_rot_init, .get_position = gs232a_rot_get_position, .set_position = gs232a_rot_set_position, - .stop = gs232a_rot_stop, + .stop = gs232a_rot_stop, + .get_level = gs232a_rot_get_level, + .set_level = gs232a_rot_set_level, }; /* ************************************************************************* */ @@ -384,10 +466,10 @@ const struct rot_caps gs232a_rot_caps = ROT_MODEL(ROT_MODEL_GS232A), .model_name = "GS-232A", .mfg_name = "Yaesu", - .version = "20201205.0", + .version = "20201203.0", .copyright = "LGPL", .status = RIG_STATUS_BETA, - .rot_type = ROT_TYPE_OTHER, + .rot_type = ROT_TYPE_AZEL, .port_type = RIG_PORT_SERIAL, .serial_rate_min = 150, .serial_rate_max = 9600, @@ -405,26 +487,125 @@ const struct rot_caps gs232a_rot_caps = .min_el = 0.0, .max_el = 180.0, /* requires G-5400B, G-5600B, G-5500, or G-500/G-550 */ + .has_get_level = GS232A_LEVELS, + .has_set_level = ROT_LEVEL_SET(GS232A_LEVELS), + + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, + + .rot_init = gs232a_rot_init, .get_position = gs232a_rot_get_position, .set_position = gs232a_rot_set_position, - .stop = gs232a_rot_stop, + .stop = gs232a_rot_stop, .move = gs232a_rot_move, + .get_level = gs232a_rot_get_level, + .set_level = gs232a_rot_set_level, }; /* ************************************************************************* */ +/* + * Generic GS232A azimuth rotator capabilities. + */ +const struct rot_caps gs232a_az_rot_caps = +{ + ROT_MODEL(ROT_MODEL_GS232A_AZ), + .model_name = "GS-232A azimuth", + .mfg_name = "Yaesu", + .version = "20201203.0", + .copyright = "LGPL", + .status = RIG_STATUS_BETA, + .rot_type = ROT_TYPE_AZIMUTH, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 150, + .serial_rate_max = 9600, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 50, + .timeout = 400, + .retry = 3, + .min_az = -180.0, + .max_az = 450.0, /* vary according to rotator type */ + .min_el = 0.0, + .max_el = 0.0, + + .rot_init = gs232a_rot_init, + .has_get_level = GS232A_LEVELS, + .has_set_level = ROT_LEVEL_SET(GS232A_LEVELS), + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, + + .get_position = gs232a_rot_get_position, + .set_position = gs232a_rot_set_position, + .stop = gs232a_rot_stop, + .move = gs232a_rot_move, + .get_level = gs232a_rot_get_level, + .set_level = gs232a_rot_set_level, +}; +/* ************************************************************************* */ +/* + * Generic GS232A elevation rotator capabilities. + */ + +const struct rot_caps gs232a_el_rot_caps = +{ + ROT_MODEL(ROT_MODEL_GS232A_EL), + .model_name = "GS-232A elevation", + .mfg_name = "Yaesu", + .version = "20201203.0", + .copyright = "LGPL", + .status = RIG_STATUS_BETA, + .rot_type = ROT_TYPE_ELEVATION, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 150, + .serial_rate_max = 9600, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 50, + .timeout = 400, + .retry = 3, + + .min_az = 0.0, + .max_az = 0.0, + .min_el = 0.0, + .max_el = 180.0, /* requires G-5400B, G-5600B, G-5500, or G-500/G-550 */ + + .has_get_level = GS232A_LEVELS, + .has_set_level = ROT_LEVEL_SET(GS232A_LEVELS), + + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, + + .rot_init = gs232a_rot_init, + .get_position = gs232a_rot_get_position, + .set_position = gs232a_rot_set_position, + .stop = gs232a_rot_stop, + .move = gs232a_rot_move, + .get_level = gs232a_rot_get_level, + .set_level = gs232a_rot_set_level, +}; + +/* ************************************************************************* */ + DECLARE_INITROT_BACKEND(gs232a) { rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rot_register(&gs232a_rot_caps); + rot_register(&gs232a_az_rot_caps); + rot_register(&gs232a_el_rot_caps); rot_register(&gs232_generic_rot_caps); rot_register(&gs232b_rot_caps); + rot_register(&gs232b_az_rot_caps); + rot_register(&gs232b_el_rot_caps); rot_register(&f1tetracker_rot_caps); rot_register(&gs23_rot_caps); rot_register(&gs232_rot_caps); diff --git a/rotators/gs232a/gs232a.h b/rotators/gs232a/gs232a.h index c6c84053..681fbc85 100644 --- a/rotators/gs232a/gs232a.h +++ b/rotators/gs232a/gs232a.h @@ -23,8 +23,12 @@ #define _ROT_GS232A_H 1 extern const struct rot_caps gs232a_rot_caps; +extern const struct rot_caps gs232a_az_rot_caps; +extern const struct rot_caps gs232a_el_rot_caps; extern const struct rot_caps gs232_generic_rot_caps; extern const struct rot_caps gs232b_rot_caps; +extern const struct rot_caps gs232b_az_rot_caps; +extern const struct rot_caps gs232b_el_rot_caps; extern const struct rot_caps f1tetracker_rot_caps; extern const struct rot_caps gs23_rot_caps; extern const struct rot_caps gs232_rot_caps; diff --git a/rotators/gs232a/gs232b.c b/rotators/gs232a/gs232b.c index a9f0f28c..8a5bf593 100644 --- a/rotators/gs232a/gs232b.c +++ b/rotators/gs232a/gs232b.c @@ -27,26 +27,22 @@ // cppcheck-suppress * #include <stdio.h> // cppcheck-suppress * -#include <stdlib.h> -// cppcheck-suppress * #include <string.h> /* String function definitions */ // cppcheck-suppress * -#include <unistd.h> /* UNIX standard function definitions */ -// cppcheck-suppress * #include <math.h> #include "hamlib/rotator.h" #include "serial.h" #include "misc.h" -#include "register.h" - -#include "gs232a.h" +#include "idx_builtin.h" #define EOM "\r" #define REPLY_EOM "\n" #define BUFSZ 64 +#define GS232B_LEVELS ROT_LEVEL_SPEED + /** * gs232b_transaction * @@ -274,36 +270,85 @@ gs232b_rot_stop(ROT *rot) } -static int -gs232b_rot_move(ROT *rot, int direction, int speed) +static int gs232b_rot_get_level(ROT *rot, setting_t level, value_t *val) +{ + struct rot_state *rs = &rot->state; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); + + switch (level) { + case ROT_LEVEL_SPEED: + val->i = rs->current_speed; + break; + default: + return -RIG_ENAVAIL; + } + + return RIG_OK; +} + + +static int gs232b_rot_set_level(ROT *rot, setting_t level, value_t val) { struct rot_state *rs = &rot->state; char cmdstr[24]; int retval; - unsigned x_speed; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called: %s\n", __func__, rot_strlevel(level)); + + switch (level) { + case ROT_LEVEL_SPEED: { + int speed = val.i; + if (speed < 1) { + speed = 1; + } else if (speed > 4) { + speed = 4; + } + + /* between 1 (slowest) and 4 (fastest) */ + sprintf(cmdstr, "X%u" EOM, speed); + retval = gs232b_transaction(rot, cmdstr, NULL, 0, 1); + + if (retval != RIG_OK) { + return retval; + } + + rs->current_speed = speed; + break; + } + default: + return -RIG_ENAVAIL; + } + + return RIG_OK; +} + + +static int gs232b_rot_move(ROT *rot, int direction, int speed) +{ + char cmdstr[24]; + int retval; rig_debug(RIG_DEBUG_TRACE, "%s called %d %d\n", __func__, direction, speed); if (speed != ROT_SPEED_NOCHANGE) { + value_t gs232b_speed; + if (speed < 1 || speed > 100) { rig_debug(RIG_DEBUG_ERR, "%s: Invalid speed value (1-100)! (%d)\n", __func__, speed); return -RIG_EINVAL; } - x_speed = (3 * speed) / 100 + 1; + gs232b_speed.i = (3 * speed) / 100 + 1; - /* between 1 (slowest) and 4 (fastest) */ - sprintf(cmdstr, "X%u" EOM, x_speed); - retval = gs232b_transaction(rot, cmdstr, NULL, 0, 1); + retval = gs232b_rot_set_level(rot, ROT_LEVEL_SPEED, gs232b_speed); if (retval != RIG_OK) { return retval; } - - rs->current_speed = speed; } switch (direction) @@ -340,6 +385,20 @@ gs232b_rot_move(ROT *rot, int direction, int speed) return RIG_OK; } + +static int gs232b_rot_init(ROT *rot) +{ + struct rot_state *rs = &rot->state; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + // Set default speed to half of maximum + rs->current_speed = 3; + + return RIG_OK; +} + + /* ************************************************************************* */ /* * Generic GS232B rotator capabilities. @@ -350,10 +409,10 @@ const struct rot_caps gs232b_rot_caps = ROT_MODEL(ROT_MODEL_GS232B), .model_name = "GS-232B", .mfg_name = "Yaesu", - .version = "20201202.0", + .version = "20201203.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, - .rot_type = ROT_TYPE_OTHER, + .rot_type = ROT_TYPE_AZEL, .port_type = RIG_PORT_SERIAL, .serial_rate_min = 1200, .serial_rate_max = 9600, @@ -371,10 +430,110 @@ const struct rot_caps gs232b_rot_caps = .min_el = 0.0, .max_el = 180.0, /* requires G-5400B, G-5600B, G-5500, or G-500/G-550 */ + .has_get_level = GS232B_LEVELS, + .has_set_level = ROT_LEVEL_SET(GS232B_LEVELS), + + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, + + .rot_init = gs232b_rot_init, + .get_position = gs232b_rot_get_position, + .set_position = gs232b_rot_set_position, + .stop = gs232b_rot_stop, + .move = gs232b_rot_move, + .get_level = gs232b_rot_get_level, + .set_level = gs232b_rot_set_level, +}; + + +/* ************************************************************************* */ +/* + * Generic GS232B azimuth rotator capabilities. + */ + +const struct rot_caps gs232b_az_rot_caps = +{ + ROT_MODEL(ROT_MODEL_GS232B_AZ), + .model_name = "GS-232B azimuth", + .mfg_name = "Yaesu", + .version = "20201203.0", + .copyright = "LGPL", + .status = RIG_STATUS_STABLE, + .rot_type = ROT_TYPE_AZIMUTH, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 1200, + .serial_rate_max = 9600, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 50, + .timeout = 400, + .retry = 3, + + .min_az = -180.0, + .max_az = 450.0, /* vary according to rotator type */ + .min_el = 0.0, + .max_el = 0.0, + + .has_get_level = GS232B_LEVELS, + .has_set_level = ROT_LEVEL_SET(GS232B_LEVELS), + + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, + + .rot_init = gs232b_rot_init, + .get_position = gs232b_rot_get_position, + .set_position = gs232b_rot_set_position, + .stop = gs232b_rot_stop, + .move = gs232b_rot_move, + .get_level = gs232b_rot_get_level, + .set_level = gs232b_rot_set_level, +}; + + +/* ************************************************************************* */ +/* + * Generic GS232B elevation rotator capabilities. + */ + +const struct rot_caps gs232b_el_rot_caps = +{ + ROT_MODEL(ROT_MODEL_GS232B_EL), + .model_name = "GS-232B elevation", + .mfg_name = "Yaesu", + .version = "20201203.0", + .copyright = "LGPL", + .status = RIG_STATUS_STABLE, + .rot_type = ROT_TYPE_ELEVATION, + .port_type = RIG_PORT_SERIAL, + .serial_rate_min = 1200, + .serial_rate_max = 9600, + .serial_data_bits = 8, + .serial_stop_bits = 1, + .serial_parity = RIG_PARITY_NONE, + .serial_handshake = RIG_HANDSHAKE_NONE, + .write_delay = 0, + .post_write_delay = 50, + .timeout = 400, + .retry = 3, + + .min_az = 0.0, + .max_az = 0.0, + .min_el = 0.0, + .max_el = 180.0, /* requires G-5400B, G-5600B, G-5500, or G-500/G-550 */ + + .has_get_level = GS232B_LEVELS, + .has_set_level = ROT_LEVEL_SET(GS232B_LEVELS), + + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, + + .rot_init = gs232b_rot_init, .get_position = gs232b_rot_get_position, .set_position = gs232b_rot_set_position, .stop = gs232b_rot_stop, .move = gs232b_rot_move, + .get_level = gs232b_rot_get_level, + .set_level = gs232b_rot_set_level, }; /* end of file */ commit aa9caf574ec623f73d6595123698e643b47ac144 Author: Mikael Nousiainen <mik...@ik...> Date: Thu Dec 3 21:40:34 2020 +0200 Add get_status command for rotator status flags. Add missing rotator caps in dumpcaps output. (cherry picked from commit 457211a7e353d3c5d7a93d606afb5d680ef18a10) diff --git a/include/hamlib/amplifier.h b/include/hamlib/amplifier.h index 7d61cea8..b7af885d 100644 --- a/include/hamlib/amplifier.h +++ b/include/hamlib/amplifier.h @@ -397,6 +397,10 @@ extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t); extern HAMLIB_EXPORT(const struct confparams *) rig_ext_lookup HAMLIB_PARAMS((RIG *rig, const char *name)); + +extern HAMLIB_EXPORT(setting_t) amp_parse_level(const char *s); +extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t); + //! @endcond diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 47696121..b8c4832f 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2787,16 +2787,6 @@ extern HAMLIB_EXPORT(scan_t) rig_parse_scan(const char *s); extern HAMLIB_EXPORT(rptr_shift_t) rig_parse_rptr_shift(const char *s); extern HAMLIB_EXPORT(chan_type_t) rig_parse_mtype(const char *s); -extern HAMLIB_EXPORT(setting_t) rot_parse_func(const char *s); -extern HAMLIB_EXPORT(setting_t) rot_parse_level(const char *s); -extern HAMLIB_EXPORT(setting_t) rot_parse_parm(const char *s); -extern HAMLIB_EXPORT(const char *) rot_strfunc(setting_t); -extern HAMLIB_EXPORT(const char *) rot_strlevel(setting_t); -extern HAMLIB_EXPORT(const char *) rot_strparm(setting_t); - -extern HAMLIB_EXPORT(setting_t) amp_parse_level(const char *s); -extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t); - extern HAMLIB_EXPORT(const char *) rig_license HAMLIB_PARAMS(()); extern HAMLIB_EXPORT(const char *) rig_version HAMLIB_PARAMS(()); extern HAMLIB_EXPORT(const char *) rig_copyright HAMLIB_PARAMS(()); diff --git a/include/hamlib/rotator.h b/include/hamlib/rotator.h index 4a38bf87..0cff2267 100644 --- a/include/hamlib/rotator.h +++ b/include/hamlib/rotator.h @@ -200,20 +200,27 @@ typedef enum { * \brief Rotator status flags */ typedef enum { - ROT_STATUS_BUSY = (1 << 1), /*!< Rotator is busy, not accepting commands */ - ROT_STATUS_MOVING = (1 << 2), /*!< Rotator is currently moving (direction type not specified) */ - ROT_STATUS_MOVING_AZ = (1 << 3), /*!< Azimuth rotator is currently moving */ - ROT_STATUS_MOVING_EL = (1 << 4), /*!< Elevation rotator is currently moving */ - ROT_STATUS_UP_LIMIT = (1 << 5), /*!< The elevation rotator has reached its limit to move up */ - ROT_STATUS_DOWN_LIMIT = (1 << 6), /*!< The elevation rotator has reached its limit to move down */ - ROT_STATUS_LEFT_LIMIT = (1 << 7), /*!< The azimuth rotator has reached its limit to move left (CCW) */ - ROT_STATUS_RIGHT_LIMIT = (1 << 8), /*!< The azimuth rotator has reached its limit to move right (CW) */ - ROT_STATUS_UP_OVERLAP = (1 << 9), /*!< The elevation rotator has rotated up past 360 degrees */ - ROT_STATUS_DOWN_OVERLAP = (1 << 10), /*!< The elevation rotator has rotated down past 0 degrees */ - ROT_STATUS_LEFT_OVERLAP = (1 << 11), /*!< The azimuth rotator has rotated left (CCW) past 0 degrees */ - ROT_STATUS_RIGHT_OVERLAP = (1 << 12), /*!< The azimuth rotator has rotated right (CW) past 360 degrees */ + ROT_STATUS_NONE = 0, + ROT_STATUS_BUSY = (1 << 0), /*!< Rotator is busy, not accepting commands */ + ROT_STATUS_MOVING = (1 << 1), /*!< Rotator is currently moving (direction type not specified) */ + ROT_STATUS_MOVING_AZ = (1 << 2), /*!< Azimuth rotator is currently moving (direction not specified) */ + ROT_STATUS_MOVING_LEFT = (1 << 3), /*!< Azimuth rotator is currently moving left */ + ROT_STATUS_MOVING_RIGHT = (1 << 4), /*!< Azimuth rotator is currently moving right */ + ROT_STATUS_MOVING_EL = (1 << 5), /*!< Elevation rotator is currently moving (direction not specified) */ + ROT_STATUS_MOVING_UP = (1 << 6), /*!< Elevation rotator is currently moving up */ + ROT_STATUS_MOVING_DOWN = (1 << 7), /*!< Elevation rotator is currently moving down */ + ROT_STATUS_LIMIT_UP = (1 << 8), /*!< The elevation rotator has reached its limit to move up */ + ROT_STATUS_LIMIT_DOWN = (1 << 9), /*!< The elevation rotator has reached its limit to move down */ + ROT_STATUS_LIMIT_LEFT = (1 << 10), /*!< The azimuth rotator has reached its limit to move left (CCW) */ + ROT_STATUS_LIMIT_RIGHT = (1 << 11), /*!< The azimuth rotator has reached its limit to move right (CW) */ + ROT_STATUS_OVERLAP_UP = (1 << 12), /*!< The elevation rotator has rotated up past 360 degrees */ + ROT_STATUS_OVERLAP_DOWN = (1 << 13), /*!< The elevation rotator has rotated down past 0 degrees */ + ROT_STATUS_OVERLAP_LEFT = (1 << 14), /*!< The azimuth rotator has rotated left (CCW) past 0 degrees */ + ROT_STATUS_OVERLAP_RIGHT = (1 << 16), /*!< The azimuth rotator has rotated right (CW) past 360 degrees */ } rot_status_t; +#define ROT_STATUS_N(n) (1u<<(n)) + /** * \brief Macro for not changing the rotator speed with move() function @@ -339,6 +346,8 @@ struct rot_caps { setting_t has_get_parm; /*!< List of get parm */ setting_t has_set_parm; /*!< List of set parm */ + rot_status_t has_status; /*!< Supported status flags */ + gran_t level_gran[RIG_SETTING_MAX]; /*!< level granularity (i.e. steps) */ gran_t parm_gran[RIG_SETTING_MAX]; /*!< parm granularity (i.e. steps) */ @@ -409,12 +418,9 @@ struct rot_caps { int (*set_ext_parm)(ROT *rot, token_t token, value_t val); int (*get_ext_parm)(ROT *rot, token_t token, value_t *val); - const char *macro_name; /*!< Macro name. */ + int (*get_status)(ROT *rot, rot_status_t *status); - rot_status_t status_caps; /*!< Supported status flags */ - - rot_status_t (*get_status)(ROT *rot); - /* more to come... */ + const char *macro_name; /*!< Macro name. */ }; //! @endcond @@ -449,6 +455,8 @@ struct rot_state { setting_t has_get_parm; /*!< List of get parm */ setting_t has_set_parm; /*!< List of set parm */ + rot_status_t has_status; /*!< Supported status flags */ + gran_t level_gran[RIG_SETTING_MAX]; /*!< level granularity */ gran_t parm_gran[RIG_SETTING_MAX]; /*!< parm granularity */ @@ -614,6 +622,10 @@ rot_get_ext_parm HAMLIB_PARAMS((ROT *rig, extern HAMLIB_EXPORT(const char *) rot_get_info HAMLIB_PARAMS((ROT *rot)); +extern HAMLIB_EXPORT(int) +rot_get_status HAMLIB_PARAMS((ROT *rot, + rot_status_t *status)); + extern HAMLIB_EXPORT(int) rot_register HAMLIB_PARAMS((const struct rot_caps *caps)); @@ -734,6 +746,14 @@ dmmm2dec HAMLIB_PARAMS((int degrees, double seconds, int sw)); +extern HAMLIB_EXPORT(setting_t) rot_parse_func(const char *s); +extern HAMLIB_EXPORT(setting_t) rot_parse_level(const char *s); +extern HAMLIB_EXPORT(setting_t) rot_parse_parm(const char *s); +extern HAMLIB_EXPORT(const char *) rot_strfunc(setting_t); +extern HAMLIB_EXPORT(const char *) rot_strlevel(setting_t); +extern HAMLIB_EXPORT(const char *) rot_strparm(setting_t); +extern HAMLIB_EXPORT(const char *) rot_strstatus(rot_status_t); + //! @endcond /** diff --git a/rigs/dummy/rot_dummy.c b/rigs/dummy/rot_dummy.c index 5cd31783..d5b8b994 100644 --- a/rigs/dummy/rot_dummy.c +++ b/rigs/dummy/rot_dummy.c @@ -39,6 +39,10 @@ #define DUMMY_ROT_LEVEL ROT_LEVEL_SPEED #define DUMMY_ROT_PARM 0 +#define DUMMY_ROT_STATUS (ROT_STATUS_MOVING | ROT_STATUS_MOVING_AZ | ROT_STATUS_MOVING_LEFT | ROT_STATUS_MOVING_RIGHT | \ + ROT_STATUS_MOVING_EL | ROT_STATUS_MOVING_UP | ROT_STATUS_MOVING_DOWN | \ + ROT_STATUS_LIMIT_UP | ROT_STATUS_LIMIT_DOWN | ROT_STATUS_LIMIT_LEFT | ROT_STATUS_LIMIT_RIGHT) + struct dummy_rot_priv_data { azimuth_t az; @@ -47,6 +51,7 @@ struct dummy_rot_priv_data struct timeval tv; /* time last az/el update */ azimuth_t target_az; elevation_t target_el; + rot_status_t status; setting_t funcs; value_t levels[RIG_SETTING_MAX]; @@ -254,27 +259,13 @@ static int dummy_rot_set_position(ROT *rot, azimuth_t az, elevation_t el) return RIG_OK; } - -/* - * Get position of rotor, simulating slow rotation - */ -static int dummy_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) +static void dummy_rot_simulate_rotation(ROT *rot) { - struct dummy_rot_priv_data *priv = (struct dummy_rot_priv_data *) + struct dummy_rot_priv_data *priv = (struct dummy_rot_priv_data *) rot->state.priv; struct timeval tv; unsigned elapsed; /* ms */ - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - if (priv->az == priv->target_az && - priv->el == priv->target_el) - { - *az = priv->az; - *el = priv->el; - return RIG_OK; - } - gettimeofday(&tv, NULL); elapsed = (tv.tv_sec - priv->tv.tv_sec) * 1000 + @@ -289,16 +280,19 @@ static int dummy_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) { /* target reached */ priv->az = priv->target_az; + priv->status &= ~(ROT_STATUS_MOVING_AZ | ROT_STATUS_MOVING_LEFT | ROT_STATUS_MOVING_RIGHT); } else { if (priv->az < priv->target_az) { priv->az += (azimuth_t)elapsed * DEG_PER_MS; + priv->status |= ROT_STATUS_MOVING_AZ | ROT_STATUS_MOVING_RIGHT; } else { priv->az -= (azimuth_t)elapsed * DEG_PER_MS; + priv->status |= ROT_STATUS_MOVING_AZ | ROT_STATUS_MOVING_LEFT; } } @@ -306,23 +300,54 @@ static int dummy_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) { /* target reached */ priv->el = priv->target_el; + priv->status &= ~(ROT_STATUS_MOVING_EL | ROT_STATUS_MOVING_UP | ROT_STATUS_MOVING_DOWN); } else { if (priv->el < priv->target_el) { priv->el += (elevation_t)elapsed * DEG_PER_MS; + priv->status |= ROT_STATUS_MOVING_EL | ROT_STATUS_MOVING_UP; } else { priv->el -= (elevation_t)elapsed * DEG_PER_MS; + priv->status |= ROT_STATUS_MOVING_EL | ROT_STATUS_MOVING_DOWN; } } - *az = priv->az; - *el = priv->el; + if (priv->status & (ROT_STATUS_MOVING_AZ | ROT_STATUS_MOVING_EL)) { + priv->status |= ROT_STATUS_MOVING; + } else { + priv->status &= ~(ROT_STATUS_MOVING); + } priv->tv = tv; +} + + +/* + * Get position of rotor, simulating slow rotation + */ +static int dummy_rot_get_position(ROT *rot, azimuth_t *az, elevation_t *el) +{ + struct dummy_rot_priv_data *priv = (struct dummy_rot_priv_data *) + rot->state.priv; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (priv->az == priv->target_az && + priv->el == priv->target_el) + { + *az = priv->az; + *el = priv->el; + return RIG_OK; + } + + dummy_rot_simulate_rotation(rot); + + *az = priv->az; + *el = priv->el; return RIG_OK; } @@ -839,16 +864,27 @@ static int dummy_get_ext_parm(ROT *rot, token_t token, value_t *val) } +static int dummy_rot_get_status(ROT *rot, rot_status_t *status) +{ + struct dummy_rot_priv_data *priv = (struct dummy_rot_priv_data *)rot->state.priv; + + dummy_rot_simulate_rotation(rot); + + *status = priv->status; + + return RIG_OK; +} + + /* * Dummy rotator capabilities. */ - const struct rot_caps dummy_rot_caps = { ROT_MODEL(ROT_MODEL_DUMMY), .model_name = "Dummy", .mfg_name = "Hamlib", - .version = "20201202.0", + .version = "20201203.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_AZEL, @@ -875,6 +911,8 @@ const struct rot_caps dummy_rot_caps = .extparms = dummy_ext_parms, .cfgparams = dummy_cfg_params, + .has_status = DUMMY_ROT_STATUS, + .rot_init = dummy_rot_init, .rot_cleanup = dummy_rot_cleanup, .rot_open = dummy_rot_open, @@ -904,7 +942,8 @@ const struct rot_caps dummy_rot_caps = .set_ext_parm = dummy_set_ext_parm, .get_ext_parm = dummy_get_ext_parm, - .get_info = dummy_rot_get_info, + .get_info = dummy_rot_get_info, + .get_status = dummy_rot_get_status, }; DECLARE_INITROT_BACKEND(dummy) diff --git a/src/misc.c b/src/misc.c index 4893acf9..a4564035 100644 --- a/src/misc.c +++ b/src/misc.c @@ -48,7 +48,6 @@ # include <sys/time.h> #endif -#include <unistd.h> #include <math.h> #include <hamlib/rig.h> @@ -1759,6 +1758,54 @@ int HAMLIB_API rig_flush(hamlib_port_t *port) return serial_flush(port); // we must be on serial port } + +static struct +{ + rot_status_t status; + const char *str; +} rot_status_str[] = +{ + { ROT_STATUS_BUSY, "BUSY" }, + { ROT_STATUS_MOVING, "MOVING" }, + { ROT_STATUS_MOVING_AZ, "MOVING_AZ" }, + { ROT_STATUS_MOVING_LEFT, "MOVING_LEFT" }, + { ROT_STATUS_MOVING_RIGHT, "MOVING_RIGHT" }, + { ROT_STATUS_MOVING_EL, "MOVING_EL" }, + { ROT_STATUS_MOVING_UP, "MOVING_UP" }, + { ROT_STATUS_MOVING_DOWN, "MOVING_DOWN" }, + { ROT_STATUS_LIMIT_UP, "LIMIT_UP" }, + { ROT_STATUS_LIMIT_DOWN, "LIMIT_DOWN" }, + { ROT_STATUS_LIMIT_LEFT, "LIMIT_LEFT" }, + { ROT_STATUS_LIMIT_RIGHT, "LIMIT_RIGHT" }, + { ROT_STATUS_OVERLAP_UP, "OVERLAP_UP" }, + { ROT_STATUS_OVERLAP_DOWN, "OVERLAP_DOWN" }, + { ROT_STATUS_OVERLAP_LEFT, "OVERLAP_LEFT" }, + { ROT_STATUS_OVERLAP_RIGHT, "OVERLAP_RIGHT" }, + { 0xffffff, "" }, +}; + + +/** + * \brief Convert enum ROT_STATUS_... to a string + * \param status ROT_STATUS_... + * \return the corresponding string value + */ +const char *HAMLIB_API rot_strstatus(rot_status_t status) +{ + int i; + + for (i = 0 ; rot_status_str[i].str[0] != '\0'; i++) + { + if (status == rot_status_str[i].status) + { + return rot_status_str[i].str; + } + } + + return ""; +} + + //! @endcond /** @} */ diff --git a/src/rotator.c b/src/rotator.c index 9e687ef7..8cb36a7e 100644 --- a/src/rotator.c +++ b/src/rotator.c @@ -283,6 +283,8 @@ ROT *HAMLIB_API rot_init(rot_model_t rot_model) rs->has_get_parm = caps->has_get_parm; rs->has_set_parm = caps->has_set_parm; + rs->has_status = caps->has_status; + memcpy(rs->level_gran, caps->level_gran, sizeof(gran_t)*RIG_SETTING_MAX); memcpy(rs->parm_gran, caps->parm_gran, sizeof(gran_t)*RIG_SETTING_MAX); @@ -597,6 +599,9 @@ int HAMLIB_API rot_set_position(ROT *rot, return -RIG_EINVAL; } + azimuth += rot->state.az_offset; + elevation += rot->state.el_offset; + caps = rot->caps; rs = &rot->state; @@ -648,6 +653,8 @@ int HAMLIB_API rot_get_position(ROT *rot, { const struct rot_caps *caps; const struct rot_state *rs; + azimuth_t az; + elevation_t el; int retval; rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); @@ -665,19 +672,21 @@ int HAMLIB_API rot_get_position(ROT *rot, return -RIG_ENAVAIL; } - retval = caps->get_position(rot, azimuth, elevation); + retval = caps->get_position(rot, &az, &el); if (retval != RIG_OK) { return retval; } - rot_debug(RIG_DEBUG_VERBOSE, "%s: got az=%.2f, el=%.2f\n", __func__, *azimuth, - *elevation); + rot_debug(RIG_DEBUG_VERBOSE, "%s: got az=%.2f, el=%.2f\n", __func__, az, el); if (rs->south_zero) { - *azimuth += *azimuth >= 180 ? -180 : 180; - rot_debug(RIG_DEBUG_VERBOSE, "%s: south adj to az=%.2f\n", __func__, *azimuth); + az += az >= 180 ? -180 : 180; + rot_debug(RIG_DEBUG_VERBOSE, "%s: south adj to az=%.2f\n", __func__, az); } + *azimuth = az - rot->state.az_offset; + *elevation = el - rot->state.el_offset; + return RIG_OK; } @@ -841,4 +850,33 @@ const char *HAMLIB_API rot_get_info(ROT *rot) return rot->caps->get_info(rot); } + +/** + * \brief get status flags from the rotator + * \param rot The rot handle + * \param status a pointer to a rot_status_t variable that will receive the status flags + * + * Gets the active status flags from the rotator. + * + * \return RIG_OK if the operation has been successful, otherwise + * a negative value if an error occurred (in which case, cause is + * set appropriately). + */ +int HAMLIB_API rot_get_status(ROT *rot, rot_status_t *status) +{ + rot_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (CHECK_ROT_ARG(rot)) + { + return -RIG_EINVAL; + } + + if (rot->caps->get_status == NULL) + { + return -RIG_ENAVAIL; + } + + return rot->caps->get_status(rot, status); +} + /*! @} */ diff --git a/tests/dumpcaps_rot.c b/tests/dumpcaps_rot.c index 0f8def4f..90cfd7c7 100644 --- a/tests/dumpcaps_rot.c +++ b/tests/dumpcaps_rot.c @@ -146,6 +146,17 @@ int dumpcaps_rot(ROT *rot, FILE *fout) "Post Write delay:\t%dmS\n", caps->post_write_delay); + if (rot->state.has_status != 0) + { + rot_sprintf_status(prntbuf, rot->state.has_status); + } + else + { + strcpy(prntbuf, "None\n"); + } + + fprintf(fout, "Status flags: %s\n", prntbuf); + rot_sprintf_func(prntbuf, caps->has_get_func); fprintf(fout, "Get functions: %s\n", prntbuf); @@ -223,7 +234,16 @@ int dumpcaps_rot(ROT *rot, FILE *fout) fprintf(fout, "Can Park:\t\t%c\n", caps->park != NULL ? 'Y' : 'N'); fprintf(fout, "Can Reset:\t\t%c\n", caps->reset != NULL ? 'Y' : 'N'); fprintf(fout, "Can Move:\t\t%c\n", caps->move != NULL ? 'Y' : 'N'); + fprintf(fout, "Can get Info:\t\t%c\n", caps->get_info != NULL ? 'Y' : 'N'); + fprintf(fout, "Can get Status:\t\t%c\n", caps->get_status != NULL ? 'Y' : 'N'); + + fprintf(fout, "Can set Func:\t%c\n", caps->set_func != NULL ? 'Y' : 'N'); + fprintf(fout, "Can get Func:\t%c\n", caps->get_func != NULL ? 'Y' : 'N'); + fprintf(fout, "Can set Level:\t%c\n", caps->set_level != NULL ? 'Y' : 'N'); + fprintf(fout, "Can get Level:\t%c\n", caps->get_level != NULL ? 'Y' : 'N'); + fprintf(fout, "Can set Param:\t%c\n", caps->set_parm != NULL ? 'Y' : 'N'); + fprintf(fout, "Can get Param:\t%c\n", caps->get_parm != NULL ? 'Y' : 'N'); fprintf(fout, "\nOverall backend warnings: %d\n", backend_warnings); diff --git a/tests/rotctl_parse.c b/tests/rotctl_parse.c index 2e500d76..9b45e593 100644 --- a/tests/rotctl_parse.c +++ b/tests/rotctl_parse.c @@ -187,6 +187,7 @@ declare_proto_rot(get_func); declare_proto_rot(set_parm); declare_proto_rot(get_parm); declare_proto_rot(get_info); +declare_proto_rot(get_status); declare_proto_rot(inter_set_conf); /* interactive mode set_conf */ declare_proto_rot(send_cmd); declare_proto_rot(dump_state); @@ -224,6 +225,7 @@ struct test_table test_list[] = { 'x', "get_parm", ACTION(get_parm), ARG_IN1 | ARG_OUT2, "Parm", "Parm Value" }, { 'C', "set_conf", ACTION(inter_set_conf), ARG_IN, "Token", "Value" }, { '_', "get_info", ACTION(get_info), ARG_OUT, "Info" }, + { 's', "get_status", ACTION(get_status), ARG_OUT, "Status flags" }, { 'w', "send_cmd", ACTION(send_cmd), ARG_IN1 | ARG_IN_LINE | ARG_OUT2, "Cmd", "Reply" }, { '1', "dump_caps", ACTION(dump_caps), }, { 0x8f, "dump_state", ACTION(dump_state), ARG_OUT }, @@ -1729,7 +1731,7 @@ declare_proto_rot(set_position) CHKSCN1ARG(sscanf(arg1, "%f", &az)); CHKSCN1ARG(sscanf(arg2, "%f", &el)); - return rot_set_position(rot, az + rot->state.az_offset, el); + return rot_set_position(rot, az, el); } @@ -1742,8 +1744,6 @@ declare_proto_rot(get_position) status = rot_get_position(rot, &az, &el); - az -= rot->state.az_offset; - if (status != RIG_OK) { return status; @@ -1809,6 +1809,32 @@ declare_proto_rot(get_info) } +/* 's' */ +declare_proto_rot(get_status) +{ + int result; + rot_status_t status; + char s[SPRINTF_MAX_SIZE]; + + result = rot_get_status(rot, &status); + + if (result != RIG_OK) + { + return result; + } + + if ((interactive && prompt) || (interactive && !prompt && ext_resp)) + { + fprintf(fout, "%s: ", cmd->arg1); + } + + rot_sprintf_status(s, status); + fprintf(fout, "%s%c", s, resp_sep); + + return RIG_OK; +} + + /* 'M' */ declare_proto_rot(move) { diff --git a/tests/sprintflst.c b/tests/sprintflst.c index 3782aee9..2416df3a 100644 --- a/tests/sprintflst.c +++ b/tests/sprintflst.c @@ -665,6 +665,33 @@ int rig_sprintf_scan(char *str, scan_t rscan) } +int rot_sprintf_status(char *str, rot_status_t status) +{ + int i, len = 0; + + rig_debug(RIG_DEBUG_TRACE, "%s: status=%08x\n", __func__, status); + *str = '\0'; + + if (status == ROT_STATUS_NONE) + { + return 0; + } + + for (i = 0; i < 32; i++) + { + const char *sv; + sv = rot_strstatus(status & ROT_STATUS_N(i)); + + if (sv && sv[0] && (strstr(sv, "None") == 0)) + { + len += sprintf(str + len, "%s ", sv); + } + } + + return len; +} + + char *get_rig_conf_type(enum rig_conf_e type) { switch (type) diff --git a/tests/sprintflst.h b/tests/sprintflst.h index 5fa2c624..2b74f404 100644 --- a/tests/sprintflst.h +++ b/tests/sprintflst.h @@ -23,6 +23,7 @@ #define _SPRINTFLST_H 1 #include <hamlib/rig.h> +#include <hamlib/rotator.h> #define SPRINTF_MAX_SIZE 512 @@ -45,6 +46,7 @@ extern int rig_sprintf_parm_gran(char *str, setting_t parm, const gran_t *gran); extern int rot_sprintf_parm_gran(char *str, setting_t parm, const gran_t *gran); extern int rig_sprintf_vfop(char *str, vfo_op_t op); extern int rig_sprintf_scan(char *str, scan_t rscan); +extern int rot_sprintf_status(char *str, rot_status_t status); extern char *get_rig_conf_type(enum rig_conf_e type); int print_ext_param(const struct confparams *cfp, rig_ptr_t ptr); commit 2e9922b824761ca39e05ab449f0a3bfa3390d8f9 Author: Mikael Nousiainen <mik...@ik...> Date: Wed Dec 2 22:35:38 2020 +0200 Add rotator funcs/levels/parms to rotator caps dump (cherry picked from commit a661bee28394a9b19d3c4ab87aec36b8fe21a0ea) diff --git a/rigs/dummy/rot_dummy.c b/rigs/dummy/rot_dummy.c index 8fd9c370..5cd31783 100644 --- a/rigs/dummy/rot_dummy.c +++ b/rigs/dummy/rot_dummy.c @@ -31,6 +31,7 @@ #include "hamlib/rotator.h" #include "dummy_common.h" #include "register.h" +#include "idx_builtin.h" #include "rot_dummy.h" @@ -847,7 +848,7 @@ const struct rot_caps dummy_rot_caps = ROT_MODEL(ROT_MODEL_DUMMY), .model_name = "Dummy", .mfg_name = "Hamlib", - .version = "20200310.0", + .version = "20201202.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_AZEL, @@ -867,7 +868,7 @@ const struct rot_caps dummy_rot_caps = .has_get_parm = DUMMY_ROT_PARM, .has_set_parm = ROT_PARM_SET(DUMMY_ROT_PARM), - .level_gran = { [ROT_LEVEL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, + .level_gran = { [ROT_LVL_SPEED] = { .min = { .i = 1 }, .max = { .i = 4 }, .step = { .i = 1 } } }, .extlevels = dummy_ext_levels, .extfuncs = dummy_ext_funcs, diff --git a/src/idx_builtin.h b/src/idx_builtin.h index d52b2779..220246fa 100644 --- a/src/idx_builtin.h +++ b/src/idx_builtin.h @@ -23,6 +23,7 @@ #define _IDX_BUILTIN_H 1 #include <hamlib/rig.h> +#include <hamlib/rotator.h> /* * only for Hamlib internal use (backend caps) @@ -185,5 +186,9 @@ #define PARM_BAT setting2idx_builtin(RIG_PARM_BAT) #define PARM_KEYLIGHT setting2idx_builtin(RIG_PARM_KEYLIGHT) +/* Rotator levels */ + +#define ROT_LVL_SPEED setting2idx_builtin(ROT_LEVEL_SPEED) + #endif /* _IDX_BUILTIN_H */ diff --git a/tests/dumpcaps.c b/tests/dumpcaps.c index 5617f8c1..2a27f5d0 100644 --- a/tests/dumpcaps.c +++ b/tests/dumpcaps.c @@ -33,12 +33,15 @@ #include "sprintflst.h" #include "rigctl_parse.h" -static int print_ext(RIG *rig, const struct confparams *cfp, rig_ptr_t ptr); void range_print(FILE *fout, const struct freq_range_list range_list[], int rx); int range_sanity_check(const struct freq_range_list range_list[], int rx); int ts_sanity_check(const struct tuning_step_list tuning_step[]); static void dump_chan_caps(const channel_cap_t *chan, FILE *fout); +static int print_ext(RIG *rig, const struct confparams *cfp, rig_ptr_t ptr) +{ + return print_ext_param(cfp, ptr); +} /* * the rig may be in rig_init state, but not opened @@ -832,41 +835,6 @@ int dumpcaps(RIG *rig, FILE *fout) return backend_warnings; } -static int print_ext(RIG *rig, const struct confparams *cfp, rig_ptr_t ptr) -{ - int i; - fprintf((FILE *)ptr, "\t%s\n", cfp->name); - fprintf((FILE *)ptr, "\t\tType: %s\n", get_rig_conf_type(cfp->type)); - fprintf((FILE *)ptr, "\t\tDefault: %s\n", cfp->dflt != NULL ? cfp->dflt : ""); - fprintf((FILE *)ptr, "\t\tLabel: %s\n", cfp->label != NULL ? cfp->label : ""); - fprintf((FILE *)ptr, "\t\tTooltip: %s\n", - cfp->tooltip != NULL ? cfp->tooltip : ""); - - switch (cfp->type) - { - case RIG_CONF_NUMERIC: - fprintf((FILE *)ptr, "\t\tRange: %g..%g/%g\n", cfp->u.n.min, cfp->u.n.max, - cfp->u.n.step); - break; - - case RIG_CONF_COMBO: - fprintf((FILE *)ptr, "\t\tValues:"); - - for (i = 0; i < RIG_COMBO_MAX && cfp->u.c.combostr[i] != NULL; i++) - { - fprintf((FILE *)ptr, " %d=\"%s\"", i, cfp->u.c.combostr[i]); - } - - fprintf((FILE *)ptr, "\n"); - break; - - default: - break; - } - - return 1; /* process them all */ -} - void range_print(FILE *fout, const struct freq_range_list range_list[], int rx) { int i; diff --git a/tests/dumpcaps_rot.c b/tests/dumpcaps_rot.c index bc0b98b9..0f8def4f 100644 --- a/tests/dumpcaps_rot.c +++ b/tests/dumpcaps_rot.c @@ -34,6 +34,11 @@ #include "rotctl_parse.h" +static int print_ext(ROT *rot, const struct confparams *cfp, rig_ptr_t ptr) +{ + return print_ext_param(cfp, ptr); +} + /* * the rot may be in rot_init state, but not opened */ @@ -41,6 +46,7 @@ int dumpcaps_rot(ROT *rot, FILE *fout) { const struct rot_caps *caps; int backend_warnings = 0; + static char prntbuf[1024]; if (!rot || !rot->caps) { @@ -140,6 +146,51 @@ int dumpcaps_rot(ROT *rot, FILE *fout) "Post Write delay:\t%dmS\n", caps->post_write_delay); + rot_sprintf_func(prntbuf, caps->has_get_func); + fprintf(fout, "Get functions: %s\n", prntbuf); + + rot_sprintf_func(prntbuf, caps->has_set_func); + fprintf(fout, "Set functions: %s\n", prntbuf); + + fprintf(fout, "Extra functions:\n"); + rot_ext_func_foreach(rot, print_ext, fout); + + rot_sprintf_level_gran(prntbuf, caps->has_get_level, caps->level_gran); + fprintf(fout, "Get level: %s\n", prntbuf); + + if ((caps->has_get_level & RIG_LEVEL_SQLSTAT)) + { + fprintf(fout, "Warning--backend uses deprecated SQLSTAT level!\n"); + backend_warnings++; + } + + rot_sprintf_level_gran(prntbuf, caps->has_set_level, caps->level_gran); + fprintf(fout, "Set level: %s\n", prntbuf); + + if (caps->has_set_level & ROT_LEVEL_READONLY_LIST) + { + fprintf(fout, "Warning--backend can set readonly levels!\n"); + backend_warnings++; + } + + fprintf(fout, "Extra levels:\n"); + rot_ext_level_foreach(rot, print_ext, fout); + + rot_sprintf_parm_gran(prntbuf, caps->has_get_parm, caps->parm_gran); + fprintf(fout, "Get parameters: %s\n", prntbuf); + + rot_sprintf_parm_gran(prntbuf, caps->has_set_parm, caps->parm_gran); + fprintf(fout, "Set parameters: %s\n", prntbuf); + + if (caps->has_set_parm & ROT_PARM_READONLY_LIST) + { + fprintf(fout, "Warning--backend can set readonly parms!\n"); + backend_warnings++; + } + + fprintf(fout, "Extra parameters:\n"); + rot_ext_parm_foreach(rot, print_ext, fout); + fprintf(fout, "Min Azimuth:\t\t%.2f\n", caps->min_az); fprintf(fout, "Max Azimuth:\t\t%.2f\n", caps->max_az); diff --git a/tests/sprintflst.c b/tests/sprintflst.c index 181d769f..3782aee9 100644 --- a/tests/sprintflst.c +++ b/tests/sprintflst.c @@ -690,3 +690,38 @@ char *get_rig_conf_type(enum rig_conf_e type) return "... [truncated message content] |