Instrument Neutral Distributed Interface INDI 2.2.5
lx200generic.cpp
Go to the documentation of this file.
1#if 0
2LX200 Generic
3Copyright (C) 2003 - 2017 Jasem Mutlaq ([email protected])
4
5This library is free software;
6you can redistribute it and / or
7modify it under the terms of the GNU Lesser General Public
8License as published by the Free Software Foundation;
9either
10version 2.1 of the License, or (at your option) any later version.
11
12This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY;
14without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16Lesser General Public License for more details.
17
18You should have received a copy of the GNU Lesser General Public
19License along with this library;
20if not, write to the Free Software
21Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110 - 1301 USA
22
232013 - 10 - 27:
24Updated driver to use INDI::Telescope (JM)
252015 - 11 - 25:
26 Use variable POLLMS instead of static POLLMS
27
28#endif
29
30#include "lx200generic.h"
31
32#include "lx200_10micron.h"
33#include "lx200_16.h"
34#include "lx200_OnStep.h"
35#include "lx200_OpenAstroTech.h"
36#include "lx200_proxisky.h"
37#include "lx200ap_v2.h"
38#include "lx200ap_gtocp2.h"
39#include "lx200classic.h"
40#include "lx200fs2.h"
41#include "lx200gemini.h"
42#include "lx200pulsar2.h"
43#include "lx200ss2000pc.h"
44#include "lx200zeq25.h"
45#include "lx200gotonova.h"
46#include "ioptronHC8406.h"
47#include "lx200am5.h"
49#include <cmath>
50#include <memory>
51#include <cstring>
52#include <unistd.h>
53#include "eq500x.h"
54#include "lx200_esp32go.h"
55#include "toup_sh20.h"
56
57 /* There is _one_ binary for all LX200 drivers, but each binary is renamed
58 ** to its device name (i.e. lx200gps, lx200_16..etc). The main function will
59 ** fetch from std args the binary name and ISInit will create the appropriate
60 ** device afterwards. If the binary name does not match any known devices,
61 ** we simply create a generic device.
62 */
63
64#ifdef __APPLE__
65 // getprogname() is a BSD/Darwin function present in the runtime but hidden from
66 // <stdlib.h> when _POSIX_C_SOURCE or _XOPEN_SOURCE are defined. Forward-declare it
67 // explicitly to bypass the header visibility guard.
68 extern "C" const char *getprogname(void);
69#endif
70
71static const char *getProgName()
72{
73#ifdef __APPLE__
74 return getprogname();
75#else
76 extern char *__progname;
77 return __progname;
78#endif
79}
80
81#define LX200_TRACK 0
82#define LX200_SYNC 1
83
84static class Loader
85{
86 std::unique_ptr<LX200Generic> telescope;
87 public:
88 Loader()
89 {
90 // Note: these if statements use strstr() which isn't a full string match, just a substring,
91 // so if one driver name is the start of another's name, it needs to be AFTER the longer one!
92 if (strstr(getProgName(), "indi_lx200classic"))
93 {
94 IDLog("initializing from LX200 classic device...\n");
95 telescope.reset(new LX200Classic());
96 }
97 else if (strstr(getProgName(), "indi_lx200_OnStep"))
98 {
99 IDLog("initializing from LX200 OnStep device...\n");
100 telescope.reset(new LX200_OnStep());
101 }
102 else if (strstr(getProgName(), "indi_lx200_proxisky"))
103 {
104 IDLog("initializing from Proxisky UMi device...\n");
105 telescope.reset(new LX200_Proxisky());
106 }
107 else if (strstr(getProgName(), "indi_lx200gps"))
108 {
109 IDLog("initializing from LX200 GPS device...\n");
110 telescope.reset(new LX200GPS());
111 }
112 else if (strstr(getProgName(), "indi_lx200_16"))
113 {
114 IDLog("Initializing from LX200 16 device...\n");
115 telescope.reset(new LX200_16());
116 }
117 else if (strstr(getProgName(), "indi_lx200autostar"))
118 {
119 IDLog("initializing from Autostar device...\n");
120 telescope.reset(new LX200Autostar());
121 }
122 else if (strstr(getProgName(), "indi_lx200ap_v2"))
123 {
124 IDLog("initializing from Astrophysics V2 device...\n");
125 telescope.reset(new LX200AstroPhysicsV2());
126 }
127 else if (strstr(getProgName(), "indi_lx200ap_legacy"))
128 {
129 IDLog("initializing from Astrophysics GTOCP2 device...\n");
130 telescope.reset(new LX200AstroPhysicsGTOCP2());
131 }
132 else if (strstr(getProgName(), "indi_lx200gemini"))
133 {
134 IDLog("initializing from Losmandy Gemini device...\n");
135 telescope.reset(new LX200Gemini());
136 }
137 else if (strstr(getProgName(), "indi_lx200zeq25"))
138 {
139 IDLog("initializing from ZEQ25 device...\n");
140 telescope.reset(new LX200ZEQ25());
141 }
142 else if (strstr(getProgName(), "indi_lx200gotonova"))
143 {
144 IDLog("initializing from GotoNova device...\n");
145 telescope.reset(new LX200GotoNova());
146 }
147 else if (strstr(getProgName(), "indi_ioptronHC8406"))
148 {
149 IDLog("initializing from ioptron telescope Hand Controller HC8406 device...\n");
150 telescope.reset(new ioptronHC8406());
151 }
152 else if (strstr(getProgName(), "indi_lx200pulsar2"))
153 {
154 IDLog("initializing from pulsar2 device...\n");
155 telescope.reset(new LX200Pulsar2());
156 }
157 else if (strstr(getProgName(), "indi_lx200ss2000pc"))
158 {
159 IDLog("initializing from skysensor2000pc device...\n");
160 telescope.reset(new LX200SS2000PC());
161 }
162 else if (strstr(getProgName(), "indi_lx200fs2"))
163 {
164 IDLog("initializing from Astro-Electronic FS-2...\n");
165 telescope.reset(new LX200FS2());
166 }
167 else if (strstr(getProgName(), "indi_lx200_10micron"))
168 {
169 IDLog("initializing for 10Micron mount...\n");
170 telescope.reset(new LX200_10MICRON());
171 }
172 else if (strstr(getProgName(), "indi_eq500x"))
173 {
174 IDLog("initializing for EQ500X mount...\n");
175 telescope.reset(new EQ500X());
176 }
177 else if (strstr(getProgName(), "indi_lx200am5"))
178 {
179 IDLog("initializing for ZWO AM5 mount...\n");
180 telescope.reset(new LX200AM5());
181 }
182 else if (strstr(getProgName(), "indi_lx200_OpenAstroTech"))
183 {
184 IDLog("initializing for OpenAstroTech mount...\n");
185 telescope.reset(new LX200_OpenAstroTech());
186 }
187 else if (strstr(getProgName(), "indi_lx200_pegasus_nyx101"))
188 {
189 IDLog("initializing for Pegasus NYX-101 mount...\n");
190 telescope.reset(new LX200NYX101());
191 }
192 else if (strstr(getProgName(), "indi_lx200_esp32go"))
193 {
194 IDLog("initializing for ESP32go mount...\n");
195 telescope.reset(new LX200_esp32go());
196 }
197 else if (strstr(getProgName(), "indi_touptek_sh20"))
198 {
199 IDLog("initializing for TOUPTEK SH20 mount...\n");
200 telescope.reset(new ToupSH20());
201 }
202 // be nice and give them a generic device
203 else
204 telescope.reset(new LX200Generic());
205 }
206} loader;
207
208/**************************************************
209*** LX200 Generic Implementation
210***************************************************/
211
void setVersion(uint16_t vMajor, uint16_t vMinor)
Set driver version information to be defined in DRIVER_INFO property as vMajor.vMinor.
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
void setLX200Capability(uint32_t cap)
#define POLLMS
void IDLog(const char *fmt,...)
Definition indicom.c:305
#define LOG_DEBUG(txt)
Definition indilogger.h:75
@ LX200_TRACK_SIDEREAL
static Logger & getInstance()
Method to get a reference to the object (i.e., Singleton) It is a static method.
int addDebugLevel(const char *debugLevelName, const char *LoggingLevelName)
Adds a new debugging level to the driver.