OnStepX
OnStepX copied to clipboard
Adding command :SGsHH.H# on LX200 protocol
The file "src/telescope/mount/site/Site.command.cpp" does not implement the following format for the :SG command:
:SGsHH.H#
that is used by programs like SkySafari. This returns un error to set the "number of hours added to local time" . This format is documented in the LX200 protocol docs.
The comment on the .cpp file does not mention the above format: // :SG[sHH]# or :SG[sHH:MM]# (where MM is 00, 30, or 45) // Set the number of hours added to local time to yield UT1 // Return: 0 failure, 1 success
I've tested using an LX200 telescope and all 3 formats (without the "[ ]") are allowed by the original firmware.
It seems that the method "Convert::tzToDouble()" in the file "src/lib/convert/Convert.cpp" should be changed to something like below to allow this format.
bool Convert::tzToDouble(double *value, char *hm) { int16_t sign = 1; int16_t hour, minute = 0; double dHour = 0.0;
if (strlen(hm) < 1 || strlen(hm) > 6) return false;
// determine if the sign was used, skip any '+' if (hm[0] == '-') { sign = -1; hm++; } else if (hm[0] == '+') hm++;
// if there is a float part, convert it: charf = strchr(hm,'.'); if (f != NULL) { if (!atof2(hm, &dHour, false)) return false; value = sign(dHour); } else { // if there's a minute part convert it and mark the end of the hours string char m = strchr(hm,':'); if (m != NULL) { m[0] = 0; m++; if (strlen(m) != 2) return false; if (!atoi2(m, &minute, false)) return false; // only these exact minutes are allowed for time zones if (minute != 45 && minute != 30 && minute != 0) return false; }
if (!atoi2(hm, &hour, false)) return false;
*value = sign*(hour + minute/60.0);
}