Instrument Neutral Distributed Interface INDI  2.0.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 };
virtual IPState GuideWest(uint32_t ms) override
Guide west for ms milliseconds. West is defined as RA-.
const char * getDefaultName() override
Definition: arduino_st4.cpp:89
virtual bool updateProperties() override
updateProperties is called whenever there is a change in the CONNECTION status of the driver....
Definition: arduino_st4.cpp:71
static void guideTimeoutHelperE(void *p)
virtual bool initProperties() override
Initilize properties initial state and value. The child class must implement this function.
Definition: arduino_st4.cpp:48
virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override
Process the client newNumber command.
static void guideTimeoutHelperS(void *p)
virtual IPState GuideSouth(uint32_t ms) override
Guide south for ms milliseconds. South is defined as DEC-.
void guideTimeout(ARDUINO_DIRECTION direction)
virtual bool Disconnect() override
Disconnect from device.
static void guideTimeoutHelperW(void *p)
static void guideTimeoutHelperN(void *p)
virtual IPState GuideEast(uint32_t ms) override
Guide east for ms milliseconds. East is defined as RA+.
virtual IPState GuideNorth(uint32_t ms) override
Guide north for ms milliseconds. North is defined as DEC+.
The Serial class manages connection with serial devices including Bluetooth. Serial communication is ...
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
IPState
Property state.
Definition: indiapi.h:160
Combines all INDI Connection Plugins. Each INDI connection plugin is responsible of managing communic...
Definition: arduino_st4.h:34
__u8 cmd[4]
Definition: pwc-ioctl.h:2