From c0b510d80410b411541afc497ecbf2097259ea6b Mon Sep 17 00:00:00 2001 From: Nate Bargmann Date: Mon, 15 Sep 2014 05:45:45 -0500 Subject: [PATCH] Implement precision set_position for RT-21 The RT-21 will accept the command 'AP1XXX.Y;' which allows settings to 1/10 of a degree. XXX must be zero padded. '' causes the RT-21 to rotate to the position immediately with out the need for a following 'AM1;' command. Tested by Will, WC2L. --- rotorez/rotorez.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/rotorez/rotorez.c b/rotorez/rotorez.c index 37ab6e6de..51766948e 100644 --- a/rotorez/rotorez.c +++ b/rotorez/rotorez.c @@ -61,6 +61,7 @@ static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t ele static int rotorez_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation); static int erc_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation); static int rt21_rot_get_position(ROT *rot, azimuth_t *azimuth, elevation_t *elevation); +static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation); static int rotorez_rot_reset(ROT *rot, rot_reset_t reset); static int rotorez_rot_stop(ROT *rot); @@ -292,7 +293,7 @@ const struct rot_caps rt21_rot_caps = { .rot_model = ROT_MODEL_RT21, .model_name = "RT-21", .mfg_name = "Green Heron", - .version = "2014-09-12a", + .version = "2014-09-14", .copyright = "LGPL", .status = RIG_STATUS_ALPHA, .rot_type = ROT_TYPE_OTHER, @@ -318,7 +319,7 @@ const struct rot_caps rt21_rot_caps = { .rot_init = rotorez_rot_init, .rot_cleanup = rotorez_rot_cleanup, - .set_position = rotorez_rot_set_position, + .set_position = rt21_rot_set_position, .get_position = rt21_rot_get_position, // .stop = rotorez_rot_stop, // .set_conf = rotorez_rot_set_conf, @@ -415,6 +416,35 @@ static int rotorez_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t ele } +/* + * RT-21 Set position. + * + * RT-21 has a custom command to set azimuth to a precision of 1/10 of a + * degree--"AP1XXX.Y\r;". XXX must be zero padded. The '\r' causes the + * command to be executed immediately (no need to send "AM1;"). + */ + +static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth, elevation_t elevation) { + char cmdstr[16]; + int err; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rot) + return -RIG_EINVAL; + + if (azimuth < 0 || azimuth > 360) + return -RIG_EINVAL; + + sprintf(cmdstr, "AP1%05.1f\r;", azimuth); /* Total field width of 5 chars */ + err = rotorez_send_priv_cmd(rot, cmdstr); + if (err != RIG_OK) + return err; + + return RIG_OK; +} + + /* * Get position * Returns current azimuth position in whole degrees.