Instrument Neutral Distributed Interface INDI 2.2.5
celestronauxpacket.h
Go to the documentation of this file.
1/*
2 Celestron Focuser for SCT and EDGEHD
3
4 Copyright (C) 2019 Chris Rowland
5 Copyright (C) 2019 Jasem Mutlaq ([email protected])
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21*/
22
23#pragma once
24
25#include <vector>
26#include <stdint.h>
27#include <cstring>
28#include <string>
29
35namespace Aux
36{
37
38typedef std::vector<uint8_t> buffer;
39
44{
46 MC_GOTO_FAST = 0x02,
53 MC_SLEW_DONE = 0x13,
54 MC_GOTO_SLOW = 0x17,
56 MC_MOVE_POS = 0x24,
57 MC_MOVE_NEG = 0x25,
60
61 // common to all devices (maybe)
62 GET_VER = 0xfe,
63
64 // GPS device commands
65 //GPS_GET_LAT = 0x01,
66 //GPS_GET_LONG = 0x02,
67 //GPS_GET_DATE = 0x03,
68 //GPS_GET_YEAR = 0x04,
69 //GPS_GET_TIME = 0x33,
70 //GPS_TIME_VALID = 0x36,
71 //GPS_LINKED = 0x37,
72
74
79};
80
85{
86 ANY = 0x00,
87 MB = 0x01,
88 HC = 0x04,
89 HCP = 0x0d,
90 AZM = 0x10,
91 ALT = 0x11,
92 FOCUSER = 0x12,
93 APP = 0x20,
94 NEX_REMOTE = 0x22,
95 GPS = 0xb0,
96 WiFi = 0xb5,
97 BAT = 0xb6,
98 CHG = 0xb7,
99 LIGHT = 0xbf
101
106{
107 public:
111
112 // packet contents
113 static constexpr uint8_t AUX_HDR = 0x3b;
114 uint32_t length;
119
120 void FillBuffer(buffer &buf);
121
122 bool Parse (buffer buf);
123
124 private:
125 uint8_t checksum(buffer data);
126};
127
132{
133 public:
134 Communicator();
136 // send command with data and reply
137 bool sendCommand(int port, Target dest, Command cmd, buffer data, buffer &reply);
138 // send command with reply but no data
139 bool sendCommand(int port, Target dest, Command cmd, buffer &reply);
140 // send command with data but no reply
141 bool commandBlind(int port, Target dest, Command cmd, buffer data);
142
144
145 static std::string Device;
146 static void setDeviceName(const std::string &device)
147 {
148 Device = device;
149 }
150
151 private:
152 bool sendPacket(int port, Target dest, Command cmd, buffer data);
153 bool readPacket(int port, Packet &reply);
154};
155
156}
hid_device * device
The Communicator class handles high-level communication with the Celestron devices.
static std::string Device
bool commandBlind(int port, Target dest, Command cmd, buffer data)
static void setDeviceName(const std::string &device)
bool sendCommand(int port, Target dest, Command cmd, buffer data, buffer &reply)
The Packet class handles low-level communication with the Celestron devices.
void FillBuffer(buffer &buf)
Packet(Target source, Target destination, Command command)
bool Parse(buffer buf)
static constexpr uint8_t AUX_HDR
Class to provide general functionality of a GPS device.
Command
The Command enum includes all the command types sent to the various devices (motor,...
@ MC_GOTO_FAST
send 24 bit target
@ MC_GOTO_SLOW
send 24 bit target
@ MC_SET_NEG_BACKLASH
1 byte, 0-99
@ GET_VER
return 2 or 4 bytes major.minor.build
@ MC_GET_POSITION
return 24 bit position
@ FOC_GET_HS_POSITIONS
returns 2 ints low and high limits
@ MC_GET_POS_BACKLASH
1 byte, 0-99
@ FOC_CALIB_ENABLE
send 0 to start or 1 to stop
@ MC_MOVE_POS
send move rate 0-9
@ MC_SET_NEG_GUIDERATE
@ MC_MOVE_NEG
send move rate 0-9
@ MC_SLEW_DONE
return 0xFF when move finished
@ MC_SET_POS_BACKLASH
1 byte, 0-99
@ MC_GET_NEG_BACKLASH
1 byte, 0-99
@ MC_SET_POS_GUIDERATE
@ MC_SET_POSITION
send 24 bit new position
@ FOC_CALIB_DONE
returns 2 bytes [0] done, [1] state 0-12
std::vector< uint8_t > buffer
Target
The Target enum Specifies the target device of the command.
@ ALT
altitude|declination axis motor
@ FOCUSER
focuser motor
@ AZM
azimuth|hour angle axis motor
@ WiFi
WiFi Board.
@ HC
Hand Controller.
uint8_t cmd[4]
Definition pwc-ioctl.h:2