From 046f3c448dd2a3f64bc347c8a0436a52f99f3e28 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 1 Aug 2021 12:14:17 -0500 Subject: [PATCH] Allow 2nd rotator port for RT-21 Az/El model https://github.com/Hamlib/Hamlib/issues/747 --- rotators/rotorez/rotorez.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/rotators/rotorez/rotorez.c b/rotators/rotorez/rotorez.c index c9e7fe1cb..e60a3cec1 100644 --- a/rotators/rotorez/rotorez.c +++ b/rotators/rotorez/rotorez.c @@ -90,6 +90,7 @@ struct rotorez_rot_priv_data */ static int rotorez_send_priv_cmd(ROT *rot, const char *cmd); +static int rotorez_send_priv_cmd2(ROT *rot, const char *cmd); static int rotorez_flush_buffer(ROT *rot); /* @@ -309,7 +310,7 @@ const struct rot_caps rt21_rot_caps = ROT_MODEL(ROT_MODEL_RT21), .model_name = "RT-21", .mfg_name = "Green Heron", - .version = "20210723.0", + .version = "20210801.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_OTHER, @@ -488,6 +489,15 @@ static int rt21_rot_set_position(ROT *rot, azimuth_t azimuth, return err; } + if (rot->state.rotport2.pathname[0] != 0) + sprintf(cmdstr, "AP1%05.1f\r;", elevation); /* Total field width of 5 chars */ + err = rotorez_send_priv_cmd2(rot, cmdstr); + + if (err != RIG_OK) + { + return err; + } + return RIG_OK; } @@ -1003,6 +1013,30 @@ static int rotorez_send_priv_cmd(ROT *rot, const char *cmdstr) return RIG_OK; } +// send command to 2nd rotator port +static int rotorez_send_priv_cmd2(ROT *rot, const char *cmdstr) +{ + struct rot_state *rs; + int err; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + + if (!rot) + { + return -RIG_EINVAL; + } + + rs = &rot->state; + err = write_block(&rs->rotport2, cmdstr, strlen(cmdstr)); + + if (err != RIG_OK) + { + return err; + } + + return RIG_OK; +} + /* * Flush the serial input buffer