Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
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 #include "generated/modules.h"
34 #include "messages.h"
35 #include "generated/airframe.h" // AC_ID is required
36 
37 #if defined SITL
38 
39 #ifdef SIM_UART
40 #include "sim_uart.h"
43 #else /* SIM_UART */
44 
45 #include "ivy_transport.h"
46 #endif
47 
48 #else
49 #include "subsystems/datalink/udp.h"
53 #if USE_AUDIO_TELEMETRY
55 #endif
56 #ifdef USE_USB_SERIAL
57 #include "mcu_periph/usb_serial.h"
58 #endif
59 #endif
61 #ifndef DefaultChannel
62 #define DefaultChannel DOWNLINK_TRANSPORT
63 #endif
64 
65 #ifndef DefaultDevice
66 #define DefaultDevice DOWNLINK_DEVICE
67 #endif
68 
73 
74 /* Transport macros
75  *
76  * call transport functions from channel
77  */
78 #define __Transport(dev, _x) dev##_x
79 #define _Transport(dev, _x) __Transport(dev, _x)
80 #define Transport(_chan, _fun) _Transport(_chan, _fun)
81 
82 
85 #define DownlinkIDsSize(_trans, _dev, _x) (_x+2)
86 #define DownlinkSizeOf(_trans, _dev, _x) Transport(_trans, SizeOf(_dev, DownlinkIDsSize(_trans, _dev, _x)))
87 
88 #define DownlinkCheckFreeSpace(_trans, _dev, _x) Transport(_trans, CheckFreeSpace(_dev, (uint8_t)(_x)))
89 
90 #define DownlinkPutUint8(_trans, _dev, _x) Transport(_trans, PutUint8(_dev, _x))
91 
92 #define DownlinkPutInt8ByAddr(_trans, _dev, _x) Transport(_trans, PutInt8ByAddr(_dev, _x))
93 #define DownlinkPutUint8ByAddr(_trans, _dev, _x) Transport(_trans, PutUint8ByAddr(_dev, _x))
94 #define DownlinkPutInt16ByAddr(_trans, _dev, _x) Transport(_trans, PutInt16ByAddr(_dev, _x))
95 #define DownlinkPutUint16ByAddr(_trans, _dev, _x) Transport(_trans, PutUint16ByAddr(_dev, _x))
96 #define DownlinkPutInt32ByAddr(_trans, _dev, _x) Transport(_trans, PutInt32ByAddr(_dev, _x))
97 #define DownlinkPutUint32ByAddr(_trans, _dev, _x) Transport(_trans, PutUint32ByAddr(_dev, _x))
98 #define DownlinkPutFloatByAddr(_trans, _dev, _x) Transport(_trans, PutFloatByAddr(_dev, _x))
99 
100 #define DownlinkPutDoubleByAddr(_trans, _dev, _x) Transport(_trans, PutDoubleByAddr(_dev, _x))
101 
102 #define DownlinkPutFloatArray(_trans, _dev, _n, _x) Transport(_trans, PutFloatArray(_dev, _n, _x))
103 #define DownlinkPutDoubleArray(_trans, _dev, _n, _x) Transport(_trans, PutDoubleArray(_dev, _n, _x))
104 #define DownlinkPutInt16Array(_trans, _dev, _n, _x) Transport(_trans, PutInt16Array(_dev, _n, _x))
105 #define DownlinkPutUint16Array(_trans, _dev, _n, _x) Transport(_trans, PutUint16Array(_dev, _n, _x))
106 #define DownlinkPutInt32Array(_trans, _dev, _n, _x) Transport(_trans, PutInt32Array(_dev, _n, _x))
107 #define DownlinkPutUint32Array(_trans, _dev, _n, _x) Transport(_trans, PutUint32Array(_dev, _n, _x))
108 #define DownlinkPutUint8Array(_trans, _dev, _n, _x) Transport(_trans, PutUint8Array(_dev, _n, _x))
109 
110 #define DownlinkOverrun(_trans, _dev) downlink_nb_ovrn++;
111 #define DownlinkCountBytes(_trans, _dev, _n) downlink_nb_bytes += _n;
112 
113 #define DownlinkStartMessage(_trans, _dev, _name, msg_id, payload_len) { \
114  downlink_nb_msgs++; \
115  Transport(_trans, Header(_dev, DownlinkIDsSize(_trans, _dev, payload_len))); \
116  Transport(_trans, PutUint8(_dev, AC_ID)); \
117  Transport(_trans, PutNamedUint8(_dev, _name, msg_id)); \
118 }
119 
120 #define DownlinkEndMessage(_trans, _dev) Transport(_trans, Trailer(_dev))
121 
122 #endif /* DOWNLINK_H */
unsigned short uint16_t
Definition: types.h:16
Extra datalink using PPRZ protocol.
Simulation of uart transmission on an Unix pipe.
unsigned char uint8_t
Definition: types.h:14
arch independent USB API