Instrument Neutral Distributed Interface INDI  1.9.5
pegasus_falcon.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2020 Jasem Mutlaq. All rights reserved.
3 
4  Pegasus Falcon 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 <stdint.h>
29 
31 {
32  public:
33  PegasusFalcon();
34 
35  virtual bool initProperties() override;
36  virtual bool updateProperties() override;
37 
38  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
39  virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
40 
41  protected:
42  const char *getDefaultName() override;
43  virtual bool saveConfigItems(FILE *fp) override;
44 
45  // Event loop
46  virtual void TimerHit() override;
47 
48  // Rotator Overrides
49  virtual IPState MoveRotator(double angle) override;
50  virtual bool ReverseRotator(bool enabled) override;
51  virtual bool SyncRotator(double angle) override;
52  virtual bool AbortRotator() override;
53 
54  private:
55  bool Handshake() override;
56 
60  bool getFirmware();
61  bool getStatusData();
62 
66  bool reloadFirmware();
67  bool setDerotation(uint32_t ms);
68 
72 
83  bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
84  void hexDump(char * buf, const char * data, uint32_t size);
85  std::vector<std::string> split(const std::string &input, const std::string &regex);
86 
91  void cleanupResponse(char *response);
92 
97  ISwitchVectorProperty ReloadFirmwareSP;
98  ISwitch ReloadFirmwareS[1];
100  INumberVectorProperty DerotateNP;
101  INumber DerotateN[1];
103  ITextVectorProperty FirmwareTP;
104  IText FirmwareT[1] {};
105 
106  std::vector<std::string> lastStatusData;
107 
111  static constexpr const uint8_t DRIVER_STOP_CHAR {0xA};
112  static constexpr const uint8_t DRIVER_TIMEOUT {3};
113  static constexpr const uint8_t DRIVER_LEN {128};
114 };
cmd
__u8 cmd[4]
Definition: pwc-ioctl.h:4
PegasusFalcon::getDefaultName
const char * getDefaultName() override
Definition: pegasus_falcon.cpp:102
IPState
IPState
Property state.
Definition: indiapi.h:158
PegasusFalcon::MoveRotator
virtual IPState MoveRotator(double angle) override
MoveRotator Go to specific angle.
Definition: pegasus_falcon.cpp:167
INDI::Rotator
Definition: indirotator.h:45
ISwitch
One switch descriptor.
INumber
One number descriptor.
PegasusFalcon
Definition: pegasus_falcon.h:30
PegasusFalcon::TimerHit
virtual void TimerHit() override
Callback function to be called once SetTimer duration elapses.
Definition: pegasus_falcon.cpp:249
PegasusFalcon::saveConfigItems
virtual bool saveConfigItems(FILE *fp) override
saveConfigItems Saves the reverse direction property in the configuration file
Definition: pegasus_falcon.cpp:239
PegasusFalcon::ISNewSwitch
virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Process the client newSwitch command.
Definition: pegasus_falcon.cpp:147
_ITextVectorProperty
Text vector property descriptor.
Definition: indiapi.h:244
PegasusFalcon::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: pegasus_falcon.cpp:118
indirotator.h
PegasusFalcon::ReverseRotator
virtual bool ReverseRotator(bool enabled) override
ReverseRotator Reverse the direction of the rotator. CW is usually the normal direction,...
Definition: pegasus_falcon.cpp:196
_INumberVectorProperty
Number vector property descriptor.
Definition: indiapi.h:317
IText
One text descriptor.
PegasusFalcon::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: pegasus_falcon.cpp:47
PegasusFalcon::SyncRotator
virtual bool SyncRotator(double angle) override
SyncRotator Set current angle as the supplied angle without moving the rotator.
Definition: pegasus_falcon.cpp:211
PegasusFalcon::PegasusFalcon
PegasusFalcon()
Definition: pegasus_falcon.cpp:41
PegasusFalcon::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: pegasus_falcon.cpp:79
name
const char * name
Definition: indiserver.c:116
PegasusFalcon::AbortRotator
virtual bool AbortRotator() override
AbortRotator Abort all motion.
Definition: pegasus_falcon.cpp:182
ISState
ISState
Switch state.
Definition: indiapi.h:148
_ISwitchVectorProperty
Switch vector property descriptor.
Definition: indiapi.h:365