Instrument Neutral Distributed Interface INDI  1.9.2
arduino_st4.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2018 Jasem Mutlaq. All rights reserved.
3 
4  Arduino ST4 Driver.
5 
6  For this project: https://github.com/kevinferrare/arduino-st4
7 
8  This program is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by the Free
10  Software Foundation; either version 2 of the License, or (at your option)
11  any later version.
12 
13  This program is distributed in the hope that it will be useful, but WITHOUT
14  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16  more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 
23  The full GNU General Public License is included in this distribution in the
24  file called LICENSE.
25 *******************************************************************************/
26 
27 #pragma once
28 
29 #include "defaultdevice.h"
30 #include "indiguiderinterface.h"
31 #include <stdint.h>
32 
33 namespace Connection
34 {
35 class Serial;
36 }
37 
39 {
40  public:
41  ArduinoST4();
42 
43  typedef enum { ARD_N, ARD_S, ARD_W, ARD_E } ARDUINO_DIRECTION;
44 
45  virtual bool initProperties() override;
46  virtual bool updateProperties() override;
47 
48  virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override ;
49 
50  void guideTimeout(ARDUINO_DIRECTION direction);
51 
52  protected:
53  const char *getDefaultName() override;
54 
55  virtual bool Disconnect() override;
56  virtual IPState GuideNorth(uint32_t ms) override;
57  virtual IPState GuideSouth(uint32_t ms) override;
58  virtual IPState GuideEast(uint32_t ms) override;
59  virtual IPState GuideWest(uint32_t ms) override;
60 
61  // Helper functions
62  static void guideTimeoutHelperN(void *p);
63  static void guideTimeoutHelperS(void *p);
64  static void guideTimeoutHelperW(void *p);
65  static void guideTimeoutHelperE(void *p);
66 
67  private:
68  bool Handshake();
69  bool sendCommand(const char *cmd);
70 
71  int GuideNSTID { -1 };
72  int GuideWETID { -1 };
73  ARDUINO_DIRECTION guideDirection;
74 
75  int PortFD { -1 };
76 
77  Connection::Serial *serialConnection { nullptr };
78 
79  const uint8_t ARDUINO_TIMEOUT = 3;
80 };
cmd
__u8 cmd[4]
Definition: pwc-ioctl.h:4
ArduinoST4::guideTimeoutHelperE
static void guideTimeoutHelperE(void *p)
Definition: arduino_st4.cpp:207
IPState
IPState
Property state.
Definition: indiapi.h:158
ArduinoST4::initProperties
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: arduino_st4.cpp:48
Connection::Serial
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Definition: connectionserial.h:56
ArduinoST4::GuideWest
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
Definition: arduino_st4.cpp:176
ArduinoST4::ArduinoST4
ArduinoST4()
Definition: arduino_st4.cpp:43
ArduinoST4::ARDUINO_DIRECTION
ARDUINO_DIRECTION
Definition: arduino_st4.h:43
ArduinoST4::ARD_W
@ ARD_W
Definition: arduino_st4.h:43
ArduinoST4::ARD_N
@ ARD_N
Definition: arduino_st4.h:43
INDI::GuiderInterface
Definition: indiguiderinterface.h:50
defaultdevice.h
ArduinoST4::getDefaultName
const char * getDefaultName() override
Definition: arduino_st4.cpp:86
ArduinoST4::GuideEast
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
Definition: arduino_st4.cpp:158
ArduinoST4
Definition: arduino_st4.h:38
Connection
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition: arduino_st4.h:33
ArduinoST4::guideTimeoutHelperS
static void guideTimeoutHelperS(void *p)
Definition: arduino_st4.cpp:199
ArduinoST4::guideTimeoutHelperW
static void guideTimeoutHelperW(void *p)
Definition: arduino_st4.cpp:203
indiguiderinterface.h
ArduinoST4::Disconnect
virtual bool Disconnect() override
Disconnect from device.
Definition: arduino_st4.cpp:104
ArduinoST4::ARD_E
@ ARD_E
Definition: arduino_st4.h:43
ArduinoST4::ARD_S
@ ARD_S
Definition: arduino_st4.h:43
ArduinoST4::ISNewNumber
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
Definition: arduino_st4.cpp:111
ArduinoST4::GuideSouth
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
Definition: arduino_st4.cpp:140
ArduinoST4::updateProperties
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: arduino_st4.cpp:68
ArduinoST4::GuideNorth
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
Definition: arduino_st4.cpp:122
INDI::DefaultDevice
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
Definition: defaultdevice.h:118
ArduinoST4::guideTimeoutHelperN
static void guideTimeoutHelperN(void *p)
Definition: arduino_st4.cpp:195
ArduinoST4::guideTimeout
void guideTimeout(ARDUINO_DIRECTION direction)
Definition: arduino_st4.cpp:212