Instrument Neutral Distributed Interface INDI 2.2.5
pegasus_falconv2.h
Go to the documentation of this file.
1/*******************************************************************************
2 Copyright(c) 2024 Chrysikos Efstathios. All rights reserved.
3
4 Pegasus FalconV2 Rotator
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21 The full GNU General Public License is included in this distribution in the
22 file called LICENSE.
23*******************************************************************************/
24
25#pragma once
26
27#include "indirotator.h"
28#include "pegasus_wifi.h"
29#include <chrono>
30#include <stdint.h>
31
33{
34 public:
36
37 virtual bool initProperties() override;
38 virtual bool updateProperties() override;
39
40 virtual void ISGetProperties(const char *dev) override;
41 virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
42 virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
43 virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override;
44
45 protected:
46 const char *getDefaultName() override;
47 virtual bool saveConfigItems(FILE *fp) override;
48
49 // Event loop
50 virtual void TimerHit() override;
51
52 // Rotator Overrides
53 virtual IPState MoveRotator(double angle) override;
54 virtual bool ReverseRotator(bool enabled) override;
55 virtual bool SyncRotator(double angle) override;
56 virtual bool AbortRotator() override;
57
58 private:
59 bool Handshake() override;
60
64 bool getFirmware();
65 bool getStatusData();
66 bool getRotatorSpeed();
67 bool getCableLimit();
68
72 bool reloadFirmware();
73 bool setDerotation(int32_t rate);
74 bool setRotatorSpeed(uint32_t speed);
75 bool setCableLimit(bool enabled);
76
80
91 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
92 void hexDump(char * buf, const char * data, uint32_t size);
93 std::vector<std::string> split(const std::string &input, const std::string &regex);
94
99 void cleanupResponse(char *response);
100
105 INDI::PropertySwitch ReloadFirmwareSP {1};
107 INDI::PropertyNumber DerotateNP {1};
109 INDI::PropertyNumber RotatorSpeedNP {1};
111 INDI::PropertyText FirmwareTP {1};
113 INDI::PropertySwitch CableLimitSP {2};
115 PegasusAstro::WiFi wifi {this};
116
117 std::vector<std::string> lastStatusData;
118
120 double m_TargetAngle {0};
121 std::chrono::steady_clock::time_point m_MoveStarted;
123 double m_StartAngle {0};
124 bool m_DirectionChecked {true};
125
129 static constexpr const uint8_t DRIVER_STOP_CHAR {0xA};
130 static constexpr const uint8_t DRIVER_TIMEOUT {3};
131 static constexpr const uint8_t DRIVER_LEN {128};
133 static constexpr double TARGET_TOLERANCE {0.05};
135 static constexpr std::chrono::seconds MOVE_START_TIMEOUT {5};
136};
virtual bool Handshake()
perform handshake with device to check communication
The WiFi class handles the WiFi settings of Pegasus Astro devices that share the WiFi command set,...
virtual bool ISNewText(const char *dev, const char *name, char *texts[], char *names[], int n) override
Process the client newSwitch command.
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the reverse direction property in the configuration file
virtual bool AbortRotator() override
AbortRotator Abort all motion.
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 void TimerHit() override
Callback function to be called once SetTimer duration elapses.
virtual bool initProperties() override
Initialize properties initial state and value. The child class must implement this function.
virtual bool ReverseRotator(bool enabled) override
reverse action ("FN:0" disabled, "FN:1" enabled)
const char * getDefaultName() override
virtual IPState MoveRotator(double angle) override
move to degrees (Command "MD:nn.nn"; Response "MD:nn.nn")
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
virtual bool SyncRotator(double angle) override
SyncRotator Set current angle as the supplied angle without moving the rotator.
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
*brief user defined string literal for JSON values *sa std::size_t n
uint8_t cmd[4]
Definition pwc-ioctl.h:2