/
telemetry_common.h
81 lines (71 loc) · 2.84 KB
/
telemetry_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Copyright (C) 2013 Gautier Hattenberger
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/** @file subsystems/datalink/telemetry_common.h
*
* Common tools for periodic telemetry interface
* Allows subsystem to register callback functions
*/
#ifndef TELEMETRY_COMMON_H
#define TELEMETRY_COMMON_H
#include <inttypes.h>
#include "std.h"
#include "mcu_periph/link_device.h"
#include "subsystems/datalink/transport.h"
/** Telemetry callback definition
*/
typedef void (*telemetry_cb)(struct transport_tx *trans, struct link_device *dev);
/** Telemetry header
*/
struct telemetry_msg {
char msg[64]; ///< name in telemetry xml file
telemetry_cb cb; ///< callback funtion
};
/** Periodic telemetry structure.
* Contains the total number of messages (from generated telemetry file)
* and the list of registered callbacks
*/
struct periodic_telemetry {
uint8_t nb; ///< number of messages
struct telemetry_msg *msgs; ///< the list of (msg name, callbacks)
};
/** Register a telemetry callback function.
* empty implementation is provided if PERIODIC_TELEMETRY is not set or set to FALSE
* @param _pt periodic telemetry structure to register
* @param _msg message name (string) as defined in telemetry xml file
* @param _cb callback function, called according to telemetry mode and specified period
* @return TRUE if message registered with success, FALSE otherwise
*/
#if PERIODIC_TELEMETRY
extern bool_t register_periodic_telemetry(struct periodic_telemetry *_pt, const char *_msg, telemetry_cb _cb);
#else
static inline bool_t register_periodic_telemetry(struct periodic_telemetry *_pt __attribute__((unused)),
const char *_msg __attribute__((unused)), telemetry_cb _cb __attribute__((unused))) { return FALSE; }
#endif
#if USE_PERIODIC_TELEMETRY_REPORT
/** Send an error report when trying to send message that as not been register
* @param _process telemetry process id
* @param _mode telemetry mode
* @param _id id of the message in telemetry system (see var/<AC>/generated/periodic_telemetry.h)
*/
extern void periodic_telemetry_err_report(uint8_t _process, uint8_t _mode, uint8_t _id);
#endif
#endif /* TELEMETRY_COMMON_H */