Instrument Neutral Distributed Interface INDI 2.2.5
celestron_dewpower_auxproto.h
Go to the documentation of this file.
1/*
2 Celestron Aux Command
3
4 Copyright (C) 2020 Paweł T. Jochym
5 Copyright (C) 2020 Fabrizio Pollastri
6 Copyright (C) 2021 Jasem Mutlaq
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
24#pragma once
25
26#include <vector>
27#include <stddef.h>
28#include <stdint.h>
29
30typedef std::vector<uint8_t> AUXBuffer;
31
33{
34 // Port Controller Aux Commands
36 PORTCTRL_SET_POWER_ENABLED = 0x01, // (should not be used unless connected via USB port)
40
55
58
59 // Observed 2026-08-20 on real hardware: NAK/error response, sent back
60 // instead of the requested command when that command does not apply
61 // to the addressed port (e.g. PORTCTRL_GET_DH_PORT_INFO on a non-dew
62 // port). Response data is 1 byte: the command that was rejected.
63 PORTCTRL_NAK = 0xF0
64};
65
67{
68 HC = 0x04,
69 APP = 0x20,
70 // Confirmed 2026-08-20 against a real Celestron Dew Heater & Power
71 // Controller (CGX-attached, 3-port unit) via AUX destination-address
72 // sweep + GET_VERSION/GET_NUMBER_OF_PORTS/GET_INPUT_POWER/
73 // GET_ENVIRONMENT/GET_PORT_INFO round-trip. Not in the older
74 // documented AUX target list (drivers/focuser/celestronauxpacket.h),
75 // which only goes up to LIGHT = 0xBF.
76 DEW_POWER_CTRL = 0x17
77};
78
79#define CAUX_DEFAULT_IP "1.2.3.4"
80#define CAUX_DEFAULT_PORT 2000
81
82void logBytes(unsigned char *buf, int n, const char *deviceName, uint32_t debugLevel);
83
85{
86 public:
87 AUXCommand();
88 AUXCommand(const AUXBuffer &buf);
91
95 void fillBuf(AUXBuffer &buf);
96 void parseBuf(AUXBuffer buf);
97 void parseBuf(AUXBuffer buf, bool do_checksum);
98
102 const AUXTargets &source() const
103 {
104 return m_Source;
105 }
106 const AUXTargets &destination() const
107 {
108 return m_Destination;
109 }
110 const AUXBuffer &data() const
111 {
112 return m_Data;
113 }
115 {
116 return m_Command;
117 }
118 size_t dataSize() const
119 {
120 return m_Data.size();
121 }
122 const char * commandName() const
123 {
124 return commandName(m_Command);
125 }
126
130
135 uint32_t getData();
136 void setData(uint32_t value, uint8_t bytes = 3);
137 void setDataBuffer(const AUXBuffer &data) { m_Data = data; len = 3 + m_Data.size(); }
138 const AUXBuffer &getDataBuffer() const { return m_Data; }
139 bool isValid() const { return valid; }
140
141
145 uint8_t checksum(AUXBuffer buf);
146
150 const char * commandName(AUXCommands command) const;
151 const char * moduleName(AUXTargets n);
152 int responseDataSize();
153 void logResponse();
154 void logCommand();
155 static void setDebugInfo(const char *deviceName, uint8_t debugLevel);
156
157 static uint8_t DEBUG_LEVEL;
158 static char DEVICE_NAME[64];
159
160 private:
161 uint8_t len {0};
162 bool valid {false};
163
164 AUXCommands m_Command;
165 AUXTargets m_Source, m_Destination;
166 AUXBuffer m_Data;
167};
void logBytes(unsigned char *buf, int n, const char *deviceName, uint32_t debugLevel)
std::vector< uint8_t > AUXBuffer
@ PORTCTRL_SET_LED_BRIGHTNESS
@ PORTCTRL_GET_HEATER_LEVEL
@ PORTCTRL_SET_PORT_VOLTAGE
@ PORTCTRL_SET_PORT_ENABLED
@ PORTCTRL_DH_ENABLE_MANUAL
@ PORTCTRL_GET_NUMBER_OF_PORTS
@ PORTCTRL_ENABLE_SELF_HEATER
@ PORTCTRL_GET_DH_PORT_INFO
@ PORTCTRL_SET_EXT_CURRENT_LIMIT
@ PORTCTRL_GET_LED_BRIGHTNESS
@ PORTCTRL_GET_EXT_CURRENT_LIMIT
@ PORTCTRL_SET_POWER_ENABLED
@ PORTCTRL_GET_POWER_ENABLED
@ PORTCTRL_SELF_HEATER_STATUS
AUXCommands command() const
void setDataBuffer(const AUXBuffer &data)
uint8_t checksum(AUXBuffer buf)
Check sum.
const AUXBuffer & getDataBuffer() const
uint32_t getData()
Set and Get data.
const char * commandName() const
void parseBuf(AUXBuffer buf)
const char * moduleName(AUXTargets n)
const AUXTargets & source() const
Getters.
const AUXBuffer & data() const
static char DEVICE_NAME[64]
static void setDebugInfo(const char *deviceName, uint8_t debugLevel)
void fillBuf(AUXBuffer &buf)
Buffer Management.
void setData(uint32_t value, uint8_t bytes=3)
Set encoder position in steps.
const AUXTargets & destination() const