2012-07-21 11:13:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Protocol {
|
|
|
|
|
2013-12-20 21:16:01 +01:00
|
|
|
enum class Code : uint8_t {
|
|
|
|
Heartbeat = 'h',
|
2013-12-28 21:19:24 +01:00
|
|
|
Pong = 'p',
|
2013-12-27 21:35:37 +01:00
|
|
|
Inputs = 'i',
|
2013-12-28 21:19:24 +01:00
|
|
|
Request = 'R',
|
|
|
|
Version = 'v',
|
2013-12-29 18:50:44 +01:00
|
|
|
Demand = 'd',
|
|
|
|
State = 's',
|
2014-01-14 19:57:54 +01:00
|
|
|
Counters = 'c',
|
2014-02-21 22:46:56 +01:00
|
|
|
IMU = 'm',
|
2013-12-20 21:16:01 +01:00
|
|
|
};
|
2013-12-17 20:48:07 +01:00
|
|
|
|
2013-12-20 21:16:01 +01:00
|
|
|
struct Generic {
|
2012-07-21 11:13:57 +02:00
|
|
|
};
|
|
|
|
|
2012-07-25 11:04:45 +02:00
|
|
|
struct Heartbeat {
|
2013-12-20 21:16:01 +01:00
|
|
|
Code code;
|
2013-12-29 18:50:44 +01:00
|
|
|
|
2012-07-25 11:04:45 +02:00
|
|
|
uint8_t version;
|
|
|
|
uint8_t device_id;
|
2013-12-29 18:50:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct State {
|
|
|
|
enum class Flags : uint8_t {
|
|
|
|
None = 0,
|
2013-12-29 21:08:31 +01:00
|
|
|
RemoteOK = 1,
|
|
|
|
InControl = 2,
|
|
|
|
InShutdown = 4,
|
|
|
|
PilotAllowed = 8,
|
2013-12-29 18:50:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Code code;
|
|
|
|
Flags flags;
|
2012-07-25 11:04:45 +02:00
|
|
|
};
|
|
|
|
|
2014-01-14 19:57:54 +01:00
|
|
|
struct Counters {
|
|
|
|
Code code;
|
|
|
|
|
|
|
|
uint8_t demands;
|
|
|
|
|
|
|
|
uint8_t sent;
|
|
|
|
uint8_t received;
|
|
|
|
uint8_t rx_errors;
|
|
|
|
};
|
|
|
|
|
2013-12-20 21:16:01 +01:00
|
|
|
struct Pong {
|
|
|
|
Code code;
|
|
|
|
};
|
|
|
|
|
2013-12-29 18:50:44 +01:00
|
|
|
struct Input {
|
|
|
|
static const int8_t Missing = -128;
|
2014-02-02 15:04:14 +01:00
|
|
|
static const uint8_t Reference12MHz = 2;
|
2013-12-20 21:16:01 +01:00
|
|
|
|
|
|
|
Code code;
|
2014-01-14 19:57:54 +01:00
|
|
|
uint8_t reference;
|
2013-12-29 18:50:44 +01:00
|
|
|
int8_t channels[6];
|
2013-12-20 21:16:01 +01:00
|
|
|
};
|
|
|
|
|
2013-12-29 18:50:44 +01:00
|
|
|
struct Demand {
|
2014-01-05 16:21:28 +01:00
|
|
|
static const int8_t PassThrough = -127;
|
|
|
|
static const int8_t Reserved = -120;
|
|
|
|
|
2013-12-29 18:50:44 +01:00
|
|
|
enum class Flags : uint8_t {
|
|
|
|
None = 0,
|
|
|
|
TakeControl = 1,
|
|
|
|
};
|
2012-07-27 11:49:05 +02:00
|
|
|
|
2013-12-20 21:16:01 +01:00
|
|
|
Code code;
|
2013-12-29 18:50:44 +01:00
|
|
|
Flags flags;
|
|
|
|
int8_t channels[6];
|
2012-07-27 11:49:05 +02:00
|
|
|
};
|
|
|
|
|
2014-02-21 22:46:56 +01:00
|
|
|
struct IMU {
|
|
|
|
Code code;
|
|
|
|
uint8_t id;
|
|
|
|
int16_t accels[3];
|
|
|
|
int16_t gyros[3];
|
|
|
|
};
|
|
|
|
|
2013-12-28 21:19:24 +01:00
|
|
|
struct Request {
|
|
|
|
Code code;
|
|
|
|
Code requested;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Version {
|
|
|
|
Code code;
|
|
|
|
char version[18];
|
|
|
|
};
|
|
|
|
|
2013-12-27 21:35:37 +01:00
|
|
|
} // namespace Protocol
|