diff --git a/rotators/skywatcher/skywatcher.c b/rotators/skywatcher/skywatcher.c index c7b65801b..4216b963d 100644 --- a/rotators/skywatcher/skywatcher.c +++ b/rotators/skywatcher/skywatcher.c @@ -58,9 +58,10 @@ static int skywatcher_cmd(ROT *rot, const char *cmd, char *response, rig_flush(port); size_t cmd_len = strlen(cmd); ERROR_CHECK(write_block(port, (unsigned char *) cmd, cmd_len)); - // echo from the device - int code = read_string(port, (unsigned char *) response, response_len, "\r", 1, - 0, 1); + + // the actual response + int code = read_string(port, (unsigned char *) response, response_len, "\r", 1, 0, + 1); if (code < 0) { @@ -212,14 +213,26 @@ int skywatcher_set_motor_position(ROT *rot, int motor_index, float angle) if (!stopped) { - return RIG_EPROTO; + // ignore instructions to move the motor as long as it is moving + rig_debug(RIG_DEBUG_TRACE, "%s called: motor:%d angle:%f but the motor is moving - ignoring \n", __func__, motor_index, angle); + // pretend it's OK + return RIG_OK; + + /* + Changed behavior for incoming requests to change position. + If the motor is moving, the requests are silently ignored. + Stopping the motor movement before each request to change position caused the movement from point A to point B to take a very long time + because tracking applications send the dynamic position of the tracked object (e.g. satellite) in regular short intervals and in case + the rotator was on the opposite side, by the time the rotator reached the position of the object, + the object had traveled a considerable distance. gereta @ 10.Mar.2025 + */ } SNPRINTF(req, sizeof(req), ":G%d00\r", motor_index); ERROR_CHECK(skywatcher_cmd(rot, req, str, sizeof(str))); uint32_t cpr; ERROR_CHECK(skywatcher_get_spr(rot, motor_index, &cpr)); - double ticks_per_angle = (double) cpr / 360.0; + double ticks_per_angle = (double) cpr / 360.0; uint32_t value = ((uint32_t)(ticks_per_angle * angle)) & 0xFFFFFF; value = value | 0x800000; SNPRINTF(req, sizeof(req), ":S%d%02X%02X%02X\r", motor_index, (value & 0xFF), @@ -234,9 +247,7 @@ int skywatcher_set_motor_position(ROT *rot, int motor_index, float angle) static int skywatcher_set_position(ROT *rot, azimuth_t az, elevation_t el) { rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __func__, az, el); - ERROR_CHECK(skywatcher_stop(rot)); - // stop is called for 1 then for 2 motor. do motor position in reverse because it awaits "stop motor" state. - // potentially saving 1 call to :f + ERROR_CHECK(skywatcher_set_motor_position(rot, 2, el)); ERROR_CHECK(skywatcher_set_motor_position(rot, 1, az)); return RIG_OK; @@ -270,6 +281,16 @@ static int skywatcher_cleanup(ROT *rot) return RIG_OK; } +static int skywatcher_park(ROT *rot) +{ + rig_debug(RIG_DEBUG_TRACE, "%s called: %d %d\n", __func__, 0, 0); + + ERROR_CHECK(skywatcher_set_motor_position(rot, 1, 0)); + ERROR_CHECK(skywatcher_set_motor_position(rot, 2, 0)); + + return RIG_OK; +} + /* ************************************************************************* */ /* * Protocol documentation: @@ -280,7 +301,7 @@ const struct rot_caps skywatcher_rot_caps = ROT_MODEL(ROT_MODEL_SKYWATCHER), .model_name = "Sky-Watcher", .mfg_name = "Sky-Watcher", - .version = "20240825.0", + .version = "20250310.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rot_type = ROT_TYPE_AZEL, @@ -307,6 +328,7 @@ const struct rot_caps skywatcher_rot_caps = .set_position = skywatcher_set_position, .stop = skywatcher_stop, .get_info = skywatcher_get_info, + .park = skywatcher_park, };