Instrument Neutral Distributed Interface INDI 2.2.5
lx200am5.h
Go to the documentation of this file.
1/*
2 ZWO Mount INDI driver
3
4 Copyright (C) 2015-2027 Jasem Mutlaq
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#pragma once
22
23#include "lx200generic.h"
24#include "indipropertyswitch.h"
25#include "indipropertynumber.h"
26#include "indipropertytext.h"
27
28#include <chrono>
29
30class LX200AM5 : public LX200Generic
31{
32 public:
33 LX200AM5();
34 virtual ~LX200AM5() override = default;
35
36 virtual bool updateProperties() override;
37 virtual bool initProperties() override;
38
39 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
40 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
41
42 protected:
43 virtual const char *getDefaultName() override;
44
45 // Communication
46 virtual bool checkConnection() override;
47
48 // Motion & Goto
49 virtual bool ReadScopeStatus() override;
50 virtual bool SetSlewRate(int index) override;
51
52 // Tracking
53 virtual bool SetTrackEnabled(bool enabled) override;
54
55 // Time & Location
56 virtual bool updateLocation(double latitude, double longitude, double elevation) override;
57 virtual bool setUTCOffset(double offset) override;
58 virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override;
59
60 // Parking
61 virtual bool Park() override;
62 virtual bool UnPark() override;
63 virtual bool SetCurrentPark() override;
64 virtual bool SetDefaultPark() override;
65
66 // Home
67 virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override;
68
69 // Config
70 virtual bool saveConfigItems(FILE *fp) override;
71
72 private:
73
77
88 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
96 bool sendStatusCommand(const char * cmd, char * res);
97 void hexDump(char * buf, const char * data, int size);
98 std::vector<std::string> split(const std::string &input, const std::string &regex);
99
103 // Go Home
104 //INDI::PropertySwitch HomeSP {1};
105 // Mount Type
106 INDI::PropertySwitch MountTypeSP {2};
107 enum
108 {
109 Azimuth,
110 Equatorial
111 };
112 // Guide Rate
113 INDI::PropertyNumber GuideRateNP {1};
114 // Buzzer control
115 INDI::PropertySwitch BuzzerSP {3};
116 enum
117 {
118 Off,
119 Low,
120 High
121 };
122
123 // Heavy duty control
124 INDI::PropertySwitch HeavyDutyModeSP {2};
125
126 // Meridian Flip Control
127 INDI::PropertySwitch MeridianFlipSP {2};
128
129 // Post Meridian Track Control
130 INDI::PropertySwitch PostMeridianTrackSP {2};
131 enum
132 {
133 TRACK,
134 STOP
135 };
136
137 // Meridian Limit
138 INDI::PropertyNumber MeridianLimitNP {1};
139
140 // Altitude Limits
141 INDI::PropertySwitch AltitudeLimitSP {3};
142 enum
143 {
144 ALT_LIMIT_ENABLE,
145 ALT_LIMIT_DISABLE,
146 ALT_LIMIT_GET
147 };
148 INDI::PropertyNumber AltitudeLimitUpperNP {1};
149 INDI::PropertyNumber AltitudeLimitLowerNP {1};
150
151 // Multi-Star Alignment
152 INDI::PropertySwitch MultiStarAlignSP {1};
153 enum
154 {
155 CLEAR_ALIGNMENT_DATA
156 };
157
158 // Variable Slew Speed
159 INDI::PropertyNumber VariableSlewRateNP {1};
160
161 // Mount model and firmware version
162 INDI::PropertyText FirmwareTP {2};
163 enum
164 {
165 FIRMWARE_MODEL,
166 FIRMWARE_VERSION
167 };
168
169 // Whether a custom park position was stored in the mount (:Sp01#). The mount cannot be queried
170 // for it, so it is kept in the config only and never defined. Without one, park goes home.
171 INDI::PropertySwitch CustomParkSP {1};
172
173
177 void setup();
178
179 // Homing
180 bool goHome();
181 bool park();
182 bool setHome();
183
184 // Firmware
185 void getFirmwareInfo();
186 bool hasMountPark() const
187 {
188 return m_FirmwareVersion >= FIRMWARE_MOUNT_PARK;
189 }
190 bool hasCustomParkPosition() const
191 {
192 return m_FirmwareVersion >= FIRMWARE_CUSTOM_PARK_POSITION;
193 }
194
195 // Mount park position (firmware dependent)
196 bool parkToMountPosition();
197 bool getMountParkState(char &state);
198 void checkMountParkState();
199 void updateMountPark(bool slewComplete);
200 void failMountPark(const char *reason);
201
202 // Altitude Limits
203 bool setAltitudeLimitEnabled(bool enable);
204 bool getAltitudeLimitStatus();
205 bool setAltitudeLimitUpper(double limit);
206 bool getAltitudeLimitUpper();
207 bool setAltitudeLimitLower(double limit);
208 bool getAltitudeLimitLower();
209
210 // Multi-Star Alignment
211 bool clearMultiStarAlignmentData();
212
213 // Variable Slew Speed
214 bool setVariableSlewRate(double rate);
215
216 // Guide Rate
217 bool setGuideRate(double value);
218 bool getGuideRate();
219
220 // Buzzer
221 bool getBuzzer();
222 bool setBuzzer(int value);
223
224 // Heavy Duty Mode
225 bool getHeavyDutyMode();
226 bool setHeavyDutyMode(bool enable);
227
228 // Mount type
229 bool setMountType(int type);
230 bool getMountType();
231
232 // Track Mode
233 bool getTrackMode();
234 bool isTracking();
235
236 // Meridian Flip
237 bool setMeridianFlipSettings(bool enabled, bool track, double limit);
238 bool getMeridianFlipSettings();
239
240
244 // # is the stop char
245 static const char DRIVER_STOP_CHAR { 0x23 };
246 // Wait up to a maximum of 3 seconds for serial input
247 static constexpr const uint8_t DRIVER_TIMEOUT {3};
248 // Maximum buffer for sending/receiving.
249 static constexpr const uint8_t DRIVER_LEN {64};
250 // Slew Modes
251 static constexpr const uint8_t SLEW_MODES {10};
252 static constexpr const char * MERIDIAN_FLIP_TAB {"Meridian Flip"};
253 static constexpr const char * ALTITUDE_LIMIT_TAB {"Altitude Limits"};
254 static constexpr const char * ALIGNMENT_TAB {"Alignment"};
255
256 // Firmware versions encoded as (major << 16) | (minor << 8) | patch
257 // :hP# parks, :Gps# reports the park state and :Spu# unparks.
258 static constexpr uint32_t FIRMWARE_MOUNT_PARK {0x010109};
259 // :Sp01# stores the current position as the park position.
260 static constexpr uint32_t FIRMWARE_CUSTOM_PARK_POSITION {0x010300};
261 // Give up a park that does not start moving within this time.
262 static constexpr std::chrono::seconds PARK_START_TIMEOUT {5};
263
264 uint32_t m_FirmwareVersion {0};
265
266 // Parking to the mount park position (:hP#), tracked with :Gps#.
267 bool m_MountParking {false};
268 bool m_ParkMoved {false};
269 std::chrono::steady_clock::time_point m_ParkDeadline;
270};
int SetSlewRate(void)
virtual bool ReadScopeStatus() override
Read telescope status.
virtual IPState ExecuteHomeAction(TelescopeHomeAction action) override
Execute a homing action.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
Definition lx200am5.cpp:173
virtual bool SetDefaultPark() override
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
Definition lx200am5.cpp:820
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition lx200am5.cpp:55
virtual bool Park() override
Park the telescope to its home position.
Definition lx200am5.cpp:907
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition lx200am5.cpp:410
virtual const char * getDefaultName() override
Definition lx200am5.cpp:242
virtual bool UnPark() override
Unpark the telescope if already parked.
Definition lx200am5.cpp:926
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool checkConnection() override
Definition lx200am5.cpp:250
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition lx200am5.cpp:301
virtual ~LX200AM5() override=default
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
Definition lx200am5.cpp:872
virtual bool setUTCOffset(double offset) override
Definition lx200am5.cpp:799
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition lx200am5.cpp:958
virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override
Definition lx200am5.cpp:810
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint16_t type
Definition pwc-ioctl.h:0
uint8_t cmd[4]
Definition pwc-ioctl.h:2