Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
downlink.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2006 Pascal Brisset, Antoine Drouin
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
28 #ifndef DOWNLINK_H
29 #define DOWNLINK_H
30 
31 #include <inttypes.h>
32 
33 #ifndef PPRZ_DATALINK_EXPORT
34 
35 #include "generated/modules.h"
36 #include "messages.h"
37 #include "generated/airframe.h" // AC_ID is required
38 
39 #if defined SITL
40 
41 #ifdef SIM_UART
42 #include "sim_uart.h"
45 #else /* SIM_UART */
46 
47 #include "ivy_transport.h"
48 #endif
49 
50 #else
52 #include "subsystems/datalink/udp.h"
57 #if USE_SUPERBITRF
58 #include "subsystems/datalink/superbitrf.h"
59 #endif
60 #if USE_AUDIO_TELEMETRY
62 #endif
63 #ifdef USE_USB_SERIAL
64 #include "mcu_periph/usb_serial.h"
65 #endif
66 #include "mcu_periph/uart.h"
67 
68 #endif
70 #else /* PPRZ_DATALINK_EXPORT defined */
71 
72 #include "messages.h"
73 #include "pprz_transport.h"
74 #ifndef AC_ID
75 #define AC_ID 0
76 #endif
77 
78 #endif
79 
80 #ifndef DefaultChannel
81 #define DefaultChannel DOWNLINK_TRANSPORT
82 #endif
83 
84 // FIXME are DOWNLINK_AP|FBW_DEVICE distinction really necessary ?
85 // by default use AP_DEVICE if nothing is set ?
86 #ifndef DOWNLINK_DEVICE
87 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
88 #endif
89 
90 #ifndef DefaultDevice
91 #define DefaultDevice DOWNLINK_DEVICE
92 #endif
93 
98 
99 /* Transport macros
100  *
101  * call transport functions from channel
102  */
103 #define __Transport(dev, _x) dev##_x
104 #define _Transport(dev, _x) __Transport(dev, _x)
105 #define Transport(_chan, _fun) _Transport(_chan, _fun)
106 
107 
110 #define DownlinkIDsSize(_trans, _dev, _x) (_x+2)
111 #define DownlinkSizeOf(_trans, _dev, _x) Transport(_trans, SizeOf(_dev, DownlinkIDsSize(_trans, _dev, _x)))
112 
113 #define DownlinkCheckFreeSpace(_trans, _dev, _x) Transport(_trans, CheckFreeSpace(_dev, (uint8_t)(_x)))
114 
115 #define DownlinkPutUint8(_trans, _dev, _x) Transport(_trans, PutUint8(_dev, _x))
116 
117 #define DownlinkPutInt8ByAddr(_trans, _dev, _x) Transport(_trans, PutInt8ByAddr(_dev, _x))
118 #define DownlinkPutUint8ByAddr(_trans, _dev, _x) Transport(_trans, PutUint8ByAddr(_dev, _x))
119 #define DownlinkPutInt16ByAddr(_trans, _dev, _x) Transport(_trans, PutInt16ByAddr(_dev, _x))
120 #define DownlinkPutUint16ByAddr(_trans, _dev, _x) Transport(_trans, PutUint16ByAddr(_dev, _x))
121 #define DownlinkPutInt32ByAddr(_trans, _dev, _x) Transport(_trans, PutInt32ByAddr(_dev, _x))
122 #define DownlinkPutUint32ByAddr(_trans, _dev, _x) Transport(_trans, PutUint32ByAddr(_dev, _x))
123 #define DownlinkPutFloatByAddr(_trans, _dev, _x) Transport(_trans, PutFloatByAddr(_dev, _x))
124 
125 #define DownlinkPutDoubleByAddr(_trans, _dev, _x) Transport(_trans, PutDoubleByAddr(_dev, _x))
126 #define DownlinkPutUint64ByAddr(_trans, _dev, _x) Transport(_trans, PutUint64ByAddr(_dev, _x))
127 #define DownlinkPutInt64ByAddr(_trans, _dev, _x) Transport(_trans, PutInt64ByAddr(_dev, _x))
128 #define DownlinkPutCharByAddr(_trans, _dev, _x) Transport(_trans, PutCharByAddr(_dev, _x))
129 
130 #define DownlinkPutFloatArray(_trans, _dev, _n, _x) Transport(_trans, PutFloatArray(_dev, _n, _x))
131 #define DownlinkPutDoubleArray(_trans, _dev, _n, _x) Transport(_trans, PutDoubleArray(_dev, _n, _x))
132 #define DownlinkPutInt16Array(_trans, _dev, _n, _x) Transport(_trans, PutInt16Array(_dev, _n, _x))
133 #define DownlinkPutUint16Array(_trans, _dev, _n, _x) Transport(_trans, PutUint16Array(_dev, _n, _x))
134 #define DownlinkPutInt32Array(_trans, _dev, _n, _x) Transport(_trans, PutInt32Array(_dev, _n, _x))
135 #define DownlinkPutUint32Array(_trans, _dev, _n, _x) Transport(_trans, PutUint32Array(_dev, _n, _x))
136 #define DownlinkPutInt64Array(_trans, _dev, _n, _x) Transport(_trans, PutInt64Array(_dev, _n, _x))
137 #define DownlinkPutUint64Array(_trans, _dev, _n, _x) Transport(_trans, PutUint64Array(_dev, _n, _x))
138 #define DownlinkPutInt8Array(_trans, _dev, _n, _x) Transport(_trans, PutInt8Array(_dev, _n, _x))
139 #define DownlinkPutUint8Array(_trans, _dev, _n, _x) Transport(_trans, PutUint8Array(_dev, _n, _x))
140 #define DownlinkPutCharArray(_trans, _dev, _n, _x) Transport(_trans, PutCharArray(_dev, _n, _x))
141 
142 #define DownlinkPutFloatFixedArray(_trans, _dev, _n, _x) Transport(_trans, PutFloatFixedArray(_dev, _n, _x))
143 #define DownlinkPutDoubleFixedArray(_trans, _dev, _n, _x) Transport(_trans, PutDoubleFixedArray(_dev, _n, _x))
144 #define DownlinkPutInt16FixedArray(_trans, _dev, _n, _x) Transport(_trans, PutInt16FixedArray(_dev, _n, _x))
145 #define DownlinkPutUint16FixedArray(_trans, _dev, _n, _x) Transport(_trans, PutUint16FixedArray(_dev, _n, _x))
146 #define DownlinkPutInt32FixedArray(_trans, _dev, _n, _x) Transport(_trans, PutInt32FixedArray(_dev, _n, _x))
147 #define DownlinkPutUint32FixedArray(_trans, _dev, _n, _x) Transport(_trans, PutUint32FixedArray(_dev, _n, _x))
148 #define DownlinkPutInt64FixedArray(_trans, _dev, _n, _x) Transport(_trans, PutInt64FixedArray(_dev, _n, _x))
149 #define DownlinkPutUint64FixedArray(_trans, _dev, _n, _x) Transport(_trans, PutUint64FixedArray(_dev, _n, _x))
150 #define DownlinkPutInt8FixedArray(_trans, _dev, _n, _x) Transport(_trans, PutInt8FixedArray(_dev, _n, _x))
151 #define DownlinkPutUint8FixedArray(_trans, _dev, _n, _x) Transport(_trans, PutUint8FixedArray(_dev, _n, _x))
152 #define DownlinkPutCharFixedArray(_trans, _dev, _n, _x) Transport(_trans, PutCharFixedArray(_dev, _n, _x))
153 
154 #define DownlinkOverrun(_trans, _dev) downlink_nb_ovrn++;
155 #define DownlinkCountBytes(_trans, _dev, _n) downlink_nb_bytes += _n;
156 
157 #define DownlinkStartMessage(_trans, _dev, _name, msg_id, payload_len) { \
158  downlink_nb_msgs++; \
159  Transport(_trans, Header(_dev, DownlinkIDsSize(_trans, _dev, payload_len))); \
160  Transport(_trans, PutUint8(_dev, AC_ID)); \
161  Transport(_trans, PutNamedUint8(_dev, _name, msg_id)); \
162 }
163 
164 #define DownlinkEndMessage(_trans, _dev) Transport(_trans, Trailer(_dev))
165 
166 #endif /* DOWNLINK_H */
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
Extra datalink using PPRZ protocol.
Simulation of uart transmission on an Unix pipe.
Building and Paparazzi frames with timestamp for data logger.
W5100 ethernet chip I/O.
unsigned char uint8_t
Definition: types.h:14
arch independent USB API