Instrument Neutral Distributed Interface INDI 2.2.5
lx200am5.cpp
Go to the documentation of this file.
1/*
2 ZWO Mount INDI driver
3
4 Copyright (C) 2022-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#include "lx200am5.h"
22
24#include "lx200driver.h"
25#include "indicom.h"
26
27#include <libnova/transform.h>
28
29#include <cmath>
30#include <cstring>
31#include <stdio.h>
32#include <termios.h>
33#include <unistd.h>
34#include <regex>
35
55
57{
59
62
63 tcpConnection->setDefaultHost("192.168.4.1");
64 tcpConnection->setDefaultPort(4030);
65 tcpConnection->setLANSearchEnabled(true);
66
67 if (strstr(getDeviceName(), "WiFi"))
69
73 // The last known mount type decides the pier side capability before connecting.
74 if (!MountTypeSP.load())
75 {
76 // Older configurations stored it in MOUNT_TYPE (0 = Alt-Az, 1 = Equatorial).
77 int legacyType = 1;
78 if (IUGetConfigOnSwitchIndex(getDeviceName(), "MOUNT_TYPE", &legacyType) == 0 && legacyType == 0)
80 }
81
84
85 // Slew Rates
86
87 SlewRateSP[0].setLabel("0.25x");
88 SlewRateSP[1].setLabel("0.5x");
89 SlewRateSP[2].setLabel("1x");
90 SlewRateSP[3].setLabel("2x");
91 SlewRateSP[4].setLabel("4x");
92 SlewRateSP[5].setLabel("8x");
93 SlewRateSP[6].setLabel("20x");
94 SlewRateSP[7].setLabel("60x");
95 SlewRateSP[8].setLabel("720x");
96 SlewRateSP[9].setLabel("1440x");
97 SlewRateSP.reset();
98 // 1440x is the default
99 SlewRateSP[9].setState(ISS_ON);
100
101 // Home/Zero position
102 // HomeSP[0].fill("GO", "Go", ISS_OFF);
103 // HomeSP.fill(getDeviceName(), "TELESCOPE_HOME", "Home", MAIN_CONTROL_TAB, IP_RW, ISR_ATMOST1, 60, IPS_IDLE);
104
105 // Guide Rate
106 GuideRateNP[0].fill("RATE", "Rate", "%.2f", 0.1, 0.9, 0.1, 0.5);
107 GuideRateNP.fill(getDeviceName(), "GUIDE_RATE", "Guiding Rate", MOTION_TAB, IP_RW, 60, IPS_IDLE);
108 GuideRateNP.load();
109
110 // Buzzer
111 BuzzerSP[Off].fill("OFF", "Off", ISS_OFF);
112 BuzzerSP[Low].fill("LOW", "Low", ISS_OFF);
113 BuzzerSP[High].fill("HIGH", "High", ISS_ON);
114 BuzzerSP.fill(getDeviceName(), "BUZZER", "Buzzer", OPTIONS_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE);
115
116 // Heavy Duty Mode
117 HeavyDutyModeSP[INDI_ENABLED].fill("INDI_ENABLED", "Enabled", ISS_OFF);
118 HeavyDutyModeSP[INDI_DISABLED].fill("INDI_DISABLED", "Disabled", ISS_OFF);
119 HeavyDutyModeSP.fill(getDeviceName(), "HEAVY_DUTY_MODE", "Heavy Duty Mode", MOTION_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE);
120
121 // Meridian Flip Enable
122 MeridianFlipSP[INDI_ENABLED].fill("INDI_ENABLED", "Enabled", ISS_ON);
123 MeridianFlipSP[INDI_DISABLED].fill("INDI_DISABLED", "Disabled", ISS_OFF);
124 MeridianFlipSP.fill(getDeviceName(), "MERIDIAN_FLIP", "Meridian Flip", MERIDIAN_FLIP_TAB, IP_RW, ISR_1OFMANY, 60, IPS_IDLE);
125 MeridianFlipSP.load();
126
127 // Post Meridian Track
128 PostMeridianTrackSP[TRACK].fill("TRACK", "Track", ISS_ON);
129 PostMeridianTrackSP[STOP].fill("STOP", "Stop", ISS_OFF);
130 PostMeridianTrackSP.fill(getDeviceName(), "POST_MERIDIAN_TRACK", "After Meridian", MERIDIAN_FLIP_TAB, IP_RW, ISR_1OFMANY,
131 60, IPS_IDLE);
132 PostMeridianTrackSP.load();
133
134 // Meridian Flip Limit
135 MeridianLimitNP[0].fill("LIMIT", "Limit (deg)", "%.f", -15, 15, 1, 0);
136 MeridianLimitNP.fill(getDeviceName(), "MERIDIAN_LIMIT", "Meridian Limit", MERIDIAN_FLIP_TAB, IP_RW, 60, IPS_IDLE);
137 MeridianLimitNP.load();
138
139 // Altitude Limits
140 AltitudeLimitSP[INDI_ENABLED].fill("ENABLE", "Enable", ISS_OFF);
141 AltitudeLimitSP[INDI_DISABLED].fill("DISABLE", "Disable", ISS_ON);
142 AltitudeLimitSP.fill(getDeviceName(), "ALTITUDE_LIMIT_CONTROL", "Altitude Limit Control", ALTITUDE_LIMIT_TAB, IP_RW,
143 ISR_1OFMANY, 60, IPS_IDLE);
144
145 AltitudeLimitUpperNP[0].fill("UPPER_LIMIT", "Upper Limit (deg)", "%.f", 60, 90, 1, 90);
146 AltitudeLimitUpperNP.fill(getDeviceName(), "ALTITUDE_UPPER_LIMIT", "Altitude Upper Limit", ALTITUDE_LIMIT_TAB, IP_RW, 60,
147 IPS_IDLE);
148
149 AltitudeLimitLowerNP[0].fill("LOWER_LIMIT", "Lower Limit (deg)", "%.f", 0, 30, 1, 0);
150 AltitudeLimitLowerNP.fill(getDeviceName(), "ALTITUDE_LOWER_LIMIT", "Altitude Lower Limit", ALTITUDE_LIMIT_TAB, IP_RW, 60,
151 IPS_IDLE);
152
153 // Multi-Star Alignment
154 MultiStarAlignSP[CLEAR_ALIGNMENT_DATA].fill("CLEAR", "Clear Data", ISS_OFF);
155 MultiStarAlignSP.fill(getDeviceName(), "MULTI_STAR_ALIGNMENT", "Multi-Star Alignment", ALIGNMENT_TAB, IP_RW, ISR_ATMOST1,
156 60, IPS_IDLE);
157
158 // Variable Slew Speed
159 VariableSlewRateNP[0].fill("RATE", "Rate (x Sidereal)", "%.2f", 0.00, 1440.00, 0.01, 1440.00);
160 VariableSlewRateNP.fill(getDeviceName(), "VARIABLE_SLEW_RATE", "Variable Slew Rate", MOTION_TAB, IP_RW, 60, IPS_IDLE);
161
162 // Firmware
163 FirmwareTP[FIRMWARE_MODEL].fill("MODEL", "Model", "");
164 FirmwareTP[FIRMWARE_VERSION].fill("VERSION", "Version", "");
165 FirmwareTP.fill(getDeviceName(), "MOUNT_FIRMWARE", "Firmware", INFO_TAB, IP_RO, 60, IPS_IDLE);
166
167 // Custom park position (config only, never defined)
168 CustomParkSP[0].fill("SET", "Set", ISS_OFF);
169 CustomParkSP.fill(getDeviceName(), "CUSTOM_PARK_POSITION", "Custom Park", SITE_TAB, IP_RW, ISR_NOFMANY, 60, IPS_IDLE);
170 CustomParkSP.load();
171
172 return true;
173}
174
179{
181
182 if (isConnected())
183 {
184 setup();
185
186 //defineProperty(HomeSP);
187 defineProperty(GuideRateNP);
188 defineProperty(BuzzerSP);
189 defineProperty(HeavyDutyModeSP);
190
191 // Only define meridian flip properties for equatorial mount
192 if (getMountType() != MOUNT_ALTAZ)
193 {
194 defineProperty(MeridianFlipSP);
195 defineProperty(PostMeridianTrackSP);
196 defineProperty(MeridianLimitNP);
197 }
198
199 // Altitude Limits
200 defineProperty(AltitudeLimitSP);
201 defineProperty(AltitudeLimitUpperNP);
202 defineProperty(AltitudeLimitLowerNP);
203
204 // Multi-Star Alignment
205 defineProperty(MultiStarAlignSP);
206
207 // Variable Slew Speed
208 defineProperty(VariableSlewRateNP);
209
210 defineProperty(FirmwareTP);
211 }
212 else
213 {
214 //deleteProperty(HomeSP);
215 deleteProperty(GuideRateNP);
216 deleteProperty(BuzzerSP);
217 deleteProperty(HeavyDutyModeSP);
218
219 // Only delete meridian flip properties if they were defined
220 if (getMountType() != MOUNT_ALTAZ)
221 {
222 deleteProperty(MeridianFlipSP);
223 deleteProperty(PostMeridianTrackSP);
224 deleteProperty(MeridianLimitNP);
225 }
226
227 // Altitude Limits
228 deleteProperty(AltitudeLimitSP);
229 deleteProperty(AltitudeLimitUpperNP);
230 deleteProperty(AltitudeLimitLowerNP);
231
232 // Multi-Star Alignment
233 deleteProperty(MultiStarAlignSP);
234
235 // Variable Slew Speed
236 deleteProperty(VariableSlewRateNP);
237
238 deleteProperty(FirmwareTP);
239 }
240
241 return true;
242}
243
248{
249 return "ZWO AM5";
250}
251
256{
257 LOG_DEBUG("Checking AM5 connection...");
258
259 double targetRA = 0;
260 for (int i = 0; i < 2; i++)
261 {
262 if (getLX200RA(PortFD, &targetRA) == 0)
263 return true;
264
265 const struct timespec ms250_delay = {.tv_sec = 0, .tv_nsec = 250000000};
266 nanosleep(&ms250_delay, NULL);
267 }
268
269 return false;
270}
271
275void LX200AM5::setup()
276{
277 InitPark();
278
279 getFirmwareInfo();
280 readMountType();
281 getTrackMode();
282 getGuideRate();
283 getBuzzer();
284 getHeavyDutyMode();
285
286 // Only get meridian flip settings for equatorial mount
287 if (getMountType() != MOUNT_ALTAZ)
288 getMeridianFlipSettings();
289
290 // Get altitude limit settings
291 getAltitudeLimitStatus();
292 getAltitudeLimitUpper();
293 getAltitudeLimitLower();
294
295 // A park made outside the driver (e.g. by the vendor app) leaves the mount latched in the parked state.
296 checkMountParkState();
297}
298
302bool LX200AM5::ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n)
303{
304 if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
305 {
306 // Buzzer
307 if (BuzzerSP.isNameMatch(name))
308 {
309 return updateProperty(BuzzerSP, states, names, n, [this, names]()
310 {
311 if (BuzzerSP[Off].isNameMatch(names[0]))
312 return setBuzzer(Off);
313 if (BuzzerSP[Low].isNameMatch(names[0]))
314 return setBuzzer(Low);
315 if (BuzzerSP[High].isNameMatch(names[0]))
316 return setBuzzer(High);
317 return false;
318 }, true);
319 }
320
321 // Heavy Duty Mode
322 if (HeavyDutyModeSP.isNameMatch(name))
323 {
324 return updateProperty(HeavyDutyModeSP, states, names, n, [this, names]()
325 {
326 return setHeavyDutyMode(HeavyDutyModeSP[INDI_ENABLED].isNameMatch(names[0]));
327 }, true);
328 }
329
330 // Meridian Flip Enable
331 if (MeridianFlipSP.isNameMatch(name))
332 {
333 return updateProperty(MeridianFlipSP, states, names, n, [this, names]()
334 {
335 return setMeridianFlipSettings(MeridianFlipSP[INDI_ENABLED].isNameMatch(names[0]),
336 PostMeridianTrackSP[TRACK].getState() == ISS_ON,
337 MeridianLimitNP[0].getValue());
338 }, true);
339 }
340
341 // Post Meridian Track
342 if (PostMeridianTrackSP.isNameMatch(name))
343 {
344 return updateProperty(PostMeridianTrackSP, states, names, n, [this, names]()
345 {
346 return setMeridianFlipSettings(MeridianFlipSP[INDI_ENABLED].getState() == ISS_ON,
347 PostMeridianTrackSP[TRACK].isNameMatch(names[0]),
348 MeridianLimitNP[0].getValue());
349 }, true);
350 }
351
352 // Custom park position, only received when the config is loaded.
353 if (CustomParkSP.isNameMatch(name))
354 {
355 CustomParkSP.update(states, names, n);
356 return true;
357 }
358
359 // Altitude Limit Enable/Disable
360 if (AltitudeLimitSP.isNameMatch(name))
361 {
362 return updateProperty(AltitudeLimitSP, states, names, n, [this, names]()
363 {
364 return setAltitudeLimitEnabled(AltitudeLimitSP[INDI_ENABLED].isNameMatch(names[0]));
365 }, true);
366 }
367
368 // Multi-Star Alignment (momentary action — handled manually like AbortRotatorSP in rotator interface)
369 if (MultiStarAlignSP.isNameMatch(name))
370 {
371 MultiStarAlignSP.update(states, names, n);
372 if (MultiStarAlignSP[CLEAR_ALIGNMENT_DATA].getState() == ISS_ON)
373 {
374 MultiStarAlignSP.setState(clearMultiStarAlignmentData() ? IPS_OK : IPS_ALERT);
375
376 }
377 else
378 MultiStarAlignSP.setState(IPS_IDLE);
379
380 MultiStarAlignSP.apply();
381 return true;
382 }
383 }
384
385 return LX200Generic::ISNewSwitch(dev, name, states, names, n);
386}
387
391bool LX200AM5::ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n)
392{
393 if (dev != nullptr && strcmp(dev, getDeviceName()) == 0)
394 {
395 // Guide Rate
396 if (GuideRateNP.isNameMatch(name))
397 {
398 return updateProperty(GuideRateNP, values, names, n, [this, values]()
399 {
400 return setGuideRate(values[0]);
401 }, true);
402 }
403
404 // Meridian Flip Limit
405 if (MeridianLimitNP.isNameMatch(name))
406 {
407 return updateProperty(MeridianLimitNP, values, names, n, [this, values]()
408 {
409 return setMeridianFlipSettings(MeridianFlipSP[INDI_ENABLED].getState() == ISS_ON,
410 PostMeridianTrackSP[TRACK].getState() == ISS_ON,
411 values[0]);
412 }, true);
413 }
414
415 // Altitude Upper Limit
416 if (AltitudeLimitUpperNP.isNameMatch(name))
417 {
418 return updateProperty(AltitudeLimitUpperNP, values, names, n, [this, values]()
419 {
420 return setAltitudeLimitUpper(values[0]);
421 }, true);
422 }
423
424 // Altitude Lower Limit
425 if (AltitudeLimitLowerNP.isNameMatch(name))
426 {
427 return updateProperty(AltitudeLimitLowerNP, values, names, n, [this, values]()
428 {
429 return setAltitudeLimitLower(values[0]);
430 }, true);
431 }
432
433 // Variable Slew Rate
434 if (VariableSlewRateNP.isNameMatch(name))
435 {
436 return updateProperty(VariableSlewRateNP, values, names, n, [this, values]()
437 {
438 return setVariableSlewRate(values[0]);
439 });
440 }
441 }
442
443 return LX200Generic::ISNewNumber(dev, name, values, names, n);
444}
445
450{
451 if (type == MOUNT_EQ_FORK)
452 {
453 LOG_ERROR("AM5 supports Alt-Az and German equatorial modes only.");
454 return false;
455 }
456
457 // When disconnected the selection is only saved.
458 if (!isConnected())
459 return true;
460
461 if (!sendCommand((type == MOUNT_ALTAZ) ? ":AA#" : ":AP#"))
462 return false;
463
464 LOG_WARN("You must restart mount for change to take effect.");
465 return true;
466}
467
471bool LX200AM5::readMountType()
472{
473 char response[DRIVER_LEN] = {0};
474 if (!sendCommand(":GU#", response))
475 return false;
476
477 if (strchr(response, 'Z'))
479 else if (strchr(response, 'G'))
481 return true;
482}
483
488{
489 char command[DRIVER_LEN] = {0};
490 snprintf(command, DRIVER_LEN, ":R%d#", index);
491 return sendCommand(command);
492}
493
494
495
499bool LX200AM5::setGuideRate(double value)
500{
501 char command[DRIVER_LEN] = {0};
502 snprintf(command, DRIVER_LEN, ":Rg%.2f#", value);
503 return sendCommand(command);
504}
505
509bool LX200AM5::getGuideRate()
510{
511 char response[DRIVER_LEN] = {0};
512 if (sendCommand(":Ggr#", response))
513 {
514 float rate = 0;
515 int result = sscanf(response, "%f", &rate);
516 if (result == 1)
517 {
518 GuideRateNP[0].setValue(rate);
519 return true;
520 }
521 }
522
523 GuideRateNP.setState(IPS_ALERT);
524 return false;
525
526}
527
531bool LX200AM5::getTrackMode()
532{
533 char response[DRIVER_LEN] = {0};
534 if (sendCommand(":GT#", response))
535 {
536 TrackModeSP.reset();
537 auto onIndex = response[0] - 0x30;
538 if (onIndex >= 0 && onIndex < static_cast<int>(TrackModeSP.count()))
539 {
540 TrackModeSP[onIndex].setState(ISS_ON);
541 return true;
542 }
543 }
544
545 TrackModeSP.setState(IPS_ALERT);
546 return false;
547
548}
549
553bool LX200AM5::setBuzzer(int value)
554{
555 char command[DRIVER_LEN] = {0};
556 snprintf(command, DRIVER_LEN, ":SBu%d#", value);
557 return sendCommand(command);
558}
559
563bool LX200AM5::getBuzzer()
564{
565 char response[DRIVER_LEN] = {0};
566 if (sendCommand(":GBu#", response))
567 {
568 BuzzerSP.reset();
569 auto onIndex = response[0] - 0x30;
570 if (onIndex >= 0 && onIndex < static_cast<int>(BuzzerSP.count()))
571 {
572 BuzzerSP[onIndex].setState(ISS_ON);
573 BuzzerSP.setState(IPS_OK);
574 return true;
575 }
576 }
577
578 BuzzerSP.setState(IPS_ALERT);
579 return true;
580
581}
582
586bool LX200AM5::getHeavyDutyMode()
587{
588 char response[DRIVER_LEN] = {0};
589 if (sendCommand(":GRl#", response))
590 {
591 HeavyDutyModeSP.reset();
592
593 if (strcmp(response, "1440#") == 0)
594 {
595 HeavyDutyModeSP[INDI_DISABLED].setState(ISS_ON);
596 }
597
598 if (strcmp(response, "720#") == 0)
599 {
600 HeavyDutyModeSP[INDI_ENABLED].setState(ISS_ON);
601 }
602
603 HeavyDutyModeSP.setState(IPS_OK);
604 return true;
605 }
606 else
607 {
608 HeavyDutyModeSP.setState(IPS_ALERT);
609 return true;
610 }
611}
612
616bool LX200AM5::setHeavyDutyMode(bool enable)
617{
618 // Reply must be read, otherwise it is left in the input stream for the next command.
619 char response[DRIVER_LEN] = {0};
620 return sendCommand(enable ? ":SRl720#" : ":SRl1440#", response, -1, 1) && response[0] == '1';
621}
622
626bool LX200AM5::setMeridianFlipSettings(bool enabled, bool track, double limit)
627{
628 char command[DRIVER_LEN] = {0};
629 snprintf(command, DRIVER_LEN, ":STa%d%d%c%02d#", enabled ? 1 : 0, track ? 1 : 0,
630 limit >= 0 ? '+' : '-', static_cast<int>(std::abs(limit)));
631 char response[2] = {0};
632 auto rc = sendCommand(command, response, -1, 1);
633 return rc && response[0] == '1';
634}
635
639bool LX200AM5::getMeridianFlipSettings()
640{
641 char response[DRIVER_LEN] = {0};
642 if (sendCommand(":GTa#", response))
643 {
644 if (strlen(response) >= 5)
645 {
646 // First digit: meridian flip enabled
647 MeridianFlipSP.reset();
648 MeridianFlipSP[response[0] == '1' ? INDI_ENABLED : INDI_DISABLED].setState(ISS_ON);
649 MeridianFlipSP.setState(IPS_OK);
650
651 // Second digit: track after meridian
652 PostMeridianTrackSP.reset();
653 PostMeridianTrackSP[response[1] == '1' ? TRACK : STOP].setState(ISS_ON);
654 PostMeridianTrackSP.setState(IPS_OK);
655
656 // Last three digits: limit angle
657 char *sign = &response[2];
658 char *limit = &response[3];
659 int limitValue = atoi(limit);
660 if (*sign == '-')
661 limitValue = -limitValue;
662 MeridianLimitNP[0].setValue(limitValue);
663 MeridianLimitNP.setState(IPS_OK);
664
665 return true;
666 }
667 }
668
669 MeridianFlipSP.setState(IPS_ALERT);
670 PostMeridianTrackSP.setState(IPS_ALERT);
671 MeridianLimitNP.setState(IPS_ALERT);
672 return false;
673}
674
678bool LX200AM5::setAltitudeLimitEnabled(bool enable)
679{
680 // Reply must be read, otherwise it is left in the input stream for the next command.
681 char response[DRIVER_LEN] = {0};
682 return sendCommand(enable ? ":SLE#" : ":SLD#", response, -1, 1) && response[0] == '1';
683}
684
688bool LX200AM5::getAltitudeLimitStatus()
689{
690 char response[DRIVER_LEN] = {0};
691 if (sendCommand(":GLC#", response))
692 {
693 AltitudeLimitSP.reset();
694 AltitudeLimitSP[response[0] == '1' ? INDI_ENABLED : INDI_DISABLED].setState(ISS_ON);
695 AltitudeLimitSP.setState(IPS_OK);
696 return true;
697 }
698 AltitudeLimitSP.setState(IPS_ALERT);
699 return false;
700}
701
705bool LX200AM5::setAltitudeLimitUpper(double limit)
706{
707 char command[DRIVER_LEN] = {0};
708 snprintf(command, DRIVER_LEN, ":SLH%02d#", static_cast<int>(limit));
709 char response[2] = {0};
710 auto rc = sendCommand(command, response, -1, 1);
711 return rc && response[0] == '1';
712}
713
717bool LX200AM5::getAltitudeLimitUpper()
718{
719 char response[DRIVER_LEN] = {0};
720 if (sendCommand(":GLH#", response))
721 {
722 int limit = 0;
723 if (sscanf(response, "%d#", &limit) == 1)
724 {
725 AltitudeLimitUpperNP[0].setValue(limit);
726 AltitudeLimitUpperNP.setState(IPS_OK);
727 return true;
728 }
729 }
730 AltitudeLimitUpperNP.setState(IPS_ALERT);
731 return false;
732}
733
737bool LX200AM5::setAltitudeLimitLower(double limit)
738{
739 char command[DRIVER_LEN] = {0};
740 snprintf(command, DRIVER_LEN, ":SLL%02d#", static_cast<int>(limit));
741 char response[2] = {0};
742 auto rc = sendCommand(command, response, -1, 1);
743 return rc && response[0] == '1';
744}
745
749bool LX200AM5::getAltitudeLimitLower()
750{
751 char response[DRIVER_LEN] = {0};
752 if (sendCommand(":GLL#", response))
753 {
754 int limit = 0;
755 if (sscanf(response, "%d#", &limit) == 1)
756 {
757 AltitudeLimitLowerNP[0].setValue(limit);
758 AltitudeLimitLowerNP.setState(IPS_OK);
759 return true;
760 }
761 }
762 AltitudeLimitLowerNP.setState(IPS_ALERT);
763 return false;
764}
765
769bool LX200AM5::clearMultiStarAlignmentData()
770{
771 char response[2] = {0};
772 auto rc = sendCommand(":NSC#", response, -1, 1);
773 return rc && response[0] == '1';
774}
775
779bool LX200AM5::setVariableSlewRate(double rate)
780{
781 char command[DRIVER_LEN] = {0};
782 snprintf(command, DRIVER_LEN, ":Rv%.2f#", rate);
783 return sendCommand(command);
784}
785
789bool LX200AM5::setUTCOffset(double offset)
790{
791 int h {0}, m {0}, s {0};
792 char command[DRIVER_LEN] = {0};
793 offset *= -1;
794 getSexComponents(offset, &h, &m, &s);
795
796 snprintf(command, DRIVER_LEN, ":SG%c%02d:%02d#", offset >= 0 ? '+' : '-', std::abs(h), m);
797 return setStandardProcedure(PortFD, command) == 0;
798}
799
800bool LX200AM5::setLocalDate(uint8_t days, uint8_t months, uint16_t years)
801{
802 char command[DRIVER_LEN] = {0};
803 snprintf(command, DRIVER_LEN, ":SC%02d/%02d/%02d#", months, days, years % 100);
804 return setStandardProcedure(PortFD, command) == 0;
805}
806
811{
812 char response[DRIVER_LEN] = {0};
813 bool rc = sendCommand(enabled ? ":Te#" : ":Td#", response, 4, 1);
814 return rc && response[0] == '1';
815}
816
820bool LX200AM5::isTracking()
821{
822 char response[DRIVER_LEN] = {0};
823 bool rc = sendCommand(":GAT#", response);
824 return rc && response[0] == '1';
825}
826
830bool LX200AM5::goHome()
831{
832 return sendCommand(":hC#");
833}
834
838bool LX200AM5::park()
839{
840 // JM 2025.11.08: Many users do not like default ZWO parking position
841 // which is horizontal and does not go back to expected home position
842 // with CW down and looking at celestial pole.
843 // For now this is reverted now back to go back to that position instead
844 // of parking until ZWO releases update for custom parking positions.
845 return goHome();
846 //return sendCommand(":hP#");
847}
848
852bool LX200AM5::setHome()
853{
854 const char cmd[] = ":SOa#";
855 char status = '0';
856 return sendCommand(cmd, &status, strlen(cmd), sizeof(status)) && status == '1';
857}
858
862bool LX200AM5::updateLocation(double latitude, double longitude, double elevation)
863{
864 INDI_UNUSED(elevation);
865 int d{0}, m{0}, s{0};
866
867 // JM 2021-04-10: MUST convert from INDI longitude to standard longitude.
868 // DO NOT REMOVE
869 if (longitude > 180)
870 longitude = longitude - 360;
871
872 char command[DRIVER_LEN] = {0};
873 // Reverse as per Meade way
874 longitude *= -1;
875 getSexComponents(longitude, &d, &m, &s);
876 snprintf(command, DRIVER_LEN, ":Sg%c%03d*%02d:%02d#", longitude >= 0 ? '+' : '-', std::abs(d), m, s);
877 if (setStandardProcedure(PortFD, command) < 0)
878 {
879 LOG_ERROR("Error setting site longitude coordinates");
880 return false;
881 }
882
883 getSexComponents(latitude, &d, &m, &s);
884 snprintf(command, DRIVER_LEN, ":St%c%02d*%02d:%02d#", latitude >= 0 ? '+' : '-', std::abs(d), m, s);
885 if (setStandardProcedure(PortFD, command) < 0)
886 {
887 LOG_ERROR("Error setting site latitude coordinates");
888 return false;
889 }
890
891 return true;
892}
893
898{
899 m_MountParking = false;
900
901 bool rc = false;
902 // Without a custom park position, the mount would go to its factory park position which is horizontal.
903 if (hasCustomParkPosition() && CustomParkSP[0].getState() == ISS_ON)
904 rc = parkToMountPosition();
905 else
906 rc = park();
907
908 if (rc)
910 return rc;
911}
912
917{
918 // :hP# latches the parked state in the mount and only :Spu# releases it.
919 if (hasMountPark())
920 {
921 char response[DRIVER_LEN] = {0};
922 if (!sendStatusCommand(":Spu#", response))
923 {
924 LOG_ERROR("Failed to unpark mount.");
925 return false;
926 }
927
928 if (response[0] != '1')
929 {
930 // A mount that is not latched as parked (e.g. parked by going home) refuses to unpark.
931 char state = 0;
932 if (!getMountParkState(state) || state != '0')
933 {
934 LOGF_ERROR("Mount refused to unpark (%s).", response);
935 return false;
936 }
937 }
938 }
939
941 SetParked(false);
942 return true;
943}
944
949{
950 if (!hasCustomParkPosition())
951 {
952 LOGF_WARN("Setting the park position requires mount firmware 1.3.0 or later (detected %s).",
953 FirmwareTP[FIRMWARE_VERSION].getText());
954 return false;
955 }
956
957 char response[DRIVER_LEN] = {0};
958 if (!sendStatusCommand(":Sp01#", response))
959 {
960 LOG_ERROR("Failed to set park position.");
961 return false;
962 }
963
964 switch (response[0])
965 {
966 case '1':
967 LOG_INFO("Current position is stored as the mount park position.");
968 break;
969 case '2':
970 LOG_INFO("Current position is already the mount park position.");
971 break;
972 case '3':
973 LOG_ERROR("Mount refused the park position: only one park position can be set.");
974 return false;
975 case '4':
976 LOG_ERROR("Mount refused the park position: only available in equatorial mode.");
977 return false;
978 case '5':
979 LOG_ERROR("Mount refused the park position: the mount has to be homed first.");
980 return false;
981 case '9':
982 LOG_ERROR("Mount refused the park position: the mount is moving.");
983 return false;
984 default:
985 LOGF_ERROR("Mount refused the park position (%s).", response);
986 return false;
987 }
988
989 // Park to the stored position from now on.
990 CustomParkSP[0].setState(ISS_ON);
991 saveConfig();
992 return true;
993}
994
1000{
1001 CustomParkSP[0].setState(ISS_OFF);
1002 saveConfig();
1003
1004 LOG_INFO("Mount parks at the home position.");
1005 return true;
1006}
1007
1011bool LX200AM5::parkToMountPosition()
1012{
1013 char status[DRIVER_LEN] = {0};
1014 if (!sendCommand(":GU#", status))
1015 return false;
1016
1017 if (strchr(status, 'Z'))
1018 {
1019 LOG_ERROR("Parking to the mount park position is only available in equatorial mode.");
1020 return false;
1021 }
1022
1023 if (!SetTrackEnabled(false))
1024 {
1025 LOG_ERROR("Failed to stop tracking before parking.");
1026 return false;
1027 }
1028
1029 m_ParkMoved = false;
1030 m_ParkDeadline = std::chrono::steady_clock::now() + PARK_START_TIMEOUT;
1031
1032 LOG_INFO("Parking to the mount park position...");
1033 m_MountParking = sendCommand(":hP#");
1034 return m_MountParking;
1035}
1036
1040bool LX200AM5::getMountParkState(char &state)
1041{
1042 char response[DRIVER_LEN] = {0};
1043 if (!sendCommand(":Gps#", response))
1044 return false;
1045
1046 state = response[0];
1047 return true;
1048}
1049
1053void LX200AM5::checkMountParkState()
1054{
1055 m_MountParking = false;
1056
1057 char state = 0;
1058 if (!hasMountPark() || !getMountParkState(state))
1059 return;
1060
1061 if (state == '2' && !isParked())
1062 {
1063 LOG_INFO("Mount reports it is parked.");
1064 SetParked(true);
1065 }
1066 else if (state == '1')
1067 {
1068 LOG_INFO("Mount is parking...");
1070 m_MountParking = true;
1071 m_ParkMoved = true;
1072 ParkSP.setState(IPS_BUSY);
1073 ParkSP.apply();
1074 }
1075}
1076
1080void LX200AM5::updateMountPark(bool slewComplete)
1081{
1082 const bool slewing = !slewComplete;
1083 const bool timedOut = std::chrono::steady_clock::now() > m_ParkDeadline;
1084
1085 char state = 0;
1086 // Try again on next poll.
1087 if (!getMountParkState(state))
1088 return;
1089
1090 switch (state)
1091 {
1092 case '2':
1093 m_MountParking = false;
1094 SetParked(true);
1095 break;
1096
1097 case '1':
1098 m_ParkMoved = true;
1099 break;
1100
1101 case '0':
1102 if (slewing)
1103 m_ParkMoved = true;
1104 else if (!m_ParkMoved && timedOut)
1105 failMountPark("mount did not start moving to the park position");
1106 break;
1107
1108 default:
1109 failMountPark("mount reported a park error");
1110 break;
1111 }
1112}
1113
1117void LX200AM5::failMountPark(const char *reason)
1118{
1119 LOGF_ERROR("Park failed: %s.", reason);
1120 m_MountParking = false;
1122 ParkSP.reset();
1123 ParkSP[isParked() ? PARK : UNPARK].setState(ISS_ON);
1124 ParkSP.setState(IPS_ALERT);
1125 ParkSP.apply();
1126}
1127
1132{
1133 if (!isConnected())
1134 return false;
1135
1136 bool slewComplete = false, isHome = false;
1137 char status[DRIVER_LEN] = {0};
1138 if (sendCommand(":GU#", status))
1139 {
1140 slewComplete = strchr(status, 'N');
1141 isHome = strchr(status, 'H');
1142 }
1143
1144 if (HomeSP.getState() == IPS_BUSY && isHome)
1145 {
1146 HomeSP.reset();
1147 HomeSP.setState(IPS_OK);
1148 LOG_INFO("Arrived at home.");
1149 HomeSP.apply();
1151 }
1152 else if (TrackState == SCOPE_SLEWING)
1153 {
1154 // Check if LX200 is done slewing
1155 if (slewComplete)
1156 {
1158 LOG_INFO("Slew is complete. Tracking...");
1159 }
1160 }
1161 else if (TrackState == SCOPE_PARKING)
1162 {
1163 if (m_MountParking)
1164 updateMountPark(slewComplete);
1165 else if (slewComplete)
1166 SetParked(true);
1167 }
1168 else
1169 {
1170 // Tracking changed?
1171 auto wasTracking = TrackStateSP[INDI_ENABLED].getState() == ISS_ON;
1172 auto nowTracking = isTracking();
1173 if (wasTracking != nowTracking)
1174 TrackState = nowTracking ? SCOPE_TRACKING : SCOPE_IDLE;
1175 }
1176
1178 {
1179 EqNP.setState(IPS_ALERT);
1180 LOG_ERROR("Error reading RA/DEC.");
1181 EqNP.apply();
1182 return false;
1183 }
1184
1185 if (HasPierSide())
1186 {
1187 char response[DRIVER_LEN] = {0};
1188 if (sendCommand(":Gm#", response))
1189 {
1190 if (response[0] == 'W')
1192 else if (response[0] == 'E')
1194 else
1196 }
1197 }
1198
1200
1201 return true;
1202}
1203
1207void LX200AM5::getFirmwareInfo()
1208{
1209 m_FirmwareVersion = 0;
1210
1211 char response[DRIVER_LEN] = {0};
1212 if (sendCommand(":GVP#", response))
1213 {
1214 char *term = strchr(response, DRIVER_STOP_CHAR);
1215 if (term)
1216 *term = '\0';
1217 FirmwareTP[FIRMWARE_MODEL].setText(response);
1218 }
1219
1220 memset(response, 0, sizeof(response));
1221 if (sendCommand(":GV#", response))
1222 {
1223 char *term = strchr(response, DRIVER_STOP_CHAR);
1224 if (term)
1225 *term = '\0';
1226 FirmwareTP[FIRMWARE_VERSION].setText(response);
1227
1228 int major = 0, minor = 0, patch = 0;
1229 if (sscanf(response, "%d.%d.%d", &major, &minor, &patch) == 3)
1230 m_FirmwareVersion = (major << 16) | (minor << 8) | patch;
1231 else
1232 LOGF_WARN("Unexpected firmware version format: %s", response);
1233 }
1234
1235 FirmwareTP.setState(m_FirmwareVersion > 0 ? IPS_OK : IPS_ALERT);
1236
1237 LOGF_INFO("Mount %s firmware %s.", FirmwareTP[FIRMWARE_MODEL].getText(), FirmwareTP[FIRMWARE_VERSION].getText());
1238 if (!hasCustomParkPosition())
1239 LOG_INFO("Mount parks at the home position. Custom park position requires firmware 1.3.0 or later.");
1240 else if (CustomParkSP[0].getState() == ISS_ON)
1241 LOG_INFO("Mount parks at the custom park position.");
1242 else
1243 LOG_INFO("Mount parks at the home position. To use a custom park position, slew to it and set it as current park position.");
1244}
1245
1249bool LX200AM5::sendStatusCommand(const char * cmd, char * res)
1250{
1251 int nbytes_written = 0, nbytes_read = 0;
1252
1253 tcflush(PortFD, TCIOFLUSH);
1254
1255 LOGF_DEBUG("CMD <%s>", cmd);
1256 int rc = tty_write_string(PortFD, cmd, &nbytes_written);
1257 if (rc == TTY_OK)
1258 rc = tty_read(PortFD, res, 1, DRIVER_TIMEOUT, &nbytes_read);
1259 // Errors are reported as e<code>#
1260 if (rc == TTY_OK && res[0] == 'e')
1261 rc = tty_nread_section(PortFD, res + 1, DRIVER_LEN - 2, DRIVER_STOP_CHAR, DRIVER_TIMEOUT, &nbytes_read);
1262
1263 if (rc != TTY_OK)
1264 {
1265 char errstr[MAXRBUF] = {0};
1266 tty_error_msg(rc, errstr, MAXRBUF);
1267 LOGF_ERROR("Serial error: %s.", errstr);
1268 return false;
1269 }
1270
1271 char *term = strchr(res, DRIVER_STOP_CHAR);
1272 if (term)
1273 *term = '\0';
1274 else if (res[0] != 'e')
1275 res[1] = '\0';
1276
1277 LOGF_DEBUG("RES <%s>", res);
1278
1279 tcflush(PortFD, TCIOFLUSH);
1280
1281 return true;
1282}
1283
1287bool LX200AM5::sendCommand(const char * cmd, char * res, int cmd_len, int res_len)
1288{
1289 int nbytes_written = 0, nbytes_read = 0, rc = -1;
1290
1291 tcflush(PortFD, TCIOFLUSH);
1292
1293 if (cmd_len > 0)
1294 {
1295 char hex_cmd[DRIVER_LEN * 3] = {0};
1296 hexDump(hex_cmd, cmd, cmd_len);
1297 LOGF_DEBUG("CMD <%s>", hex_cmd);
1298 rc = tty_write(PortFD, cmd, cmd_len, &nbytes_written);
1299 }
1300 else
1301 {
1302 LOGF_DEBUG("CMD <%s>", cmd);
1303 rc = tty_write_string(PortFD, cmd, &nbytes_written);
1304 }
1305
1306 if (rc != TTY_OK)
1307 {
1308 char errstr[MAXRBUF] = {0};
1309 tty_error_msg(rc, errstr, MAXRBUF);
1310 LOGF_ERROR("Serial write error: %s.", errstr);
1311 return false;
1312 }
1313
1314 if (res == nullptr)
1315 {
1316 tcdrain(PortFD);
1317 return true;
1318 }
1319
1320 if (res_len > 0)
1321 rc = tty_read(PortFD, res, res_len, DRIVER_TIMEOUT, &nbytes_read);
1322 else
1323 rc = tty_nread_section(PortFD, res, DRIVER_LEN, DRIVER_STOP_CHAR, DRIVER_TIMEOUT, &nbytes_read);
1324
1325 if (rc != TTY_OK)
1326 {
1327 char errstr[MAXRBUF] = {0};
1328 tty_error_msg(rc, errstr, MAXRBUF);
1329 LOGF_ERROR("Serial read error: %s.", errstr);
1330 return false;
1331 }
1332
1333 if (res_len > 0)
1334 {
1335 char hex_res[DRIVER_LEN * 3] = {0};
1336 hexDump(hex_res, res, res_len);
1337 LOGF_DEBUG("RES <%s>", hex_res);
1338 }
1339 else
1340 {
1341 LOGF_DEBUG("RES <%s>", res);
1342 }
1343
1344 tcflush(PortFD, TCIOFLUSH);
1345
1346 return true;
1347}
1348
1353{
1354 switch (action)
1355 {
1356 case HOME_GO:
1357 if (goHome())
1358 return IPS_BUSY;
1359 else
1360 return IPS_ALERT;
1361
1362 case HOME_SET:
1363 // The ZWO AM5 protocol does not have a specific "set home" command.
1364 // We can potentially use the current position as home, but for now,
1365 // we'll mark it as unsupported.
1366 LOG_WARN("Setting home position is not supported by the ZWO AM5 protocol.");
1367 return IPS_ALERT;
1368
1369 case HOME_FIND:
1370 // The ZWO AM5 protocol does not have a specific "find home" command.
1371 LOG_WARN("Finding home position is not supported by the ZWO AM5 protocol.");
1372 return IPS_ALERT;
1373
1374 default:
1375 return IPS_ALERT;
1376 }
1377}
1378
1382void LX200AM5::hexDump(char * buf, const char * data, int size)
1383{
1384 for (int i = 0; i < size; i++)
1385 sprintf(buf + 3 * i, "%02X ", static_cast<uint8_t>(data[i]));
1386
1387 if (size > 0)
1388 buf[3 * size - 1] = '\0';
1389}
1390
1394std::vector<std::string> LX200AM5::split(const std::string &input, const std::string &regex)
1395{
1396 // passing -1 as the submatch index parameter performs splitting
1397 std::regex re(regex);
1398 std::sregex_token_iterator
1399 first{input.begin(), input.end(), re, -1},
1400 last;
1401 return {first, last};
1402}
1403
1408{
1410
1411 GuideRateNP.save(fp);
1412 BuzzerSP.save(fp);
1413 HeavyDutyModeSP.save(fp);
1414 MeridianFlipSP.save(fp);
1415 PostMeridianTrackSP.save(fp);
1416 MeridianLimitNP.save(fp);
1417 AltitudeLimitSP.save(fp);
1418 AltitudeLimitUpperNP.save(fp);
1419 AltitudeLimitLowerNP.save(fp);
1420 VariableSlewRateNP.save(fp);
1421 CustomParkSP.save(fp);
1422
1423 return true;
1424}
bool isConnected() const
INDI::PropertyText getText(const char *name) const
bool updateProperty(PropertyType &property, ValueType *values, char *names[], int n, std::function< bool()> updater, bool saveConfig=false)
Generic helper function to update an INDI property based on an external operation.
virtual bool saveConfig(bool silent=false, const char *property=nullptr)
Save the current properties in a configuration file.
void setActiveConnection(Connection::Interface *existingConnection)
setActiveConnection Switch the active connection to the passed connection plugin
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)
TelescopeStatus TrackState
TelescopeMountType getMountType() const
void SetTelescopeCapability(uint32_t cap, uint8_t slewRateCount)
SetTelescopeCapability sets the Telescope capabilities. All capabilities must be initialized.
bool isParked()
isParked is mount currently parked?
virtual void SetParked(bool isparked)
SetParked Change the mount parking status. The data park file (stored in ~/.indi/ParkData....
Connection::TCP * tcpConnection
TelescopeMountType
Mount geometry reported in the standard TELESCOPE_MOUNT_TYPE property. The values are the indices of ...
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 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.
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:178
virtual bool SetMountType(TelescopeMountType type) override
SetMountType Called when the user selects a different mount type in TELESCOPE_MOUNT_TYPE....
Definition lx200am5.cpp:449
virtual bool SetDefaultPark() override
Definition lx200am5.cpp:999
virtual bool SetTrackEnabled(bool enabled) override
SetTrackEnabled Engages or disengages mount tracking. If there are no tracking modes available,...
Definition lx200am5.cpp:810
virtual bool initProperties() override
Called to initialize basic properties required all the time.
Definition lx200am5.cpp:56
virtual bool Park() override
Park the telescope to its home position.
Definition lx200am5.cpp:897
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition lx200am5.cpp:391
virtual const char * getDefaultName() override
Definition lx200am5.cpp:247
virtual bool UnPark() override
Unpark the telescope if already parked.
Definition lx200am5.cpp:916
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:255
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition lx200am5.cpp:302
virtual bool updateLocation(double latitude, double longitude, double elevation) override
Update telescope location settings.
Definition lx200am5.cpp:862
virtual bool setUTCOffset(double offset) override
Definition lx200am5.cpp:789
virtual bool SetCurrentPark() override
SetCurrentPark Set current coordinates/encoders value as the desired parking position.
Definition lx200am5.cpp:948
virtual bool SetSlewRate(int index) override
SetSlewRate Set desired slew rate index.
Definition lx200am5.cpp:487
virtual bool setLocalDate(uint8_t days, uint8_t months, uint16_t years) override
Definition lx200am5.cpp:800
virtual bool initProperties() override
Called to initialize basic properties required all the time.
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool updateProperties() override
Called when connected state changes, to add/remove properties.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
void setLX200Capability(uint32_t cap)
const char * INFO_TAB
INFO_TAB Where all the properties for general information are located.
const char * MOTION_TAB
MOTION_TAB Where all the motion control properties of the device are located.
const char * SITE_TAB
SITE_TAB Where all site information setting are located.
const char * OPTIONS_TAB
OPTIONS_TAB Where all the driver's options are located. Those may include auxiliary controls,...
INDI::PropertySwitch ParkSP
INDI::PropertyNumber EqNP
INDI::PropertySwitch TrackStateSP
INDI::PropertySwitch HomeSP
INDI::PropertySwitch SlewRateSP
INDI::PropertySwitch TrackModeSP
INDI::PropertySwitch MountTypeSP
Standard TELESCOPE_MOUNT_TYPE property, indexed by TelescopeMountType. Writable if the driver sets TE...
ISState
Switch state.
Definition indiapi.h:148
@ ISS_OFF
Definition indiapi.h:149
@ ISS_ON
Definition indiapi.h:150
@ IP_RW
Definition indiapi.h:184
@ IP_RO
Definition indiapi.h:182
IPState
Property state.
Definition indiapi.h:158
@ IPS_BUSY
Definition indiapi.h:161
@ IPS_ALERT
Definition indiapi.h:162
@ IPS_IDLE
Definition indiapi.h:159
@ IPS_OK
Definition indiapi.h:160
@ ISR_1OFMANY
Definition indiapi.h:171
@ ISR_NOFMANY
Definition indiapi.h:173
@ ISR_ATMOST1
Definition indiapi.h:172
int tty_write(int fd, const char *buf, int nbytes, int *nbytes_written)
Writes a buffer to fd.
Definition indicom.c:418
void getSexComponents(double value, int *d, int *m, int *s)
Definition indicom.c:243
int tty_read(int fd, char *buf, int nbytes, int timeout, int *nbytes_read)
read buffer from terminal
Definition indicom.c:548
int tty_write_string(int fd, const char *buf, int *nbytes_written)
Writes a null terminated string to fd.
Definition indicom.c:473
void tty_error_msg(int err_code, char *err_msg, int err_msg_len)
Retrieve the tty error message.
Definition indicom.c:1243
int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Definition indicom.c:759
Implementations for common driver routines.
@ TTY_OK
Definition indicom.h:54
#define INDI_UNUSED(x)
Definition indidevapi.h:132
#define MAXRBUF
Definition indidriver.c:52
int IUGetConfigOnSwitchIndex(const char *dev, const char *property, int *index)
IUGetConfigOnSwitchIndex Opens configuration file and reads single switch property to find ON switch ...
Definition indidriver.c:719
*brief user defined string literal for JSON values *sa std::size_t n
#define LOGF_INFO(fmt,...)
Definition indilogger.h:82
#define LOG_DEBUG(txt)
Definition indilogger.h:75
#define LOGF_WARN(fmt,...)
Definition indilogger.h:81
#define LOG_WARN(txt)
Definition indilogger.h:73
#define LOGF_DEBUG(fmt,...)
Definition indilogger.h:83
#define LOG_ERROR(txt)
Shorter logging macros. In order to use these macros, the function (or method) "getDeviceName()" must...
Definition indilogger.h:72
#define LOGF_ERROR(fmt,...)
Definition indilogger.h:80
#define LOG_INFO(txt)
Definition indilogger.h:74
#define getDeviceName
int setStandardProcedure(int fd, const char *data)
#define getLX200DEC(fd, x)
@ LX200_24
Definition lx200driver.h:64
#define getLX200RA(fd, x)
json_pointer res
uint16_t type
Definition pwc-ioctl.h:0
uint8_t cmd[4]
Definition pwc-ioctl.h:2