Instrument Neutral Distributed Interface INDI 2.2.5
focuser_driver.h
Go to the documentation of this file.
1/*
2 Skeleton Focuser Driver
3
4 Modify this driver when developing new absolute position
5 based focusers. This driver uses serial communication by default
6 but it can be changed to use networked TCP/UDP connection as well.
7
8 Copyright(c) 2019 Jasem Mutlaq. All rights reserved.
9
10 Thanks to Rigel Systems, especially Gene Nolan and Leon Palmer,
11 for their support in writing this driver.
12
13 This library is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 2.1 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26*/
27
28#pragma once
29
30#include "indifocuser.h"
31
33{
34 public:
36
37 virtual bool Handshake() override;
38 const char *getDefaultName() override;
39
40 bool initProperties() override;
41 bool updateProperties() override;
42
43 bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override;
44
45 // If you define any Number properties, then you need to override ISNewNumber to respond to number property requests.
46 //bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override;
47
48 protected:
49 void TimerHit() override;
50
51 IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override;
52 IPState MoveAbsFocuser(uint32_t targetTicks) override;
53 bool SyncFocuser(uint32_t ticks) override;
54 bool AbortFocuser() override;
55
56 bool saveConfigItems(FILE *fp) override;
57
58 private:
59
63
64 INumberVectorProperty TemperatureNP;
65 INumber TemperatureN[1];
66
67 ISwitchVectorProperty SteppingModeSP;
68 ISwitch SteppingModeS[2];
69 typedef enum
70 {
71 STEPPING_FULL,
72 STEPPING_HALF,
73 } SteppingMode;
74
78 bool readTemperature();
79 bool readPosition();
80 bool readStepping();
81
85 bool setStepping(SteppingMode mode);
86
90
101 bool sendCommand(const char * cmd, char * res = nullptr, int cmd_len = -1, int res_len = -1);
102
110 void hexDump(char * buf, const char * data, int size);
111
116 bool getStartupValues();
117
121 bool isMoving();
122
126 int32_t m_TargetDiff { 0 };
127 uint16_t m_TemperatureCounter { 0 };
128
132 static constexpr const char * STEPPING_TAB = "Stepping";
133 // '#' is the stop char
134 static const char DRIVER_STOP_CHAR { 0x23 };
135 // Update temperature every 10x POLLMS. For 500ms, we would
136 // update the temperature one every 5 seconds.
137 static constexpr const uint8_t DRIVER_TEMPERATURE_FREQ {10};
138 // Wait up to a maximum of 3 seconds for serial input
139 static constexpr const uint8_t DRIVER_TIMEOUT {3};
140 // Maximum buffer for sending/receiving.
141 static constexpr const uint8_t DRIVER_LEN {64};
142};
bool SyncFocuser(uint32_t ticks) override
SyncFocuser Set current position to ticks without moving the focuser.
const char * getDefaultName() override
bool initProperties() override
Initializes the default properties for the focuser device. Sets up standard INDI properties,...
IPState MoveRelFocuser(FocusDirection dir, uint32_t ticks) override
MoveFocuser the focuser to an relative position.
IPState MoveAbsFocuser(uint32_t targetTicks) override
MoveFocuser the focuser to an absolute position.
bool AbortFocuser() override
AbortFocuser all focus motion.
bool updateProperties() override
Updates the state and definition of properties based on the current connection status....
void TimerHit() override
Callback function to be called once SetTimer duration elapses.
bool saveConfigItems(FILE *fp) override
virtual bool Handshake() override
Performs a device-specific handshake after a connection is established. This method should be overrid...
bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override
Processes incoming new switch states from the client for this device. Handles updates to FocuserInter...
ISState
Switch state.
Definition indiapi.h:148
IPState
Property state.
Definition indiapi.h:158
uint8_t cmd[4]
Definition pwc-ioctl.h:2
One number descriptor.
One switch descriptor.
Number vector property descriptor.
Definition indiapi.h:317
Switch vector property descriptor.
Definition indiapi.h:365