diff -uNr indi.virgin/libindi/drivers/telescope/celestrondriver.cpp indi.celestrongps/libindi/drivers/telescope/celestrondriver.cpp --- indi.virgin/libindi/drivers/telescope/celestrondriver.cpp 2017-06-05 22:29:33.446877698 +0200 +++ indi.celestrongps/libindi/drivers/telescope/celestrondriver.cpp 2017-06-16 23:58:15.248507995 +0200 @@ -191,7 +191,15 @@ if (rc == false) return false; - if (info->controllerVersion >= 2.2) + DEBUGDEVICE(celestron_device, INDI::Logger::DBG_DEBUG, "Getting controller variant..."); + rc = get_celestron_variant(fd, info); + + if (rc == false) + return false; + + if (((info->controllerVariant == ISSTARSENSE) && + info->controllerVersion >= MINSTSENSVER) || + (info->controllerVersion >= 2.2)) { DEBUGDEVICE(celestron_device, INDI::Logger::DBG_DEBUG, "Getting controller model..."); rc = get_celestron_model(fd, info); @@ -280,6 +288,59 @@ return false; } + +bool get_celestron_variant (int fd, FirmwareInfo * info) +{ + char cmd[] = "v"; + int errcode = 0; + char errmsg[MAXRBUF]; + char response[16]; + int nbytes_read = 0; + int nbytes_written = 0; + + DEBUGFDEVICE(celestron_device, INDI::Logger::DBG_DEBUG, "CMD (%s)", cmd); + + if (celestron_simulation) + { + char res = 0x11; + snprintf(response, 16, "%c#", res); + nbytes_read = strlen(response); + } + else + { + tcflush(fd, TCIOFLUSH); + + if ( (errcode = tty_write(fd, cmd, strlen(cmd), &nbytes_written)) != TTY_OK) + { + tty_error_msg(errcode, errmsg, MAXRBUF); + DEBUGFDEVICE(celestron_device, INDI::Logger::DBG_ERROR, "%s", errmsg); + return false; + } + + if ( (errcode = tty_read_section(fd, response, '#', CELESTRON_TIMEOUT, &nbytes_read))) + { + tty_error_msg(errcode, errmsg, MAXRBUF); + DEBUGFDEVICE(celestron_device, INDI::Logger::DBG_ERROR, "%s", errmsg); + return false; + } + } + + if (nbytes_read > 0) + { + response[nbytes_read] = '\0'; + DEBUGFDEVICE(celestron_device, INDI::Logger::DBG_DEBUG, "RES (%02X %02X)", response[0], response[1]); + + if (nbytes_read == 2) + { + info->controllerVariant = response[0]; + return true; + } + } + + DEBUGFDEVICE(celestron_device, INDI::Logger::DBG_ERROR, "Received #%d bytes, expected 2.", nbytes_read); + return false; + +} bool get_celestron_model (int fd, FirmwareInfo * info) { diff -uNr indi.virgin/libindi/drivers/telescope/celestrondriver.h indi.celestrongps/libindi/drivers/telescope/celestrondriver.h --- indi.virgin/libindi/drivers/telescope/celestrondriver.h 2017-06-05 22:29:33.446877698 +0200 +++ indi.celestrongps/libindi/drivers/telescope/celestrondriver.h 2017-06-16 23:58:15.248507995 +0200 @@ -27,6 +27,11 @@ #include +/* Starsense specific constants */ +#define ISNEXSTAR 0x11 +#define ISSTARSENSE 0x13 +#define MINSTSENSVER float(1.18) + typedef enum { GPS_OFF, GPS_ON } CELESTRON_GPS_STATUS; typedef enum { SR_1, SR_2, SR_3, SR_4, SR_5, SR_6, SR_7, SR_8, SR_9} CELESTRON_SLEW_RATE; typedef enum { TRACK_OFF, TRACK_ALTAZ, TRACK_EQN, TRACK_EQS} CELESTRON_TRACK_MODE; @@ -43,6 +48,8 @@ std::string DEFirmware; float controllerVersion; + char controllerVariant; + } FirmwareInfo; /************************************************************************** @@ -75,6 +82,8 @@ bool get_celestron_firmware(int fd, FirmwareInfo * info); /** Get version */ bool get_celestron_version(int fd, FirmwareInfo * info); +/** Get hand controller variant */ +bool get_celestron_variant(int fd, FirmwareInfo * info); /** Get Mount model */ bool get_celestron_model(int fd, FirmwareInfo * info); /** Get GPS Firmware version */ diff -uNr indi.virgin/libindi/drivers/telescope/celestrongps.cpp indi.celestrongps/libindi/drivers/telescope/celestrongps.cpp --- indi.virgin/libindi/drivers/telescope/celestrongps.cpp 2017-06-05 22:29:33.446877698 +0200 +++ indi.celestrongps/libindi/drivers/telescope/celestrongps.cpp 2017-06-16 23:58:15.248507995 +0200 @@ -112,6 +112,7 @@ fwInfo.Version = "Invalid"; fwInfo.controllerVersion = 0; + fwInfo.controllerVariant = ISNEXSTAR; INDI::Logger::getInstance().addDebugLevel("Scope Verbose", "SCOPE"); @@ -209,7 +210,7 @@ { if (isConnected()) { - uint32_t cap = TELESCOPE_CAN_GOTO | TELESCOPE_CAN_ABORT | TELESCOPE_CAN_PARK; + uint32_t cap = TELESCOPE_CAN_GOTO | TELESCOPE_CAN_ABORT; if (get_celestron_firmware(PortFD, &fwInfo)) { @@ -225,14 +226,39 @@ DEBUG(INDI::Logger::DBG_WARNING, "Failed to retrive firmware information."); } - if (fwInfo.controllerVersion <= 4.1) + /* Since issues have been observed with Starsense, + enabe parking only with Nexstar controller */ + + if (fwInfo.controllerVariant == ISSTARSENSE) + { + if (fwInfo.controllerVersion >= MINSTSENSVER) + { + DEBUG(INDI::Logger::DBG_SESSION, "Starsense controller detected."); + } + else + { + DEBUGF(INDI::Logger::DBG_WARNING, "Starsense controller detected, but firmware is too old. Current version is %4.2f, but minimum required version is %4.2f. Please update your Starsense firmware.", fwInfo.controllerVersion, MINSTSENSVER); + } + } + else + { + cap |= TELESCOPE_CAN_PARK; + } + + if (((fwInfo.controllerVariant == ISSTARSENSE) && + (fwInfo.controllerVersion < MINSTSENSVER)) || + ((fwInfo.controllerVariant == ISNEXSTAR) && + (fwInfo.controllerVersion <= 4.1))) { DEBUG(INDI::Logger::DBG_WARNING, "Mount firmware does not support sync."); } else cap |= TELESCOPE_CAN_SYNC; - if (fwInfo.controllerVersion < 2.3) + if (((fwInfo.controllerVariant == ISSTARSENSE) && + (fwInfo.controllerVersion < MINSTSENSVER)) || + ((fwInfo.controllerVariant == ISNEXSTAR) && + (fwInfo.controllerVersion < 2.3))) { DEBUG(INDI::Logger::DBG_WARNING, "Mount firmware does not support update of time and location settings."); } @@ -283,6 +309,8 @@ // JM 2014-04-14: User (davidw) reported AVX mount serial communication times out issuing "h" command with firmware 5.28 // Therefore disabling query until it is fixed. + // Does not seem to be a problem with Starsense on AVX with + // firmware 1.18, hence leave it enabled if (fwInfo.controllerVersion >= 2.3 && fwInfo.Model != "AVX") { double utc_offset; @@ -355,7 +383,10 @@ bool CelestronGPS::Sync(double ra, double dec) { - if (fwInfo.controllerVersion <= 4.1) + if (((fwInfo.controllerVariant == ISSTARSENSE) && + (fwInfo.controllerVersion < MINSTSENSVER)) || + ((fwInfo.controllerVariant == ISNEXSTAR) && + (fwInfo.controllerVersion <= 4.1))) { DEBUGF(INDI::Logger::DBG_WARNING, "Firmwre version 4.1 or higher is required to sync. Current version is %3.1f", fwInfo.controllerVersion); return false; @@ -939,7 +970,10 @@ { INDI_UNUSED(elevation); - if (fwInfo.controllerVersion < 2.3) + if (((fwInfo.controllerVariant == ISSTARSENSE) && + (fwInfo.controllerVersion < MINSTSENSVER)) || + ((fwInfo.controllerVariant == ISNEXSTAR) && + (fwInfo.controllerVersion < 2.3))) { DEBUGF(INDI::Logger::DBG_WARNING, "Firmwre version 2.3 or higher is required to update location. Current version is %3.1f", fwInfo.controllerVersion); return false; @@ -950,7 +984,10 @@ bool CelestronGPS::updateTime(ln_date * utc, double utc_offset) { - if (fwInfo.controllerVersion < 2.3) + if (((fwInfo.controllerVariant == ISSTARSENSE) && + (fwInfo.controllerVersion < MINSTSENSVER)) || + ((fwInfo.controllerVariant == ISNEXSTAR) && + (fwInfo.controllerVersion < 2.3))) { DEBUGF(INDI::Logger::DBG_WARNING, "Firmwre version 2.3 or higher is required to update time. Current version is %3.1f", fwInfo.controllerVersion); return false;