35#define LIBRARY_TAB "Library"
36#define FIRMWARE_TAB "Firmware data"
37#define STATUS_TAB "ONStep Status"
39#define ALIGN_TAB "Align"
40#define OUTPUT_TAB "Outputs"
41#define ENVIRONMENT_TAB "Weather"
42#define ROTATOR_TAB "Rotator"
53 currentSubCatalog = 0;
90 return "LX200 OnStep";
141 MaxSlewRateNP[0].fill(
"maxSlew",
"Rate",
"%f", 0.0, 9.0, 1.0, 5.0);
155 BacklashNP[0].fill(
"Backlash DEC",
"DE",
"%g", 0, 3600, 1, 15);
156 BacklashNP[1].fill(
"Backlash RA",
"RA",
"%g", 0, 3600, 1, 15);
224 TFCCoefficientNP[0].fill(
"TFC Coefficient",
"TFC Coefficient µm/°C",
"%+03.5f", -999.99999, 999.99999, 1, 100);
227 TFCDeadbandNP[0].fill(
"TFC Deadband",
"TFC Deadband µm",
"%g", 1, 32767, 1, 5);
265 OSFocus2TargNP[0].fill(
"FocusTarget2",
"Abs Pos",
"%g", -25000, 25000, 1, 0);
336 OSNAlignTP[0].fill(
"0",
"Align Process Status",
"Align not started");
337 OSNAlignTP[1].fill(
"1",
"1. Manual Process",
"Point towards the NCP");
338 OSNAlignTP[2].fill(
"2",
"2. Plate Solver Process",
"Point towards the NCP");
339 OSNAlignTP[3].fill(
"3",
"Manual Action after 1",
"Press 'Start Align'");
340 OSNAlignTP[4].fill(
"4",
"Current Status",
"Not Updated");
341 OSNAlignTP[5].fill(
"5",
"Max Stars",
"Not Updated");
342 OSNAlignTP[6].fill(
"6",
"Current Star",
"Not Updated");
343 OSNAlignTP[7].fill(
"7",
"# of Align Stars",
"Not Updated");
346 OSNAlignErrTP[0].fill(
"0",
"EQ Polar Error Alt",
"Available once Aligned");
347 OSNAlignErrTP[1].fill(
"1",
"EQ Polar Error Az",
"Available once Aligned");
364 IUFillSwitchVector(&OSOutput1SP, OSOutput1S, 2,
getDeviceName(),
"Output 1",
"Output 1",
OUTPUT_TAB,
IP_RW,
ISR_ATMOST1, 60,
369 IUFillSwitchVector(&OSOutput2SP, OSOutput2S, 2,
getDeviceName(),
"Output 2",
"Output 2",
OUTPUT_TAB,
IP_RW,
ISR_ATMOST1, 60,
376 snprintf(port_name,
sizeof(port_name),
"Output %d", i);
403 OSSetHumidityNP[0].fill(
"Set Relative Humidity (%)",
"%",
"%5.2f", 0, 100, 1, 70);
406 OSSetPressureNP[0].fill(
"Set Pressure (hPa)",
"hPa",
"%4f", 500, 1500, 1, 1010);
412 OSSetAltitudeNP[0].fill(
"Set Altitude (m)",
"m",
"%4f", 0, 20000, 1, 110);
417 addParameter(
"WEATHER_TEMPERATURE",
"Temperature (C)", -40, 85, 15);
418 addParameter(
"WEATHER_HUMIDITY",
"Humidity %", 0, 100, 15);
419 addParameter(
"WEATHER_BAROMETER",
"Pressure (hPa)", 0, 1500, 15);
420 addParameter(
"WEATHER_DEWPOINT",
"Dew Point (C)", 0, 100, 15);
421 addParameter(
"WEATHER_CPU_TEMPERATURE",
"OnStep CPU Temperature", -274, 200, -274);
434 if (dev !=
nullptr && strcmp(dev,
getDeviceName()) != 0)
return;
447 if (!activeConnection->
name().compare(
"CONNECTION_TCP"))
449 LOG_INFO(
"Network based connection, detection timeouts set to 2 seconds");
455 LOG_INFO(
"Non-Network based connection, detection timeouts set to 0.1 seconds");
499 if (error_or_fail > 0 && response[0] ==
'1')
516 LOGF_DEBUG(
"error_or_fail = %u, response = %c", error_or_fail, response[0]);
539 LOG_INFO(
"Version unknown or OnStepX (Checking for OnStepX Focusers)");
540 for (
int i = 0; i < 9; i++)
544 snprintf(
cmd,
sizeof(
cmd),
":F%dA#", i + 1);
547 if (!fail_or_error && read_buffer[0] ==
'1')
554 if(fail_or_error < 0)
557 LOGF_INFO(
"Function call failed in a way that says OnStep doesn't have this setup, stopping Focuser probing, return: %i",
578 LOG_INFO(
"At least one focuser found, showing interface");
582 LOG_DEBUG(
"Focusers checked Variables:");
588 if (error_or_fail > 0)
590 if (rotator_response[0] ==
'D' || rotator_response[0] ==
'R')
598 if (rotator_response[0] ==
'D')
602 if (rotator_response[0] ==
'0')
610 LOG_WARN(
"Error on response to rotator check (:GX98#) CHECK CONNECTION");
672 double longitude = -1000, latitude = -1000;
771 LOG_INFO(
"Initialization Complete");
779 if (strstr(name,
"FOCUS_"))
781 if (strstr(name,
"ROTATOR_"))
784 if (
EqNP.isNameMatch(name))
793 for (
int x = 0; x <
n; x++)
801 if ((
ra >= 0) && (
ra <= 24) && (
dec >= -90) && (
dec <= 90))
808 LOG_DEBUG(
"Please unpark the mount before issuing any motion/sync commands.");
816 if (Telescope::CanSync())
818 auto oneSwitch =
CoordSP.findWidgetByName(
"SYNC");
819 if (oneSwitch && oneSwitch->getState() ==
ISS_ON)
840 char object_name[256];
846 LOG_ERROR(
"Failed to select catalog object.");
871 snprintf(
cmd, 5,
":R%d#", (
int)values[0]);
878 LOGF_DEBUG(
"Setting Max Slew Rate to %f\n", values[0]);
881 LOG_ERROR(
"Setting Max Slew Rate Failed");
888 LOGF_INFO(
"Slewrate set to %04.1f", values[0]);
900 double bklshdec = 0, bklshra = 0;
902 for (nset = i = 0; i <
n; i++)
906 bklshdec = values[i];
907 LOGF_DEBUG(
"===CMD==> Backlash DEC= %f", bklshdec);
908 nset += bklshdec >= 0 && bklshdec <= 999;
913 LOGF_DEBUG(
"===CMD==> Backlash RA= %f", bklshra);
914 nset += bklshra >= 0 && bklshra <= 999;
920 snprintf(
cmd, 9,
":$BD%d#", (
int)bklshdec);
927 const struct timespec timeout = {0, 100000000L};
928 nanosleep(&timeout,
nullptr);
929 snprintf(
cmd, 9,
":$BR%d#", (
int)bklshra);
955 double minAlt = 0, maxAlt = 0;
958 for (nset = i = 0; i <
n; i++)
963 nset += minAlt >= -30.0 && minAlt <= 30.0;
968 nset += maxAlt >= 60.0 && maxAlt <= 90.0;
976 LOG_ERROR(
"Error setting min elevation limit.");
983 LOG_ERROR(
"Error setting max elevation limit.");
996 LOG_ERROR(
"elevation limit missing or invalid.");
1006 double minPMEast = 0, minPMWest = 0;
1008 for (nset = i = 0; i <
n; i++)
1012 minPMEast = values[i];
1013 LOGF_DEBUG(
"===CMD==> minutesPastMeridianN[0]/East = %f", minPMEast);
1014 nset += minPMEast >= -180 && minPMEast <= 180;
1018 minPMWest = values[i];
1019 LOGF_DEBUG(
"===CMD==> minutesPastMeridianN[1]/West= %f", minPMWest);
1020 nset += minPMWest >= -180 && minPMWest <= 180;
1026 snprintf(
cmd, 20,
":SXE9,%d#", (
int) minPMEast);
1031 LOG_ERROR(
"Error minutesPastMeridian East.");
1033 const struct timespec timeout = {0, 100000000L};
1034 nanosleep(&timeout,
nullptr);
1035 snprintf(
cmd, 20,
":SXEA,%d#", (
int) minPMWest);
1040 LOG_ERROR(
"Error minutesPastMeridian West.");
1053 LOG_ERROR(
"minutesPastMeridian invalid.");
1065 if ((values[0] >= -25000) && (values[0] <= 25000))
1067 snprintf(
cmd, 15,
":fR%d#", (
int)values[0]);
1070 OSFocus2TargNP.apply(
"Focuser 2 position (relative) moved by %d", (
int)values[0]);
1084 for(
int i = 0; i <
n; i++)
1086 int value = (int)values[i];
1094 snprintf(
cmd,
sizeof(
cmd),
":SXX%d,V%d#", port, value);
1101 LOGF_ERROR(
"Set port %d to value =%d failed", port, value);
1119 if ((values[0] >= -100) && (values[0] <= 100))
1122 snprintf(
cmd, 15,
":SX9A,%d#", (
int)values[0]);
1140 if ((values[0] >= 0) && (values[0] <= 100))
1142 snprintf(
cmd, 15,
":SX9C,%d#", (
int)values[0]);
1160 if ((values[0] >= 500) && (values[0] <= 1100))
1162 snprintf(
cmd, 15,
":SX9B,%d#", (
int)values[0]);
1182 if (abs(values[0]) < 1000)
1184 snprintf(
cmd, 15,
":FC%+3.5f#", values[0]);
1202 if ((values[0] >= 1) && (values[0] <= 32768))
1204 snprintf(
cmd, 15,
":FD%d#", (
int)values[0]);
1207 TFCDeadbandNP.apply(
"TFC Deadbandset to %d", (
int)values[0]);
1221 if (strstr(name,
"WEATHER_"))
1251 LOG_WARN(
"Telescope is Parked, Unpark before tracking.");
1270 LOG_DEBUG(
"TrackStateSP intercept, OnStep driver, should never get here");
1277 if (
ReticSP.isNameMatch(name))
1308 snprintf(
cmd,
sizeof(
cmd),
":R%d#", index);
1315 LOGF_DEBUG(
"Setting Max Slew Rate to %u\n", index);
1317 LOG_ERROR(
"Setting Max Slew Rate Failed");
1344 TrackCompSP.apply(
"Full Compensated Tracking On");
1362 TrackCompSP.apply(
"Refraction Tracking Disabled");
1554 snprintf(
cmd, 5,
":FZ#");
1562 snprintf(
cmd, 5,
":FH#");
1578 LOGF_INFO(
"Primary focuser set: Focuser 1 in INDI/Controllable Focuser = OnStep Focuser %d", index + 1);
1581 LOG_INFO(
"If using OnStep: Focuser 2 in INDI = OnStep Focuser 2");
1585 LOG_INFO(
"If using OnStep: Focuser 2 in INDI = OnStep Focuser 1");
1591 snprintf(
cmd, 7,
":FA%d#", index + 1 );
1613 snprintf(
cmd, 5,
":F%d#", index + 1);
1628 strncpy(
cmd,
":f+#",
sizeof(
cmd));
1632 strncpy(
cmd,
":f-#",
sizeof(
cmd));
1636 strncpy(
cmd,
":fQ#",
sizeof(
cmd));
1639 const struct timespec timeout = {0, 100000000L};
1640 nanosleep(&timeout,
nullptr);
1659 strncpy(
cmd,
":r-#",
sizeof(
cmd));
1663 strncpy(
cmd,
":r+#",
sizeof(
cmd));
1729 else if (index == 1)
1760 if ((index_stars <= 8) && (index_stars >= 0))
1762 int stars = index_stars + 1;
1764 LOGF_INFO(
"Align index: %d, stars: %d", index_stars, stars);
1803 LOG_INFO(
"Step 1: Goto a bright star between 50 and 80 degrees N/S from the pole. Preferably on the Meridian.");
1804 LOG_INFO(
"Step 2: Make sure it is centered.");
1805 LOG_INFO(
"Step 3: Press Refine Polar Alignment.");
1806 LOG_INFO(
"Step 4: Using the mount's Alt and Az screws manually recenter the star. (Video mode if your camera supports it will be helpful.)");
1807 LOG_INFO(
"Optional: Start a new alignment.");
1816 snprintf(
cmd, 5,
":MP#");
1830 if(res > 0 && response[0] ==
'0')
1832 LOG_INFO(
"Command for Refine Polar Alignment Successful");
1840 LOGF_ERROR(
"Command for Refine Polar Alignment Failed, error=%s", response[0]);
1863 snprintf(
cmd,
sizeof(
cmd),
":Fc0#");
1870 snprintf(
cmd,
sizeof(
cmd),
":Fc1#");
1883#ifdef ONSTEP_NOTDONE
1884 if (OSOutput1SP.isNameMatch(name))
1886 OSOutput1SP.update(states, names,
n);
1887 if (OSOutput1SP[0].getState() ==
ISS_ON)
1892 else if (OSOutput1SP[1].getState() ==
ISS_ON)
1897 OSOutput1SP.apply();
1900 if (OSOutput2SP.isNameMatch(name))
1902 OSOutput2SP.update(states, names,
n);
1903 if (OSOutput2SP[0].getState() ==
ISS_ON)
1908 else if (OSOutput2SP[1].getState() ==
ISS_ON)
1913 OSOutput2SP.apply();
1919 if (strstr(name,
"FOCUS"))
1924 if (strstr(name,
"ROTATOR"))
1940 char buffer[128] = {0};
1954 LOG_INFO(
"Old OnStep (V1/V2 depreciated) detected, setting some defaults");
1955 LOG_INFO(
"Note: Everything should work, but it may have timeouts in places, as it's not tested against.");
1962 LOG_INFO(
"V3 OnStep detected, setting some defaults");
1969 LOG_INFO(
"V4 OnStep detected, setting some defaults");
1976 LOG_INFO(
"V5 OnStep detected, setting some defaults");
1983 LOG_INFO(
"OnStepX detected, setting some defaults");
1989 LOG_INFO(
"OnStep/OnStepX version could not be detected");
1999 bool mountTypeDetected =
false;
2004 mountTypeDetected =
true;
2005 switch (mountTypeResponse[0])
2010 LOG_INFO(
"Mount type detected: AltAz");
2015 LOG_INFO(
"Mount type detected: Fork (Equatorial)");
2020 LOG_INFO(
"Mount type detected: GEM");
2023 mountTypeDetected =
false;
2028 if (!mountTypeDetected)
2029 LOGF_WARN(
"Could not determine mount type via :GW# (error %d, reply '%s'), "
2030 "it will be determined from :GU# status", gw_error, mountTypeResponse);
2035 LOG_INFO(
"=============== Parkdata loaded");
2040 LOG_INFO(
"=============== Parkdata Load Failed");
2051 if(error_or_fail != 1 || response[0] !=
'1')
2053 LOGF_WARN(
"===CMD==> Set Park Pos %s", response);
2058 LOG_WARN(
"Park Value set to current position");
2067 LOG_WARN(
"Park Position set to Default value, 20/80");
2079 if ((response[0] !=
'1') || (failure_or_error < 0))
2098 Telescope::AbortSP.apply();
2101 Telescope::AbortSP.setState(
IPS_OK);
2104 Telescope::AbortSP.apply();
2132 LOG_INFO(
"Parking telescope in progress...");
2138static const char *gotoStopReason(
Errors error)
2143 return "Motor/Driver Fault";
2145 return "Below Horizon Limit";
2147 return "Limit Sense";
2149 return "Dec Limit Exceeded";
2151 return "Azm Limit Exceeded";
2153 return "Under Pole Limit Exceeded";
2156 return "Meridian Limit Exceeded";
2158 return "Above Overhead Limit";
2170 bool pier_not_set =
true;
2180 tcflush(
PortFD, TCIOFLUSH);
2194 if (error_or_fail > 1)
2201 if (sscanf(
OSStat,
"%s%[pIPF]%s%[0-9]%[0-9]%[0-9]", check_GU_valid1, &check_GU_valid2[0], check_GU_valid3,
2202 &check_GU_valid2[1], &check_GU_valid2[2], &check_GU_valid2[3]) != 1)
2204 LOG_WARN(
":GU# returned something that can not be right, this update aborted, will try again...");
2205 LOGF_DEBUG(
"Parameters matched: %u from %s", sscanf(
OSStat,
"%s%[pIPF]%s%[0-9]%[0-9]%[0-9]", check_GU_valid1,
2206 &check_GU_valid2[0], check_GU_valid3, &check_GU_valid2[1], &check_GU_valid2[2], &check_GU_valid2[3]),
OSStat);
2215 LOG_INFO(
"RA/DEC could not be read, possible solution if using (wireless) ethernet: Use port 9998");
2216 LOG_WARN(
"This update aborted, will try again...");
2225#ifdef DEBUG_TRACKSTATE
2312 const auto parkSeconds = std::chrono::duration_cast<std::chrono::seconds>(
2316 LOG_ERROR(
"OnStep reports that parking failed.");
2323 LOGF_ERROR(
"OnStep did not report the mount parked within %d seconds, park failed.",
2343#ifdef DEBUG_TRACKSTATE
2347 LOG_DEBUG(
"EqNP is IPS_BUSY (Goto/slew or Parking)");
2355 LOG_DEBUG(
"EqNP is IPS_IDLE (Not Tracking or Parked)");
2359 LOG_DEBUG(
"EqNP is IPS_ALERT (Something wrong)");
2364 bool trackStateUpdateNeded =
false;
2370 trackStateUpdateNeded =
true;
2376 trackStateUpdateNeded =
true;
2384 trackStateUpdateNeded =
true;
2390 trackStateUpdateNeded =
true;
2393 if (trackStateUpdateNeded)
2395#ifdef DEBUG_TRACKSTATE
2402#ifdef DEBUG_TRACKSTATE
2407 bool update_needed =
false;
2417 gotoStopReason(Lasterror) :
nullptr;
2418 if (stopReason !=
nullptr)
2420 LOGF_ERROR(
"OnStep stopped the slew: %s.", stopReason);
2422 update_needed =
true;
2427 update_needed =
true;
2428#ifdef DEBUG_TRACKSTATE
2440 update_needed =
true;
2441#ifdef DEBUG_TRACKSTATE
2451 update_needed =
true;
2452#ifdef DEBUG_TRACKSTATE
2460#ifdef DEBUG_TRACKSTATE
2463 update_needed =
true;
2467#ifdef DEBUG_TRACKSTATE
2473#ifdef DEBUG_TRACKSTATE
2476 LOG_DEBUG(
"EqNP is IPS_BUSY (Goto/slew or Parking)");
2484 LOG_DEBUG(
"EqNP is IPS_IDLE (Not Tracking or Parked)");
2488 LOG_DEBUG(
"EqNP is IPS_ALERT (Something wrong)");
2494#ifdef DEBUG_TRACKSTATE
2582 OnstepStatTP[4].setText(
"AutoRecord (waiting on index)");
2590 OnstepStatTP[4].setText(
"AutoPlaying (waiting on index)");
2621 LOG_INFO(
"Telescope detected having PEC, setting that capability");
2622 LOGF_DEBUG(
"capabilities = %x", capabilities);
2637 if (!strstr(
OSStat,
"S"))
2696 LOG_INFO(
"Telescope detected having Pier Side, adding that capability (many messages duplicated)");
2697 LOGF_DEBUG(
"capabilities = %x", capabilities);
2707 pier_not_set =
false;
2712 pier_not_set =
false;
2717 pier_not_set =
false;
2726 if (idx >= 0 && idx <
static_cast<int>(
SlewRateSP.count()) &&
SlewRateSP.findOnSwitchIndex() != idx)
2745 LOG_DEBUG(
":GU# got no answer, this update aborted, will try again...");
2766 if (
OSStat[0] & 0b10000001 == 0b10000001)
2770 if (
OSStat[0] & 0b10000010 == 0b10000010)
2774 if (
OSStat[0] & 0b10000100 == 0b10000100)
2783 if (
OSStat[0] & 0b10001000 == 0b10001000)
2792 if ((
OSStat[0] & 0b10010000 == 0b10010000
2793 ||
OSStat[0] & 0b10100000 == 0b10100000))
2795 if (
OSStat[0] & 0b10100000 == 0b10100000)
2799 if (
OSStat[0] & 0b10010000 == 0b10010000)
2803 if (
OSStat[0] & 0b11000000 == 0b11000000)
2818 if (
OSStat[1] & 0b10000001 == 0b10000001)
2822 if (
OSStat[1] & 0b10000010 == 0b10000010)
2826 if (
OSStat[1] & 0b10000011 == 0b10000011)
2831 if (
OSStat[2] & 0b10000001 == 0b10000001)
2835 if (
OSStat[2] & 0b10000010 == 0b10000010)
2840 if (
OSStat[2] & 0b10000100 == 0b10000100)
2854 if (
OSStat[2] & 0b10001000 == 0b10001000)
2858 if (
OSStat[2] & 0b10010000 == 0b10010000)
2873 if (
OSStat[2] & 0b10100000 == 0b10100000)
2882 if (
OSStat[3] & 0b10000001 == 0b10000001)
2888 if (
OSStat[3] & 0b10000010 == 0b10000010)
2894 if (
OSStat[3] & 0b10000100 == 0b10000100)
2900 if (
OSStat[3] & 0b10001000 == 0b10001000)
2909 if (
OSStat[3] & 0b10010000 == 0b10010000)
2915 if (
OSStat[3] & 0b10100000 == 0b10100000)
2920 if (
OSStat[3] & 0b11000000 == 0b11000000)
2939 PulseGuideGU =
OSStat[6] & 0b01111111;
2940 GuideRateGU =
OSStat[7] & 0b01111111;
2941 LastError =
OSStat[8] & 0b01111111;
2970 OnstepStatTP[7].setText(
"Meridian Limit (W) Exceeded");
3033 if (error_or_fail > 1)
3057 LOG_WARN(
"Communication error on Pier Side (:Gm#), this update aborted, will try again...");
3071 double backlash_DEC, backlash_RA;
3074 if (BD_error > 1 && BR_error > 1)
3082 LOG_WARN(
"Communication error on backlash (:%BD#/:%BR#), this update aborted, will try again...");
3086 double pulseguiderate = 0.0;
3089 LOGF_DEBUG(
"Guide Rate String: %s", GuideValue);
3090 pulseguiderate = atof(GuideValue);
3091 LOGF_DEBUG(
"Guide Rate: %f", pulseguiderate);
3098 LOGF_DEBUG(
"Guide Rate String: %s", GuideValue);
3099 LOG_DEBUG(
"Guide rate error response, Not setting guide rate from :GX90# response, falling back to :GU#, which may not be accurate, if custom settings are used");
3101 switch(pulseguiderateint)
3104 pulseguiderate = (double)0.25;
3107 pulseguiderate = (double)0.5;
3110 pulseguiderate = (double)1.0;
3113 pulseguiderate = 0.0;
3114 LOG_DEBUG(
"Could not get guide rate from :GU# response, not setting");
3115 LOG_WARN(
"Communication error on Guide Rate (:GX90#/:GU#), this update aborted, will try again...");
3118 if (pulseguiderate != 0.0)
3120 LOGF_DEBUG(
"Guide Rate: %f", pulseguiderate);
3131 char merdidianflipauto_response[
RB_MAX_LEN] = {0};
3135 if (merdidianflipauto_response[0] ==
'1')
3142 else if (merdidianflipauto_response[0] ==
'0')
3152 LOG_WARN(
"Communication error on meridianAutoFlip (:GX95#), this update aborted, will try again...");
3161 char preferredpierside_response[
RB_MAX_LEN] = {0};
3165 if (strstr(preferredpierside_response,
"W"))
3171 else if (strstr(preferredpierside_response,
"E"))
3177 else if (strstr(preferredpierside_response,
"B"))
3202 LOG_WARN(
"Communication error on Preferred Pier Side (:GX96#), this update aborted, will try again...");
3210 int gxea_error, gxe9_error;
3211 double minutes_past_Meridian_East, minutes_past_Meridian_West;
3225 LOG_WARN(
"Communication error on Degrees past Meridian West (:GXEA#), this update aborted, will try again...");
3231 LOG_WARN(
"Communication error on Degrees past Meridian East (:GXE9#), this update aborted, will try again...");
3247 LOGF_DEBUG(
"Elevation Limit Min: %s, %i Go_nbcar: %i", Go, Go_int, Go_error);
3251 LOG_WARN(
"Communication :Go# error, check connection.");
3264 LOGF_DEBUG(
"Elevation Limit Min: %s, %i Gh_nbcar: %i", Gh, Gh_int, Gh_error);
3268 LOG_WARN(
"Communication :Gh# error, check connection.");
3276 LOG_WARN(
"Communication error on Rotator Update, this update aborted, will try again...");
3282 double temperature_value;
3290 LOG_WARN(
"Communication error on Temperature (:GX9A#), this update aborted, will try again...");
3295 double humidity_value;
3303 LOG_WARN(
"Communication error on Humidity (:GX9C#), this update aborted, will try again...");
3309 double barometer_value;
3317 LOG_WARN(
"Communication error on Barometer (:GX9B#), this update aborted, will try again...");
3322 double dewpoint_value;
3330 LOG_WARN(
"Communication error on Dewpoint (:GX9E#), this update aborted, will try again...");
3337 double cputemp_value;
3339 if ( error_return >= 0)
3345 LOGF_DEBUG(
"CPU Temp not responded to, disabling further checks, return values: error_return: %i, cputemp_reponse: %s",
3346 error_return, cputemp_reponse);
3364 for (
int driver_number = 1; driver_number < 3; driver_number++)
3368 snprintf(TMCDriverCMD,
sizeof(TMCDriverCMD),
":GXU%i#", driver_number);
3372 if (i == -4 && TMCDriverTempValue[0] ==
'0' )
3375 snprintf(ResponseText,
sizeof(ResponseText),
"TMC Reporting not detected, Axis %i", driver_number);
3377 LOG_DEBUG(
"TMC Drivers responding as if not there, disabling further checks");
3384 if (TMCDriverTempValue[0] == 0)
3386 OnstepStatTP[8 + driver_number].setText(
"No Condition");
3391 char StepperState[1024] = {0};
3392 bool unknown_value =
false;
3393 int current_position = 0;
3394 while (TMCDriverTempValue[current_position] != 0 && unknown_value ==
false)
3396 if (TMCDriverTempValue[current_position] ==
',')
3402 if (TMCDriverTempValue[current_position] ==
'S' && TMCDriverTempValue[current_position + 1] ==
'T')
3404 strcat(StepperState,
"Standstill,");
3406 else if (TMCDriverTempValue[current_position] ==
'O' && TMCDriverTempValue[current_position + 1] ==
'A')
3408 strcat(StepperState,
"Open Load A Pair,");
3410 else if (TMCDriverTempValue[current_position] ==
'O' && TMCDriverTempValue[current_position + 1] ==
'B')
3412 strcat(StepperState,
"Open Load B Pair,");
3414 else if (TMCDriverTempValue[current_position] ==
'G' && TMCDriverTempValue[current_position + 1] ==
'A')
3416 strcat(StepperState,
"Short to Ground A Pair,");
3418 else if (TMCDriverTempValue[current_position] ==
'G' && TMCDriverTempValue[current_position + 1] ==
'B')
3420 strcat(StepperState,
"Short to Ground B Pair,");
3422 else if (TMCDriverTempValue[current_position] ==
'O' && TMCDriverTempValue[current_position + 1] ==
'T')
3424 strcat(StepperState,
"Over Temp (>150C),");
3426 else if (TMCDriverTempValue[current_position] ==
'P' && TMCDriverTempValue[current_position + 1] ==
'W')
3428 strcat(StepperState,
"Pre-Warning: Over Temp (>120C),");
3430 else if (TMCDriverTempValue[current_position] ==
'G' && TMCDriverTempValue[current_position + 1] ==
'F')
3432 strcat(StepperState,
"General Fault,");
3436 unknown_value =
true;
3439 current_position = current_position + 3;
3444 OnstepStatTP[8 + driver_number].setText(TMCDriverTempValue);
3454 OnstepStatTP[8 + driver_number].setText(
"Unknown read error");
3468 LOG_WARN(
"Communication error on Align Status Update, this update aborted, will try again...");
3476 LOG_WARN(
"Communication error on Focuser Update, this update aborted, will try again...");
3500 if(res < 0 || response[0] ==
'0')
3502 LOGF_ERROR(
"===CMD==> Track On %s", response);
3512 return setTrackRateOffsets(0, 0);
3518 if(res < 0 || response[0] ==
'0')
3520 LOGF_ERROR(
"===CMD==> Track Off %s", response);
3529 years = years % 100;
3532 snprintf(
cmd,
CMD_MAX_LEN,
":SC%02d/%02d/%02d#", months, days, years);
3541 int nbytes_write = 0;
3548 tcflush(
PortFD, TCIFLUSH);
3553 LOGF_ERROR(
"CHECK CONNECTION: Error sending command %s",
cmd);
3563 char response[1] = {0};
3565 int nbytes_write = 0, nbytes_read = 0;
3572 tcflush(
PortFD, TCIFLUSH);
3579 tcflush(
PortFD, TCIFLUSH);
3582 if (nbytes_read < 1)
3584 LOG_WARN(
"Timeout/Error on response. Check connection.");
3588 return (response[0] ==
'0');
3595 int nbytes_write = 0, nbytes_read = 0;
3607 tcflush(
fd, TCIFLUSH);
3609 if (error_type !=
TTY_OK)
3612 term = strchr(data,
'#');
3617 data[nbytes_read] =
'\0';
3621 LOG_DEBUG(
"got RB_MAX_LEN bytes back (which should never happen), last byte set to null and possible overflow");
3633 tcflush(
fd, TCIOFLUSH);
3637 tcflush(
fd, TCIOFLUSH);
3642 if (error_type >= 0)
3644 LOGF_DEBUG(
"flushIO: Information in buffer: Bytes: %u, string: %s", nbytes_read, discard_data);
3648 while (error_type > 0);
3656 int nbytes_write = 0, nbytes_read = 0;
3663 tcflush(
fd, TCIFLUSH);
3669 tcflush(
fd, TCIFLUSH);
3671 term = strchr(data,
'#');
3676 data[nbytes_read] =
'\0';
3680 LOG_DEBUG(
"got RB_MAX_LEN bytes back, last byte set to null and possible overflow");
3686 if (error_type !=
TTY_OK)
3690 tcflush(
fd, TCIOFLUSH);
3694 if (sscanf(data,
"%lf", value) != 1)
3696 LOG_WARN(
"Invalid response, check connection");
3698 tcflush(
fd, TCIOFLUSH);
3711 int nbytes_write = 0, nbytes_read = 0;
3718 tcflush(
fd, TCIFLUSH);
3724 tcflush(
fd, TCIFLUSH);
3726 term = strchr(data,
'#');
3731 data[nbytes_read] =
'\0';
3735 LOG_DEBUG(
"got RB_MAX_LEN bytes back, last byte set to null and possible overflow");
3739 if (error_type !=
TTY_OK)
3743 tcflush(
fd, TCIOFLUSH);
3746 if (sscanf(data,
"%i", value) != 1)
3748 LOG_WARN(
"Invalid response, check connection");
3750 tcflush(
fd, TCIOFLUSH);
3760 int nbytes_write = 0, nbytes_read = 0;
3767 tcflush(
fd, TCIFLUSH);
3773 tcflush(
fd, TCIFLUSH);
3775 term = strchr(data,
'#');
3780 data[nbytes_read] =
'\0';
3784 LOG_DEBUG(
"got RB_MAX_LEN bytes back, last byte set to null and possible overflow");
3790 if (error_type !=
TTY_OK)
3808 double onstep_long = 360 - longitude ;
3809 while (onstep_long < 0)
3811 while (onstep_long > 360)
3816 LOG_ERROR(
"Error setting site longitude coordinates");
3822 LOG_ERROR(
"Error setting site latitude coordinates");
3826 char l[32] = {0}, L[32] = {0};
3827 fs_sexa(l, latitude, 3, 360000);
3828 fs_sexa(L, longitude, 4, 360000);
3830 LOGF_INFO(
"Site location updated to Lat %.32s - Long %.32s", l, L);
3841 snprintf(read_buffer,
sizeof(read_buffer),
":So%02d#",
max);
3850 char read_buffer[32];
3855 snprintf(read_buffer,
sizeof(read_buffer),
":Sg%.03d:%02d:%.02f#", d, m, s);
3863 snprintf(read_buffer,
sizeof(read_buffer),
":Sg%03d:%02d#", d, m);
3867 snprintf(read_buffer,
sizeof(read_buffer),
":Sg%03d:%02d#", d, m);
3875 char read_buffer[32];
3881 snprintf(read_buffer,
sizeof(read_buffer),
":St%+.02d:%02d:%.02f#", d, m, s);
3889 snprintf(read_buffer,
sizeof(read_buffer),
":St%+03d:%02d#", d, m);
3893 snprintf(read_buffer,
sizeof(read_buffer),
":St%+03d:%02d#", d, m);
3931 char read_buffer[32];
3934 snprintf(read_buffer,
sizeof(read_buffer),
":FR%5f#", output);
3945 char read_buffer[32];
3946 snprintf(read_buffer,
sizeof(read_buffer),
":FS%06d#",
int(targetTicks));
3952 LOG_INFO(
"Unable to move focuser, out of range");
3962 char read_buffer[32];
3965 snprintf(read_buffer,
sizeof(read_buffer),
":FR%04d#", output);
3975 strncpy(
cmd,
":FQ#",
sizeof(
cmd));
3992 if (error_or_fail > 1)
4004 if (error_or_fail > 0 )
4006 if (valueStatus[0] ==
'S')
4013 else if (valueStatus[0] ==
'M')
4022 LOG_WARN(
"Communication :FT# error, check connection.");
4033 LOG_WARN(
"Communication :FT# error, check connection.");
4050 LOGF_DEBUG(
"focus_max: %s, %i, fm_nbchar: %i", focus_max, focus_max_int, fm_error);
4054 LOG_WARN(
"Communication :FM# error, check connection.");
4055 LOGF_WARN(
"focus_max: %s, %u, fm_error: %i", focus_max, focus_max[0], fm_error);
4069 LOGF_DEBUG(
"focus_min: %s, %i fi_nbchar: %i", focus_min, focus_min_int, fi_error);
4073 LOG_WARN(
"Communication :FI# error, check connection.");
4080 double focus_T_double ;
4086 LOGF_DEBUG(
"focus T°: %s, focus_T_double %i ft_nbcar: %i", focus_T, focus_T_double, ft_error);
4090 LOG_WARN(
"Communication :Ft# error, check connection.");
4091 LOGF_DEBUG(
"focus T°: %s, focus_T_double %i ft_nbcar: %i", focus_T, focus_T_double, ft_error);
4104 LOGF_DEBUG(
"focus Differential T°: %s, %i fi_nbchar: %i", focus_TD, focus_TD_int, fe_error);
4108 LOG_WARN(
"Communication :Fe# error, check connection.");
4115 int focus_Coefficient_int ;
4121 LOGF_DEBUG(
"TFC Coefficient: %s, %i fC_nbchar: %i", focus_Coeficient, focus_Coefficient_int, fC_error);
4125 LOG_WARN(
"Communication :FC# error, check connection.");
4132 int focus_Deadband_int ;
4138 LOGF_DEBUG(
"TFC Deadband: %s, %i fD_nbchar: %i", focus_Deadband, focus_Deadband_int, fD_error);
4142 LOG_WARN(
"Communication :FD# error, check connection.");
4152 if (strcmp(response,
"0"))
4158 else if (strcmp(response,
"1"))
4165 LOGF_DEBUG(
"TFC Enable: fc_nbchar:%d Fc_response: %s", res, response);
4170 LOG_WARN(
"Communication :Fc# error, check connection.");
4184 if (error_return >= 0)
4186 if ( strcmp(value,
"0") )
4188 LOG_INFO(
"Focuser 2 called, but not present, disabling polling");
4200 LOGF_INFO(
"Focuser 2 called, but returned error %i on read, disabling further polling", error_return);
4210 if (error_or_fail > 0 && value[0] >
'0' && value[0] <
'9')
4212 int temp_value = (
unsigned int)(value[0]) -
'0';
4215 if (temp_value == 0)
4219 else if (temp_value > 9 || temp_value < 0)
4223 LOGF_WARN(
"Active focuser returned out of range: %d, should be 0-9", temp_value);
4236 LOGF_DEBUG(
":Fa# returned outside values: %c, %u", value[0], value[0]);
4300 double double_value;
4304 if (error_or_fail == 1 && value[0] ==
'0')
4306 LOG_INFO(
"Detected Response that Rotator is not present, disabling further checks");
4310 if (error_or_fail < 1)
4312 LOG_WARN(
"Error talking to rotator, might be timeout (especially on network)");
4323 double min_rotator, max_rotator;
4326 bool changed_minmax =
false;
4331 if (error_or_fail > 1)
4333 changed_minmax =
true;
4338 if (error_or_fail > 1)
4340 changed_minmax =
true;
4351 if (error_or_fail > 1)
4353 if (value[0] ==
'S')
4359 else if (value[0] ==
'M')
4374 if (error_or_fail > 1)
4391 snprintf(
cmd,
sizeof(
cmd),
":rS%.03d:%02d:%02d#", d, m, s);
4415 LOG_INFO(
"Moving Rotator to Home");
4426 LOG_INFO(
"Aborting Rotation, de-rotation in same state");
4435 snprintf(
cmd,
sizeof(
cmd),
":rb%d#", steps);
4480 LOG_INFO(
"Sending Command to Start PEC Playback");
4481 strncpy(
cmd,
":$QZ+#",
sizeof(
cmd));
4487 LOG_DEBUG(
"Command to Playback PEC called when Controller does not support PEC");
4494 LOG_INFO(
"Command to Start Playback PEC called when Controller does not support PEC due to being Alt-Az, PEC Ignored going forward");
4508 LOG_INFO(
"Sending Command to Stop PEC Playback");
4509 strncpy(
cmd,
":$QZ-#",
sizeof(
cmd));
4515 LOG_DEBUG(
"Command to Stop Playing PEC called when Controller does not support PEC");
4528 LOG_INFO(
"Sending Command to Start PEC record");
4535 LOG_DEBUG(
"Command to Record PEC called when Controller does not support PEC");
4548 LOG_INFO(
"Sending Command to Clear PEC record");
4555 LOG_DEBUG(
"Command to clear PEC called when Controller does not support PEC");
4569 LOG_INFO(
"Sending Command to Save PEC to EEPROM");
4576 LOG_DEBUG(
"Command to save PEC called when Controller does not support PEC");
4591 LOG_INFO(
"Command to give PEC called when Controller does not support PEC due to being Alt-Az Disabled");
4606 if (error_or_fail > 1)
4609 if (value[0] ==
'I')
4615 LOG_INFO(
"Controller reports PEC Ignored and not supported");
4616 LOG_INFO(
"No Further PEC Commands will be processed, unless status changed");
4618 else if (value[0] ==
'R')
4624 else if (value[0] ==
'r')
4630 else if (value[0] ==
'P')
4636 else if (value[0] ==
'p')
4647 if (value[1] ==
'.')
4665 LOG_DEBUG(
"Timeout or other error on :$QZ?#");
4681 LOG_WARN(
"PEC Reading NOT Implemented");
4686 LOG_DEBUG(
"Command to Read PEC called when Controller does not support PEC");
4697 LOG_WARN(
"PEC Writing NOT Implemented");
4702 LOG_DEBUG(
"Command to Read PEC called when Controller does not support PEC");
4714 LOG_INFO(
"Sending Command to Start Alignment");
4716 OSNAlignTP[1].setText(
"GOTO a star, center it");
4717 OSNAlignTP[2].setText(
"GOTO a star, Solve and Sync");
4718 OSNAlignTP[3].setText(
"Press 'Issue Align' if not solving");
4723 if(error_or_fail != 4 || read_buffer[0] <
'0' || read_buffer[0] >
'9' || read_buffer[1] <
'0' || read_buffer[1] >
':'
4724 || read_buffer[2] <
'0' || read_buffer[2] >
'9')
4726 LOGF_INFO(
"Getting Alignment Status: response Error, response = %s>", read_buffer);
4731 int max_stars = read_buffer[0] -
'0';
4732 if (stars > max_stars)
4734 LOG_INFO(
"Tried to start Align with too many stars.");
4735 LOGF_INFO(
"Starting Align with %d stars", max_stars);
4738 snprintf(
cmd,
sizeof(
cmd),
":A%.1d#", stars);
4739 LOGF_INFO(
"Started Align with %s, max possible stars: %d",
cmd, max_stars);
4754 LOG_INFO(
"Sending Command to Record Star");
4755 strncpy(
cmd,
":A+#",
sizeof(
cmd));
4773 char stars[5] = {0};
4774 int max_stars, current_star, align_stars;
4778 if(error_or_fail != 4 || read_buffer[0] <
'0' || read_buffer[0] >
'9' || read_buffer[1] <
'0' || read_buffer[1] >
':'
4779 || read_buffer[2] <
'0' || read_buffer[2] >
'9')
4781 LOGF_INFO(
"Getting Alignment Status: response Error, response = %s>", read_buffer);
4784 max_stars = read_buffer[0] -
'0';
4785 current_star = read_buffer[1] -
'0';
4786 align_stars = read_buffer[2] -
'0';
4787 snprintf(stars,
sizeof(stars),
"%d", max_stars);
4789 snprintf(stars,
sizeof(stars),
"%d", current_star);
4790 if (read_buffer[1] >
'9')
4798 snprintf(stars,
sizeof(stars),
"%d", align_stars);
4800 LOGF_DEBUG(
"Align: max_stars: %i current star: %u, align_stars %u", max_stars, current_star, align_stars);
4802 if (current_star <= align_stars)
4804 snprintf(msg,
sizeof(msg),
"%s Alignment: Star %d/%d", read_buffer, current_star, align_stars );
4807 if (current_star > align_stars && max_stars > 1)
4809 LOGF_DEBUG(
"Align: current star: %u, align_stars %u",
int(current_star),
int(align_stars));
4810 snprintf(msg,
sizeof(msg),
"Align: Completed");
4848 double altCor, azmCor;
4850 if (error_or_fail < 2)
4852 LOGF_INFO(
"Polar Align Error Status response Error, response = %s>", read_buffer);
4856 if (error_or_fail < 2)
4858 LOGF_INFO(
"Polar Align Error Status response Error, response = %s>", read_buffer);
4861 fs_sexa(sexabuf, (
double)azmCor / 3600, 4, 3600);
4862 snprintf(polar_error,
sizeof(polar_error),
"%f'' /%s", azmCor, sexabuf);
4864 fs_sexa(sexabuf, (
double)altCor / 3600, 4, 3600);
4865 snprintf(polar_error,
sizeof(polar_error),
"%f'' /%s", altCor, sexabuf);
4879 LOG_INFO(
"Alignment Done - May still be calculating");
4883 OSNAlignTP[3].setText(
"Write Align to NVRAM/Flash ");
4896 LOG_INFO(
"Sending Command to Finish Alignment and write");
4897 strncpy(
cmd,
":AW#",
sizeof(
cmd));
4899 if(res > 0 && response[0] ==
'1')
4901 LOG_INFO(
"Align Write Successful");
4905 OSNAlignTP[2].setText(
"And Written to EEPROM");
4912 LOGF_ERROR(
"Align Write Failed: error=%s", response);
4920#ifdef ONSTEP_NOTDONE
4999 command[5] = char(output);
5003 if (error_or_fail > 0)
5032 LOG_ERROR(
"Custom tracking rates need OnStepX.");
5053 LOG_ERROR(
"Custom tracking rates need OnStepX.");
5060 return setTrackRateOffsets((
TRACKRATE_SIDEREAL - raRate) * toSiderealSecond, deRate * toSiderealSecond);
5063bool LX200_OnStep::setTrackRateOffsets(
double raOffset,
double decOffset)
5066 if (std::fabs(raOffset) > 1800 || std::fabs(decOffset) > 1800)
5068 LOG_ERROR(
"Custom tracking rates must be within 1800 arcsec/s of sidereal tracking.");
5075 snprintf(
cmd,
sizeof(
cmd),
":SXTR,%.6f#", raOffset);
5078 LOGF_ERROR(
"Failed to set the RA tracking rate offset (%s).", response);
5082 snprintf(
cmd,
sizeof(
cmd),
":SXTD,%.6f#", decOffset);
5085 LOGF_ERROR(
"Failed to set the Dec tracking rate offset (%s).", response);
5089 LOGF_DEBUG(
"Tracking rate offsets RA %.6f, Dec %.6f arcsec per sidereal second.", raOffset, decOffset);
5108 LOG_ERROR(
"OnStep slew/syncError called with value 0-goto possible, this is normal operation");
5111 LOG_ERROR(
"OnStep slew/syncError: Below the horizon limit");
5114 LOG_ERROR(
"OnStep slew/syncError: Above Overhead limit");
5117 LOG_ERROR(
"OnStep slew/syncError: Controller in standby, Usual issue fix: Turn tracking on");
5120 LOG_ERROR(
"OnStep slew/syncError: Mount is Parked");
5123 LOG_ERROR(
"OnStep slew/syncError: Goto in progress");
5126 LOG_ERROR(
"OnStep slew/syncError: Outside limits: Max/Min Dec, Under Pole Limit, Meridian Limit, Sync attempted to wrong pier side");
5129 LOG_ERROR(
"OnStep slew/syncError: Hardware Fault");
5132 LOG_ERROR(
"OnStep slew/syncError: Already in motion");
5135 LOG_ERROR(
"OnStep slew/syncError: Unspecified Error");
5138 LOG_ERROR(
"OnStep slew/syncError: Not in range of values that should be returned! INVALID, Something went wrong!");
5157 LOG_ERROR(
"Error setting RA/DEC. Unable to Sync.");
5164 if (error_or_fail > 1)
5166 if (strcmp(read_buffer,
"N/A"))
5168 if (read_buffer[0] ==
'E' && read_buffer[1] >=
'0'
5169 && read_buffer[1] <=
'9')
5171 int error_code = read_buffer[1] -
'0';
5172 LOGF_DEBUG(
"Sync failed with response: %s, Error code: %i", read_buffer, error_code);
5181 LOG_ERROR(
"Unexpected return on sync call!");
5182 LOG_ERROR(
"Check system & Align if doing align to see if it went through!");
5189 LOG_ERROR(
"Communication error on sync! Re-issue sync!");
5200 LOG_INFO(
"OnStep: Synchronization successful.");
5224 if (error_or_fail == -4 && configured[0] ==
'0')
5227 LOG_INFO(
"Outputs not detected, disabling further checks");
5230 OutputPorts_NP[0].fill(
"Unconfigured",
"Unconfigured",
"%g", 0, 255, 1, 0);
5233 if(configured[i - 1] ==
'1')
5235 snprintf(getoutp,
sizeof(getoutp),
":GXY%d#", i);
5237 if (error_or_fail > 0)
5239 for(k = 0; k < strlen(port_name); k++)
5241 if(port_name[k] ==
',') port_name[k] =
'_';
5242 p_name[k] = port_name[k];
5249 LOGF_ERROR(
"Communication error on %s, ignoring, disconnect and reconnect to clear", getoutp);
5250 OutputPorts_NP[i].fill(
"Unconfigured",
"Unconfigured",
"%g", 0, 255, 1, 0);
5255 OutputPorts_NP[i].fill(
"Unconfigured",
"Unconfigured",
"%g", 0, 255, 1, 0);
5270 memset(<m, 0,
sizeof(ltm));
5271 memset(&utm, 0,
sizeof(utm));
5276 char utcStr[8] = {0};
5277 snprintf(utcStr, 8,
"%.2f", offset);
5282 LOG_WARN(
"Could not obtain UTC offset from mount!");
5288 LOG_WARN(
"Could not obtain local time from mount!");
5294 LOG_WARN(
"Could not obtain local date from mount!");
5300 snprintf(datetime,
MAXINDINAME,
"%sT%s", cdate, ctime);
5303 if (strptime(datetime,
"%FT%T", <m) ==
nullptr)
5305 LOGF_WARN(
"Could not process mount date and time: %s", datetime);
5311 time_epoch = mktime(<m);
5314 time_epoch -=
static_cast<int>(offset * 3600.0);
5317 localtime_r(&time_epoch, &utm);
5320 strftime(cdate,
MAXINDINAME,
"%Y-%m-%dT%H:%M:%S", &utm);
5335 int lat_dd = 0, lat_mm = 0, long_dd = 0, long_mm = 0;
5336 double lat_ssf = 0.0, long_ssf = 0.0;
5357 LOG_WARN(
"Failed to get site latitude from device.");
5364 snprintf(lat_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", lat_dd, lat_mm, lat_ssf);
5373 snprintf(lat_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", lat_dd, lat_mm, lat_ssf);
5382 LOG_WARN(
"Failed to get site latitude from device.");
5388 snprintf(lat_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", lat_dd, lat_mm, lat_ssf);
5402 LOG_WARN(
"Failed to get site longitude from device.");
5409 snprintf(lng_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", long_dd, long_mm, long_ssf);
5418 snprintf(lng_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", long_dd, long_mm, long_ssf);
5427 LOG_WARN(
"Failed to get site longitude from device.");
5433 snprintf(lng_sexagesimal,
MAXINDIFORMAT,
"%02d:%02d:%02.1lf", long_dd, long_mm, long_ssf);
5440 LOGF_INFO(
"Mount has Latitude %s (%g) Longitude %s (%g) (Longitude sign in carthography format)",
5456 const struct timespec timeout = {0, 100000000L};
5460 char RAStr[64] = {0}, DecStr[64] = {0};
5485 Telescope::AbortSP.apply();
5507 nanosleep(&timeout,
nullptr);
5525 LOGF_ERROR(
"Error Slewing to JNow RA %s - DEC %s", RAStr, DecStr);
5542 LOGF_INFO(
"Slewing to RA: %s - DEC: %s", RAStr, DecStr);
5551 LOG_DEBUG(
"OnStep SyncParkStatus called");
5584#ifdef DEBUG_TRACKSTATE
5594 LOG_DEBUG(
"TrackState: SCOPE_TRACKING");
5611 int utc_hour, utc_min;
5613 utc_hour = int(offset) * -1;
5614 utc_min = abs((offset -
int(offset)) * 60);
5615 if (utc_min > 30) utc_min = 45;
5616 snprintf(temp_string,
sizeof(temp_string),
":SG%03d:%02d#", utc_hour, utc_min);
The Interface class is the base class for all INDI connection plugins.
virtual std::string name()=0
INDI::PropertyText getText(const char *name) const
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
void setCurrentPollingPeriod(uint32_t msec)
setCurrentPollingPeriod Change the current polling period to call TimerHit() function in the driver.
void setDriverInterface(uint32_t value)
setInterface Set driver interface. By default the driver interface is set to GENERAL_DEVICE....
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
virtual bool deleteProperty(const char *propertyName)
Delete a property and unregister it. It will also be deleted from all clients.
void defineProperty(INumberVectorProperty *property)
uint32_t getCurrentPollingPeriod() const
getCurrentPollingPeriod Return the current polling period.
bool isSimulation() const
void syncDriverInfo()
syncDriverInfo sends the current driver information to the client.
void addAuxControls()
Add Debug, Simulation, and Configuration options to the driver.
uint32_t getDriverInterface() const
Connection::Interface * getActiveConnection()
INDI::PropertyNumber FocusRelPosNP
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
void SetCapability(uint32_t cap)
FI::SetCapability sets the focuser capabilities. All capabilities must be initialized.
void initProperties(const char *groupName)
Initialize focuser properties. It is recommended to call this function within initProperties() of you...
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process focus number properties.
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process focus switch properties.
INDI::PropertyNumber FocusAbsPosNP
bool processSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
Process Rotator switch properties.
RotatorInterface(DefaultDevice *defaultDevice)
void initProperties(const char *groupName)
Initialize Rotator properties. It is recommended to call this function within initProperties() of you...
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
void SetCapability(uint32_t cap)
SetRotatorCapability sets the Rotator capabilities. All capabilities must be initialized.
INDI::PropertyNumber RotatorBacklashNP
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process Rotator number properties.
INDI::PropertyNumber GotoRotatorNP
TelescopeStatus TrackState
void SetAxis1Park(double value)
SetRAPark Set current RA/AZ parking position. The data park file (stored in ~/.indi/ParkData....
void SetAxis1ParkDefault(double steps)
SetRAPark Set default RA/AZ parking position.
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
TelescopeParkData parkDataType
bool isParked()
isParked is mount currently parked?
uint32_t GetTelescopeCapability() const
GetTelescopeCapability returns the capability of the Telescope.
void NewRaDec(double ra, double dec)
The child class calls this function when it has updates.
void setPierSide(TelescopePierSide side)
bool InitPark()
InitPark Loads parking data (stored in ~/.indi/ParkData.xml) that contains parking status and parking...
void SetAxis2Park(double steps)
SetDEPark Set current DEC/ALT parking position. The data park file (stored in ~/.indi/ParkData....
void setMountType(TelescopeMountType type)
setMountType Report the mount type in TELESCOPE_MOUNT_TYPE. Drivers call it when the type is fixed by...
void SetParkDataType(TelescopeParkData type)
setParkDataType Sets the type of parking data stored in the park data file and presented to the user.
@ TELESCOPE_HAS_TRACK_RATE
@ TELESCOPE_HAS_PIER_SIDE
@ TELESCOPE_CAN_CONTROL_TRACK
void SetAxis2ParkDefault(double steps)
SetDEParkDefault Set default DEC/ALT parking position.
void addParameter(std::string name, std::string label, double numMinOk, double numMaxOk, double percWarning, bool flipWarning=false)
Add a physical weather measurable parameter to the weather driver.
bool setCriticalParameter(std::string name)
setCriticalParameter Set parameter that is considered critical to the operation of the observatory....
bool syncCriticalParameters()
Synchronize and update the state of all critical parameters.
void setParameterValue(std::string name, double value)
setParameterValue Update weather parameter value
bool processNumber(const char *dev, const char *name, double values[], char *names[], int n)
Process weather number properties.
virtual bool saveConfigItems(FILE *fp)
saveConfigItems Save parameters ranges in the config file.
INDI::PropertyNumber ParametersNP
void initProperties(const char *statusGroup, const char *paramsGroup)
Initialize focuser properties. It is recommended to call this function within initProperties() of you...
bool updateProperties()
updateProperties Define or Delete Rotator properties based on the connection status of the base devic...
INDI::PropertyLight critialParametersLP
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool getLocalDate(char *dateString)
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
virtual bool getUTFOffset(double *offset)
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool getLocalTime(char *timeString)
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
virtual bool checkConnection()
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual void getBasicData()
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
void setLX200Capability(uint32_t cap)
@ LX200_HAS_PULSE_GUIDING
@ LX200_HAS_PRECISE_TRACKING_FREQ
@ LX200_HAS_ALIGNMENT_TYPE
@ LX200_HAS_TRACKING_FREQ
bool AbortRotator() override
AbortRotator Abort all motion.
char OldOSStat[RB_MAX_LEN]
IPState ClearPECBuffer(int axis)
virtual bool Goto(double ra, double dec) override
Move the scope to the supplied RA and DEC coordinates.
INDI::PropertyNumber OSSetTemperatureNP
IPState PECStatus(int axis)
virtual void Init_Outputs()
virtual bool MoveNS(INDI_DIR_NS dir, TelescopeMotionCommand command) override
Start or Stop the telescope motion in the direction dir.
int getCommandSingleCharResponse(int fd, char *data, const char *cmd)
IPState MoveFocuser(FocusDirection dir, int speed, uint16_t duration) override
MoveFocuser the focuser in a particular direction with a specific speed for a finite duration.
int getCommandDoubleResponse(int fd, double *value, char *data, const char *cmd)
INDI::PropertySwitch TFCCompensationSP
virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override
Execute a homing action.
INDI::PropertyNumber OutputPorts_NP
int getCommandIntResponse(int fd, int *value, char *data, const char *cmd)
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
OnStepVersion OnStepMountVersion
virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override
INDI::PropertyNumber MaxSlewRateNP
IPState OSDisableOutput(int output)
int m_MissedStatusReplies
INDI::PropertySwitch HomePauseSP
INDI::PropertyNumber GuideRateNP
virtual bool setUTCOffset(double offset) override
INDI::PropertyNumber TFCDeadbandNP
INDI::PropertyNumber ElevationLimitNP
INDI::PropertyText VersionTP
INDI::PropertySwitch OSRotatorDerotateSP
IPState OSEnableOutput(int output)
INDI::PropertyNumber ObjectNoNP
INDI::PropertySwitch OSPECStatusSP
IPState AlignStartGeometric(int stars)
IPState StartPECPlayback(int axis)
bool SetRotatorBacklash(int32_t steps) override
SetRotatorBacklash Set the Rotatorer backlash compensation value.
uint32_t m_RememberPollingPeriod
virtual bool UnPark() override
Unpark the telescope if already parked.
IPState StopPECPlayback(int axis)
IPState SavePECBuffer(int axis)
INDI::PropertySwitch OSNAlignWriteSP
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
INDI::PropertyNumber minutesPastMeridianNP
virtual bool MoveWE(INDI_DIR_WE dir, TelescopeMotionCommand command) override
Move the telescope in the direction dir.
virtual bool Sync(double ra, double dec) override
Set the telescope current RA and DEC coordinates to the supplied RA and DEC coordinates.
INDI::PropertyText OnstepStatTP
virtual void getBasicData() override
virtual bool SetDefaultPark() override
SetDefaultPark Set default coordinates/encoders value as the desired parking position.
IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
bool sendOnStepCommand(const char *cmd)
INDI::PropertySwitch OSFocus2RateSP
INDI::PropertySwitch OSNAlignSP
virtual int setSiteLongitude(int fd, double Long)
long int OSTimeoutMicroSeconds
IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
IPState AlignAddStar()
AlignStartGeometric starts the OnStep Multistar align process.
INDI::PropertyNumber TFCCoefficientNP
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
INDI::PropertySwitch OSFocus1InitializeSP
virtual bool initProperties() override
Called to initialize basic properties required all the time.
INDI::PropertySwitch TrackAxisSP
bool sendOnStepCommandBlind(const char *cmd)
IPState StartPECRecord(int axis)
bool OSSupports_bitfield_Gu
virtual int setSiteLatitude(int fd, double Long)
long int OSTimeoutSeconds
virtual void SyncParkStatus(bool isparked) override
SyncParkStatus Update the state and switches for parking.
virtual bool SetTrackMode(uint8_t mode) override
SetTrackMode Set active tracking mode. Do not change track state.
virtual bool sendScopeLocation() override
INDI::PropertyNumber BacklashNP
int setMinElevationLimit(int fd, int min)
IPState ReadPECBuffer(int axis)
IPState WritePECBuffer(int axis)
INDI::PropertyText OSNAlignErrTP
char OldOSPier[RB_MAX_LEN]
IPState HomeRotator() override
HomeRotator Go to home position.
INDI::PropertyNumber OSSetHumidityNP
virtual bool Park() override
Park the telescope to its home position.
static constexpr int MAX_MISSED_STATUS_REPLIES
virtual void slewError(int slewCode) override
INDI::PropertyNumber OSSetAltitudeNP
bool SetRotatorBacklashEnabled(bool enabled) override
SetRotatorBacklashEnabled Enables or disables the Rotator backlash compensation.
INDI::PropertyText ObjectInfoTP
INDI::PropertySwitch ReticSP
int getCommandSingleCharErrorOrLongResponse(int fd, char *data, const char *cmd)
virtual bool UpdateAlignErr()
INDI::PropertySwitch OSPECRecordSP
virtual bool SetTrackRate(double raRate, double deRate) override
SetTrackRate Set custom tracking rates.
INDI::PropertyNumber FocusTemperatureNP
INDI::PropertyNumber OSFocus2TargNP
std::chrono::steady_clock::time_point m_ParkStartTime
INDI::PropertySwitch OSPECReadSP
INDI::PropertySwitch OSFocus2MotionSP
virtual bool sendScopeTime() override
bool OSGetOutputState(int output)
virtual bool UpdateAlignStatus()
INDI::PropertySwitch OSFocusSelectSP
IPState MoveRotator(double angle) override
MoveRotator Go to specific angle.
void PrintTrackState()
PrintTrackState will print to the debug log the status of TrackState if DEBUG_TRACKSTATE is defined o...
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
INDI::PropertyText OSNAlignTP
virtual const char * getDefaultName() override
INDI::PropertySwitch OSPECIndexSP
virtual void ISGetProperties(const char *dev) override
define the driver's properties to the client. Usually, only a minimum set of properties are defined t...
INDI::PropertySwitch FrequencyAdjustSP
virtual void SetParked(bool isparked) override
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
INDI::PropertySwitch OSNAlignPolarRealignSP
INDI::PropertySwitch OSNAlignStarsSP
INDI::PropertySwitch PreferredPierSideSP
virtual bool Handshake() override
perform handshake with device to check communication
INDI::PropertyNumber OSSetPressureNP
INDI::PropertySwitch TrackCompSP
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool ReadScopeStatus() override
Read telescope status.
bool AbortFocuser() override
AbortFocuser all focus motion.
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
INDI::PropertySwitch AutoFlipSP
const char * MAIN_CONTROL_TAB
MAIN_CONTROL_TAB Where all the primary controls for the device are located.
const char * MOTION_TAB
MOTION_TAB Where all the motion control properties of the device are located.
const char * FOCUS_TAB
FOCUS_TAB Where all the properties for focuser are located.
INDI::PropertySwitch ParkSP
INDI::PropertySwitch AbortSP
INDI::PropertyNumber TrackRateNP
INDI::PropertySwitch MovementNSSP
INDI::PropertyNumber EqNP
INDI::PropertySwitch TrackStateSP
INDI::PropertySwitch PECStateSP
INDI::PropertySwitch SlewRateSP
INDI::PropertySwitch TrackModeSP
INDI::PropertyText TimeTP
INDI::PropertySwitch MovementWESP
INDI::PropertySwitch ParkOptionSP
INDI::PropertySwitch CoordSP
INDI::PropertyNumber LocationNP
INDI::PropertyNumber TargetNP
void getSexComponentsIID(double value, int *d, int *m, double *s)
int f_scansexa(const char *str0, double *dp)
convert sexagesimal string str AxBxC to double. x can be anything non-numeric. Any missing A,...
void getSexComponents(double value, int *d, int *m, int *s)
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
int fs_sexa(char *out, double a, int w, int fracbase)
Converts a sexagesimal number to a string. sprint the variable a in sexagesimal format into out[].
int tty_read_expanded(int fd, char *buf, int nbytes, long timeout_seconds, long timeout_microseconds, int *nbytes_read)
read buffer from terminal with a delimiter
int tty_nread_section_expanded(int fd, char *buf, int nsize, char stop_char, long timeout_seconds, long timeout_microseconds, int *nbytes_read)
read buffer from terminal with a delimiter
void IUFillSwitch(ISwitch *sp, const char *name, const char *label, ISState s)
Assign attributes for a switch property. The switch's auxiliary elements will be set to NULL.
void IUFillSwitchVector(ISwitchVectorProperty *svp, ISwitch *sp, int nsp, const char *dev, const char *name, const char *label, const char *group, IPerm p, ISRule r, double timeout, IPState s)
Assign attributes for a switch vector property. The vector's auxiliary elements will be set to NULL.
int IUGetConfigNumber(const char *dev, const char *property, const char *member, double *value)
IUGetConfigNumber Opens configuration file and reads single number property.
void IDMessage(const char *dev, const char *fmt,...)
*brief user defined string literal for JSON values *sa std::size_t n
#define LOGF_INFO(fmt,...)
#define LOGF_WARN(fmt,...)
#define LOGF_DEBUG(fmt,...)
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
#define LOGF_ERROR(fmt,...)
#define DEBUGF(priority, msg,...)
#define TRACKRATE_SIDEREAL
INDI::WeatherInterface WI
@ ERR_GOTO_ERR_ABOVE_OVERHEAD
@ ERR_GOTO_ERR_OUTSIDE_LIMITS
@ ERR_GOTO_ERR_BELOW_HORIZON
@ ERR_GOTO_ERR_UNSPECIFIED
@ ERR_GOTO_ERR_HARDWARE_FAULT
std::mutex lx200CommsLock
int getSiteLongitude(int fd, int *ddd, int *mm, double *ssf)
int getSiteLatitudeAlt(int fd, int *dd, int *mm, double *ssf, const char *cmd)
int setMaxElevationLimit(int fd, int max)
int setObjectRA(int fd, double ra, bool addSpace)
int getLX200EquatorialFormat()
int setStandardProcedure(int fd, const char *data)
int setObjectDEC(int fd, double dec, bool addSpace)
int getSiteLongitudeAlt(int fd, int *ddd, int *mm, double *ssf, const char *cmd)
int getSiteLatitude(int fd, int *dd, int *mm, double *ssf)
int selectCatalogObject(int fd, int catalog, int NNNN)
#define getVersionDate(fd, x)
#define increaseReticleBrightness(fd)
#define getObjectInfo(fd, x)
#define getVersionTime(fd, x)
#define getLX200DEC(fd, x)
#define getVersionNumber(fd, x)
#define getLX200RA(fd, x)
#define decreaseReticleBrightness(fd)
#define getProductName(fd, x)