Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
downlink.h
Go to the documentation of this file.
1 /*
2  * Paparazzi $Id$
3  *
4  * Copyright (C) 2003-2006 Pascal Brisset, Antoine Drouin
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
30 #ifndef DOWNLINK_H
31 #define DOWNLINK_H
32 
33 #include <inttypes.h>
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
51 #include "subsystems/datalink/pprz_transport.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