Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
downlink.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 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
30
31#if (defined DATALINK) || PERIODIC_TELEMETRY
33#endif
34
35#if PERIODIC_TELEMETRY
37#include "mcu_periph/sys_time.h"
38
39static uint32_t last_down_nb_bytes = 0; // previous number of bytes sent
40static uint32_t last_up_nb_msgs = 0; // previous number of received messages
41static uint32_t last_ts = 0; // timestamp in usec when last message was send
42
43static void send_downlink(struct transport_tx *trans, struct link_device *dev)
44{
45 // current timestamp
47 // compute downlink byte rate
48 if (now_ts > last_ts) {
49 uint16_t down_rate = (1000 * ((uint32_t)dev->nb_bytes - last_down_nb_bytes)) / (now_ts - last_ts);
51
53#if defined DATALINK || defined SITL
54 last_down_nb_bytes = dev->nb_bytes;
56#else
59#endif
60
62 &up_rate, &dev->nb_ovrn);
63 }
64}
65#endif
66
67void downlink_init(void)
68{
69 // Set initial counters
70 (DefaultDevice).device.nb_ovrn = 0;
71 (DefaultDevice).device.nb_bytes = 0;
72 (DefaultDevice).device.nb_msgs = 0;
73
74#if PERIODIC_TELEMETRY
76#endif
77}
78
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
uint16_t foo
Definition main_demo5.c:58
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
Architecture independent timing functions.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition telemetry.c:51
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
Definition telemetry.h:66
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.