Instrument Neutral Distributed Interface INDI 2.2.5
avalon_upas.h
Go to the documentation of this file.
1/*******************************************************************************
2 Avalon Instruments Universal Polar Alignment System (UPAS)
3
4 Copyright (C) 2026 Jasem Mutlaq ([email protected])
5
6 GRBL-based serial protocol.
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21*******************************************************************************/
22
23#pragma once
24
25#include "defaultdevice.h"
26#include "indipacinterface.h"
28
43{
44 public:
45 AvalonUPAS();
46 virtual ~AvalonUPAS() override = default;
47
48 const char *getDefaultName() override;
49
50 bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
51 bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
52
53 protected:
54 bool initProperties() override;
55 bool updateProperties() override;
56 bool saveConfigItems(FILE *fp) override;
57
58 bool Handshake();
59 void TimerHit() override;
60
61 // PACInterface – axis movement
62 IPState MoveAZ(double degrees) override;
63 IPState MoveALT(double degrees) override;
64 IPState MoveBoth(double azDegrees, double altDegrees) override;
65
66 // PACInterface – abort, speed and reverse
67 bool AbortMotion() override;
68 bool SetPACSpeed(uint16_t speed) override;
69 bool ReverseAZ(bool enabled) override;
70 bool ReverseALT(bool enabled) override;
71
72 private:
76
85 bool sendCommand(const char *cmd, char *res = nullptr, int cmd_len = -1, int res_len = -1);
86
88 bool parseStatus(const char *response);
89
90 void hexDump(char *buf, const char *data, int size);
91
95
96 // Gear ratio (mm per degree) for each axis; converts PAC interface degrees to GRBL mm.
97 INDI::PropertyNumber GearRatioNP {2};
98 enum
99 {
100 GEAR_AZ,
101 GEAR_ALT
102 };
103
104 // Read-only firmware version string returned at connect.
105 INDI::PropertyText FirmwareTP {1};
106
110 bool m_IsMoving {false};
111 uint8_t m_ReverseFlags {0};
112
113 int PortFD {-1};
114 Connection::Serial *serialConnection {nullptr};
115
119 static constexpr uint8_t DRIVER_TIMEOUT {3};
120 static constexpr uint8_t DRIVER_LEN {128};
121 static constexpr char DRIVER_STOP_CHAR {'\n'};
122};
The AvalonUPAS class drives the Avalon Instruments Universal Polar Alignment System (UPAS) via its GR...
Definition avalon_upas.h:43
bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
bool saveConfigItems(FILE *fp) override
saveConfigItems Save specific properties in the provide config file handler. Child class usually over...
bool Handshake()
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
bool AbortMotion() override
AbortMotion Abort all axis motion immediately.
IPState MoveAZ(double degrees) override
Move the azimuth axis by the given number of degrees.
IPState MoveBoth(double azDegrees, double altDegrees) override
MoveBoth Move both axes in a single coordinated operation.
bool ReverseAZ(bool enabled) override
ReverseAZ Reverse the direction of azimuth axis movement.
bool ReverseALT(bool enabled) override
ReverseALT Reverse the direction of altitude axis movement.
const char * getDefaultName() override
bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual ~AvalonUPAS() override=default
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
IPState MoveALT(double degrees) override
MoveALT Move the altitude axis by the given number of degrees.
bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
bool SetPACSpeed(uint16_t speed) override
SetPACSpeed Set the motor speed used for axis movements.
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2