Protocol.h
Go to the documentation of this file.
1 /*
2 BSD 2-Clause License
3 
4 Copyright (c) 2019, Simranjeet Singh
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice, this
11  list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #ifndef PROTOCOL_H
30 #define PROTOCOL_H
31 
32 #include <stdint.h>
33 #include <vector>
34 #include <eyantra_drone/Common.h>
35 
36 extern int8_t inputBuffer[1024];
37 extern uint8_t bufferIndex;
38 //extern NSMutableArray* requests;
39 
40 static const int MSP_FC_VERSION=3;
41 static const int MSP_RAW_IMU=102;
42 static const int MSP_RC = 105;
43 static const int MSP_ATTITUDE=108;
44 static const int MSP_ALTITUDE=109;
45 static const int MSP_ANALOG=110;
46 static const int MSP_SET_RAW_RC=200;
47 static const int MSP_ACC_CALIBRATION=205;
48 static const int MSP_MAG_CALIBRATION=206;
49 static const int MSP_SET_MOTOR=214;
50 static const int MSP_SET_ACC_TRIM=239;
51 static const int MSP_ACC_TRIM=240;
52 static const int MSP_EEPROM_WRITE = 250;
53 static const int MSP_SET_POS= 216;
54 
55 static const int IDLE = 0, HEADER_START = 1, HEADER_M = 2, HEADER_ARROW = 3, HEADER_SIZE = 4, HEADER_CMD = 5, HEADER_ERR = 6;
56 
57 extern int roll;
58 extern int pitch;
59 extern int yaw;
60 extern float battery;
61 extern int rssi;
62 
63 extern float accX;
64 extern float accY;
65 extern float accZ;
66 
67 extern float gyroX;
68 extern float gyroY;
69 extern float gyroZ;
70 
71 extern float magX;
72 extern float magY;
73 extern float magZ;
74 
75 extern float alt;
76 
77 extern int FC_versionMajor;
78 extern int FC_versionMinor;
79 extern int FC_versionPatchLevel;
80 
81 extern int trim_roll;
82 extern int trim_pitch;
83 
84 
85 extern float rcThrottle, rcRoll, rcPitch, rcYaw, rcAUX1 , rcAUX2, rcAUX3, rcAUX4 ;
86 
87 class Protocol{
88 
89 public:
90 
91 
92 int read8();
93 int read16();
94 int read32();
95 
96 void evaluateCommand(int command);
97 
98 
99 void sendRequestMSP(std::vector<int8_t> data);
100 void sendMulRequestMSP(std::vector<int8_t> data, int i);
101 
102 void sendRequestMSP_SET_RAW_RC(int channels[]);
103 void sendMulRequestMSP_SET_RAW_RC(int channels[]);
104 
105 void sendRequestMSP_SET_POS(int posArray[]);
106 
107 
108 void sendRequestMSP_GET_DEBUG(std::vector<int> requests);
109 void sendMulRequestMSP_GET_DEBUG(std::vector<int> requests, int index);
110 
111 std::vector<int8_t> createPacketMSP(int msp, std::vector<int8_t>payload);
112 
113 
114 private:
115 
116 
117 };
118 
119 
120 #endif
static const int HEADER_ERR
Definition: Protocol.h:55
float rcAUX1
Definition: Protocol.cpp:63
uint8_t bufferIndex
Definition: Protocol.cpp:36
static const int HEADER_CMD
Definition: Protocol.h:55
static const int MSP_ATTITUDE
Definition: Protocol.h:43
float rcAUX4
Definition: Protocol.cpp:63
int FC_versionMajor
Definition: Protocol.cpp:56
static const int MSP_MAG_CALIBRATION
Definition: Protocol.h:48
int i
int8_t inputBuffer[1024]
Definition: Protocol.cpp:35
static const int MSP_EEPROM_WRITE
Definition: Protocol.h:52
uint8_t command
int rssi
Definition: Protocol.cpp:44
float gyroY
Definition: Protocol.cpp:49
float accZ
Definition: Protocol.cpp:47
void sendMulRequestMSP_SET_RAW_RC(int channels[])
Definition: Protocol.cpp:213
float accY
Definition: Protocol.cpp:46
float rcPitch
Definition: Protocol.cpp:63
int pitch
Definition: Protocol.cpp:41
float gyroZ
Definition: Protocol.cpp:50
float rcThrottle
Definition: Protocol.cpp:63
static const int MSP_FC_VERSION
Definition: Protocol.h:40
static const int HEADER_SIZE
Definition: Protocol.h:55
void sendRequestMSP(std::vector< int8_t > data)
Definition: Protocol.cpp:157
int trim_roll
Definition: Protocol.cpp:60
int FC_versionMinor
Definition: Protocol.cpp:57
static const int MSP_SET_POS
Definition: Protocol.h:53
static const int MSP_RC
Definition: Protocol.h:42
int FC_versionPatchLevel
Definition: Protocol.cpp:58
void sendRequestMSP_GET_DEBUG(std::vector< int > requests)
Definition: Protocol.cpp:246
static const int MSP_ALTITUDE
Definition: Protocol.h:44
static const int HEADER_ARROW
Definition: Protocol.h:55
float rcAUX3
Definition: Protocol.cpp:63
static const int MSP_ACC_TRIM
Definition: Protocol.h:51
void evaluateCommand(int command)
Definition: Protocol.cpp:84
int trim_pitch
Definition: Protocol.cpp:61
int roll
Definition: Protocol.cpp:40
float rcRoll
Definition: Protocol.cpp:63
float battery
Definition: Protocol.cpp:43
int read16()
Definition: Protocol.cpp:70
void sendMulRequestMSP_GET_DEBUG(std::vector< int > requests, int index)
Definition: Protocol.cpp:255
int read32()
Definition: Protocol.cpp:78
static const int MSP_ACC_CALIBRATION
Definition: Protocol.h:47
static const int IDLE
Definition: Protocol.h:55
float alt
Definition: Protocol.cpp:54
float magY
Definition: Protocol.cpp:52
std::vector< int8_t > createPacketMSP(int msp, std::vector< int8_t >payload)
Definition: Protocol.cpp:167
static const int HEADER_M
Definition: Protocol.h:55
void sendRequestMSP_SET_POS(int posArray[])
Definition: Protocol.cpp:230
float magZ
Definition: Protocol.cpp:53
float magX
Definition: Protocol.cpp:51
static const int MSP_SET_MOTOR
Definition: Protocol.h:49
static const int MSP_ANALOG
Definition: Protocol.h:45
float rcAUX2
Definition: Protocol.cpp:63
static const int MSP_SET_ACC_TRIM
Definition: Protocol.h:50
void sendMulRequestMSP(std::vector< int8_t > data, int i)
Definition: Protocol.cpp:162
float accX
Definition: Protocol.cpp:45
static const int HEADER_START
Definition: Protocol.h:55
static const int MSP_SET_RAW_RC
Definition: Protocol.h:46
static const int MSP_RAW_IMU
Definition: Protocol.h:41
int read8()
Definition: Protocol.cpp:65
float gyroX
Definition: Protocol.cpp:48
void sendRequestMSP_SET_RAW_RC(int channels[])
Definition: Protocol.cpp:197
float rcYaw
Definition: Protocol.cpp:63
int yaw
Definition: Protocol.cpp:42


edrone_client
Author(s): Simranjeet Singh
autogenerated on Sun Dec 1 2019 03:30:51