CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_ADSB/GDL90_protocol/hostGDL90Support.h
Views: 1799
1
/*
2
Copyright (C) 2021 Kraus Hamdani Aerospace Inc. All rights reserved.
3
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
18
Author: GDL90/UCP protocol by uAvionix, 2021.
19
Implemented by: Tom Pittenger
20
*/
21
22
#ifndef _GDL90_H_
23
#define _GDL90_H_
24
25
#include <stdint.h>
26
27
#define GDL90_QUEUE_LENGTH (2)
28
29
#define GDL90_FLAG_BYTE (0x7E)
30
#define GDL90_CONTROL_ESCAPE_BYTE (0x7D)
31
#define GDL90_STUFF_BYTE (0x20)
32
#define GDL90_OVERHEAD_LENGTH (3) // Not counting framing bytes
33
34
35
// Transmit message sizes
36
#define GDL90_TX_MAX_PAYLOAD_LENGTH (552)
37
#define GDL90_TX_MAX_PACKET_LENGTH (GDL90_TX_MAX_PAYLOAD_LENGTH + GDL90_OVERHEAD_LENGTH)
38
#define GDL90_TX_MAX_FRAME_LENGTH (2 + ((15 * GDL90_TX_MAX_PACKET_LENGTH) / 10)) // IF every other byte was stuffed
39
40
// Receive message sizes
41
#define GDL90_RX_MAX_PAYLOAD_LENGTH (128)
42
#define GDL90_RX_MAX_PACKET_LENGTH (GDL90_RX_MAX_PAYLOAD_LENGTH + GDL90_OVERHEAD_LENGTH)
43
44
typedef union __attribute__((__packed__))
45
{
46
struct __attribute__((__packed__))
47
{
48
GDL90_MESSAGE_ID messageId;
49
uint8_t payload[GDL90_TX_MAX_PAYLOAD_LENGTH];
50
uint16_t crc; // Actually CRC location varies. This is a placeholder
51
};
52
uint8_t raw[GDL90_TX_MAX_PACKET_LENGTH];
53
} GDL90_TX_MESSAGE;
54
55
typedef union __attribute__((__packed__))
56
{
57
struct __attribute__((__packed__))
58
{
59
GDL90_MESSAGE_ID messageId;
60
uint8_t payload[GDL90_RX_MAX_PAYLOAD_LENGTH];
61
uint16_t crc; // Actually CRC location varies. This is a placeholder
62
};
63
uint8_t raw[GDL90_RX_MAX_PACKET_LENGTH];
64
} GDL90_RX_MESSAGE;
65
66
typedef enum
67
{
68
GDL90_RX_IDLE,
69
GDL90_RX_IN_PACKET,
70
GDL90_RX_UNSTUFF,
71
} GDL90_RX_STATE;
72
73
typedef struct
74
{
75
GDL90_RX_STATE state;
76
uint16_t length;
77
uint8_t prev_data;
78
} GDL90_RX_STATUS;
79
80
#endif
81
82