98 lines
1.5 KiB
C++
98 lines
1.5 KiB
C++
#include <string.h>
|
|
|
|
#include "uart.h"
|
|
#include "tick.h"
|
|
|
|
#include "com.h"
|
|
|
|
enum class MESSAGES_ID : unsigned char
|
|
{
|
|
SysInfo = 1,
|
|
GyroInfo = 2,
|
|
AccelInfo = 3,
|
|
GpsInfo = 4,
|
|
InertialInfo = 5,
|
|
BatteryInfo = 6,
|
|
Ack = 7,
|
|
StatusCommand = 8,
|
|
StatusAllCommands = 9,
|
|
Command = 10,
|
|
RequestReg = 11,
|
|
ResponseReg = 12,
|
|
Auth = 13,
|
|
OpenKey = 14,
|
|
MissionCount = 15,
|
|
MissionItem = 16,
|
|
MissionItemAck = 17,
|
|
MissionRequestItem = 18,
|
|
RequestLastMessage = 19,
|
|
ConnectionTest = 20,
|
|
|
|
CountMenuCategories = 32,
|
|
CategoriesMenu = 33,
|
|
CategoriesParameters = 34,
|
|
};
|
|
|
|
enum class COMMANDS_NAME : unsigned char
|
|
{
|
|
ChangeNav = 1,
|
|
ChangeSpeed = 2,
|
|
Land = 3,
|
|
GoHome = 4,
|
|
StopEngine = 5,
|
|
StartEngine = 6,
|
|
Pause = 7,
|
|
Continue = 8,
|
|
GoToGlobal = 9,
|
|
GoToLocal = 10,
|
|
|
|
SetParameter = 15,
|
|
};
|
|
|
|
enum class ERROR_CODE_COMMAND : unsigned char
|
|
{
|
|
NoError = 0,
|
|
};
|
|
|
|
#pragma pack(push,1)
|
|
|
|
struct HeaderBegin
|
|
{
|
|
unsigned char stx = 0xAA;
|
|
unsigned short len1;
|
|
unsigned short len2;
|
|
unsigned char crc;
|
|
unsigned char data[0];
|
|
|
|
bool CheckCRC()
|
|
{
|
|
if(len1!=len2) return false;
|
|
unsigned char test = 0;
|
|
for (unsigned short a = 0; a < len1; a++) test ^= data[a];
|
|
return crc==test;
|
|
}
|
|
};
|
|
|
|
struct HeaderMessages
|
|
{
|
|
MESSAGES_ID msgId;
|
|
unsigned char srcId;
|
|
unsigned char dstId;
|
|
unsigned char len;
|
|
unsigned char data[0];
|
|
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
//void TELE_Init()
|
|
//{
|
|
// UART2_Init(57600);
|
|
//}
|
|
//
|
|
//void TELE_Update(const void* info, unsigned long size, unsigned long update)
|
|
//{
|
|
//
|
|
//}
|